Skip to content

Commit

Permalink
fix: add cad capability data to item share tag
Browse files Browse the repository at this point in the history
  • Loading branch information
pandier authored and panda885 committed Oct 8, 2023
1 parent 629a668 commit 0f508b5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/java/vazkii/psi/common/item/ItemCAD.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 0f508b5

Please sign in to comment.