mojira.dev
MC-231389

Lightning hitting a waxed copper block does not clean surrounding weathering copper blocks

The Bug

Lightning (using /summon command) 'de-ages' the oxidized copper block it hits fully and also some surrounding blocks a few oxidization levels but that does not happen when the lightning hits a block that is waxed.

Expected Result

Lightning obviously would not de-age the waxed block itself but the non-waxed surrounding blocks should still be affected by it.

Observed Result

None of the blocks got de-aged, even though it did set fire on the surrounding blocks.

Steps to Reproduce

1. Create 2 copper block testing areas. I'm using 7x7 ones.

2. First test -  summon lightning by standing on the non-waxed block
3. Notice that the block itself will fully de-age and some blocks around it will de-age some levels.
4. Second test - Try summoning lightning by standing on a waxed block.

5. Notice that the waxed block would not de-age (intended)  but any other blocks around it don't de-age either.

These waxed blocks can also create a sort of occlusion (See Photo) where if you summon lightning on either side, the waxed copper blocks in the middle would not let the de-aging effect of lightning pass to the other side.

Code analysis

Code analysis can be found in this comment.

Attachments

Comments 7

Can confirm. This issue occurs in vanilla.

Can confirm in 21w39a.

Can confirm in 21w42a.

Can confirm in 21w43a.

Can confirm in 1.18 Pre-release 1.

I think I figured out the issue.

net.minecraft.world.entity.LightningBolt.java (Mojang mappings, 1.18-rc1, variable renamings)

...
    private static void clearCopperOnLightningStrike(Level level, BlockPos blockPos) {
        ...
        if (!(blockState.getBlock() instanceof WeatheringCopper)) {
            return;
        }
        level.setBlockAndUpdate(blockPos2, WeatheringCopper.getFirst(level.getBlockState(blockPos2)));
        BlockPos.MutableBlockPos mutableBlockPos = blockPos.mutable();
        int j = level.random.nextInt(3) + 3;
        for (int i = 0; i < j; ++i) {
            int k = level.random.nextInt(8) + 1;
            LightningBolt.randomWalkCleaningCopper(level, blockPos2, mutableBlockPos, k);
        }
    }
...

More specifically, this:

...
 if (!(blockState.getBlock() instanceof WeatheringCopper)) {
            return;
        }
...

The lightning bolt only proceeds with the cleaning process if the striked block is part of the WeatheringCopper interface, which obviously does not include waxed blocks. This seems OK, but the process to clean nearby weathering copper blocks is also done by randomStepCleaningCopper(...), which is called by randomWalkCleaningCopper(...). So, if the lightning bolt hits a waxed copper block it will not clean any surrounding copper, regardless of whether it is waxed or not.

fixed in 1.20.3

[media]

charlygulati

(Unassigned)

Confirmed

Block states, Entities

1.17.1, 21w39a, 21w42a, 21w43a, 1.18 Pre-release 1, ..., 22w18a, 1.19.1, 1.19.2, 1.20.2, 1.21.7

Retrieved