Fix MatteryContainer of capacitor bank getting recreated

This commit is contained in:
DBotThePony 2021-08-20 22:00:43 +07:00
parent 92bde060f6
commit a0af840ab9
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -144,7 +144,7 @@ public class BlockEntityMatterCapacitorBank extends BlockEntityMattery implement
private final LazyOptional<IMatterHandler> resolver = LazyOptional.of(() -> matter); private final LazyOptional<IMatterHandler> resolver = LazyOptional.of(() -> matter);
public MatteryContainer matter_container = new MatteryContainer(this::setChanged, 6 * 2) { public final MatteryContainer matter_container = new MatteryContainer(this::setChanged, 6 * 2) {
@Override @Override
public void setChanged(int slot, ItemStack new_state, ItemStack old_state) { public void setChanged(int slot, ItemStack new_state, ItemStack old_state) {
super.setChanged(slot, new_state, old_state); super.setChanged(slot, new_state, old_state);
@ -182,9 +182,7 @@ public class BlockEntityMatterCapacitorBank extends BlockEntityMattery implement
@Override @Override
public void load(CompoundTag nbt) { public void load(CompoundTag nbt) {
if (nbt.contains("matter_container") && nbt.get("matter_container") instanceof CompoundTag tag) matter_container.deserializeNBT(nbt.get("matter_container"));
matter_container = MatteryContainer.of(this::setChanged, tag, matter_container.getContainerSize());
super.load(nbt); super.load(nbt);
} }