geforkt von Mirrors/Paper
SPIGOT-7664: Item meta should prevail over block states
By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
Ursprung
317917800c
Commit
850e49f268
@ -18,7 +18,7 @@
|
||||
}
|
||||
};
|
||||
private static final String REMOVED_PREFIX = "!";
|
||||
@@ -270,6 +270,38 @@
|
||||
@@ -270,6 +270,42 @@
|
||||
|
||||
a() {}
|
||||
|
||||
@ -31,6 +31,10 @@
|
||||
+ this.map.remove(type);
|
||||
+ }
|
||||
+
|
||||
+ public boolean isSet(DataComponentType<?> type) {
|
||||
+ return map.containsKey(type);
|
||||
+ }
|
||||
+
|
||||
+ public boolean 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()));
|
||||
|
||||
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.DataComponentType;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.core.component.TypedDataComponent;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.nbt.DynamicOpsNBT;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
@ -173,13 +174,20 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
|
||||
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) {
|
||||
builder.set(key.TYPE, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
<T> Applicator putIfAbsent(TypedDataComponent<?> component) {
|
||||
if (!builder.isSet(component.type())) {
|
||||
builder.set(component);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
DataComponentPatch build() {
|
||||
return builder.build();
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren