Skip to content
This repository has been archived by the owner on Apr 14, 2024. It is now read-only.

Identity comparison for air block. #1

Open
KrystilizeNevaDies opened this issue Jul 23, 2022 · 7 comments
Open

Identity comparison for air block. #1

KrystilizeNevaDies opened this issue Jul 23, 2022 · 7 comments

Comments

@KrystilizeNevaDies
Copy link
Member

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

@emortaldev
Copy link
Member

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

@KrystilizeNevaDies
Copy link
Member Author

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

@mworzala
Copy link

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

@KrystilizeNevaDies
Copy link
Member Author

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

@mworzala
Copy link

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.

@KrystilizeNevaDies
Copy link
Member Author

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

@mworzala
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants