diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2016-08-27 01:34:08 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-08-27 01:34:08 +1000 |
commit | 072f6322fb789703f163030edf4b60bf5a0201af (patch) | |
tree | 9d2d9c2ba6fe3bc5139a9868ee4eca95629fdd95 /src/Java/miscutil/xmod/forestry/bees/alveary/gui | |
parent | f555ac2e146e572155e176131c23e73cd74684f1 (diff) | |
download | GT5-Unofficial-072f6322fb789703f163030edf4b60bf5a0201af.tar.gz GT5-Unofficial-072f6322fb789703f163030edf4b60bf5a0201af.tar.bz2 GT5-Unofficial-072f6322fb789703f163030edf4b60bf5a0201af.zip |
+ Attempted to add custom IC2 generators.
% Refactored the xmod package to be a parent, beside core. No longer is it a child, it needs room to grow.
Diffstat (limited to 'src/Java/miscutil/xmod/forestry/bees/alveary/gui')
3 files changed, 168 insertions, 0 deletions
diff --git a/src/Java/miscutil/xmod/forestry/bees/alveary/gui/CONTAINER_FrameHousing.java b/src/Java/miscutil/xmod/forestry/bees/alveary/gui/CONTAINER_FrameHousing.java new file mode 100644 index 0000000000..78dc096f65 --- /dev/null +++ b/src/Java/miscutil/xmod/forestry/bees/alveary/gui/CONTAINER_FrameHousing.java @@ -0,0 +1,98 @@ +package miscutil.xmod.forestry.bees.alveary.gui; + +import miscutil.core.lib.CORE; +import miscutil.core.slots.SlotFrame; +import miscutil.xmod.forestry.bees.alveary.TileAlvearyFrameHousing; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import forestry.api.apiculture.IHiveFrame; +import forestry.core.gui.tooltips.ToolTip; + +public class CONTAINER_FrameHousing extends Container +{ + private TileAlvearyFrameHousing te; + + public static final int INPUT_1 = 0; + private final ResourceLocation beeFrameIcon = new ResourceLocation(CORE.MODID, "textures/items/machine_Charger.png"); + public ToolTip newTip = new ToolTip(); + private final SlotFrame beeFrameSlot; + + private int slotID = 0; + + public CONTAINER_FrameHousing(TileAlvearyFrameHousing te, EntityPlayer player) + { + this.te = te; + this.beeFrameSlot = new SlotFrame(te, slotID++, 80, 35); + + //Fuel Slot A + beeFrameSlot.setBackgroundIconTexture(beeFrameIcon); + + addSlotToContainer(beeFrameSlot); + + //Inventory + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 9; j++) + { + addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + // Hotbar + for (int i = 0; i < 9; i++) + { + addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); + } + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotRaw) + { + ItemStack stack = null; + Slot slot = (Slot)inventorySlots.get(slotRaw); + + if (slot != null && slot.getHasStack()) + { + ItemStack stackInSlot = slot.getStack(); + stack = stackInSlot.copy(); + + + //If your inventory only stores certain instances of Items, + //you can implement shift-clicking to your inventory like this: + // Check that the item is the right type + if (!(stack.getItem() instanceof IHiveFrame)){ + return null; + } + + if (slotRaw < 1) + { + if (!mergeItemStack(stackInSlot, 3 * 9, inventorySlots.size(), true)) + { + return null; + } + } + else if (!mergeItemStack(stackInSlot, 0, 3 * 9, false)) + { + return null; + } + + if (stackInSlot.stackSize == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + } + return stack; + } + + @Override + public boolean canInteractWith(EntityPlayer player) + { + return te.isUseableByPlayer(player); + } +}
\ No newline at end of file diff --git a/src/Java/miscutil/xmod/forestry/bees/alveary/gui/GUI_FrameHousing.java b/src/Java/miscutil/xmod/forestry/bees/alveary/gui/GUI_FrameHousing.java new file mode 100644 index 0000000000..35b982cd9a --- /dev/null +++ b/src/Java/miscutil/xmod/forestry/bees/alveary/gui/GUI_FrameHousing.java @@ -0,0 +1,49 @@ +package miscutil.xmod.forestry.bees.alveary.gui; + +import miscutil.core.lib.CORE; +import miscutil.xmod.forestry.bees.alveary.TileAlvearyFrameHousing; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +public class GUI_FrameHousing extends GuiContainer +{ + private ResourceLocation texture = new ResourceLocation(CORE.MODID, "textures/gui/machine_Charger.png"); + + private InventoryPlayer inventory; + private TileAlvearyFrameHousing te; + + public GUI_FrameHousing(TileAlvearyFrameHousing te, EntityPlayer player) + { + super(new CONTAINER_FrameHousing(te, player)); + inventory = player.inventory; + this.te = te; + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) + { + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) + { + fontRendererObj.drawString(I18n.format("Alveary Frame Housing"), (xSize / 2) - (fontRendererObj.getStringWidth(I18n.format("Alveary Frame Housing")) / 2), 6, 4210752, false); + fontRendererObj.drawString(I18n.format(inventory.getInventoryName()), 8, ySize - 96 + 2, 4210752); + //fontRendererObj.drawString(I18n.format("Charge:"+te.getCharge()+"~"), 8, ySize - 96 + 2, 4210752); + //fontRendererObj.drawString(I18n.format("Progress:"+te.getProgress()+"ticks"), 80, ySize - 96 + 2, 4210752); + } +}
\ No newline at end of file diff --git a/src/Java/miscutil/xmod/forestry/bees/alveary/gui/InventoryFrameHousing.java b/src/Java/miscutil/xmod/forestry/bees/alveary/gui/InventoryFrameHousing.java new file mode 100644 index 0000000000..cdd3def450 --- /dev/null +++ b/src/Java/miscutil/xmod/forestry/bees/alveary/gui/InventoryFrameHousing.java @@ -0,0 +1,21 @@ +package miscutil.xmod.forestry.bees.alveary.gui; + +import miscutil.xmod.forestry.bees.alveary.TileAlvearyFrameHousing; +import net.minecraft.item.ItemStack; +import forestry.api.apiculture.BeeManager; +import forestry.core.inventory.InventoryAdapterTile; +import forestry.core.utils.ItemStackUtil; + +public class InventoryFrameHousing extends InventoryAdapterTile<TileAlvearyFrameHousing> +{ + public InventoryFrameHousing(TileAlvearyFrameHousing alvearyFrame) + { + super(alvearyFrame, 1, "FrameHousingInv"); + } + + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) + { + return ItemStackUtil.containsItemStack(BeeManager.inducers.keySet(), itemStack); + } +} |