Fix item storage blocks. Closes #2717
This commit is contained in:
parent
cf9965a598
commit
c887d1652d
2 changed files with 3 additions and 8 deletions
|
@ -141,6 +141,7 @@ public class RebornInventory<T extends MachineBaseBlockEntity> extends Inventory
|
||||||
|
|
||||||
public void setHashChanged() {
|
public void setHashChanged() {
|
||||||
this.hasChanged = true;
|
this.hasChanged = true;
|
||||||
|
this.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHashChanged(boolean changed) {
|
public void setHashChanged(boolean changed) {
|
||||||
|
|
|
@ -75,23 +75,21 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
|
||||||
|
|
||||||
public StorageUnitBaseBlockEntity(BlockPos pos, BlockState state) {
|
public StorageUnitBaseBlockEntity(BlockPos pos, BlockState state) {
|
||||||
super(TRBlockEntities.STORAGE_UNIT, pos, state);
|
super(TRBlockEntities.STORAGE_UNIT, pos, state);
|
||||||
|
inventory = new RebornInventory<>(2, "ItemInventory", 64, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StorageUnitBaseBlockEntity(BlockPos pos, BlockState state, TRContent.StorageUnit type) {
|
public StorageUnitBaseBlockEntity(BlockPos pos, BlockState state, TRContent.StorageUnit type) {
|
||||||
super(TRBlockEntities.STORAGE_UNIT, pos, state);
|
super(TRBlockEntities.STORAGE_UNIT, pos, state);
|
||||||
|
inventory = new RebornInventory<>(2, "ItemInventory", 64, this);
|
||||||
configureEntity(type);
|
configureEntity(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureEntity(TRContent.StorageUnit type) {
|
private void configureEntity(TRContent.StorageUnit type) {
|
||||||
|
|
||||||
// Set capacity to local config unless overridden by server
|
// Set capacity to local config unless overridden by server
|
||||||
if(serverCapacity == -1){
|
if(serverCapacity == -1){
|
||||||
this.maxCapacity = type.capacity;
|
this.maxCapacity = type.capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
storeItemStack = ItemStack.EMPTY;
|
storeItemStack = ItemStack.EMPTY;
|
||||||
inventory = new RebornInventory<>(2, "ItemInventory", 64, this);
|
|
||||||
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,8 +311,6 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
|
||||||
if (tagCompound.contains("lockedItem")) {
|
if (tagCompound.contains("lockedItem")) {
|
||||||
lockedItemStack = ItemStack.fromNbt(tagCompound.getCompound("lockedItem"));
|
lockedItemStack = ItemStack.fromNbt(tagCompound.getCompound("lockedItem"));
|
||||||
}
|
}
|
||||||
|
|
||||||
inventory.read(tagCompound);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -340,8 +336,6 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
|
||||||
if (isLocked()) {
|
if (isLocked()) {
|
||||||
tagCompound.put("lockedItem", lockedItemStack.writeNbt(new NbtCompound()));
|
tagCompound.put("lockedItem", lockedItemStack.writeNbt(new NbtCompound()));
|
||||||
}
|
}
|
||||||
|
|
||||||
inventory.write(tagCompound);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue