diff --git a/src/main/java/vazkii/psi/common/item/ItemCAD.java b/src/main/java/vazkii/psi/common/item/ItemCAD.java index c1579560..b10eeb66 100644 --- a/src/main/java/vazkii/psi/common/item/ItemCAD.java +++ b/src/main/java/vazkii/psi/common/item/ItemCAD.java @@ -129,6 +129,22 @@ public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundT return data; } + @Override + public @Nullable CompoundTag getShareTag(ItemStack stack) { + CompoundTag nbt = stack.getOrCreateTag(); + stack.getCapability(PsiAPI.CAD_DATA_CAPABILITY).ifPresent(data -> nbt.put("CapabilityData", data.serializeNBT())); + return nbt; + } + + @Override + public void readShareTag(ItemStack stack, @Nullable CompoundTag nbt) { + super.readShareTag(stack, nbt); + + if (nbt != null) { + stack.getCapability(PsiAPI.CAD_DATA_CAPABILITY).ifPresent(data -> data.deserializeNBT(nbt.getCompound("CapabilityData"))); + } + } + @Override public void inventoryTick(ItemStack stack, Level world, Entity entityIn, int itemSlot, boolean isSelected) { CompoundTag compound = stack.getOrCreateTag();