Make BlockDataMeta#setBlockData hide unspecified states

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2024-11-23 21:08:50 +11:00
parent 8f7a88cc91
commit 0f66e39e46
2 changed files with 7 additions and 3 deletions

View File

@ -253,10 +253,14 @@ public class CraftBlockData implements BlockData {
return stateString.toString();
}
public Map<String, String> toStates() {
public Map<String, String> toStates(boolean hideUnspecified) {
return (hideUnspecified && parsedStates != null) ? toStates(parsedStates) : toStates(state.getValues());
}
private static Map<String, String> toStates(Map<IBlockState<?>, Comparable<?>> states) {
Map<String, String> compound = new HashMap<>();
for (Map.Entry<IBlockState<?>, Comparable<?>> entry : state.getValues().entrySet()) {
for (Map.Entry<IBlockState<?>, Comparable<?>> entry : states.entrySet()) {
IBlockState iblockstate = (IBlockState) entry.getKey();
compound.put(iblockstate.getName(), iblockstate.getName(entry.getValue()));

View File

@ -1318,7 +1318,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@Override
public void setBlockData(BlockData blockData) {
this.blockData = (blockData == null) ? null : ((CraftBlockData) blockData).toStates();
this.blockData = (blockData == null) ? null : ((CraftBlockData) blockData).toStates(true);
}
@Override