Supports block state for adventure tags (item meta)#8128
Closed
Lulu13022002 wants to merge 1 commit into
Closed
Conversation
Machine-Maker
requested changes
Jul 12, 2022
Member
There was a problem hiding this comment.
You cannot use BlockData to accurately represent the tags in CanPlaceOn and CanDestroy. If I have minecraft:chest[waterlogged=true] in a CanPlaceOn tag, that means the block can be placed on any chest, facing any direction as long as its waterlogged. The BlockData instance returned in item meta does not reflect that. If I do
// ["minecraft:chest[waterlogged=true]"]
BlockData data = itemMeta.getPlaceOnDatas().iterator().next();
((Chest) data).getFacing(); // this will return NORTH which is wrong
itemMeta.setPlaceableData(Set.of(data)); // will correctly serialize to "minecraft:chest[waterlogged=true]" because of the parsedStates BUT
itemStack.setItemMeta(itemMeta);
itemMeta = itemStack.getItemMeta();
Chest chest = (Chest) itemMeta.getPlaceableData().iterator().next();
// a plugin wants to know if this place on tag is only for chests facing north
if (chest.getFacing() == NORTH) {
// the plugin incorrectly thinks this itemstack can only be placed on chests facing north
}
Contributor
Author
|
Yep i have forgot the default values on uninitialized keys so i need to create a new class i think ? or is there any api already present in paper/bukkit ? also this breaks only for plugin, the serialization work well |
Member
|
#7223 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #6719
This allow block data into the CanDestroyOn and CanPlaceOn tags for vanilla state.
The deprecated material and namespaced key will now be backed into a block data with default state (internal)
The getters now check both tags, data and namespaced keys.
Examples: