SPIGOT-7664: Item meta should prevail over block states
This commit is contained in:
parent
c2ccc46ec3
commit
4af0f22e8a
@ -18,7 +18,7 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
private static final String REMOVED_PREFIX = "!";
|
private static final String REMOVED_PREFIX = "!";
|
||||||
@@ -270,6 +270,38 @@
|
@@ -270,6 +270,42 @@
|
||||||
|
|
||||||
a() {}
|
a() {}
|
||||||
|
|
||||||
@ -31,6 +31,10 @@
|
|||||||
+ this.map.remove(type);
|
+ this.map.remove(type);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ public boolean isSet(DataComponentType<?> type) {
|
||||||
|
+ return map.containsKey(type);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ public boolean isEmpty() {
|
+ public boolean isEmpty() {
|
||||||
+ return this.map.isEmpty();
|
+ return this.map.isEmpty();
|
||||||
+ }
|
+ }
|
||||||
|
@ -212,7 +212,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
|
|||||||
tag.put(BLOCK_ENTITY_TAG, CustomData.of(blockEntityTag.getSnapshotNBTWithoutComponents()));
|
tag.put(BLOCK_ENTITY_TAG, CustomData.of(blockEntityTag.getSnapshotNBTWithoutComponents()));
|
||||||
|
|
||||||
for (TypedDataComponent<?> component : blockEntityTag.collectComponents()) {
|
for (TypedDataComponent<?> component : blockEntityTag.collectComponents()) {
|
||||||
tag.builder.set(component);
|
tag.putIfAbsent(component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ import net.minecraft.core.IRegistryCustom;
|
|||||||
import net.minecraft.core.component.DataComponentPatch;
|
import net.minecraft.core.component.DataComponentPatch;
|
||||||
import net.minecraft.core.component.DataComponentType;
|
import net.minecraft.core.component.DataComponentType;
|
||||||
import net.minecraft.core.component.DataComponents;
|
import net.minecraft.core.component.DataComponents;
|
||||||
|
import net.minecraft.core.component.TypedDataComponent;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.nbt.DynamicOpsNBT;
|
import net.minecraft.nbt.DynamicOpsNBT;
|
||||||
import net.minecraft.nbt.NBTBase;
|
import net.minecraft.nbt.NBTBase;
|
||||||
@ -173,13 +174,20 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|||||||
|
|
||||||
static final class Applicator {
|
static final class Applicator {
|
||||||
|
|
||||||
final DataComponentPatch.a builder = DataComponentPatch.builder();
|
private final DataComponentPatch.a builder = DataComponentPatch.builder();
|
||||||
|
|
||||||
<T> Applicator put(ItemMetaKeyType<T> key, T value) {
|
<T> Applicator put(ItemMetaKeyType<T> key, T value) {
|
||||||
builder.set(key.TYPE, value);
|
builder.set(key.TYPE, value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<T> Applicator putIfAbsent(TypedDataComponent<?> component) {
|
||||||
|
if (!builder.isSet(component.type())) {
|
||||||
|
builder.set(component);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
DataComponentPatch build() {
|
DataComponentPatch build() {
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user