aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2022-01-09 02:29:10 +0000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2022-01-09 02:29:10 +0000
commitc7536873578a600131e5ca647fac664594efbfd3 (patch)
tree252e8bb9aa925d3bb6948c3c180df148fb2aa89e /src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic
parenta69fddc219dd6cf5d94952603f6bf348ed847fe5 (diff)
downloadGT5-Unofficial-c7536873578a600131e5ca647fac664594efbfd3.tar.gz
GT5-Unofficial-c7536873578a600131e5ca647fac664594efbfd3.tar.bz2
GT5-Unofficial-c7536873578a600131e5ca647fac664594efbfd3.zip
Ported some GT4 content:
Added GT Crop Managers. Added GT Auto Crafting Tables. Added GT Inventory Managers.
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic')
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GT_Container_CropHarvestor.java214
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GT_GUIContainer_CropHarvestor.java72
2 files changed, 286 insertions, 0 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GT_Container_CropHarvestor.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GT_Container_CropHarvestor.java
new file mode 100644
index 0000000000..d56efdf0a4
--- /dev/null
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GT_Container_CropHarvestor.java
@@ -0,0 +1,214 @@
+package gtPlusPlus.xmod.gregtech.api.gui.basic;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.gui.GT_ContainerMetaTile_Machine;
+import gregtech.api.gui.GT_Slot_Holo;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.util.GT_Utility;
+import gregtech.common.tileentities.boilers.GT_MetaTileEntity_Boiler;
+import gtPlusPlus.core.slots.SlotNoInput;
+import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_CropHarvestor;
+import ic2.core.item.DamageHandler;
+import ic2.core.item.ItemIC2;
+import ic2.core.util.StackUtil;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+
+public class GT_Container_CropHarvestor extends GT_ContainerMetaTile_Machine {
+
+ public boolean mModeAlternative = false;
+ public int mWaterAmount = 0;
+ public int mWaterRealAmount = 0;
+
+ public GT_Container_CropHarvestor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) {
+ super(aInventoryPlayer, aTileEntity);
+ }
+
+ public void addSlots(InventoryPlayer aInventoryPlayer) {
+
+
+ int aSlot = 1;
+
+ addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 48, 64, false, true, 1));
+ addSlotToContainer(new SlotWeedEx(mTileEntity, aSlot++, 8, 14));
+ addSlotToContainer(new SlotWeedEx(mTileEntity, aSlot++, 26, 14));
+ addSlotToContainer(new SlotFertilizer(mTileEntity, aSlot++, 8, 32));
+ addSlotToContainer(new SlotFertilizer(mTileEntity, aSlot++, 26, 32));
+ addSlotToContainer(new SlotFertilizer(mTileEntity, aSlot++, 8, 50));
+ addSlotToContainer(new SlotFertilizer(mTileEntity, aSlot++, 26, 50));
+
+
+ addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 61, 7));
+ addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 79, 7));
+ addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 97, 7));
+ addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 115, 7));
+ addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 133, 7));
+ addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 151, 7));
+
+ addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 61, 25));
+ addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 79, 25));
+ addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 97, 25));
+ addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 115, 25));
+ addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 133, 25));
+ addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 151, 25));
+
+ addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 61, 43));
+ addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 79, 43));
+ addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 97, 43));
+ addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 115, 43));
+ addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 133, 43));
+ addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 151, 43));
+
+
+ }
+
+ public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) {
+
+ GT_MetaTileEntity_CropHarvestor machine = (GT_MetaTileEntity_CropHarvestor) mTileEntity.getMetaTileEntity();
+
+ if (aSlotIndex == 0) {
+ machine.mModeAlternative = !machine.mModeAlternative;
+ return null;
+ }
+
+ Slot tSlot = (Slot)inventorySlots.get(aSlotIndex);
+ if (tSlot != null) {
+ /*if (mTileEntity.getMetaTileEntity() == null) return null;
+ GT_MetaTileEntity_ElectricBufferSmall mte = (GT_MetaTileEntity_ElectricBufferSmall)mTileEntity.getMetaTileEntity();
+ if (aSlotIndex == 1) {
+ mte.bOutput = !mte.bOutput;
+ if (aPlayer.worldObj.isRemote)
+ GT_Utility.sendChatToPlayer(aPlayer, new ChatComponentTranslation("metatileentity.status.energy_out." + mte.bOutput));
+ return null;
+ } else if (aSlotIndex == 2) {
+ mte.bRedstoneIfFull = !mte.bRedstoneIfFull;
+ if (aPlayer.worldObj.isRemote)
+ GT_Utility.sendChatToPlayer(aPlayer, new ChatComponentTranslation("metatileentity.status.redstone_if_full." + mte.bRedstoneIfFull));
+ return null;
+ } else if (aSlotIndex == 3) {
+ mte.bInvert = !mte.bInvert;
+ if (aPlayer.worldObj.isRemote)
+ GT_Utility.sendChatToPlayer(aPlayer, new ChatComponentTranslation("metatileentity.status.redstone_invert." + mte.bInvert));
+ return null;
+ }*/
+ }
+
+ return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer);
+ }
+
+ @Override
+ public int getSlotCount() {
+ return 24;
+ }
+
+ @Override
+ public int getSlotStartIndex() {
+ return 1;
+ }
+
+ @Override
+ public int getShiftClickSlotCount() {
+ return 6;
+ }
+
+ @Override
+ public void detectAndSendChanges() {
+ super.detectAndSendChanges();
+ if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) {
+ return;
+ }
+
+ // GT_MetaTileEntity_Boiler.getCapacity() is used for both water and steam capacity.
+ int capacity = ((GT_MetaTileEntity_CropHarvestor) this.mTileEntity.getMetaTileEntity()).getCapacity();
+
+ mModeAlternative = ((GT_MetaTileEntity_CropHarvestor) mTileEntity.getMetaTileEntity()).mModeAlternative;
+ mWaterRealAmount = ((GT_MetaTileEntity_CropHarvestor) mTileEntity.getMetaTileEntity()).getFluidAmount();
+ this.mWaterAmount = Math.min(54, Math.max(0, this.mWaterRealAmount * 54 / (capacity - 100)));
+ for (Object crafter : this.crafters) {
+ ICrafting var1 = (ICrafting) crafter;
+ var1.sendProgressBarUpdate(this, 102, mModeAlternative ? 1 : 0);
+ var1.sendProgressBarUpdate(this, 103, this.mWaterAmount);
+ var1.sendProgressBarUpdate(this, 104, this.mWaterRealAmount);
+ }
+ }
+
+ @Override
+ public void addCraftingToCrafters(ICrafting par1ICrafting) {
+ super.addCraftingToCrafters(par1ICrafting);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void updateProgressBar(int par1, int par2) {
+ super.updateProgressBar(par1, par2);
+ switch (par1) {
+ case 102:
+ mModeAlternative = (par2 != 0);
+ break;
+ case 103:
+ this.mWaterAmount = par2;
+ break;
+ case 104:
+ this.mWaterRealAmount = par2;
+ break;
+ }
+ }
+
+ public static class SlotWeedEx extends Slot {
+
+ public SlotWeedEx(final IInventory inventory, final int slot, final int x, final int y) {
+ super(inventory, slot, x, y);
+
+ }
+
+ @Override
+ public synchronized boolean isItemValid(final ItemStack itemstack) {
+ return isWeedEx(itemstack);
+ }
+
+ @Override
+ public int getSlotStackLimit() {
+ return 1;
+ }
+
+ private static boolean isWeedEx(ItemStack aStack) {
+ if (aStack != null && aStack.getItem() instanceof ItemIC2) {
+ if (aStack.getItem().getUnlocalizedName().equals("ic2.itemWeedEx")) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ public class SlotFertilizer extends Slot {
+
+ public SlotFertilizer(final IInventory inventory, final int slot, final int x, final int y) {
+ super(inventory, slot, x, y);
+
+ }
+
+ @Override
+ public synchronized boolean isItemValid(final ItemStack aStack) {
+ if (aStack != null && aStack.getItem() instanceof ItemIC2) {
+ if (aStack.getItem().getUnlocalizedName().equals("ic2.itemFertilizer")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int getSlotStackLimit() {
+ return 64;
+ }
+
+ }
+
+}
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GT_GUIContainer_CropHarvestor.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GT_GUIContainer_CropHarvestor.java
new file mode 100644
index 0000000000..ff2894f94a
--- /dev/null
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GT_GUIContainer_CropHarvestor.java
@@ -0,0 +1,72 @@
+package gtPlusPlus.xmod.gregtech.api.gui.basic;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import gregtech.api.gui.GT_GUIContainerMetaTile_Machine;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.common.gui.GT_Container_Boiler;
+import gtPlusPlus.core.lib.CORE;
+import net.minecraft.entity.player.InventoryPlayer;
+
+public class GT_GUIContainer_CropHarvestor extends GT_GUIContainerMetaTile_Machine {
+
+ private final String mLocalName;
+
+ public GT_GUIContainer_CropHarvestor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aLocalName) {
+ super(new GT_Container_CropHarvestor(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "CropHarvestor.png");
+ mLocalName = aLocalName;
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+ drawTooltip(par1, par2);
+ //fontRendererObj.drawString("Crop Manager ("+this.mContainer.mTileEntity.getInputVoltage()+"v)", 8, 4, 4210752);
+ //fontRendererObj.drawString(mLocalName, 70, 69, 4210752);
+ }
+
+ @Override
+ protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
+ super.drawGuiContainerBackgroundLayer(par1, par2, par3);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+
+ if (((GT_Container_CropHarvestor) mContainer).mModeAlternative) {
+ drawTexturedModalRect(x + 48, y + 64, 177, 37, 16, 16);
+ }
+
+ int tScale = ((GT_Container_CropHarvestor) this.mContainer).mWaterAmount;
+ if (tScale > 0) {
+ drawTexturedModalRect(x + 47, y + 61 - tScale, 204, 54 - tScale, 10, tScale);
+ };
+
+ }
+
+ private void drawTooltip(int x2, int y2) {
+ int xStart = (width - xSize) / 2;
+ int yStart = (height - ySize) / 2;
+ int x = x2 - xStart;
+ int y = y2 - yStart + 5;
+ List<String> list = new ArrayList<>();
+ if (y >= 68 && y <= 85) {
+ if (x >= 47 && x <= 64) {
+ if (((GT_Container_CropHarvestor) mContainer).mModeAlternative) {
+ list.add("Disable Hydration/Fertilizing/Weed-EX");
+ }
+ else {
+ list.add("Enable Hydration/Fertilizing/Weed-EX");
+ }
+ }
+ }
+ if (y >= 12 && y <= 66) {
+ if (x >= 47 && x <= 56) {
+ int aWater = ((GT_Container_CropHarvestor) mContainer).mWaterRealAmount;
+ list.add("Water: "+aWater+"L / "+((GT_Container_CropHarvestor) mContainer).mTileEntity.getMetaTileEntity().getCapacity()+"L");
+ }
+ }
+ if (!list.isEmpty())
+ drawHoveringText(list, x, y, fontRendererObj);
+ }
+
+}