mojira.dev
MC-88674

Growing cactus placed on blocks other than (red) sand drops two cacti instead of breaking

If you do this command:
/setblock ~ ~-1 ~ cactus
while standing on a surface, that cactus block will continue dropping cacti forever.

The cactus block has to be on the ground, but not on sand. It still can't touch any blocks on the sides.


Code analysis by @unknown can be found in this comment.

Linked issues

Comments 8

Confirmed for

  • 15w37a

You should mention that increasing the randomTickSpeed makes it easier to see the bug.
This does not happen with reeds. They break completely. For cacti it seems like the source and the newly grown block broke (2 items) but the source still remains

the concept of duplication doesn't count when using setblock

Then remove "Infinite" from the title and rather call it "Incorrect growing behaviour of cactus at invalid location" or something like this

Then you're saying it yourself "invalid location", why would mojang support it?

Maybe it affects the main mechanics of cacti blocks and can cause other bugs

This bug is manifested as well on Mesa biomes where cacti naturally grow on hardened clay blocks.

The probable cause of it is that as the cactus grows another block (only works with 1-block cacti) it recognizes its position as invalid and "breaks" but the cactus remains as it was previously located there. The reason it appears more easily at higher tick speeds is obviously because cacti grow more quickly at higher tick speeds.

Another manifestation of the bug I have noticed is if there is a cactus growing on a valid surface (let's assume it's 2 blocks high for the purpose of this situation) and there is something that it would be directly adjacent to if it grew one block higher (such as the leaves of a tree, or a platform created by a player) the cactus would grow high enough to interfere with it anyways and, as one would expect, break and drop. This might be WIA in this situation, but the invalid surface bug described here is certainly an offshoot of it.

Curiously it does not effect cacti 2 blocks tall, nor would it effect cacti 3 blocks tall as they reached their maximum height limit and do not grow any more.

Please link to this comment in the description

The following is based on a decompiled version of Minecraft 1.10 using MCP 9.30.

The reason for this is that the method net.minecraft.block.BlockCactus.updateTick(World, BlockPos, IBlockState, Random) does not test if the old cactus block is still there when trying to sett the AGE value of it to 0 again.

The following happens when the cactus grows:

  1. New cactus is placed

  2. Old one is updated and because it is at an invalid position replaced by air and dropped

  3. Removing the old cactus updates the new cactus breaking it as well

  4. New cactus with AGE value of 0 is set at position of old cactus assuming it is still there

  5. (Checking if position of new cactus is valid and dropping it otherwise)[[1]|#comment_323197_note1]

This could be fixed by either checking if the old cactus block still exists before setting a new one with AGE value of 0 or as done with reeds the method net.minecraft.block.BlockCactus.updateTick(World, BlockPos, IBlockState, Random) could before doing anything test if the old cactus block is valid or otherwise drop it.

1 In case the position at which the new cactus block is created is invalid the game tries to destroy an air block. Luckily the method net.minecraft.world.World.destroyBlock(BlockPos, boolean) prevents that but to prevent any exploits classes overriding the method net.minecraft.block.Block.func_189540_a(IBlockState, World, BlockPos, Block) should test if the block at this position is the expected block.

Apparently this issue has been fixed in some of the 1.13 snapshots.

Tarun Boddupalli

(Unassigned)

Confirmed

Minecraft 15w37a, Minecraft 15w45a, Minecraft 1.10.2, Minecraft 1.12.2

Minecraft 18w05a

Retrieved