SPIGOT-7664: Item meta should prevail over block states
By: md_5 <git@md-5.net>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user