Fixed drawer controllers not working with external storage

This commit is contained in:
Raoul Van den Berge
2016-07-02 16:16:09 +02:00
parent 96b5d243d1
commit 7e69d52687
2 changed files with 15 additions and 3 deletions

View File

@@ -37,7 +37,7 @@ public class BlockExternalStorage extends BlockSlave {
super.neighborChanged(state, world, pos, block);
if (!world.isRemote) {
((TileExternalStorage) world.getTileEntity(pos)).refreshStorage();
((TileExternalStorage) world.getTileEntity(pos)).updateStorage();
}
}

View File

@@ -40,6 +40,7 @@ public class TileExternalStorage extends TileSlave implements IStorageProvider,
private int capacity;
private List<ExternalStorage> storages = new ArrayList<ExternalStorage>();
private int lastDrawerCount;
@Override
public int getEnergyUsage() {
@@ -50,6 +51,17 @@ public class TileExternalStorage extends TileSlave implements IStorageProvider,
public void updateSlave() {
}
@Override
public void update() {
super.update();
if (getFacingTile() instanceof IDrawerGroup && lastDrawerCount != ((IDrawerGroup) getFacingTile()).getDrawerCount()) {
lastDrawerCount = ((IDrawerGroup) getFacingTile()).getDrawerCount();
updateStorage();
}
}
@Override
public void writeContainerData(ByteBuf buf) {
super.writeContainerData(buf);
@@ -144,8 +156,8 @@ public class TileExternalStorage extends TileSlave implements IStorageProvider,
markDirty();
}
// Called when the neighbor block changes
public void refreshStorage() {
// Called when the neighbor block changes or when a drawer is added or removed to a drawer group
public void updateStorage() {
storages.clear();
TileEntity facing = getFacingTile();