diff --git a/src/main/java/com/simibubi/create/content/equipment/armor/BacktankBlock.java b/src/main/java/com/simibubi/create/content/equipment/armor/BacktankBlock.java index 967f0a7f67..93e7fc44df 100644 --- a/src/main/java/com/simibubi/create/content/equipment/armor/BacktankBlock.java +++ b/src/main/java/com/simibubi/create/content/equipment/armor/BacktankBlock.java @@ -184,8 +184,10 @@ public ItemStack getCloneItemStack(BlockGetter blockGetter, BlockPos pos, BlockS Optional blockEntityOptional = getBlockEntityOptional(blockGetter, pos); CompoundTag forgeCapsTag = blockEntityOptional.map(BacktankBlockEntity::getForgeCapsTag) + .map(CompoundTag::copy) .orElse(null); CompoundTag vanillaTag = blockEntityOptional.map(BacktankBlockEntity::getVanillaTag) + .map(CompoundTag::copy) .orElse(new CompoundTag()); int air = blockEntityOptional.map(BacktankBlockEntity::getAirLevel) .orElse(0); diff --git a/src/main/java/com/simibubi/create/content/equipment/armor/BacktankBlockEntity.java b/src/main/java/com/simibubi/create/content/equipment/armor/BacktankBlockEntity.java index 181e5b1bb3..6b03b0947f 100644 --- a/src/main/java/com/simibubi/create/content/equipment/armor/BacktankBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/equipment/armor/BacktankBlockEntity.java @@ -120,10 +120,10 @@ protected void write(CompoundTag compound, boolean clientPacket) { compound.putInt("Air", airLevel); compound.putInt("Timer", airLevelTimer); compound.putInt("CapacityEnchantment", capacityEnchantLevel); - + if (this.customName != null) compound.putString("CustomName", Component.Serializer.toJson(this.customName)); - + compound.put("VanillaTag", vanillaTag); if (forgeCapsTag != null) compound.put("ForgeCapsTag", forgeCapsTag); @@ -136,10 +136,10 @@ protected void read(CompoundTag compound, boolean clientPacket) { airLevel = compound.getInt("Air"); airLevelTimer = compound.getInt("Timer"); capacityEnchantLevel = compound.getInt("CapacityEnchantment"); - + if (compound.contains("CustomName", 8)) this.customName = Component.Serializer.fromJson(compound.getString("CustomName")); - + vanillaTag = compound.getCompound("VanillaTag"); forgeCapsTag = compound.contains("ForgeCapsTag") ? compound.getCompound("ForgeCapsTag") : null; @@ -181,16 +181,18 @@ public void setCustomName(Component customName) { public void setCapacityEnchantLevel(int capacityEnchantLevel) { this.capacityEnchantLevel = capacityEnchantLevel; } - + public void setTags(CompoundTag vanillaTag, @Nullable CompoundTag forgeCapsTag) { - this.vanillaTag = vanillaTag; - this.forgeCapsTag = forgeCapsTag; + this.vanillaTag = vanillaTag.copy(); + this.forgeCapsTag = forgeCapsTag == null ? null : forgeCapsTag.copy(); + // Prevent nesting of the ctrl+pick block added tag + vanillaTag.remove("BlockEntityTag"); } public CompoundTag getVanillaTag() { return vanillaTag; } - + public CompoundTag getForgeCapsTag() { return forgeCapsTag; }