Skip to content

Commit

Permalink
made base cover not add item inventory nbt if the slots are empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Sep 19, 2023
1 parent 4faa0cd commit 2d1b243
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions common/src/main/java/muramasa/antimatter/cover/BaseCover.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,13 @@ public ItemStack getDroppedStack() {
ItemStack stack = ICover.super.getDroppedStack();
if (inventories != null && getFactory().hasGui()){
CompoundTag nbt = new CompoundTag();
this.inventories.forEach((f, i) -> nbt.put(f.getId(), i.serialize(new CompoundTag())));
stack.getOrCreateTag().put("coverInventories", nbt);
this.inventories.forEach((f, i) -> {
if (i.isEmpty()) return;
nbt.put(f.getId(), i.serialize(new CompoundTag()));
});
if (!nbt.isEmpty()) {
stack.getOrCreateTag().put("coverInventories", nbt);
}
}
return stack;
}
Expand All @@ -162,6 +167,7 @@ public void addInfoFromStack(ItemStack stack) {
if (!nbt.contains(f.getId())) return;
i.deserialize(nbt.getCompound(f.getId()));
});
handler.getTile().setChanged();
}
}
}
Expand Down Expand Up @@ -223,7 +229,10 @@ public GuiData getGui() {
public CompoundTag serialize() {
CompoundTag nbt = new CompoundTag();
if (inventories != null && getFactory().hasGui()){
this.inventories.forEach((f, i) -> nbt.put(f.getId(), i.serialize(new CompoundTag())));
this.inventories.forEach((f, i) -> {
if (i.isEmpty()) return;
nbt.put(f.getId(), i.serialize(new CompoundTag()));
});
}
return nbt;
}
Expand Down

0 comments on commit 2d1b243

Please sign in to comment.