Skip to content

Commit

Permalink
Fix #115
Browse files Browse the repository at this point in the history
  • Loading branch information
Edivad99 committed Sep 13, 2023
1 parent 0624a97 commit b2e636e
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ public IEnergyStorage getBatteryCart() {
@Override
public void readAdditionalSaveData(CompoundTag tag) {
super.readAdditionalSaveData(tag);
this.cartStorage.deserializeNBT(tag.getCompound("battery"));
this.cartStorage.receiveEnergy(tag.getInt("energy"), false);
}

@Override
public void addAdditionalSaveData(CompoundTag tag) {
super.addAdditionalSaveData(tag);
tag.put("battery", this.cartStorage.serializeNBT());
tag.putInt("energy", this.cartStorage.getEnergyStored());
}

@Override
Expand All @@ -175,13 +175,13 @@ protected void loadFromItemStack(ItemStack itemStack) {
if (this.cartStorage == null) {
this.cartStorage = new ChargeCartStorageImpl(MAX_CHARGE);
}
this.cartStorage.deserializeNBT(tag.getCompound("battery"));
this.cartStorage.receiveEnergy(tag.getInt("energy"), false);
}

@Override
public ItemStack getPickResult() {
var itemStack = super.getPickResult();
itemStack.getOrCreateTag().put("battery", this.cartStorage.serializeNBT());
itemStack.getOrCreateTag().putInt("energy", this.cartStorage.getEnergyStored());
return itemStack;
}

Expand Down

0 comments on commit b2e636e

Please sign in to comment.