aboutsummaryrefslogtreecommitdiff
path: root/src/Java/binnie/craftgui/minecraft
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-01-20 14:24:34 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-01-20 14:24:34 +1000
commit869c206c4fcc8001bd2e1d66f704290331813835 (patch)
tree96735ce8fe4665e2759c3374221d6f06f4527df2 /src/Java/binnie/craftgui/minecraft
parentec2c72827f01dd4bb2174137f1ab162f9ddaab62 (diff)
downloadGT5-Unofficial-869c206c4fcc8001bd2e1d66f704290331813835.tar.gz
GT5-Unofficial-869c206c4fcc8001bd2e1d66f704290331813835.tar.bz2
GT5-Unofficial-869c206c4fcc8001bd2e1d66f704290331813835.zip
Initial Commit
Diffstat (limited to 'src/Java/binnie/craftgui/minecraft')
-rw-r--r--src/Java/binnie/craftgui/minecraft/ContainerCraftGUI.java549
-rw-r--r--src/Java/binnie/craftgui/minecraft/CustomSlot.java54
-rw-r--r--src/Java/binnie/craftgui/minecraft/Dialog.java53
-rw-r--r--src/Java/binnie/craftgui/minecraft/EnumColor.java32
-rw-r--r--src/Java/binnie/craftgui/minecraft/GUIIcon.java30
-rw-r--r--src/Java/binnie/craftgui/minecraft/GuiCraftGUI.java605
-rw-r--r--src/Java/binnie/craftgui/minecraft/IMachineInformation.java6
-rw-r--r--src/Java/binnie/craftgui/minecraft/IMinecraftTooltip.java9
-rw-r--r--src/Java/binnie/craftgui/minecraft/IWindowAffectsShiftClick.java8
-rw-r--r--src/Java/binnie/craftgui/minecraft/InventoryType.java8
-rw-r--r--src/Java/binnie/craftgui/minecraft/ListMap.java149
-rw-r--r--src/Java/binnie/craftgui/minecraft/MinecraftGUI.java14
-rw-r--r--src/Java/binnie/craftgui/minecraft/MinecraftTooltip.java63
-rw-r--r--src/Java/binnie/craftgui/minecraft/ModuleCraftGUI.java18
-rw-r--r--src/Java/binnie/craftgui/minecraft/Window.java338
-rw-r--r--src/Java/binnie/craftgui/minecraft/WindowInventory.java144
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlEnergyBar.java161
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlErrorState.java113
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlHelp.java41
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlIconDisplay.java25
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlImage.java25
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlInfo.java38
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlItemDisplay.java98
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlLiquidTank.java223
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlMachineProgress.java14
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlPlayerInventory.java108
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlPowerSystem.java39
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlProgress.java30
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlProgressBase.java100
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlSlide.java113
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlSlot.java221
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlSlotArray.java76
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlSlotBase.java77
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlSlotCharge.java43
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlTabIcon.java47
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlUser.java41
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/EnumHighlighting.java28
-rw-r--r--src/Java/binnie/craftgui/minecraft/render/MinecraftTexture.java10
-rw-r--r--src/Java/binnie/craftgui/minecraft/render/RenderCommand.java16
39 files changed, 3767 insertions, 0 deletions
diff --git a/src/Java/binnie/craftgui/minecraft/ContainerCraftGUI.java b/src/Java/binnie/craftgui/minecraft/ContainerCraftGUI.java
new file mode 100644
index 0000000000..9b6a2809d9
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/ContainerCraftGUI.java
@@ -0,0 +1,549 @@
+package binnie.craftgui.minecraft;
+
+import binnie.core.BinnieCore;
+import binnie.core.machines.IMachine;
+import binnie.core.machines.Machine;
+import binnie.core.machines.network.INetwork.RecieveGuiNBT;
+import binnie.core.machines.network.INetwork.SendGuiNBT;
+import binnie.core.machines.power.ErrorState;
+import binnie.core.machines.power.IErrorStateSource;
+import binnie.core.machines.power.IPoweredMachine;
+import binnie.core.machines.power.IProcess;
+import binnie.core.machines.power.ITankMachine;
+import binnie.core.machines.power.PowerInfo;
+import binnie.core.machines.power.ProcessInfo;
+import binnie.core.machines.power.TankInfo;
+import binnie.core.machines.transfer.TransferRequest;
+import binnie.core.machines.transfer.TransferRequest.TransferSlot;
+import binnie.core.network.packet.MessageContainerUpdate;
+import binnie.core.proxy.BinnieProxy;
+import binnie.craftgui.minecraft.control.ControlSlot;
+import binnie.craftgui.minecraft.control.EnumHighlighting;
+import com.mojang.authlib.GameProfile;
+import cpw.mods.fml.relauncher.Side;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class ContainerCraftGUI
+ extends Container
+{
+ private Window window;
+
+ public ContainerCraftGUI(Window window)
+ {
+ this.window = window;
+ IMachine machine = Machine.getMachine(window.getInventory());
+ if (getSide() == Side.SERVER)
+ {
+ this.inventoryItemStacks = new ListMap();
+ this.inventorySlots = new ListMap();
+ if (machine != null)
+ {
+ GameProfile user = machine.getOwner();
+ if (user != null)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ nbt.setString("username", user.getName());
+ sendNBTToClient("username", nbt);
+ }
+ }
+ }
+ }
+
+ protected Slot addSlotToContainer(Slot slot)
+ {
+ return super.addSlotToContainer(slot);
+ }
+
+ private Side getSide()
+ {
+ return this.window.isServer() ? Side.SERVER : Side.CLIENT;
+ }
+
+ public Slot getSlot(int par1)
+ {
+ if ((par1 < 0) || (par1 >= this.inventorySlots.size())) {
+ return null;
+ }
+ return (Slot)this.inventorySlots.get(par1);
+ }
+
+ public void putStackInSlot(int par1, ItemStack par2ItemStack)
+ {
+ if (getSlot(par1) != null) {
+ getSlot(par1).putStack(par2ItemStack);
+ }
+ }
+
+ public void putStacksInSlots(ItemStack[] par1ArrayOfItemStack)
+ {
+ for (int i = 0; i < par1ArrayOfItemStack.length; i++) {
+ if (getSlot(i) != null) {
+ getSlot(i).putStack(par1ArrayOfItemStack[i]);
+ }
+ }
+ }
+
+ public void onContainerClosed(EntityPlayer par1EntityPlayer)
+ {
+ super.onContainerClosed(par1EntityPlayer);
+
+ WindowInventory inventory = this.window.getWindowInventory();
+ for (int i = 0; i < inventory.getSizeInventory(); i++) {
+ if (inventory.dispenseOnClose(i))
+ {
+ ItemStack stack = inventory.getStackInSlot(i);
+ if (stack != null)
+ {
+ stack = new TransferRequest(stack, par1EntityPlayer.inventory).transfer(true);
+ if (stack != null) {
+ par1EntityPlayer.dropPlayerItemWithRandomChoice(stack, false);
+ }
+ }
+ }
+ }
+ }
+
+ public ItemStack slotClick(int slotNum, int mouseButton, int modifier, EntityPlayer player)
+ {
+ Slot slot = getSlot(slotNum);
+ if (((slot instanceof CustomSlot)) && (((CustomSlot)slot).handleClick()))
+ {
+ ((CustomSlot)slot).onSlotClick(this, mouseButton, modifier, player);
+ return player.inventory.getItemStack();
+ }
+ ItemStack stack = super.slotClick(slotNum, mouseButton, modifier, player);
+ return stack;
+ }
+
+ public void sendNBTToClient(String key, NBTTagCompound nbt)
+ {
+ this.syncedNBT.put(key, nbt);
+ }
+
+ public boolean canInteractWith(EntityPlayer var1)
+ {
+ return true;
+ }
+
+ public final ItemStack transferStackInSlot(EntityPlayer player, int slotID)
+ {
+ return shiftClick(player, slotID);
+ }
+
+ private ItemStack shiftClick(EntityPlayer player, int slotnumber)
+ {
+ TransferRequest request = getShiftClickRequest(player, slotnumber);
+ if (request == null) {
+ return null;
+ }
+ ItemStack itemstack = request.transfer(true);
+ Slot shiftClickedSlot = (Slot)this.inventorySlots.get(slotnumber);
+
+ shiftClickedSlot.putStack(itemstack);
+ shiftClickedSlot.onSlotChanged();
+
+ return null;
+ }
+
+ private TransferRequest getShiftClickRequest(EntityPlayer player, int slotnumber)
+ {
+ if (slotnumber < 0) {
+ return null;
+ }
+ Slot shiftClickedSlot = (Slot)this.inventorySlots.get(slotnumber);
+
+ ItemStack itemstack = null;
+ if (shiftClickedSlot.getHasStack()) {
+ itemstack = shiftClickedSlot.getStack().copy();
+ }
+ IInventory playerInventory = player.inventory;
+ IInventory containerInventory = this.window.getInventory();
+ IInventory windowInventory = this.window.getWindowInventory();
+
+ IInventory fromPlayer = containerInventory == null ? windowInventory : containerInventory;
+
+ int[] target = new int[36];
+ for (int i = 0; i < 36; i++) {
+ target[i] = i;
+ }
+ TransferRequest request;
+ TransferRequest request;
+ if (shiftClickedSlot.inventory == playerInventory) {
+ request = new TransferRequest(itemstack, fromPlayer).setOrigin(shiftClickedSlot.inventory);
+ } else {
+ request = new TransferRequest(itemstack, playerInventory).setOrigin(shiftClickedSlot.inventory).setTargetSlots(target);
+ }
+ if ((this.window instanceof IWindowAffectsShiftClick)) {
+ ((IWindowAffectsShiftClick)this.window).alterRequest(request);
+ }
+ return request;
+ }
+
+ public final ItemStack tankClick(EntityPlayer player, int slotID)
+ {
+ if (player.inventory.getItemStack() == null) {
+ return null;
+ }
+ ItemStack heldItem = player.inventory.getItemStack().copy();
+
+ heldItem = new TransferRequest(heldItem, this.window.getInventory()).setOrigin(player.inventory).setTargetSlots(new int[0]).setTargetTanks(new int[] { slotID }).transfer(true);
+
+
+ player.inventory.setItemStack(heldItem);
+ if ((player instanceof EntityPlayerMP)) {
+ ((EntityPlayerMP)player).updateHeldItem();
+ }
+ return heldItem;
+ }
+
+ public boolean handleNBT(Side side, EntityPlayer player, String name, NBTTagCompound action)
+ {
+ if (side == Side.SERVER)
+ {
+ if (name.equals("tank-click")) {
+ tankClick(player, action.getByte("id"));
+ }
+ if (name.equals("slot-reg"))
+ {
+ int type = action.getByte("t");
+ int index = action.getShort("i");
+ int slotNumber = action.getShort("n");
+ getOrCreateSlot(InventoryType.values()[(type % 4)], index, slotNumber);
+ }
+ }
+ if (name.contains("tank-update")) {
+ onTankUpdate(action);
+ } else if (name.equals("power-update")) {
+ onPowerUpdate(action);
+ } else if (name.equals("process-update")) {
+ onProcessUpdate(action);
+ } else if (name.equals("error-update")) {
+ onErrorUpdate(action);
+ } else if (name.equals("mouse-over-slot")) {
+ onMouseOverSlot(player, action);
+ } else if (name.equals("shift-click-info")) {
+ onRecieveShiftClickHighlights(player, action);
+ }
+ return false;
+ }
+
+ private Map<String, NBTTagCompound> syncedNBT = new HashMap();
+ private Map<String, NBTTagCompound> sentNBT = new HashMap();
+
+ public void detectAndSendChanges()
+ {
+ super.detectAndSendChanges();
+
+
+
+
+ ITankMachine tanks = (ITankMachine)Machine.getInterface(ITankMachine.class, this.window.getInventory());
+ IPoweredMachine powered = (IPoweredMachine)Machine.getInterface(IPoweredMachine.class, this.window.getInventory());
+ IErrorStateSource error = (IErrorStateSource)Machine.getInterface(IErrorStateSource.class, this.window.getInventory());
+ IProcess process = (IProcess)Machine.getInterface(IProcess.class, this.window.getInventory());
+ if ((tanks != null) && (this.window.isServer())) {
+ for (int i = 0; i < tanks.getTankInfos().length; i++)
+ {
+ TankInfo tank = tanks.getTankInfos()[i];
+ if (!getTankInfo(i).equals(tank))
+ {
+ this.syncedNBT.put("tank-update-" + i, createTankNBT(i, tank));
+
+ this.syncedTanks.put(Integer.valueOf(i), tank);
+ }
+ }
+ }
+ if ((powered != null) && (this.window.isServer())) {
+ this.syncedNBT.put("power-update", createPowerNBT(powered.getPowerInfo()));
+ }
+ if ((process != null) && (this.window.isServer())) {
+ this.syncedNBT.put("process-update", createProcessNBT(process.getInfo()));
+ }
+ if ((error != null) && (this.window.isServer())) {
+ this.syncedNBT.put("error-update", createErrorNBT(error));
+ }
+ INetwork.SendGuiNBT machineSync = (INetwork.SendGuiNBT)Machine.getInterface(INetwork.SendGuiNBT.class, this.window.getInventory());
+ if (machineSync != null) {
+ machineSync.sendGuiNBT(this.syncedNBT);
+ }
+ Map<String, NBTTagCompound> sentThisTime = new HashMap();
+ for (Map.Entry<String, NBTTagCompound> nbt : this.syncedNBT.entrySet())
+ {
+ ((NBTTagCompound)nbt.getValue()).setString("type", (String)nbt.getKey());
+
+
+
+
+
+
+ boolean shouldSend = true;
+ NBTTagCompound lastSent = (NBTTagCompound)this.sentNBT.get(nbt.getKey());
+ if (lastSent != null) {
+ shouldSend = !lastSent.equals(nbt.getValue());
+ }
+ if (shouldSend)
+ {
+ for (int j = 0; j < this.crafters.size(); j++) {
+ if ((this.crafters.get(j) instanceof EntityPlayerMP))
+ {
+ EntityPlayerMP player = (EntityPlayerMP)this.crafters.get(j);
+ BinnieCore.proxy.sendToPlayer(new MessageContainerUpdate((NBTTagCompound)nbt.getValue()), player);
+ }
+ }
+ sentThisTime.put(nbt.getKey(), nbt.getValue());
+ }
+ }
+ this.sentNBT.putAll(sentThisTime);
+
+ this.syncedNBT.clear();
+ }
+
+ private NBTTagCompound createErrorNBT(IErrorStateSource error)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ ErrorState state = null;
+ if (error.canWork() != null)
+ {
+ nbt.setByte("type", (byte)0);
+ state = error.canWork();
+ }
+ else if (error.canProgress() != null)
+ {
+ nbt.setByte("type", (byte)1);
+ state = error.canProgress();
+ }
+ if (state != null) {
+ state.writeToNBT(nbt);
+ }
+ return nbt;
+ }
+
+ public NBTTagCompound createPowerNBT(PowerInfo powerInfo)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ powerInfo.writeToNBT(nbt);
+ return nbt;
+ }
+
+ public NBTTagCompound createProcessNBT(ProcessInfo powerInfo)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ powerInfo.writeToNBT(nbt);
+ return nbt;
+ }
+
+ public NBTTagCompound createTankNBT(int tank, TankInfo tankInfo)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ tankInfo.writeToNBT(nbt);
+ nbt.setByte("tank", (byte)tank);
+ return nbt;
+ }
+
+ private Map<Integer, TankInfo> syncedTanks = new HashMap();
+ private PowerInfo syncedPower = new PowerInfo();
+ private ProcessInfo syncedProcess = new ProcessInfo();
+ private int errorType = 0;
+ private ErrorState error = null;
+
+ public void onTankUpdate(NBTTagCompound nbt)
+ {
+ int tankID = nbt.getByte("tank");
+ TankInfo tank = new TankInfo();
+ tank.readFromNBT(nbt);
+ this.syncedTanks.put(Integer.valueOf(tankID), tank);
+ }
+
+ public void onProcessUpdate(NBTTagCompound nbt)
+ {
+ this.syncedProcess = new ProcessInfo();
+ this.syncedProcess.readFromNBT(nbt);
+ }
+
+ public void onPowerUpdate(NBTTagCompound nbt)
+ {
+ this.syncedPower = new PowerInfo();
+ this.syncedPower.readFromNBT(nbt);
+ }
+
+ public PowerInfo getPowerInfo()
+ {
+ return this.syncedPower;
+ }
+
+ public ProcessInfo getProcessInfo()
+ {
+ return this.syncedProcess;
+ }
+
+ public TankInfo getTankInfo(int tank)
+ {
+ return this.syncedTanks.containsKey(Integer.valueOf(tank)) ? (TankInfo)this.syncedTanks.get(Integer.valueOf(tank)) : new TankInfo();
+ }
+
+ public void onErrorUpdate(NBTTagCompound nbt)
+ {
+ this.errorType = nbt.getByte("type");
+ if (nbt.hasKey("name"))
+ {
+ this.error = new ErrorState("", "");
+ this.error.readFromNBT(nbt);
+ }
+ else
+ {
+ this.error = null;
+ }
+ }
+
+ public ErrorState getErrorState()
+ {
+ return this.error;
+ }
+
+ public int getErrorType()
+ {
+ return this.errorType;
+ }
+
+ public CustomSlot[] getCustomSlots()
+ {
+ List<CustomSlot> slots = new ArrayList();
+ for (Object object : this.inventorySlots) {
+ if ((object instanceof CustomSlot)) {
+ slots.add((CustomSlot)object);
+ }
+ }
+ return (CustomSlot[])slots.toArray(new CustomSlot[0]);
+ }
+
+ private int mousedOverSlotNumber = -1;
+
+ public void setMouseOverSlot(Slot slot)
+ {
+ if (slot.slotNumber != this.mousedOverSlotNumber)
+ {
+ this.mousedOverSlotNumber = slot.slotNumber;
+ ((List)ControlSlot.highlighting.get(EnumHighlighting.ShiftClick)).clear();
+ NBTTagCompound nbt = new NBTTagCompound();
+ nbt.setShort("slot", (short)slot.slotNumber);
+ this.window.sendClientAction("mouse-over-slot", nbt);
+ }
+ }
+
+ private void onMouseOverSlot(EntityPlayer player, NBTTagCompound data)
+ {
+ int slotnumber = data.getShort("slot");
+ TransferRequest request = getShiftClickRequest(player, slotnumber);
+ if (request == null) {
+ return;
+ }
+ request.transfer(false);
+ NBTTagCompound nbt = new NBTTagCompound();
+
+ List<Integer> slots = new ArrayList();
+ for (TransferRequest.TransferSlot tslot : request.getInsertedSlots())
+ {
+ Slot slot = getSlot(tslot.inventory, tslot.id);
+ if (slot != null) {
+ slots.add(Integer.valueOf(slot.slotNumber));
+ }
+ }
+ int[] array = new int[slots.size()];
+ for (int i = 0; i < slots.size(); i++) {
+ array[i] = ((Integer)slots.get(i)).intValue();
+ }
+ nbt.setIntArray("slots", array);
+ nbt.setShort("origin", (short)slotnumber);
+
+ this.syncedNBT.put("shift-click-info", nbt);
+ }
+
+ private void onRecieveShiftClickHighlights(EntityPlayer player, NBTTagCompound data)
+ {
+ ((List)ControlSlot.highlighting.get(EnumHighlighting.ShiftClick)).clear();
+ for (int slotnumber : data.getIntArray("slots")) {
+ ((List)ControlSlot.highlighting.get(EnumHighlighting.ShiftClick)).add(Integer.valueOf(slotnumber));
+ }
+ }
+
+ private CustomSlot getSlot(IInventory inventory, int id)
+ {
+ for (Object o : this.inventorySlots)
+ {
+ CustomSlot slot = (CustomSlot)o;
+ if ((slot.inventory == inventory) && (slot.getSlotIndex() == id)) {
+ return slot;
+ }
+ }
+ return null;
+ }
+
+ public void recieveNBT(Side side, EntityPlayer player, NBTTagCompound action)
+ {
+ String name = action.getString("type");
+ if (handleNBT(side, player, name, action)) {
+ return;
+ }
+ this.window.recieveGuiNBT(getSide(), player, name, action);
+ INetwork.RecieveGuiNBT machine = (INetwork.RecieveGuiNBT)Machine.getInterface(INetwork.RecieveGuiNBT.class, this.window.getInventory());
+ if (machine != null) {
+ machine.recieveGuiNBT(getSide(), player, name, action);
+ }
+ }
+
+ public Slot getOrCreateSlot(InventoryType type, int index)
+ {
+ IInventory inventory = getInventory(type);
+ Slot slot = getSlot(inventory, index);
+ if (slot == null)
+ {
+ slot = new CustomSlot(inventory, index);
+ addSlotToContainer(slot);
+ }
+ NBTTagCompound nbt = new NBTTagCompound();
+ nbt.setByte("t", (byte)type.ordinal());
+ nbt.setShort("i", (short)index);
+ nbt.setShort("n", (short)slot.slotNumber);
+ this.window.sendClientAction("slot-reg", nbt);
+ return slot;
+ }
+
+ protected IInventory getInventory(InventoryType type)
+ {
+ if (type == InventoryType.Machine) {
+ return this.window.getInventory();
+ }
+ if (type == InventoryType.Player) {
+ return this.window.getPlayer().inventory;
+ }
+ if (type == InventoryType.Window) {
+ return this.window.getWindowInventory();
+ }
+ return null;
+ }
+
+ private Slot getOrCreateSlot(InventoryType type, int index, int slotNumber)
+ {
+ IInventory inventory = getInventory(type);
+ if (this.inventorySlots.get(slotNumber) != null) {
+ return null;
+ }
+ Slot slot = new CustomSlot(inventory, index);
+ slot.slotNumber = slotNumber;
+ this.inventorySlots.add(slotNumber, slot);
+ this.inventoryItemStacks.add(slotNumber, (Object)null);
+ return slot;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/CustomSlot.java b/src/Java/binnie/craftgui/minecraft/CustomSlot.java
new file mode 100644
index 0000000000..ae45ffb3fd
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/CustomSlot.java
@@ -0,0 +1,54 @@
+package binnie.craftgui.minecraft;
+
+import binnie.core.machines.Machine;
+import binnie.core.machines.inventory.IInventorySlots;
+import binnie.core.machines.inventory.InventorySlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+public class CustomSlot
+ extends Slot
+{
+ public boolean isItemValid(ItemStack par1ItemStack)
+ {
+ return this.inventory.isItemValidForSlot(getSlotIndex(), par1ItemStack);
+ }
+
+ public CustomSlot(IInventory inventory, int index)
+ {
+ super(inventory, index, 0, 0);
+ }
+
+ public InventorySlot getInventorySlot()
+ {
+ IInventorySlots slots = (IInventorySlots)Machine.getInterface(IInventorySlots.class, this.inventory);
+ if (slots != null) {
+ return slots.getSlot(getSlotIndex());
+ }
+ return null;
+ }
+
+ public boolean handleClick()
+ {
+ InventorySlot slot = getInventorySlot();
+ return (slot != null) && (slot.isRecipe());
+ }
+
+ public void onSlotClick(ContainerCraftGUI container, int mouseButton, int modifier, EntityPlayer player)
+ {
+ ItemStack stack = player.inventory.getItemStack();
+ if ((stack == null) || (mouseButton == 2))
+ {
+ putStack(null);
+ }
+ else
+ {
+ stack = stack.copy();
+ stack.stackSize = 1;
+ putStack(stack);
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/Dialog.java b/src/Java/binnie/craftgui/minecraft/Dialog.java
new file mode 100644
index 0000000000..efd67dec25
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/Dialog.java
@@ -0,0 +1,53 @@
+package binnie.craftgui.minecraft;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventHandler.Origin;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+
+public abstract class Dialog
+ extends Control
+{
+ public Dialog(IWidget parent, float w, float h)
+ {
+ super(parent, (parent.w() - w) / 2.0F, (parent.h() - h) / 2.0F, w, h);
+ addAttribute(Attribute.MouseOver);
+ addAttribute(Attribute.AlwaysOnTop);
+ addAttribute(Attribute.BlockTooltip);
+ initialise();
+ addEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ if (!Dialog.this.getArea().contains(Dialog.this.getRelativeMousePosition()))
+ {
+ Dialog.this.onClose();
+ Dialog.this.getParent().deleteChild(Dialog.this);
+ }
+ }
+ }.setOrigin(EventHandler.Origin.Any, this));
+ }
+
+ public abstract void initialise();
+
+ public abstract void onClose();
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.gradientRect(getArea().outset(400), -1442840576, -1442840576);
+ CraftGUI.Render.texture(CraftGUITexture.Window, getArea());
+ CraftGUI.Render.texture(CraftGUITexture.TabOutline, getArea().inset(4));
+ }
+
+ public boolean isMouseOverWidget(IPoint relativeMouse)
+ {
+ return true;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/EnumColor.java b/src/Java/binnie/craftgui/minecraft/EnumColor.java
new file mode 100644
index 0000000000..e778cf31c8
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/EnumColor.java
@@ -0,0 +1,32 @@
+package binnie.craftgui.minecraft;
+
+public enum EnumColor
+{
+ Black("Black", 0, '0'), DarkBlue("Dark Blue", 170, '1'), DarkGreen("Dark Green", 43520, '2'), DarkAqua("Dark Aqua", 43690, '3'), DarkRed("Dark Red", 11141120, '4'), Purple("Purple", 11141290, '5'), Gold("Gold", 16755200, '6'), Grey("Grey", 11184810, '7'), DarkGrey("Dark Grey", 5592405, '8'), Blue("Blue", 5592575, '9'), Green("Green", 5635925, 'a'), Aqua("Aqua", 5636095, 'b'), Red("Red", 16733525, 'c'), Pink("Pink", 16733695, 'd'), Yellow("Yellow", 16777045, 'e'), White("White", 16777215, 'f');
+
+ int colour;
+ String name;
+ char code;
+
+ private EnumColor(String name, int colour, char code)
+ {
+ this.name = name;
+ this.colour = colour;
+ this.code = code;
+ }
+
+ public int getColour()
+ {
+ return this.colour;
+ }
+
+ public String getCode()
+ {
+ return "ยง" + this.code;
+ }
+
+ public String toString()
+ {
+ return this.name;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/GUIIcon.java b/src/Java/binnie/craftgui/minecraft/GUIIcon.java
new file mode 100644
index 0000000000..96338b2551
--- /dev/null
+++