TNT icon indicating copy to clipboard operation
TNT copied to clipboard

Identity comparison for air block.

Open KrystilizeNevaDies opened this issue 3 years ago • 7 comments
trafficstars

Comparing with Block.AIR should be Block.AIR.compare(block), not an identity comparison.

KrystilizeNevaDies avatar Jul 23 '22 23:07 KrystilizeNevaDies

Does it matter? I thought it only mattered for blocks with data like rotations and stuff

emortaldev avatar Jul 23 '22 23:07 emortaldev

An air block with a different block handler or different nbt would not equal. Actually Block.withProperties("") would even be a different object

KrystilizeNevaDies avatar Jul 23 '22 23:07 KrystilizeNevaDies

those should be different in this case. Otherwise the nbt/handler will be removed

mworzala avatar Jul 23 '22 23:07 mworzala

Even with the exact same nbt, block handler, and properties, as long as it's a different block object, they will not be equal

KrystilizeNevaDies avatar Jul 23 '22 23:07 KrystilizeNevaDies

Block#compare uses ID by default, meaning two air blocks with different handler or NBT will be considered the same. Then the RLE being used on air here will remove the handler and NBT. You can use compare, but also need to check handler and nbt.

mworzala avatar Jul 23 '22 23:07 mworzala

@mworzala wouldn't you be ignoring block handlers? I don't see how you could serialise them?

KrystilizeNevaDies avatar Jul 24 '22 08:07 KrystilizeNevaDies

you should serialize the nbt + the name of the block handler if present.

This does bring up a different problem with this implementation though, it A: assumes that there is a block handler if there is NBT on a block and B: uses the block name as the block handler. It needs to save the block handler separately if present.

mworzala avatar Jul 24 '22 09:07 mworzala