diff --git a/resources/assets/resonantinduction/textures/gui/batterybox_gui.png b/resources/assets/resonantinduction/textures/gui/batterybox_gui.png index 9d845a2cb..a44d57d5f 100644 Binary files a/resources/assets/resonantinduction/textures/gui/batterybox_gui.png and b/resources/assets/resonantinduction/textures/gui/batterybox_gui.png differ diff --git a/src/resonantinduction/battery/BlockBattery.java b/src/resonantinduction/battery/BlockBattery.java index 023c3c932..df07d2782 100644 --- a/src/resonantinduction/battery/BlockBattery.java +++ b/src/resonantinduction/battery/BlockBattery.java @@ -96,6 +96,11 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider } } } + + if(!world.isRemote) + { + entityPlayer.openGui(ResonantInduction.INSTNACE, 0, world, x, y, z); + } return true; } diff --git a/src/resonantinduction/battery/ContainerBattery.java b/src/resonantinduction/battery/ContainerBattery.java index de7d54ae3..1b9df9653 100644 --- a/src/resonantinduction/battery/ContainerBattery.java +++ b/src/resonantinduction/battery/ContainerBattery.java @@ -25,13 +25,13 @@ public class ContainerBattery extends Container { for(int slotY = 0; slotY < 9; ++slotY) { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 125 + slotX * 18)); } } for(slotX = 0; slotX < 9; ++slotX) { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 183)); } tileEntity.openChest(); diff --git a/src/resonantinduction/battery/GuiBattery.java b/src/resonantinduction/battery/GuiBattery.java index bab1ec8ed..d5a00c6cb 100644 --- a/src/resonantinduction/battery/GuiBattery.java +++ b/src/resonantinduction/battery/GuiBattery.java @@ -18,6 +18,7 @@ public class GuiBattery extends GuiContainer { super(new ContainerBattery(inventory, tentity)); tileEntity = tentity; + ySize+=41; } @Override @@ -27,7 +28,10 @@ public class GuiBattery extends GuiContainer int yAxis = (mouseY - (height - ySize) / 2); fontRenderer.drawString("Battery", 43, 6, 0x404040); - fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 0x00CD00); + fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 0x404040); + fontRenderer.drawString("Cells: " + tileEntity.clientCells + " / " + tileEntity.structure.getMaxCells(), 62, 23, 0x404040); + fontRenderer.drawString("Energy: " + tileEntity.getEnergyStored() + " / " + tileEntity.getMaxEnergyStored(), 62, 32, 0x404040); + fontRenderer.drawString("Volume: " + tileEntity.structure.getVolume(), 62, 41, 0x404040); } @Override @@ -41,5 +45,8 @@ public class GuiBattery extends GuiContainer int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); + + int scale = (int)((tileEntity.getEnergyStored() / tileEntity.getMaxEnergyStored()) * 105); + drawTexturedModalRect(guiWidth + 61, guiHeight + 102, 0, 207, scale, 12); } } diff --git a/src/resonantinduction/battery/SynchronizedBatteryData.java b/src/resonantinduction/battery/SynchronizedBatteryData.java index c0ca748ce..9a613f9dc 100644 --- a/src/resonantinduction/battery/SynchronizedBatteryData.java +++ b/src/resonantinduction/battery/SynchronizedBatteryData.java @@ -45,7 +45,14 @@ public class SynchronizedBatteryData public void sortInventory() { - ItemStack[] toSort = (ItemStack[])SetUtil.copy(inventory).toArray(); + Object[] array = SetUtil.copy(inventory).toArray(); + + ItemStack[] toSort = new ItemStack[array.length]; + + for(int i = 0; i < array.length-1; i++) + { + toSort[i] = (ItemStack)array[i]; + } boolean cont = true; ItemStack temp; diff --git a/src/resonantinduction/battery/TileEntityBattery.java b/src/resonantinduction/battery/TileEntityBattery.java index e6d06fcf1..b4fb2e126 100644 --- a/src/resonantinduction/battery/TileEntityBattery.java +++ b/src/resonantinduction/battery/TileEntityBattery.java @@ -33,6 +33,7 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver public float clientEnergy; public int clientCells; + public float clientMaxEnergy; @Override public void updateEntity() @@ -43,6 +44,11 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver if(!worldObj.isRemote) { + if(playersUsing.size() > 0) + { + PacketHandler.sendTileEntityPacketToClients(this, getNetworkedData(new ArrayList()).toArray()); + } + if(ticks == 5 && !structure.isMultiblock) { update(); @@ -65,7 +71,7 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver player.closeScreen(); } - PacketHandler.sendTileEntityPacketToClients(this, getNetworkedData(new ArrayList())); + PacketHandler.sendTileEntityPacketToClients(this, getNetworkedData(new ArrayList()).toArray()); } prevStructure = structure; @@ -187,20 +193,26 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver public float getMaxEnergyStored() { - float max = 0; - - for (ItemStack itemStack : structure.inventory) + if(!worldObj.isRemote) { - if (itemStack != null) + float max = 0; + + for (ItemStack itemStack : structure.inventory) { - if (itemStack.getItem() instanceof IBattery) + if (itemStack != null) { - max += ((IBattery) itemStack.getItem()).getMaxEnergyStored(); + if (itemStack.getItem() instanceof IBattery) + { + max += ((IBattery) itemStack.getItem()).getMaxEnergyStored(); + } } } + + return max; + } + else { + return clientMaxEnergy; } - - return max; } public float getEnergyStored() @@ -235,13 +247,11 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver clientEnergy = input.readFloat(); clientCells = input.readInt(); + clientMaxEnergy = input.readFloat(); - if(structure.isMultiblock) - { - structure.height = input.readInt(); - structure.length = input.readInt(); - structure.width = input.readInt(); - } + structure.height = input.readInt(); + structure.length = input.readInt(); + structure.width = input.readInt(); } catch(Exception e) {} } @@ -252,13 +262,11 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver data.add(getEnergyStored()); data.add(structure.inventory.size()); + data.add(getMaxEnergyStored()); - if(structure.isMultiblock) - { - data.add(structure.height); - data.add(structure.length); - data.add(structure.width); - } + data.add(structure.height); + data.add(structure.length); + data.add(structure.width); return data; }