This commit is contained in:
Calclavia 2013-08-04 23:45:36 -04:00
commit ba5f23f540
6 changed files with 52 additions and 25 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View file

@ -97,6 +97,11 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
} }
} }
if(!world.isRemote)
{
entityPlayer.openGui(ResonantInduction.INSTNACE, 0, world, x, y, z);
}
return true; return true;
} }

View file

@ -25,13 +25,13 @@ public class ContainerBattery extends Container
{ {
for(int slotY = 0; slotY < 9; ++slotY) 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) 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(); tileEntity.openChest();

View file

@ -18,6 +18,7 @@ public class GuiBattery extends GuiContainer
{ {
super(new ContainerBattery(inventory, tentity)); super(new ContainerBattery(inventory, tentity));
tileEntity = tentity; tileEntity = tentity;
ySize+=41;
} }
@Override @Override
@ -27,7 +28,10 @@ public class GuiBattery extends GuiContainer
int yAxis = (mouseY - (height - ySize) / 2); int yAxis = (mouseY - (height - ySize) / 2);
fontRenderer.drawString("Battery", 43, 6, 0x404040); 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 @Override
@ -41,5 +45,8 @@ public class GuiBattery extends GuiContainer
int xAxis = (mouseX - (width - xSize) / 2); int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2); int yAxis = (mouseY - (height - ySize) / 2);
int scale = (int)((tileEntity.getEnergyStored() / tileEntity.getMaxEnergyStored()) * 105);
drawTexturedModalRect(guiWidth + 61, guiHeight + 102, 0, 207, scale, 12);
} }
} }

View file

@ -45,7 +45,14 @@ public class SynchronizedBatteryData
public void sortInventory() 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; boolean cont = true;
ItemStack temp; ItemStack temp;

View file

@ -33,6 +33,7 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
public float clientEnergy; public float clientEnergy;
public int clientCells; public int clientCells;
public float clientMaxEnergy;
@Override @Override
public void updateEntity() public void updateEntity()
@ -43,6 +44,11 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
if(!worldObj.isRemote) if(!worldObj.isRemote)
{ {
if(playersUsing.size() > 0)
{
PacketHandler.sendTileEntityPacketToClients(this, getNetworkedData(new ArrayList()).toArray());
}
if(ticks == 5 && !structure.isMultiblock) if(ticks == 5 && !structure.isMultiblock)
{ {
update(); update();
@ -65,7 +71,7 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
player.closeScreen(); player.closeScreen();
} }
PacketHandler.sendTileEntityPacketToClients(this, getNetworkedData(new ArrayList())); PacketHandler.sendTileEntityPacketToClients(this, getNetworkedData(new ArrayList()).toArray());
} }
prevStructure = structure; prevStructure = structure;
@ -186,6 +192,8 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
} }
public float getMaxEnergyStored() public float getMaxEnergyStored()
{
if(!worldObj.isRemote)
{ {
float max = 0; float max = 0;
@ -202,6 +210,10 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
return max; return max;
} }
else {
return clientMaxEnergy;
}
}
public float getEnergyStored() public float getEnergyStored()
{ {
@ -235,13 +247,11 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
clientEnergy = input.readFloat(); clientEnergy = input.readFloat();
clientCells = input.readInt(); clientCells = input.readInt();
clientMaxEnergy = input.readFloat();
if(structure.isMultiblock)
{
structure.height = input.readInt(); structure.height = input.readInt();
structure.length = input.readInt(); structure.length = input.readInt();
structure.width = input.readInt(); structure.width = input.readInt();
}
} catch(Exception e) {} } catch(Exception e) {}
} }
@ -252,13 +262,11 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
data.add(getEnergyStored()); data.add(getEnergyStored());
data.add(structure.inventory.size()); data.add(structure.inventory.size());
data.add(getMaxEnergyStored());
if(structure.isMultiblock)
{
data.add(structure.height); data.add(structure.height);
data.add(structure.length); data.add(structure.length);
data.add(structure.width); data.add(structure.width);
}
return data; return data;
} }