diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2016-05-30 03:20:09 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-05-30 03:20:09 +1000 |
commit | 9a1352dac23c09cb333edf7b2db7cce07c15ee91 (patch) | |
tree | 9936ab004f549bd7320f4f9e077da9e7c99b6c84 /src/Java/miscutil/core/gui | |
parent | 2859490274895866f864e66ba7ac18882b0dfb53 (diff) | |
download | GT5-Unofficial-9a1352dac23c09cb333edf7b2db7cce07c15ee91.tar.gz GT5-Unofficial-9a1352dac23c09cb333edf7b2db7cce07c15ee91.tar.bz2 GT5-Unofficial-9a1352dac23c09cb333edf7b2db7cce07c15ee91.zip |
+Helium Generator, Initial Commit
+Reformatted Item Generation
Diffstat (limited to 'src/Java/miscutil/core/gui')
-rw-r--r-- | src/Java/miscutil/core/gui/ContainerHeliumGenerator.java | 95 | ||||
-rw-r--r-- | src/Java/miscutil/core/gui/GUIHeliumGenerator.java | 44 | ||||
-rw-r--r-- | src/Java/miscutil/core/gui/ModGUI.java | 37 |
3 files changed, 175 insertions, 1 deletions
diff --git a/src/Java/miscutil/core/gui/ContainerHeliumGenerator.java b/src/Java/miscutil/core/gui/ContainerHeliumGenerator.java new file mode 100644 index 0000000000..ae8e2d3176 --- /dev/null +++ b/src/Java/miscutil/core/gui/ContainerHeliumGenerator.java @@ -0,0 +1,95 @@ +package miscutil.core.gui; + +import miscutil.core.tileentities.TileEntityHeliumGenerator; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.inventory.SlotFurnace; +import net.minecraft.item.ItemStack; + +public class ContainerHeliumGenerator extends Container { + private TileEntityHeliumGenerator tileThis; + + public ContainerHeliumGenerator(InventoryPlayer player, TileEntityHeliumGenerator machine) + { + this.tileThis = machine; + this.addSlotToContainer(new SlotFurnace(player.player, machine, 2, 80, 35)); + int i; + + for (i = 0; i < 3; ++i) + { + for (int j = 0; j < 9; ++j) + { + this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142)); + } + } + + public boolean canInteractWith(EntityPlayer player) + { + return this.tileThis.isUseableByPlayer(player); + } + + /** + * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. + */ + public ItemStack transferStackInSlot(EntityPlayer player, int slotNumber) + { + ItemStack itemstack = null; + Slot slot = (Slot)this.inventorySlots.get(slotNumber); + + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + if (slotNumber == 0) + { + if (!this.mergeItemStack(itemstack1, 1, 37, true)) + { + return null; + } + + slot.onSlotChange(itemstack1, itemstack); + } + else + { + if (slotNumber >= 1 && slotNumber < 28) + { + if (!this.mergeItemStack(itemstack1, 28, 37, false)) + { + return null; + } + } + else if (slotNumber >= 28 && slotNumber < 37 && !this.mergeItemStack(itemstack1, 1, 28, false)) + { + return null; + } + } + + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + + if (itemstack1.stackSize == itemstack.stackSize) + { + return null; + } + + slot.onPickupFromSlot(player, itemstack1); + } + + return itemstack; + } +}
\ No newline at end of file diff --git a/src/Java/miscutil/core/gui/GUIHeliumGenerator.java b/src/Java/miscutil/core/gui/GUIHeliumGenerator.java new file mode 100644 index 0000000000..6510f7480f --- /dev/null +++ b/src/Java/miscutil/core/gui/GUIHeliumGenerator.java @@ -0,0 +1,44 @@ +package miscutil.core.gui; + +import miscutil.core.lib.CORE; +import miscutil.core.tileentities.TileEntityHeliumGenerator; +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 cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class GUIHeliumGenerator extends GuiContainer +{ + private static final ResourceLocation collectorGuiTexture = new ResourceLocation(CORE.MODID, "textures/gui/helium_collector_gui.png"); + + public GUIHeliumGenerator(InventoryPlayer player, TileEntityHeliumGenerator machine) + { + super(new ContainerHeliumGenerator(player, machine)); + } + + /** + * Draw the foreground layer for the GuiContainer (everything in front of the items) + */ + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) + { + String s = StatCollector.translateToLocal("container.helium_collector"); + this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752); + this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + } + + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(collectorGuiTexture); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + + } +}
\ No newline at end of file diff --git a/src/Java/miscutil/core/gui/ModGUI.java b/src/Java/miscutil/core/gui/ModGUI.java index 28987ccc1b..1e4d172637 100644 --- a/src/Java/miscutil/core/gui/ModGUI.java +++ b/src/Java/miscutil/core/gui/ModGUI.java @@ -1,6 +1,12 @@ package miscutil.core.gui; +import miscutil.MiscUtils; +import miscutil.core.tileentities.TileEntityHeliumGenerator; import miscutil.core.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; +import cpw.mods.fml.common.network.IGuiHandler; +import cpw.mods.fml.common.network.NetworkRegistry; public class ModGUI { @@ -8,8 +14,37 @@ public class ModGUI { public static void init(){ Utils.LOG_INFO("Registering GUIs."); - + NetworkRegistry.INSTANCE.registerGuiHandler(MiscUtils.instance, new GUI_HANDLER()); //Register GuiHandler //NetworkRegistry.INSTANCE.registerGuiHandler(MiscUtils.instance, new GuiHandler()); } } + +class GUI_HANDLER implements IGuiHandler { + + @Override + public Object getClientGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z){ + if(ID == 0) + return false; + else if(ID == 1) + return false; + else if(ID == 2) + return new GUIHeliumGenerator(player.inventory, (TileEntityHeliumGenerator)world.getTileEntity(x, y, z)); + else if(ID == 3) + return false; + return null; + } + + @Override + public Object getServerGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z){ + if(ID == 0) + return false; + else if(ID == 1) + return false; + else if(ID == 2) + return new ContainerHeliumGenerator(player.inventory, (TileEntityHeliumGenerator)world.getTileEntity(x, y, z)); + else if(ID == 3) + return false; + return null; + } +} |