Compare commits

..

3 commits

Author SHA1 Message Date
Eclipse
8150091888
Fix equippable component writing (#868)
Some checks failed
Java CI with Gradle / build (push) Has been cancelled
Deploy / build (push) Has been cancelled
2024-11-07 19:03:03 +08:00
basaigh
88188c5b39
Merge pull request #867 from AJ-Ferguson/lock-nbt
Read lock data component as compound nbt
2024-11-07 10:07:35 +00:00
AJ Ferguson
f82aa5bc87 Read lock data component as compound nbt 2024-11-07 04:44:11 -05:00
2 changed files with 2 additions and 9 deletions

View file

@ -86,7 +86,7 @@ public class DataComponentType<T> {
public static final DataComponentType<List<ItemStack>> CONTAINER = new DataComponentType<>(listReader(ItemCodecHelper::readOptionalItemStack), listWriter(MinecraftCodecHelper::writeOptionalItemStack), ObjectDataComponent::new); public static final DataComponentType<List<ItemStack>> CONTAINER = new DataComponentType<>(listReader(ItemCodecHelper::readOptionalItemStack), listWriter(MinecraftCodecHelper::writeOptionalItemStack), ObjectDataComponent::new);
public static final DataComponentType<BlockStateProperties> BLOCK_STATE = new DataComponentType<>(ItemCodecHelper::readBlockStateProperties, ItemCodecHelper::writeBlockStateProperties, ObjectDataComponent::new); public static final DataComponentType<BlockStateProperties> BLOCK_STATE = new DataComponentType<>(ItemCodecHelper::readBlockStateProperties, ItemCodecHelper::writeBlockStateProperties, ObjectDataComponent::new);
public static final DataComponentType<List<BeehiveOccupant>> BEES = new DataComponentType<>(listReader(ItemCodecHelper::readBeehiveOccupant), listWriter(ItemCodecHelper::writeBeehiveOccupant), ObjectDataComponent::new); public static final DataComponentType<List<BeehiveOccupant>> BEES = new DataComponentType<>(listReader(ItemCodecHelper::readBeehiveOccupant), listWriter(ItemCodecHelper::writeBeehiveOccupant), ObjectDataComponent::new);
public static final DataComponentType<String> LOCK = new DataComponentType<>(ItemCodecHelper::readLock, ItemCodecHelper::writeLock, ObjectDataComponent::new); public static final DataComponentType<NbtMap> LOCK = new DataComponentType<>(ItemCodecHelper::readCompoundTag, ItemCodecHelper::writeAnyTag, ObjectDataComponent::new);
public static final DataComponentType<NbtMap> CONTAINER_LOOT = new DataComponentType<>(ItemCodecHelper::readCompoundTag, ItemCodecHelper::writeAnyTag, ObjectDataComponent::new); public static final DataComponentType<NbtMap> CONTAINER_LOOT = new DataComponentType<>(ItemCodecHelper::readCompoundTag, ItemCodecHelper::writeAnyTag, ObjectDataComponent::new);
protected final int id; protected final int id;

View file

@ -158,6 +158,7 @@ public class ItemCodecHelper extends MinecraftCodecHelper {
} }
this.writeNullable(buf, equippable.model(), this::writeResourceLocation); this.writeNullable(buf, equippable.model(), this::writeResourceLocation);
this.writeNullable(buf, equippable.cameraOverlay(), this::writeResourceLocation);
this.writeNullable(buf, equippable.allowedEntities(), this::writeHolderSet); this.writeNullable(buf, equippable.allowedEntities(), this::writeHolderSet);
buf.writeBoolean(equippable.dispensable()); buf.writeBoolean(equippable.dispensable());
buf.writeBoolean(equippable.swappable()); buf.writeBoolean(equippable.swappable());
@ -637,12 +638,4 @@ public class ItemCodecHelper extends MinecraftCodecHelper {
this.writeVarInt(buf, occupant.getTicksInHive()); this.writeVarInt(buf, occupant.getTicksInHive());
this.writeVarInt(buf, occupant.getMinTicksInHive()); this.writeVarInt(buf, occupant.getMinTicksInHive());
} }
public String readLock(ByteBuf buf) {
return this.readAnyTag(buf, NbtType.STRING);
}
public void writeLock(ByteBuf buf, String key) {
this.writeAnyTag(buf, key);
}
} }