Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False BlockState default values (also enforced after set_pinv(pinv()) ) #1350

Open
Nilleke opened this issue Jan 26, 2023 · 1 comment
Open
Labels
bug Things that don't work as designed

Comments

@Nilleke
Copy link
Contributor

Nilleke commented Jan 26, 2023

CommandHelper seems to retrieve default BlockState values for unspecified states when at least one state is specified, and enforces them after a set_pinv(pinv()).

Tested on:

CommandHelper-3.3.5-b309
Purpur-1.19.3-b1895


Test item without BlockState:

/give @s bee_nest

This is a normal bee nest without honey level or forced facing direction.
pinv() returns:

{meta: null, name: BEE_NEST, qty: 1}

after set_pinv(pinv()) it still returns the same information and the item works the same

Test item with BlockState:

/give @s bee_nest{BlockStateTag:{honey_level:5}}

This places a bee nest with honey level 5 and respects the direction the player is facing.
However pinv() returns:

{meta: {blockdata: {block: bee_nest, facing: north, honey_level: 5}, display: null, enchants: {}, flags: {}, flowerlocation: null, lore: null, model: null, modifiers: null, repair: 0}, name: BEE_NEST, qty: 1}

This falsely claims the facing direction is forced to north.
After doing set_pinv(pinv()) it still returns the same information but the added default values (like facing: north) are actually enforced, any value that was specified previously (like honey_level) is kept.

@PseudoKnight
Copy link
Contributor

PseudoKnight commented Jan 27, 2023

There doesn't appear to be a (supported) way to fix this. There is a method to "ignoreUnspecified" states, but that only applies to when we're creating a new BlockData from a string, like via Bukkit.createBlockData().

Also, for future reference, the issue is with both getting AND setting BlockDataMeta. Getting BlockDataMeta will always have default values with no easy way to filter them. (was thinking about generating default BlockData and then comparing states, but that's not trivial and doesn't fix the other problem) Setting BlockDataMeta will always insert default values into the item. (can confirm with /data get entity @s) I can't think of a way to fix this without digging into NBT again.

For now it's all or nothing with BlockDataMeta.

@PseudoKnight PseudoKnight added the bug Things that don't work as designed label Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Things that don't work as designed
Projects
None yet
Development

No branches or pull requests

2 participants