mojira.dev
MC-90741

Client-side calls block.getHardness (world, pos) *after* placing air

I apologize for using Forge's "deobfuscated" names...

While walking through one of my mods in the debugger, I stumbled upon an apparent bug in core code. When a player breaks a block, the client side calls the breaking block's method (getHardness), and passes world & position arguments after replacing that block in the world with air. If the block then tries to access its blockState to determine hardness based on subtype, the game will crash.

Granted, "vanilla" MC does not have any such block types (yet); all current blocks fall back on super.getHardness without using the booby-trapped world & blockPosition. However, the data being passed suggest that this will not always be the case, so it should be fixed before new block types are added (or before anyone tries to give variable hardness to any old block having subtypes – e.g. stone slabs).

I see 3 possible fixes:

1) Decide that hardness will never vary by subtype. Eliminate the parameters.

2) Decide that hardness may vary by blockState. Replace world & pos parameters with state, which the caller should fetch before changing the world.

3) Change the execution order on the client side to match the server side.

Comments 1

Sorry, this is not really a bug - nothing is happening that's not supposed to happen. If the vanilla game ever starts using variable hardness per block type, they'll probably run into the issue on their own and fix it.

Jeffry R. Fisher

(Unassigned)

Unconfirmed

Minecraft 1.8.8

Retrieved