ModCoderPack/MCPBot-Issues

Block.updatePostPlacement & Block.neighborChanged are misleading

Closed this issue · 4 comments

After some testing and looking at usages, I am quite sure those names are kinda wrong and misleading. I'd recommend those renames to better suit their functionality.

  • func_220069_a in net.minecraft.block.Block: neighborChanged -> neighborUpdate
  • func_196956_a in net.minecraft.block.Block: updatePostPlacement -> neighborStateChanged

Aditionally to the Blocks class this should also be reflected in the Blockstate class.

  • func_215697_a in net.minecraft.block.BlockState: neighborChanged -> neighborUpdate
  • func_196271_a in net.minecraft.block.BlockState: updatePostPlacement -> neighborStateChanged

updatePostPlacement is not equivalent to the old neighborChanged (which is what the technical community calls "block updates"). I strongly oppose that second name change. I don't know enough about the first one.

I just looked into neighborChanged and I don't see what you're seeing. It's clearly called in lots of contexts unrelated to fluids (updateComparatorOutputLevel, bunch of methods in world)

So I strongly oppose the first change as well.

All blocks that used neighborChanged in 1.12 seem to be using updatePostPlacement now.
And looking at the usages of the current neighborChanged all I can see is this:
image
which are 2 blocks that use it for interaction with water.

And I only see that method being called by 5 other blocks that don't interact with fluids.
One of which being the comparator, in which it is only used within a patch
However, the other 4 (StairsBlock, PistonHeadBlock, CactusBlock & DetectorRailBlock) seem to use it outside of patches.

On the other side again Block#updateNeighbors uses updatePostPlacement.
I think you're partially right.

updatePostPlacement however does more equal a neighborChanged method than the current one does. as updatePostPlacement is only called when the neighbor changes.
While the currentNeighborChanged seems to be more something like: onBlockUpdate

Edit: I updated the name suggestions in the opening.

And looking at the usages of the current neighborChanged all I can see is this

yes, it's "just" called from that one spot in BlockState (and some other spots), but did you see where that BlockState method is called from in turn? everywhere from World

You can't just look at immediate references like this, you have to dig into each one.