Work on battery GUI

This commit is contained in:
Aidan Brady 2013-08-04 22:32:28 -04:00
parent 54b8800ff5
commit ccbaf105eb
5 changed files with 118 additions and 1 deletions

View file

@ -6,6 +6,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import resonantinduction.base.Vector3;
import resonantinduction.battery.GuiBattery;
import resonantinduction.battery.TileEntityBattery;
import resonantinduction.contractor.TileEntityEMContractor;
import resonantinduction.fx.FXElectricBolt;
@ -52,6 +53,11 @@ public class ClientProxy extends CommonProxy
{
return new GuiMultimeter(player.inventory, ((TileEntityMultimeter) tileEntity));
}
else if (tileEntity instanceof TileEntityBattery)
{
return new GuiBattery(player.inventory, ((TileEntityBattery) tileEntity));
}
return null;
}

View file

@ -7,6 +7,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import resonantinduction.base.Vector3;
import resonantinduction.battery.ContainerBattery;
import resonantinduction.battery.TileEntityBattery;
import resonantinduction.multimeter.ContainerMultimeter;
import resonantinduction.multimeter.TileEntityMultimeter;
import cpw.mods.fml.common.network.IGuiHandler;
@ -31,6 +33,11 @@ public class CommonProxy implements IGuiHandler
{
return new ContainerMultimeter(player.inventory, ((TileEntityMultimeter) tileEntity));
}
else if (tileEntity instanceof TileEntityBattery)
{
return new ContainerBattery(player.inventory, ((TileEntityBattery) tileEntity));
}
return null;
}

View file

@ -217,7 +217,12 @@ public class BatteryUpdateProtocol
if(oldStructure != null)
{
ArrayList<Set<ItemStack>> inventories = SetUtil.split(oldStructure.inventory, iteratedNodes.size());
int maxCells = iteratedNodes.size()*BatteryManager.CELLS_PER_BATTERY;
//TODO eject these
Set<ItemStack> rejected = SetUtil.capRemains(oldStructure.inventory, maxCells);
ArrayList<Set<ItemStack>> inventories = SetUtil.split(SetUtil.cap(oldStructure.inventory, maxCells), iteratedNodes.size());
List<TileEntityBattery> iterList = SetUtil.asList(iteratedNodes);
boolean didVisibleInventory = false;

View file

@ -0,0 +1,54 @@
package resonantinduction.battery;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import resonantinduction.battery.BatteryManager.SlotBattery;
import resonantinduction.battery.BatteryManager.SlotOut;
public class ContainerBattery extends Container
{
private TileEntityBattery tileEntity;
public ContainerBattery(InventoryPlayer inventory, TileEntityBattery unit)
{
tileEntity = unit;
addSlotToContainer(new SlotBattery(unit, 0, 8, 22));
addSlotToContainer(new SlotOut(unit, 1, 8, 58));
addSlotToContainer(new SlotBattery(unit, 2, 31, 22));
addSlotToContainer(new SlotBattery(unit, 3, 31, 58));
int slotX;
for(slotX = 0; slotX < 3; ++slotX)
{
for(int slotY = 0; slotY < 9; ++slotY)
{
addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18));
}
}
for(slotX = 0; slotX < 9; ++slotX)
{
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
}
tileEntity.openChest();
tileEntity.playersUsing.add(inventory.player);
}
@Override
public void onContainerClosed(EntityPlayer entityplayer)
{
super.onContainerClosed(entityplayer);
tileEntity.closeChest();
tileEntity.playersUsing.remove(entityplayer);
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer)
{
return tileEntity.isUseableByPlayer(entityplayer);
}
}

View file

@ -0,0 +1,45 @@
package resonantinduction.battery;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import resonantinduction.ResonantInduction;
public class GuiBattery extends GuiContainer
{
private static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.GUI_DIRECTORY + "batterybox_gui.png");
public TileEntityBattery tileEntity;
public GuiBattery(InventoryPlayer inventory, TileEntityBattery tentity)
{
super(new ContainerBattery(inventory, tentity));
tileEntity = tentity;
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
fontRenderer.drawString("Battery", 43, 6, 0x404040);
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 0x00CD00);
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int mouseX, int mouseY)
{
mc.renderEngine.func_110577_a(TEXTURE);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
}
}