diff options
Diffstat (limited to 'src/main/java')
14 files changed, 2809 insertions, 11 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index c5c4de002d..8497c91ab1 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -532,6 +532,34 @@ public enum GregtechItemList implements GregtechItemContainer { //Gt4 Workbenches GT4_Workbench_Bronze, GT4_Workbench_Advanced, + + //GT4 automation + GT4_Electric_Auto_Workbench_LV, + GT4_Electric_Auto_Workbench_MV, + GT4_Electric_Auto_Workbench_HV, + GT4_Electric_Auto_Workbench_EV, + GT4_Electric_Auto_Workbench_IV, + GT4_Electric_Auto_Workbench_LuV, + GT4_Electric_Auto_Workbench_ZPM, + GT4_Electric_Auto_Workbench_UV, + GT4_Electric_Inventory_Manager_LV, + GT4_Electric_Inventory_Manager_MV, + GT4_Electric_Inventory_Manager_HV, + GT4_Electric_Inventory_Manager_EV, + GT4_Electric_Inventory_Manager_IV, + GT4_Electric_Inventory_Manager_LuV, + GT4_Electric_Inventory_Manager_ZPM, + GT4_Electric_Inventory_Manager_UV, + + //GT4 Crop Harvester + GT4_Crop_Harvester_LV, + GT4_Crop_Harvester_MV, + GT4_Crop_Harvester_HV, + GT4_Crop_Harvester_EV, + GT4_Crop_Harvester_IV, + GT4_Crop_Harvester_LuV, + GT4_Crop_Harvester_ZPM, + GT4_Crop_Harvester_UV, //Geothermal Engines diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricAutoWorkbench.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricAutoWorkbench.java new file mode 100644 index 0000000000..1af597c05a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricAutoWorkbench.java @@ -0,0 +1,141 @@ +package gtPlusPlus.xmod.gregtech.api.gui.automation; + +import com.google.gson.JsonObject; + +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.gui.GT_Slot_Output; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ElectricAutoWorkbench; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_CropHarvestor; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class GT_Container_ElectricAutoWorkbench extends GT_ContainerMetaTile_Machine { + + public int mMode; + public int mThroughPut; + + public GT_Container_ElectricAutoWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new Slot(mTileEntity, 0, 8, 5)); + addSlotToContainer(new Slot(mTileEntity, 1, 26, 5)); + addSlotToContainer(new Slot(mTileEntity, 2, 44, 5)); + addSlotToContainer(new Slot(mTileEntity, 3, 8, 23)); + addSlotToContainer(new Slot(mTileEntity, 4, 26, 23)); + addSlotToContainer(new Slot(mTileEntity, 5, 44, 23)); + addSlotToContainer(new Slot(mTileEntity, 6, 8, 41)); + addSlotToContainer(new Slot(mTileEntity, 7, 26, 41)); + addSlotToContainer(new Slot(mTileEntity, 8, 44, 41)); + + addSlotToContainer(new GT_Slot_Output(mTileEntity, 9, 8, 60)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 10, 26, 60)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 11, 44, 60)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 12, 62, 60)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 13, 80, 60)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 14, 98, 60)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 15, 116, 60)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 16, 134, 60)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 17, 152, 60)); + + addSlotToContainer(new GT_Slot_Output(mTileEntity, 18, 152, 41)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 19, 64, 6, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 20, 81, 6, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 21, 98, 6, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 22, 64, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 23, 81, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 24, 98, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 25, 64, 40, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 26, 81, 40, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 27, 98, 40, false, false, 1)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 28, 152, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 29, 121, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 29, 121, 5, false, false, 1)); + } + + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + if (aSlotIndex < 18) return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + + Slot tSlot = (Slot)inventorySlots.get(aSlotIndex); + if (tSlot != null) { + if (mTileEntity.getMetaTileEntity() == null) return null; + if (aSlotIndex > 18 && aSlotIndex < 28) { + ItemStack tStack = aPlayer.inventory.getItemStack(); + if (tStack != null) { + tStack = GT_Utility.copy(1, tStack); + } + tSlot.putStack(tStack); + return null; + } + if (aSlotIndex == 28) return null; + if (aSlotIndex == 29) { + if (aMouseclick == 0) { + ((GT_MetaTileEntity_ElectricAutoWorkbench)mTileEntity.getMetaTileEntity()).switchModeForward(); + } else { + ((GT_MetaTileEntity_ElectricAutoWorkbench)mTileEntity.getMetaTileEntity()).switchModeBackward(); + } + return null; + } + if (aSlotIndex == 30) { + ((GT_MetaTileEntity_ElectricAutoWorkbench)mTileEntity.getMetaTileEntity()).switchThrough(); + return null; + } + } + + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + public int getSlotCount() { + return 19; + } + + public int getShiftClickSlotCount() { + return 9; + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { + return; + } + mMode = ((GT_MetaTileEntity_ElectricAutoWorkbench) mTileEntity.getMetaTileEntity()).mMode; + mThroughPut = ((GT_MetaTileEntity_ElectricAutoWorkbench) mTileEntity.getMetaTileEntity()).mThroughPut; + for (Object crafter : this.crafters) { + ICrafting var1 = (ICrafting) crafter; + var1.sendProgressBarUpdate(this, 103, this.mMode); + var1.sendProgressBarUpdate(this, 104, this.mThroughPut); + } + } + + @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 103: + this.mMode = par2; + break; + case 104: + this.mThroughPut = par2; + break; + } + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricInventoryManager.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricInventoryManager.java new file mode 100644 index 0000000000..3e8f509dfd --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricInventoryManager.java @@ -0,0 +1,267 @@ +package gtPlusPlus.xmod.gregtech.api.gui.automation; + +import java.util.Iterator; + +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 gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ElectricInventoryManager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +public class GT_Container_ElectricInventoryManager extends GT_ContainerMetaTile_Machine { + + public int[] mTargetDirections = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + public int[] mRangeDirections = new int[]{0, 0, 0, 0}; + public int mTargetInOut; + public int mTargetEnergy; + + public GT_Container_ElectricInventoryManager(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new Slot(mTileEntity, 0, 155, 5)); + addSlotToContainer(new Slot(mTileEntity, 1, 155, 23)); + addSlotToContainer(new Slot(mTileEntity, 2, 155, 41)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 3, 5, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 4, 5, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 5, 5, 41, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 6, 61, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 7, 61, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 8, 61, 41, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 9, 80, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 10, 80, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 11, 80, 41, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 12, 136, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 13, 136, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 14, 136, 41, false, true, 1)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 24, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 24, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 24, 41, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 42, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 42, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 42, 41, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 99, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 99, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 99, 41, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 117, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 117, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 117, 41, false, true, 1)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 24, 60, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 42, 60, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 99, 60, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 117, 60, false, true, 1)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 5, 60, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 61, 60, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 80, 60, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 136, 60, false, true, 1)); + } + + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + if (aSlotIndex < 3 || aSlotIndex >= getAllSlotCount()) + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + Slot tSlot = (Slot) inventorySlots.get(aSlotIndex); + if (tSlot != null) { + if (mTileEntity.getMetaTileEntity() == null) + return null; + if (aSlotIndex < 15) { + ItemStack tStack = aPlayer.inventory.getItemStack(); + if (tStack != null) { + tStack = GT_Utility.copy(tStack); + if (aMouseclick != 0) { + tStack.setItemDamage(OreDictionary.WILDCARD_VALUE); + } + tSlot.putStack(tStack); + } + else { + if (tSlot.getStack() != null) { + if (aMouseclick == 0) { + tSlot.getStack().stackSize -= (aShifthold == 1 ? 8 : 1); + if (tSlot.getStack().stackSize <= 0) { + tSlot.putStack(null); + } + } + else { + tSlot.getStack().stackSize += (aShifthold == 1 ? 8 : 1); + if (tSlot.getStack().stackSize > tSlot.getStack().getMaxStackSize()) { + tSlot.getStack().stackSize = tSlot.getStack().getMaxStackSize(); + } + } + } + } + return null; + } + else if (aSlotIndex >= 27 && aSlotIndex <= 30) { + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).iterateRangeDirection(aSlotIndex - 27); + } + else if (aSlotIndex >= 31 && aSlotIndex <= 34) { + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).switchRangeEnergy(aSlotIndex - 31); + } + else if (aSlotIndex % 3 == 0) { + if (aMouseclick != 0) + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).switchSlot1InOut((aSlotIndex - 15) / 3); + else + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).iterateSlot1Direction((aSlotIndex - 15) / 3); + } + else if (aSlotIndex % 3 == 1) { + if (aMouseclick != 0) + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).switchSlot2InOut((aSlotIndex - 16) / 3); + else + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).iterateSlot2Direction((aSlotIndex - 16) / 3); + } + else if (aSlotIndex % 3 == 2) { + if (aMouseclick != 0) + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).switchSlot3InOut((aSlotIndex - 17) / 3); + else + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).iterateSlot3Direction((aSlotIndex - 17) / 3); + } + } + return null; + } + + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { + return; + } + mTargetDirections = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + mRangeDirections = new int[]{0, 0, 0, 0}; + + mRangeDirections[0] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeDirection(0); + mRangeDirections[1] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeDirection(1); + mRangeDirections[2] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeDirection(2); + mRangeDirections[3] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeDirection(3); + + mTargetDirections[0] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1Direction(0); + mTargetDirections[1] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2Direction(0); + mTargetDirections[2] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3Direction(0); + mTargetDirections[3] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1Direction(1); + mTargetDirections[4] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2Direction(1); + mTargetDirections[5] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3Direction(1); + mTargetDirections[6] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1Direction(2); + mTargetDirections[7] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2Direction(2); + mTargetDirections[8] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3Direction(2); + mTargetDirections[9] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1Direction(3); + mTargetDirections[10] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2Direction(3); + mTargetDirections[11] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3Direction(3); + + mTargetInOut = 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1InOut(0) ? 1 << 0 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2InOut(0) ? 1 << 1 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3InOut(0) ? 1 << 2 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1InOut(1) ? 1 << 3 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2InOut(1) ? 1 << 4 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3InOut(1) ? 1 << 5 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1InOut(2) ? 1 << 6 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2InOut(2) ? 1 << 7 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3InOut(2) ? 1 << 8 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1InOut(3) ? 1 << 9 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2InOut(3) ? 1 << 10 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3InOut(3) ? 1 << 11 : 0; + + mTargetEnergy = 0; + mTargetEnergy |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeEnergy(0) ? 1 << 0 : 0; + mTargetEnergy |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeEnergy(1) ? 1 << 1 : 0; + mTargetEnergy |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeEnergy(2) ? 1 << 2 : 0; + mTargetEnergy |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeEnergy(3) ? 1 << 3 : 0; + + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + for (int i = 0; i < 12; i++) + var1.sendProgressBarUpdate(this, 100 + i, mTargetDirections[i]); + var1.sendProgressBarUpdate(this, 113, mTargetInOut); + var1.sendProgressBarUpdate(this, 114, mTargetEnergy); + for (int i = 0; i < 4; i++) + var1.sendProgressBarUpdate(this, 115 + i, mRangeDirections[i]); + } + } + + @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 100 : + mTargetDirections[0] = par2; + break; + case 101 : + mTargetDirections[1] = par2; + break; + case 102 : + mTargetDirections[2] = par2; + break; + case 103 : + mTargetDirections[3] = par2; + break; + case 104 : + mTargetDirections[4] = par2; + break; + case 105 : + mTargetDirections[5] = par2; + break; + case 106 : + mTargetDirections[6] = par2; + break; + case 107 : + mTargetDirections[7] = par2; + break; + case 108 : + mTargetDirections[8] = par2; + break; + case 109 : + mTargetDirections[9] = par2; + break; + case 110 : + mTargetDirections[10] = par2; + break; + case 111 : + mTargetDirections[11] = par2; + break; + + case 113 : + mTargetInOut = par2; + break; + case 114 : + mTargetEnergy = par2; + break; + case 115 : + mRangeDirections[0] = par2; + break; + case 116 : + mRangeDirections[1] = par2; + break; + case 117 : + mRangeDirections[2] = par2; + break; + case 118 : + mRangeDirections[3] = par2; + break; + } + } + + public int getSlotCount() { + return 3; + } + + public int getShiftClickSlotCount() { + return 3; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricAutoWorkbench.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricAutoWorkbench.java new file mode 100644 index 0000000000..7d381c0e8a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricAutoWorkbench.java @@ -0,0 +1,59 @@ +package gtPlusPlus.xmod.gregtech.api.gui.automation; + +import java.util.ArrayList; +import java.util.List; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.gui.basic.GT_Container_CropHarvestor; +import net.minecraft.entity.player.InventoryPlayer; + +public class GT_GUIContainer_ElectricAutoWorkbench extends GT_GUIContainerMetaTile_Machine { + + private static final String[] mModeText = new String[] {"Normal Crafting Table", "???", "1x1", "2x2", "3x3", "Unifier", "Dust", "???", "Hammer?", "Circle"}; + + public GT_GUIContainer_ElectricAutoWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(new GT_Container_ElectricAutoWorkbench(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "ElectricAutoWorkbench.png"); + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + drawTooltip(par1, par2); + } + + @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 (mContainer != null) { + int tMode = ((GT_Container_ElectricAutoWorkbench)mContainer).mMode; + if (tMode != 0) drawTexturedModalRect(x + 120, y + 40, tMode*18, 166, 18, 18); + tMode = ((GT_Container_ElectricAutoWorkbench)mContainer).mThroughPut; + drawTexturedModalRect(x + 120, y + 4, tMode*18, 184, 18, 18); + } + } + + private void drawTooltip(final int x2, final int y2) { + final int xStart = (this.width - this.xSize) / 2; + final int yStart = (this.height - this.ySize) / 2; + final int x3 = x2 - xStart; + final int y3 = y2 - yStart + 5; + List<String> list = new ArrayList<>(); + String[] mModeText = new String[] {"Normal Crafting Table", "???", "1x1", "2x2", "3x3", "Unifier", "Dust", "???", "Hammer?", "Circle"}; + if (y3 >= 45 && y3 <= 62) { + if (x3 >= 120 && x3 <= 137) { + list.add("Mode: "+mModeText[((GT_Container_ElectricAutoWorkbench) mContainer).mMode]); + /*switch (((GT_Container_ElectricAutoWorkbench) mContainer).mMode) { + case 0: + list.add("Mode: "); + }*/ + } + } + if (!list.isEmpty()) + drawHoveringText(list, x3, y3, fontRendererObj); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricInventoryManager.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricInventoryManager.java new file mode 100644 index 0000000000..cf57d3faf1 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricInventoryManager.java @@ -0,0 +1,58 @@ +package gtPlusPlus.xmod.gregtech.api.gui.automation; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.entity.player.InventoryPlayer; + +public class GT_GUIContainer_ElectricInventoryManager extends GT_GUIContainerMetaTile_Machine { + + public GT_GUIContainer_ElectricInventoryManager(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(new GT_Container_ElectricInventoryManager(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "InventoryManager.png"); + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + + } + + @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 (mContainer != null) { + drawTexturedModalRect(x + 4, y + 4, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[0]*18, 202, 18, 54); + drawTexturedModalRect(x + 60, y + 4, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[1]*18, 202, 18, 54); + drawTexturedModalRect(x + 79, y + 4, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[2]*18, 202, 18, 54); + drawTexturedModalRect(x + 135, y + 4, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[3]*18, 202, 18, 54); + + drawTexturedModalRect(x + 23, y + 59, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[0]*18+126, 166, 18, 18); + drawTexturedModalRect(x + 41, y + 59, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[1]*18+126, 166, 18, 18); + drawTexturedModalRect(x + 98, y + 59, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[2]*18+126, 166, 18, 18); + drawTexturedModalRect(x + 116, y + 59, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[3]*18+126, 166, 18, 18); + + drawTexturedModalRect(x + 4, y + 59, 108, (((GT_Container_ElectricInventoryManager)mContainer).mTargetEnergy & 1)!=0?184:166, 18, 18); + drawTexturedModalRect(x + 60, y + 59, 108, (((GT_Container_ElectricInventoryManager)mContainer).mTargetEnergy & 2)!=0?184:166, 18, 18); + drawTexturedModalRect(x + 79, y + 59, 108, (((GT_Container_ElectricInventoryManager)mContainer).mTargetEnergy & 4)!=0?184:166, 18, 18); + drawTexturedModalRect(x + 135, y + 59, 108, (((GT_Container_ElectricInventoryManager)mContainer).mTargetEnergy & 8)!=0?184:166, 18, 18); + + int i = -1; + + drawTexturedModalRect(x + 23, y + 4, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); + drawTexturedModalRect(x + 23, y + 22, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); + drawTexturedModalRect(x + 23, y + 40, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); + drawTexturedModalRect(x + 41, y + 4, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); + drawTexturedModalRect(x + 41, y + 22, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); + drawTexturedModalRect(x + 41, y + 40, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); + drawTexturedModalRect(x + 98, y + 4, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); + drawTexturedModalRect(x + 98, y + 22, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); + drawTexturedModalRect(x + 98, y + 40, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); + drawTexturedModalRect(x + 116, y + 4, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); + drawTexturedModalRect(x + 116, y + 22, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); + drawTexturedModalRect(x + 116, y + 40, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); + } + } +} 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); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java index 7653224fd2..8195837a65 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -414,6 +414,51 @@ public class TexturesGtBlock { public static final CustomIcon Casing_Adv_Workbench_Side = new CustomIcon("TileEntities/gt4/machine_side"); public static final CustomIcon Casing_Adv_Workbench_Bottom = new CustomIcon("TileEntities/gt4/machine_bottom"); + + public static final CustomIcon Casing_Electric_Auto_Workbench_Side = new CustomIcon("TileEntities/gt4/OVERLAY_SIDE_CABINET"); + + public static final CustomIcon Casing_CropHarvester_Cutter = new CustomIcon("TileEntities/gt4/OVERLAY_CROP"); + public static final CustomIcon Casing_CropHarvester_Boxes = new CustomIcon("TileEntities/gt4/OVERLAY_BOXES"); + + public static final CustomIcon Casing_InventoryManagaer_Cyan = new CustomIcon("TileEntities/gt4/OVERLAY_CYAN"); + public static final CustomIcon Casing_InventoryManagaer_Green = new CustomIcon("TileEntities/gt4/OVERLAY_GREEN"); + public static final CustomIcon Casing_InventoryManagaer_Purple = new CustomIcon("TileEntities/gt4/OVERLAY_PURPLE"); + public static final CustomIcon Casing_InventoryManagaer_Red = new CustomIcon("TileEntities/gt4/OVERLAY_RED"); + public static final CustomIcon Casing_InventoryManagaer_Yellow = new CustomIcon("TileEntities/gt4/OVERLAY_YELLOW"); + public static final CustomIcon Casing_InventoryManagaer_Blue = new CustomIcon("TileEntities/gt4/OVERLAY_BLUE"); + + public static final CustomIcon Casing_InventoryManagaer_Cyan_Redstone = new CustomIcon("TileEntities/gt4/OVERLAY_CYAN_REDSTONE"); + public static final CustomIcon Casing_InventoryManagaer_Green_Redstone = new CustomIcon("TileEntities/gt4/OVERLAY_GREEN_REDSTONE"); + public static final CustomIcon Casing_InventoryManagaer_Purple_Redstone = new CustomIcon("TileEntities/gt4/OVERLAY_PURPLE_REDSTONE"); + public static final CustomIcon Casing_InventoryManagaer_Red_Redstone = new CustomIcon("TileEntities/gt4/OVERLAY_RED_REDSTONE"); + public static final CustomIcon Casing_InventoryManagaer_Yellow_Redstone = new CustomIcon("TileEntities/gt4/OVERLAY_YELLOW_REDSTONE"); + public static final CustomIcon Casing_InventoryManagaer_Blue_Redstone = new CustomIcon("TileEntities/gt4/OVERLAY_BLUE_REDSTONE"); + + private static final CustomIcon Casing_Test_1 = new CustomIcon("number/1"); + private static final CustomIcon Casing_Test_2 = new CustomIcon("number/2"); + private static final CustomIcon Casing_Test_3 = new CustomIcon("number/3"); + private static final CustomIcon Casing_Test_4 = new CustomIcon("number/4"); + private static final CustomIcon Casing_Test_5 = new CustomIcon("number/5"); + private static final CustomIcon Casing_Test_6 = new CustomIcon("number/6"); + private static final CustomIcon Casing_Test_7 = new CustomIcon("number/7"); + private static final CustomIcon Casing_Test_8 = new CustomIcon("number/8"); + private static final CustomIcon Casing_Test_9 = new CustomIcon("number/9"); + private static final CustomIcon Casing_Test_10 = new CustomIcon("number/10"); + private static final CustomIcon Casing_Test_11 = new CustomIcon("number/11"); + private static final CustomIcon Casing_Test_12 = new CustomIcon("number/12"); + private static final CustomIcon Casing_Test_13 = new CustomIcon("number/13"); + private static final CustomIcon Casing_Test_14 = new CustomIcon("number/14"); + private static final CustomIcon Casing_Test_15 = new CustomIcon("number/15"); + private static final CustomIcon Casing_Test_16 = new CustomIcon("number/16"); + + public static final CustomIcon[] TEST_NUMBER = new CustomIcon[] { + Casing_Test_1, Casing_Test_2, Casing_Test_3, Casing_Test_4, + Casing_Test_5, Casing_Test_6, Casing_Test_7, Casing_Test_8, + Casing_Test_9, Casing_Test_10, Casing_Test_11, Casing_Test_12, + Casing_Test_13, Casing_Test_14, Casing_Test_15, Casing_Test_16 + + }; + //Covers private static final CustomIcon Internal_Overlay_Overflow_Valve = new CustomIcon("iconsets/OVERLAY_OVERFLOW_VALVE"); public static final CustomIcon Overlay_Overflow_Valve = Internal_Overlay_Overflow_Valve; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ElectricAutoWorkbench.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ElectricAutoWorkbench.java new file mode 100644 index 0000000000..7b223f8245 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ElectricAutoWorkbench.java @@ -0,0 +1,772 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.automation; + +import java.util.ArrayList; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.gui.automation.GT_Container_ElectricAutoWorkbench; +import gtPlusPlus.xmod.gregtech.api.gui.automation.GT_GUIContainer_ElectricAutoWorkbench; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.oredict.OreDictionary; + +public class GT_MetaTileEntity_ElectricAutoWorkbench extends GT_MetaTileEntity_BasicTank { + + public int mMode = 0, mCurrentSlot = 0, mThroughPut = 0, mTicksUntilNextUpdate = 20; + public boolean mLastCraftSuccessful = false; + protected String mLocalName; + + public GT_MetaTileEntity_ElectricAutoWorkbench(final int aID, final int aTier, final String aDescription) { + super(aID, "basicmachine.automation.autoworkbench.0"+aTier, "Auto Workbench ("+GT_Values.VN[aTier]+")", aTier, 30, aDescription); + mLocalName = "Auto Workbench ("+GT_Values.VN[aTier]+")"; + } + + public GT_MetaTileEntity_ElectricAutoWorkbench(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, 30, aDescription, aTextures); + } + + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_ElectricAutoWorkbench(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_ElectricAutoWorkbench(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public boolean isTransformerUpgradable() { + return true; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex < 19; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isInputFacing(byte aSide) { + return !isOutputFacing(aSide); + } + + @Override + public boolean isOutputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long maxEUInput() { + return GT_Values.V[mTier]; + } + + @Override + public long maxEUOutput() { + return mThroughPut % 2 == 0 ? GT_Values.V[mTier] : 0; + } + + @Override + public long getMinimumStoredEU() { + return GT_Values.V[this.mTier]; + } + + @Override + public long maxEUStore() { + return GT_Values.V[this.mTier] * (this.mTier * GT_Values.V[this.mTier]); + } + + @Override + public int getSizeInventory() { + return 30; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_ElectricAutoWorkbench(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mMode", mMode); + aNBT.setInteger("mThroughPut", mThroughPut); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mMode = aNBT.getInteger("mMode"); + mThroughPut = aNBT.getInteger("mThroughPut"); + } + + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return true; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { + return aSide != getBaseMetaTileEntity().getFrontFacing() && aSide != getBaseMetaTileEntity().getBackFacing(); + } + + private static final int MAX_MODES = 10; + + public void switchModeForward() { + mMode = (mMode + 1) % MAX_MODES; + switchMode(); + } + + public void switchModeBackward() { + mMode--; + if (mMode < 0) mMode = MAX_MODES-1; + switchMode(); + } + + private void switchMode() { + mInventory[28] = null; + } + + public void switchThrough() { + mThroughPut = (mThroughPut + 1) % 4; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide() && getBaseMetaTileEntity().getUniversalEnergyStored() >= (mMode==5||mMode==6?128:2048) && (getBaseMetaTileEntity().hasWorkJustBeenEnabled() || --mTicksUntilNextUpdate<1)) { + mTicksUntilNextUpdate = 32; + + for (byte i = 19; i < 28; i++) { + if (mInventory[i] != null && mInventory[i].isItemStackDamageable() && mInventory[i].getItem().hasContainerItem()) { + mInventory[i].setItemDamage(OreDictionary.WILDCARD_VALUE); + } + } + + if (mInventory[18] == null) { + for (byte i = 0; i < 18 && mFluid != null; i++) { + ItemStack tOutput = GT_Utility.fillFluidContainer(mFluid, mInventory[i], false, true); + if (tOutput != null) { + for (byte j = 0; j < 9; j++) { + if (mInventory[j] == null || (GT_Utility.areStacksEqual(tOutput, mInventory[j]) && mInventory[j].stackSize + tOutput.stackSize <= tOutput.getMaxStackSize())) { + mFluid.amount -= GT_Utility.getFluidForFilledItem(tOutput, true).amount * tOutput.stackSize; + getBaseMetaTileEntity().decrStackSize(i, 1); + if (mInventory[j] == null) { + mInventory[j] = tOutput; + } else { + mInventory[j].stackSize++; + } + if (mFluid.amount <= 0) mFluid = null; + break; + } + } + } + } + + ItemStack[] tRecipe = new ItemStack[9]; + ItemStack tTempStack = null, tOutput = null; + + if (mInventory[17] != null && mThroughPut < 2 && mMode != 0) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[17]; + mInventory[17] = null; + } + } else { + if (!mLastCraftSuccessful) { + mCurrentSlot = (mCurrentSlot+1)%18; + for (int i = 0; i < 17 && mInventory[mCurrentSlot] == null; i++) + mCurrentSlot = (mCurrentSlot+1)%18; + } + switch (mMode) { + case 0: + if (mInventory[mCurrentSlot] != null && !isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2 && mCurrentSlot < 8) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + for (int i = 0; i < 9; i++) { + tRecipe[i] = mInventory[i+19]; + if (tRecipe[i] != null) { + tRecipe[i] = GT_Utility.copy(tRecipe[i]); + tRecipe[i].stackSize = 1; + } + } + break; + case 1: + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { + tRecipe[1] = tTempStack; + tRecipe[3] = tTempStack; + tRecipe[4] = tTempStack; + } else break; + if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { + tRecipe[2] = tTempStack; + tRecipe[5] = tTempStack; + tRecipe[6] = tTempStack; + tRecipe[7] = tTempStack; + tRecipe[8] = tTempStack; + } else break; + if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + break; + case 2: + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + break; + case 3: + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + tRecipe[1] = tTempStack; + tRecipe[3] = tTempStack; + tRecipe[4] = tTempStack; + if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + break; + case 4: + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + tRecipe[1] = tTempStack; + tRecipe[2] = tTempStack; + tRecipe[3] = tTempStack; + tRecipe[4] = tTempStack; + tRecipe[5] = tTempStack; + tRecipe[6] = tTempStack; + tRecipe[7] = tTempStack; + tRecipe[8] = tTempStack; + if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + break; + case 5: + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + + tOutput = GT_OreDictUnificator.get(true, tTempStack); + + if (tOutput != null && GT_Utility.areStacksEqual(tOutput, tTempStack)) tOutput = null; + + if (tOutput == null) { + tRecipe[0] = null; + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + } + break; + case 6: + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } else if (OrePrefixes.dustSmall.contains(mInventory[mCurrentSlot])) { + tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + tRecipe[1] = tTempStack; + tRecipe[3] = tTempStack; + tRecipe[4] = tTempStack; + if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + } else if (OrePrefixes.dustTiny.contains(mInventory[mCurrentSlot])) { + tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + tRecipe[1] = tTempStack; + tRecipe[2] = tTempStack; + tRecipe[3] = tTempStack; + tRecipe[4] = tTempStack; + tRecipe[5] = tTempStack; + tRecipe[6] = tTempStack; + tRecipe[7] = tTempStack; + tRecipe[8] = tTempStack; + if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + } else { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + break; + case 7: + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot]) || !OrePrefixes.nugget.contains(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + tRecipe[1] = tTempStack; + tRecipe[2] = tTempStack; + tRecipe[3] = tTempStack; + tRecipe[4] = tTempStack; + tRecipe[5] = tTempStack; + tRecipe[6] = tTempStack; + tRecipe[7] = tTempStack; + tRecipe[8] = tTempStack; + if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + break; + case 8: + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot]) || mInventory[mCurrentSlot].getItemDamage() <= 0 || !mInventory[mCurrentSlot].getItem().isRepairable()) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + for (int i = mCurrentSlot + 1; i < 18; i++) { + if (mInventory[i] != null && mInventory[i].getItem() == tTempStack.getItem() && mInventory[mCurrentSlot].getItemDamage()+mInventory[i].getItemDamage()>tTempStack.getMaxDamage()) { + tRecipe[0] = tTempStack; + tRecipe[1] = GT_Utility.copy(mInventory[i]); + if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + } + break; + } + } + break; + case 9: + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + for (byte i = 0, j = 0; i < 18 && j < 9 && (j < 2 || GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null); i++) { + tRecipe[j] = mInventory[(mCurrentSlot+i)%18]; + if (tRecipe[j] != null) { + tRecipe[j] = GT_Utility.copy(tRecipe[j]); + tRecipe[j].stackSize = 1; + j++; + } + } + if (tRecipe[1] == null) tRecipe[0] = null; + break; + } + } + + if (tOutput == null) tOutput = GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe); + + if (tOutput != null || mMode == 0) mInventory[28] = tOutput; + + if (tOutput == null) { + mLastCraftSuccessful = false; + } else { + if ((tTempStack = GT_OreDictUnificator.get(true, tOutput)) != null) { + tTempStack.stackSize = tOutput.stackSize; + tOutput = tTempStack; + } + + mInventory[28] = GT_Utility.copy(tOutput); + ArrayList<ItemStack> tList = recipeContent(tRecipe), tContent = benchContent(); + if (tList.size() > 0 && tContent.size() > 0) { + + boolean success = (mMode==6||mMode==7||mInventory[17]==null); + for (byte i = 0; i < tList.size() && success; i++) { + success = false; + for (byte j = 0; j < tContent.size() && !success; j++) { + if (GT_Utility.areStacksEqual(tList.get(i), tContent.get(j))) { + if (tList.get(i).stackSize <= tContent.get(j).stackSize) { + success = true; + } + } + } + } + + if (success) { + mLastCraftSuccessful = true; + + for (byte i = 8; i > -1; i--) { + for (byte j = 17; j > -1; j--) { + if (tRecipe[i] != null && mInventory[j] != null) { + if (GT_Utility.areStacksEqual(tRecipe[i], mInventory[j])) { + ItemStack tStack = GT_Utility.getContainerItem(mInventory[j], true); + if (tStack != null) { + getBaseMetaTileEntity().decrStackSize(j, 1); + if (!tStack.isItemStackDamageable() || tStack.getItemDamage() < tStack.getMaxDamage()) { + for (byte k = 9; k < 18; k++) { + if (mInventory[k] == null) { + mInventory[k] = GT_Utility.copy(tStack); + break; + } else if (GT_Utility.areStacksEqual(mInventory[k], tStack) && mInventory[k].stackSize + tStack.stackSize <= tStack.getMaxStackSize()) { + mInventory[k].stackSize += tStack.stackSize; + break; + } + } + } + } else { + getBaseMetaTileEntity().decrStackSize(j, 1); + } + break; + } + } + } + } + + mInventory[18] = GT_Utility.copy(tOutput); + getBaseMetaTileEntity().decreaseStoredEnergyUnits(mMode==5||mMode==6||mMode==7?128:2048, true); + mTicksUntilNextUpdate = 1; + } else { + mLastCraftSuccessful = false; + if (mInventory[mMode==0?8:17] != null && mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mMode==0?8:17]; + mInventory[mMode==0?8:17] = null; + mTicksUntilNextUpdate = 1; + } + } + } + + if (mInventory[18] == null && mThroughPut < 2) { + for (byte i = 0; i < 8; i++) { + for (byte j = i; ++j < 9;) { + if (GT_Utility.areStacksEqual(mInventory[i], mInventory[j]) && mInventory[i].getMaxStackSize() > 8) { + mInventory[18] = mInventory[j]; + mInventory[j] = null; + mTicksUntilNextUpdate = 1; + break; + } + } + } + } + } + } + + if (mThroughPut < 2) { + getBaseMetaTileEntity().decreaseStoredEnergyUnits(GT_Utility.moveOneItemStack(getBaseMetaTileEntity(), getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()), getBaseMetaTileEntity().getBackFacing(), getBaseMetaTileEntity().getFrontFacing(), null, false, (byte)64, (byte)1, (byte)64, (byte)1)*10, true); + } + } + } + + private boolean isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(ItemStack aStack) { + if (aStack == null) return true; + for (byte i = 19; i < 28; i++) { + if (mInventory[i] != null) { + if (GT_Utility.areStacksEqual(mInventory[i], aStack)) return true; + if (GT_Utility.areStacksEqual(GT_Utility.getContainerForFilledItem(mInventory[i], true), aStack)) return true; + } + } + return false; + } + + private ArrayList<ItemStack> recipeContent(ItemStack[] tRecipe) { + ArrayList<ItemStack> tList = new ArrayList<ItemStack>(); + for (byte i = 0; i < 9; i++) { + if (tRecipe[i] != null) { + boolean temp = false; + for (byte j = 0; j < tList.size(); j++) { + if (GT_Utility.areStacksEqual(tRecipe[i], tList.get(j))) { + tList.get(j).stackSize++; + temp = true; + break; + } + } + if (!temp) tList.add(GT_Utility.copy(1, tRecipe[i])); + } + } + return tList; + } + + private ArrayList<ItemStack> benchContent() { + ArrayList<ItemStack> tList = new ArrayList<ItemStack>(); + for (byte i = 0; i < 18; i++) { + if (mInventory[i] != null) { + boolean temp = false; + for (byte j = 0; j < tList.size(); j++) { + if (GT_Utility.areStacksEqual(mInventory[i], mInventory[j])) { + tList.get(j).stackSize += mInventory[i].stackSize; + temp = true; + break; + } + } + if (!temp) tList.add(GT_Utility.copy(mInventory[i])); + } + } + return tList; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return mMode==0?aIndex>=10:aIndex>=18; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return mMode==0?aIndex<9:aIndex<18; + } + + /*@Override + public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) + return 112; + if (GT_Utility.getOppositeSide(aSide) == aFacing) + return 113; + return 114; + }*/ + + @Override + public int getCapacity() { + return 16000; + } + + @Override + public int getTankPressure() { + return -100; + } + + @Override + public String[] getDescription() { + return new String[] { + "Automatic Crafting Table Mk III", + //this.mDescription, + CORE.GT_Tooltip }; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFront(i); + rTextures[6][i + 1] = this.getBack(i); + rTextures[7][i + 1] = this.getBottom(i); + rTextures[8][i + 1] = this.getTop(i); + rTextures[9][i + 1] = this.getSides(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return this.mTextures[0][aColorIndex + 1]; + } + else if (GT_Utility.getOppositeSide(aSide) == aFacing) { + return this.mTextures[1][aColorIndex + 1]; + } + else { + return this.mTextures[4][aColorIndex + 1]; + } + /*return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1];*/ + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Crafting_Overlay)}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(BlockIcons.OVERLAY_PIPE)}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Crafting_Overlay) }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Crafting_Overlay)}; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ElectricInventoryManager.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ElectricInventoryManager.java new file mode 100644 index 0000000000..732996de71 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ElectricInventoryManager.java @@ -0,0 +1,451 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.automation; + +import java.util.ArrayList; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.gui.automation.GT_Container_ElectricInventoryManager; +import gtPlusPlus.xmod.gregtech.api.gui.automation.GT_GUIContainer_ElectricInventoryManager; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +public class GT_MetaTileEntity_ElectricInventoryManager extends GT_MetaTileEntity_TieredMachineBlock { + + public int[] mSlotRange = new int[4]; + public boolean mWorkedLastTick = false; + protected String mLocalName; + + public GT_MetaTileEntity_ElectricInventoryManager(final int aID, final int aTier, final String aDescription) { + super(aID, "basicmachine.automation.inventorymanager.0" + aTier, "Electric Inventory Manager (" + GT_Values.VN[aTier] + ")", aTier, 16, aDescription); + mLocalName = "Auto Workbench (" + GT_Values.VN[aTier] + ")"; + } + + public GT_MetaTileEntity_ElectricInventoryManager(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, 16, aDescription, aTextures); + } + + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_ElectricInventoryManager(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_ElectricInventoryManager(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public boolean isTransformerUpgradable() { + return true; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public long maxEUInput() { + return GT_Values.V[mTier]; + } + + @Override + public long maxEUOutput() { + return GT_Values.V[mTier]; + } + + @Override + public long getMinimumStoredEU() { + return GT_Values.V[this.mTier]; + } + + @Override + public long maxEUStore() { + return GT_Values.V[this.mTier] * (this.mTier * GT_Values.V[this.mTier]); + } + + @Override + public long maxAmperesIn() { + return 4; + } + + @Override + public long maxAmperesOut() { + return 4; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex < 3; + } + + @Override + public boolean isInputFacing(byte aSide) { + return !isOutputFacing(aSide); + } + + @Override + public boolean isOutputFacing(byte aSide) { + for (int i = 0; i < mSlotRange.length; i++) { + if (aSide == getRangeDirection(i) && getRangeEnergy(i)) { + return true; + } + } + return false; + } + + @Override + public int getSizeInventory() { + return 16; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_ElectricInventoryManager(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mSlotRange0", mSlotRange[0]); + aNBT.setInteger("mSlotRange1", mSlotRange[1]); + aNBT.setInteger("mSlotRange2", mSlotRange[2]); + aNBT.setInteger("mSlotRange3", mSlotRange[3]); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mSlotRange[0] = aNBT.getInteger("mSlotRange0"); + mSlotRange[1] = aNBT.getInteger("mSlotRange1"); + mSlotRange[2] = aNBT.getInteger("mSlotRange2"); + mSlotRange[3] = aNBT.getInteger("mSlotRange3"); + } + + public void iterateRangeDirection(int aIndex) { + mSlotRange[aIndex] = (mSlotRange[aIndex] & ~7) | (((mSlotRange[aIndex] & 7) + 1) % 6); + } + + public void switchRangeEnergy(int aIndex) { + mSlotRange[aIndex] = (mSlotRange[aIndex] & ~8) | ((mSlotRange[aIndex] & 8) > 0 ? 0 : 8); + } + + public void iterateSlot1Direction(int aIndex) { + mSlotRange[aIndex] = (mSlotRange[aIndex] & ~112) | (((((mSlotRange[aIndex] & 112) >> 4) + 1) % 6) << 4); + } + + public void iterateSlot2Direction(int aIndex) { + mSlotRange[aIndex] = (mSlotRange[aIndex] & ~896) | (((((mSlotRange[aIndex] & 896) >> 7) + 1) % 6) << 7); + } + + public void iterateSlot3Direction(int aIndex) { + mSlotRange[aIndex] = (mSlotRange[aIndex] & ~7168) | (((((mSlotRange[aIndex] & 7168) >> 10) + 1) % 6) << 10); + } + + public void switchSlot1InOut(int aIndex) { + mSlotRange[aIndex] = (mSlotRange[aIndex] & ~8192) | ((mSlotRange[aIndex] & 8192) > 0 ? 0 : 8192); + } + + public void switchSlot2InOut(int aIndex) { + mSlotRange[aIndex] = (mSlotRange[aIndex] & ~16384) | ((mSlotRange[aIndex] & 16384) > 0 ? 0 : 16384); + } + + public void switchSlot3InOut(int aIndex) { + mSlotRange[aIndex] = (mSlotRange[aIndex] & ~32768) | ((mSlotRange[aIndex] & 32768) > 0 ? 0 : 32768); + } + + public byte getRangeDirection(int aIndex) { + return (byte) (mSlotRange[aIndex] & 7); + } + + public byte getSlot1Direction(int aIndex) { + return (byte) ((mSlotRange[aIndex] & 112) >> 4); + } + + public byte getSlot2Direction(int aIndex) { + return (byte) ((mSlotRange[aIndex] & 896) >> 7); + } + + public byte getSlot3Direction(int aIndex) { + return (byte) ((mSlotRange[aIndex] & 7168) >> 10); + } + + public boolean getRangeEnergy(int aIndex) { + return (mSlotRange[aIndex] & 8) > 0; + } + + public boolean getSlot1InOut(int aIndex) { + return (mSlotRange[aIndex] & 8192) > 0; + } + + public boolean getSlot2InOut(int aIndex) { + return (mSlotRange[aIndex] & 16384) > 0; + } + + public boolean getSlot3InOut(int aIndex) { + return (mSlotRange[aIndex] & 32768) > 0; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide() && getBaseMetaTileEntity().getUniversalEnergyStored() >= 5000 + && (getBaseMetaTileEntity().hasWorkJustBeenEnabled() || getBaseMetaTileEntity().getTimer() % 100 == 0 || mWorkedLastTick || getBaseMetaTileEntity().hasInventoryBeenModified())) { + mWorkedLastTick = false; + + IInventory[] tTileEntities = new IInventory[]{ + getBaseMetaTileEntity().getIInventoryAtSide((byte) 0), getBaseMetaTileEntity().getIInventoryAtSide((byte) 1), getBaseMetaTileEntity().getIInventoryAtSide((byte) 2), + getBaseMetaTileEntity().getIInventoryAtSide((byte) 3), getBaseMetaTileEntity().getIInventoryAtSide((byte) 4), getBaseMetaTileEntity().getIInventoryAtSide((byte) 5), null, null + }; + + int tCost = 0; + + for (int i = 0; i < 4; i++) { + if (tTileEntities[getRangeDirection(i)] != null) { + ArrayList<ItemStack> tList = new ArrayList<ItemStack>(); + ItemStack tStack; + tList.add(null); + + tStack = mInventory[3 + i * 3 + 0]; + if (tStack == null) { + if (getSlot1InOut(i)) + tCost += 5 + * GT_Utility.moveOneItemStack(getBaseMetaTileEntity(), tTileEntities[getRangeDirection(i)], getSlot1Direction(i), getSlot1Direction(i), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + else + tCost += 5 + * GT_Utility.moveOneItemStack(tTileEntities[getRangeDirection(i)], getBaseMetaTileEntity(), getSlot1Direction(i), getSlot1Direction(i), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } + else { + tList.set(0, tStack); + if (getSlot1InOut(i)) + tCost += 5 + * GT_Utility.moveOneItemStack(getBaseMetaTileEntity(), tTileEntities[getRangeDirection(i)], getSlot1Direction(i), getSlot1Direction(i), tList, false, (byte) tStack.stackSize, (byte) 1, (byte) 64, (byte) 1); + else + tCost += 5 + * GT_Utility.moveOneItemStack(tTileEntities[getRangeDirection(i)], getBaseMetaTileEntity(), getSlot1Direction(i), getSlot1Direction(i), tList, false, (byte) tStack.stackSize, (byte) 1, (byte) 64, (byte) 1); + } + + tStack = mInventory[3 + i * 3 + 1]; + if (tStack == null) { + if (getSlot2InOut(i)) + tCost += 5 + * GT_Utility.moveOneItemStack(getBaseMetaTileEntity(), tTileEntities[getRangeDirection(i)], getSlot2Direction(i), getSlot2Direction(i), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + else + tCost += 5 + * GT_Utility.moveOneItemStack(tTileEntities[getRangeDirection(i)], getBaseMetaTileEntity(), getSlot2Direction(i), getSlot2Direction(i), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } + else { + tList.set(0, tStack); + if (getSlot2InOut(i)) + tCost += 5 + * GT_Utility.moveOneItemStack(getBaseMetaTileEntity(), tTileEntities[getRangeDirection(i)], getSlot2Direction(i), getSlot2Direction(i), tList, false, (byte) tStack.stackSize, (byte) 1, (byte) 64, (byte) 1); + else + tCost += 5 + * GT_Utility.moveOneItemStack(tTileEntities[getRangeDirection(i)], getBaseMetaTileEntity(), getSlot2Direction(i), getSlot2Direction(i), tList, false, (byte) tStack.stackSize, (byte) 1, (byte) 64, (byte) 1); + } + + tStack = mInventory[3 + i * 3 + 2]; + if (tStack == null) { + if (getSlot3InOut(i)) + tCost += 5 + * GT_Utility.moveOneItemStack(getBaseMetaTileEntity(), tTileEntities[getRangeDirection(i)], getSlot3Direction(i), getSlot3Direction(i), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + else + tCost += 5 + * GT_Utility.moveOneItemStack(tTileEntities[getRangeDirection(i)], getBaseMetaTileEntity(), getSlot3Direction(i), getSlot3Direction(i), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } + else { + tList.set(0, tStack); + if (getSlot3InOut(i)) + tCost += 5 + * GT_Utility.moveOneItemStack(getBaseMetaTileEntity(), tTileEntities[getRangeDirection(i)], getSlot3Direction(i), getSlot3Direction(i), tList, false, (byte) tStack.stackSize, (byte) 1, (byte) 64, (byte) 1); + else + tCost += 5 + * GT_Utility.moveOneItemStack(tTileEntities[getRangeDirection(i)], getBaseMetaTileEntity(), getSlot3Direction(i), getSlot3Direction(i), tList, false, (byte) tStack.stackSize, (byte) 1, (byte) 64, (byte) 1); + } + } + } + + if (tCost > 0) { + mWorkedLastTick = true; + getBaseMetaTileEntity().decreaseStoredEnergyUnits(tCost, true); + } + } + } + + @Override + public String[] getDescription() { + return new String[]{ + "It's simpler than you think. I promise.", this.mDescription, CORE.GT_Tooltip + }; + } + + /*@Override + public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { + switch (aSide) { + case 0: return 113 + (aRedstone?8:0); + case 1: return 112 + (aRedstone?8:0); + case 2: return 116 + (aRedstone?8:0); + case 3: return 213 + (aRedstone?8:0); + case 4: return 212 + (aRedstone?8:0); + case 5: return 117 + (aRedstone?8:0); + } + return 0; + }*/ + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return true; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return true; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[16][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getBottom(i); + rTextures[1][i + 1] = this.getTop(i); + rTextures[2][i + 1] = this.getNegativeZ(i); + rTextures[3][i + 1] = this.getPositiveZ(i); + rTextures[4][i + 1] = this.getNegativeX(i); + rTextures[5][i + 1] = this.getPositiveX(i); + rTextures[6][i + 1] = this.getBottomRedstone(i); + rTextures[7][i + 1] = this.getTopRedstone(i); + rTextures[8][i + 1] = this.getNegativeZRedstone(i); + rTextures[9][i + 1] = this.getPositiveZRedstone(i); + rTextures[10][i + 1] = this.getNegativeXRedstone(i); + rTextures[11][i + 1] = this.getPositiveXRedstone(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[!aRedstone ? aSide : aSide + 6][aColorIndex < 0 ? 0 : aColorIndex]; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{ + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Red) + }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{ + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Green) + }; + } + + public ITexture[] getNegativeZ(final byte aColor) { + return new ITexture[]{ + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Blue) + }; + } + + public ITexture[] getPositiveZ(final byte aColor) { + return new ITexture[]{ + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Cyan) + }; + } + + public ITexture[] getNegativeX(final byte aColor) { + return new ITexture[]{ + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Purple) + }; + } + + public ITexture[] getPositiveX(final byte aColor) { + return new ITexture[]{ + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Yellow) + }; + } + + public ITexture[] getBottomRedstone(final byte aColor) { + return new ITexture[]{ + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Red_Redstone) + }; + } + + public ITexture[] getTopRedstone(final byte aColor) { + return new ITexture[]{ + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Green_Redstone) + }; + } + + public ITexture[] getNegativeZRedstone(final byte aColor) { + return new ITexture[]{ + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Blue_Redstone) + }; + } + + public ITexture[] getPositiveZRedstone(final byte aColor) { + return new ITexture[]{ + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Cyan_Redstone) + }; + } + + public ITexture[] getNegativeXRedstone(final byte aColor) { + return new ITexture[]{ + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Purple_Redstone) + }; + } + + public ITexture[] getPositiveXRedstone(final byte aColor) { + return new ITexture[]{ + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Yellow_Redstone) + }; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CropHarvestor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CropHarvestor.java new file mode 100644 index 0000000000..678ca46204 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CropHarvestor.java @@ -0,0 +1,660 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.gui.basic.GT_Container_CropHarvestor; +import gtPlusPlus.xmod.gregtech.api.gui.basic.GT_GUIContainer_CropHarvestor; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import ic2.api.crops.CropCard; +import ic2.api.crops.ICropTile; +import ic2.core.item.DamageHandler; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +public class GT_MetaTileEntity_CropHarvestor extends GT_MetaTileEntity_BasicTank { + + protected String mLocalName; + + private static final int SLOT_WEEDEX_1 = 1; + private static final int SLOT_WEEDEX_2 = 2; + private static final int SLOT_FERT_1 = 3; + private static final int SLOT_FERT_4 = 6; + private static final int SLOT_OUTPUT_START = 7; + + public boolean mModeAlternative = false; + + public GT_MetaTileEntity_CropHarvestor(final int aID, final int aTier, final String aDescription) { + super(aID, "basicmachine.cropharvester.0"+aTier, "Crop Manager ("+GT_Values.VN[aTier]+")", aTier, 21, aDescription); + mLocalName = "Crop Manager ("+GT_Values.VN[aTier]+")"; + } + + public GT_MetaTileEntity_CropHarvestor(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, 21, aDescription, aTextures); + mLocalName = "Crop Manager ("+GT_Values.VN[aTier]+")"; + } + + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_CropHarvestor(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_CropHarvestor(aPlayerInventory, aBaseMetaTileEntity, mLocalName); + } + + @Override + public boolean isTransformerUpgradable() { + return true; + } + + @Override + public boolean isOverclockerUpgradable() { + return true; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isInputFacing(byte aSide) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public long maxAmperesIn() { + return 8; + } + + @Override + public long getMinimumStoredEU() { + return GT_Values.V[this.mTier]; + } + + @Override + public long maxEUStore() { + return GT_Values.V[this.mTier] * (this.mTier * GT_Values.V[this.mTier]); + } + + @Override + public long maxEUInput() { + return GT_Values.V[mTier]; + } + + @Override + public int getCapacity() { + return 32000 * mTier; + } + + @Override + public int getTankPressure() { + return -100; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_CropHarvestor(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public int getSizeInventory() { + return 21; + } + + private static final int getRange(int aTier) { + switch(aTier) { + case 1: + return 1; + case 2: + return 5; + case 3: + return 9; + case 4: + return 13; + case 5: + return 17; + case 6: + return 21; + case 7: + return 25; + case 8: + return 29; + case 9: + return 33; + default: + return 0; + } + } + + private HashSet<ICropTile> mCropCache = new HashSet<ICropTile>(); + private boolean mInvalidCache = false; + + public boolean doesInventoryHaveSpace() { + for (int i = SLOT_OUTPUT_START; i < this.getSizeInventory(); i++) { + if (this.mInventory[i] == null || this.mInventory[i].stackSize < 64) { + return true; + } + } + return false; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (getBaseMetaTileEntity().isServerSide() && getBaseMetaTileEntity().isAllowedToWork() && (getBaseMetaTileEntity().hasWorkJustBeenEnabled() || aTick % 100 == 0)) { + if (this.getBaseMetaTileEntity().getUniversalEnergyStored() >= getMinimumStoredEU()) { + + int aTileX = this.getBaseMetaTileEntity().getXCoord(); + int aTileY = this.getBaseMetaTileEntity().getXCoord(); + int aTileZ = this.getBaseMetaTileEntity().getXCoord(); + + int aRadius = 10 + getRange(mTier); + int aSide = (aRadius-1)/2; + ArrayList<ItemStack> aAllDrops = new ArrayList<ItemStack>(); + + if (mCropCache.isEmpty() || aTick % 1200 == 0 || mInvalidCache) { + if (!mCropCache.isEmpty()) { + mCropCache.clear(); + } + //Logger.INFO("Looking for crops."); + for (int y = 0; y <= 2; y++) { + for (int x = (-aSide); x <= aSide; x++) { + for (int z = (-aSide); z <= aSide; z++) { + TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityOffset(x, y, z); + if (tTileEntity != null && tTileEntity instanceof ICropTile) { + ICropTile tCrop = (ICropTile) tTileEntity; + mCropCache.add(tCrop); + } + } + } + } + } + + //Process Cache + if (doesInventoryHaveSpace()) { + for (ICropTile tCrop : mCropCache) { + if (tCrop == null) { + mInvalidCache = true; + break; + } + CropCard aCrop = tCrop.getCrop(); + if (aCrop != null) { + //Logger.INFO("Found "+aCrop.displayName()+" at offset "+x+", "+y+", "+z); + if (!aCrop.canGrow(tCrop) && aCrop.canBeHarvested(tCrop)) { + if (getBaseMetaTileEntity().decreaseStoredEnergyUnits(maxEUInput(), true)) { + ItemStack[] aHarvest = tCrop.harvest_automated(true); + if (aHarvest != null && aHarvest.length > 0) { + for (ItemStack aStack : aHarvest) { + if (aStack.stackSize > 0) { + if (mTier * 5 > MathUtils.randInt(1, 100)) { + aStack.stackSize += Math.floor(tCrop.getGain()/10); + Logger.INFO("Bonus output given for "+aCrop.displayName()); + } + Logger.INFO("Harvested "+aCrop.displayName()); + aAllDrops.add(aStack); + } + } + } + } + } + if (this.mModeAlternative) { + processSecondaryFunctions(tCrop); + } + } + } + + if (!aAllDrops.isEmpty()) { + Logger.INFO("Handling "+aAllDrops.size()+" Harvests"); + Iterator<ItemStack> iter = aAllDrops.iterator(); + while (iter.hasNext()) { + ItemStack aDrop = iter.next(); + if (ItemUtils.checkForInvalidItems(aDrop)) { + + for (int i = SLOT_OUTPUT_START; i < this.getSizeInventory(); i++) { + if (this.mInventory[i] != null) { + //Logger.INFO("Slot "+i+" contains "+this.mInventory[i].getDisplayName()); + if (GT_Utility.areStacksEqual(aDrop, mInventory[i], false)) { + //Same + if (mInventory[i].stackSize < 64 && (mInventory[i].stackSize + aDrop.stackSize <= 64)) { + //can merge + //Logger.INFO("Slot "+i+" size: "+mInventory[i].stackSize+" + Drop Size: "+aDrop.stackSize+" = "+(mInventory[i].stackSize + aDrop.stackSize)); + mInventory[i].stackSize += aDrop.stackSize; + break; + } + else if (mInventory[i].stackSize < 64 && (mInventory[i].stackSize + aDrop.stackSize > 64)) { + //can merge + //Logger.INFO("Slot "+i+" size: "+mInventory[i].stackSize+" + Drop Size: "+aDrop.stackSize+" = "+(mInventory[i].stackSize + aDrop.stackSize)); + int aRemainder = mInventory[i].stackSize + aDrop.stackSize - 64; + Logger.INFO("Remainder: "+aRemainder+", Continuing."); + mInventory[i].stackSize = 64; + aDrop.stackSize = aRemainder; + continue; + } + else { + //Logger.INFO("Slot "+i+" size: 64, Continuing."); + continue; + } + } + } + else { + //Logger.INFO("Slot "+i+" is empty, setting to "+aDrop.getDisplayName()+" x"+aDrop.stackSize); + this.mInventory[i] = aDrop; + break; + } + } + } + + } + } + } + } + } + } + + public boolean hasFertilizer() { + for (int i = SLOT_FERT_1; i <= SLOT_FERT_4; i++) { + if (this.mInventory[i] != null) { + return true; + } + } + return false; + } + + public boolean consumeFertilizer(boolean aSimulate) { + if (hasFertilizer()) { + for (int i = SLOT_FERT_1; i <= SLOT_FERT_4; i++) { + if (this.mInventory[i] != null) { + consume(i, 1, aSimulate); + return true; + } + } + } + return false; + } + + public boolean hasWeedEX() { + for (int i = SLOT_WEEDEX_1; i <= SLOT_WEEDEX_2; i++) { + if (this.mInventory[i] != null) { + return true; + } + } + return false; + } + + public boolean consumeWeedEX(boolean aSimulate) { + if (hasWeedEX()) { + for (int i = SLOT_WEEDEX_1; i <= SLOT_WEEDEX_2; i++) { + if (this.mInventory[i] != null) { + damage(i, 1, aSimulate); + return true; + } + } + } + return false; + } + + public void processSecondaryFunctions(ICropTile aCrop) { + if (!mModeAlternative) { + return; + } + if (hasFertilizer() && consumeFertilizer(true) && this.getBaseMetaTileEntity().getUniversalEnergyStored() >= getMinimumStoredEU() && getBaseMetaTileEntity().decreaseStoredEnergyUnits(maxEUInput(), true) && applyFertilizer(aCrop)) { + if (consumeFertilizer(false)) { + //Logger.INFO("Consumed Fert."); + } + } + if (this.getFluidAmount() > 0 && this.getBaseMetaTileEntity().getUniversalEnergyStored() >= getMinimumStoredEU() && getBaseMetaTileEntity().decreaseStoredEnergyUnits(maxEUInput(), true) && applyHydration(aCrop)) { + //Logger.INFO("Consumed Water."); + } + if (hasWeedEX() && consumeWeedEX(true) && this.getBaseMetaTileEntity().getUniversalEnergyStored() >= getMinimumStoredEU() && getBaseMetaTileEntity().decreaseStoredEnergyUnits(maxEUInput(), true) && applyWeedEx(aCrop)) { + if (consumeWeedEX(false)) { + //Logger.INFO("Consumed Weed-EX."); + } + } + } + + + public boolean applyWeedEx(ICropTile aCrop) { + if (aCrop.getWeedExStorage() < 150) { + aCrop.setWeedExStorage(aCrop.getWeedExStorage() + 50); + boolean triggerDecline; + triggerDecline = aCrop.getWorld().rand.nextInt(3) == 0; + if (aCrop.getCrop() != null && aCrop.getCrop().isWeed(aCrop) && aCrop.getWeedExStorage() >= 75 && triggerDecline) { + switch (aCrop.getWorld().rand.nextInt(5)) { + case 0 : + if (aCrop.getGrowth() > 0) { + aCrop.setGrowth((byte) (aCrop.getGrowth() - 1)); + } + case 1 : + if (aCrop.getGain() > 0) { + aCrop.setGain((byte) (aCrop.getGain() - 1)); + } + default : + if (aCrop.getResistance() > 0) { + aCrop.setResistance((byte) (aCrop.getResistance() - 1)); + } + } + } + return true; + } else { + return false; + } + } + + public boolean applyFertilizer(ICropTile aCrop) { + if (aCrop.getNutrientStorage() >= 100) { + return false; + } else { + //Logger.INFO("Current Nutrient: "+aCrop.getNutrientStorage()+" for "+aCrop.getCrop().displayName()); + aCrop.setNutrientStorage(100); + return true; + } + } + + public boolean applyHydration(ICropTile aCrop) { + if (aCrop.getHydrationStorage() >= 200 || this.getFluidAmount() == 0) { + //Logger.INFO("Hydration Max"); + return false; + } else { + int apply = 200 - aCrop.getHydrationStorage(); + if (this.getFluidAmount() >= 0) { + int drain = 0; + if (this.getFluidAmount() >= apply) { + drain = apply; + } + else { + drain = this.getFluidAmount(); + } + this.mFluid.amount -= drain; + if (this.mFluid.amount <= 0) { + this.mFluid = null; + } + //Logger.INFO("Did Hydrate"); + aCrop.setHydrationStorage(aCrop.getHydrationStorage() + drain); + return true; + } + else { + //Logger.INFO("No water?"); + return false; + } + } + } + + public boolean consume(int aSlot, int amount, boolean simulate) { + ItemStack stack = this.mInventory[aSlot]; + if (stack != null && stack.stackSize >= amount) { + int currentAmount = Math.min(amount, stack.stackSize); + amount -= currentAmount; + if (!simulate) { + if (stack.stackSize == currentAmount) { + this.mInventory[aSlot] = null; + } else { + stack.stackSize -= currentAmount; + } + } + else { + return amount >= 0; + } + return true; + } + return false; + } + + public ItemStack damage(int aSlot, int amount, boolean simulate) { + ItemStack ret = null; + int damageApplied = 0; + ItemStack stack = this.mInventory[aSlot]; + Item item = stack.getItem(); + if (stack != null && item.isDamageable() && (ret == null + || stack.getItem() == ret.getItem() && ItemStack.areItemStackTagsEqual(stack, ret))) { + if (simulate) { + stack = stack.copy(); + } + int maxDamage = DamageHandler.getMaxDamage(stack); + while (amount > 0 && stack.stackSize > 0) { + int currentAmount = Math.min(amount, maxDamage - DamageHandler.getDamage(stack)); + DamageHandler.damage(stack, currentAmount, null); + damageApplied += currentAmount; + amount -= currentAmount; + if (DamageHandler.getDamage(stack) >= maxDamage) { + --stack.stackSize; + DamageHandler.setDamage(stack, 0); + } + + if (ret == null) { + ret = stack.copy(); + } + } + if (stack.stackSize == 0 && !simulate) { + this.mInventory[aSlot] = null; + } + } + + if (ret != null) { + int i = DamageHandler.getMaxDamage(ret); + ret.stackSize = damageApplied / i; + DamageHandler.setDamage(ret, damageApplied % i); + } + return ret; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aStack != null && aIndex >= SLOT_OUTPUT_START && aIndex < this.getSizeInventory(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (aStack != null) { + if (aStack.getItem().getUnlocalizedName().equals("ic2.itemFertilizer")) { + return aIndex >= SLOT_FERT_1 && aIndex <= SLOT_FERT_4; + } + else if (aStack.getItem().getUnlocalizedName().equals("ic2.itemWeedEx")) { + return aIndex >= SLOT_WEEDEX_1 && aIndex <= SLOT_WEEDEX_2; + } + } + return false; + } + + @Override + public String[] getDescription() { + int aRadius = 10 + getRange(mTier); + int aSide = (aRadius-1)/2; + return new String[] { + this.mDescription, + "Secondary mode can Hydrate/Fertilize/Weed-EX", + "Consumes "+maxEUInput()+"eu per harvest", + "Can harvest 2 blocks above", + "Radius: "+aSide+" each side ("+aRadius+"x3x"+aRadius+")", + "Has "+(mTier * 5)+"% chance for extra drops", + "Holds "+this.getCapacity()+"L of Water", + CORE.GT_Tooltip + }; + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { + return true; + } + + /*@Override + public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) + return 118+(aRedstone?8:0); + if (GT_Utility.getOppositeSide(aSide) == aFacing) + return 113+(aRedstone?8:0); + + int tIndex = 128+(aRedstone?8:0); + + switch (aFacing) { + case 0: + return tIndex+64; + case 1: + return tIndex+32; + case 2: switch (aSide) { + case 0: return tIndex+32; + case 1: return tIndex+32; + case 4: return tIndex+16; + case 5: return tIndex+48; + } + case 3: switch (aSide) { + case 0: return tIndex+64; + case 1: return tIndex+64; + case 4: return tIndex+48; + case 5: return tIndex+16; + } + case 4: switch (aSide) { + case 0: return tIndex+16; + case 1: return tIndex+16; + case 2: return tIndex+48; + case 3: return tIndex+16; + } + case 5: switch (aSide) { + case 0: return tIndex+48; + case 1: return tIndex+48; + case 2: return tIndex+16; + case 3: return tIndex+48; + } + } + return tIndex; + } */ + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFront(i); + rTextures[6][i + 1] = this.getBack(i); + rTextures[7][i + 1] = this.getBottom(i); + rTextures[8][i + 1] = this.getTop(i); + rTextures[9][i + 1] = this.getSides(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == 0 || aSide == 1) { + return this.mTextures[3][aColorIndex + 1]; + } + else { + return this.mTextures[4][aColorIndex + 1]; + } + /*return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + + 1];*/ + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Cutter)}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Cutter)}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Boxes)}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Boxes)}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Cutter)}; + } + + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return false; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mModeAlternative", mModeAlternative); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mModeAlternative = aNBT.getBoolean("mModeAlternative"); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_AdvancedCraftingTable.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_AdvancedCraftingTable.java index b5aa916e54..0b815bfae7 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_AdvancedCraftingTable.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_AdvancedCraftingTable.java @@ -485,7 +485,8 @@ public class GT_MetaTileEntity_AdvancedCraftingTable extends GT_MetaTileEntity_B @Override public String[] getDescription() { return new String[] { - "For the very large Projects", + isAdvanced() ? "For the very large Projects" : "For the smaller Projects", + "Hold Shift in GUI to see slot usage", this.mDescription, CORE.GT_Tooltip }; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_BronzeCraftingTable.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_BronzeCraftingTable.java index 75d46cbb53..f421d391c0 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_BronzeCraftingTable.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_BronzeCraftingTable.java @@ -72,14 +72,6 @@ public class GT_MetaTileEntity_BronzeCraftingTable extends GT_MetaTileEntity_Adv } @Override - public String[] getDescription() { - return new String[] { - "For the smaller Projects", - this.mDescription, - CORE.GT_Tooltip }; - } - - @Override public int getCapacity() { return 16000; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java index 721dbd69c3..a0a4c8a749 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java @@ -1,11 +1,15 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; +import gregtech.api.GregTech_API; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ElectricAutoWorkbench; +import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ElectricInventoryManager; import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractGenerator; import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractTerminal; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_CropHarvestor; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GT4Entity_AutoCrafter; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GT4Entity_ThermalBoiler; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_AdvancedCraftingTable; @@ -23,21 +27,55 @@ public class Gregtech4Content { public static void run() { if (LoadedMods.Gregtech) { + Logger.INFO("Max MTE: "+GregTech_API.METATILEENTITIES.length+" | "+GregTech_API.MAXIMUM_METATILE_IDS); workbenches(); thermalBoiler(); multiCrafter(); tesseracts(); shelves(); + basic(); + automation(); } } private static void workbenches() { // Gregtech 4 Workbenches Logger.INFO("Gregtech 4 Content | Registering Workbenches."); - GregtechItemList.GT4_Workbench_Bronze.set(new GT_MetaTileEntity_BronzeCraftingTable(29001, "workbench.basic", "Bronze Workbench", 0, "Stores 16000L of fluid").getStackForm(1L)); - GregtechItemList.GT4_Workbench_Advanced.set(new GT_MetaTileEntity_AdvancedCraftingTable(29002, "workbench.advanced", "Advanced Workbench", 3, "Stores 64000L of fluid").getStackForm(1L)); + GregtechItemList.GT4_Workbench_Bronze.set(new GT_MetaTileEntity_BronzeCraftingTable(31081, "workbench.basic", "Bronze Workbench", 0, "Stores 16000L of fluid").getStackForm(1L)); + GregtechItemList.GT4_Workbench_Advanced.set(new GT_MetaTileEntity_AdvancedCraftingTable(31082, "workbench.advanced", "Advanced Workbench", 3, "Stores 64000L of fluid").getStackForm(1L)); } + + private static void automation() { + GregtechItemList.GT4_Electric_Auto_Workbench_LV.set(new GT_MetaTileEntity_ElectricAutoWorkbench(31091, 1, "Automatic crafting machine").getStackForm(1L)); + GregtechItemList.GT4_Electric_Auto_Workbench_MV.set(new GT_MetaTileEntity_ElectricAutoWorkbench(31092, 2, "Automatic crafting machine").getStackForm(1L)); + GregtechItemList.GT4_Electric_Auto_Workbench_HV.set(new GT_MetaTileEntity_ElectricAutoWorkbench(31093, 3, "Automatic crafting machine").getStackForm(1L)); + GregtechItemList.GT4_Electric_Auto_Workbench_LV.set(new GT_MetaTileEntity_ElectricAutoWorkbench(31094, 4, "Automatic crafting machine").getStackForm(1L)); + GregtechItemList.GT4_Electric_Auto_Workbench_IV.set(new GT_MetaTileEntity_ElectricAutoWorkbench(31095, 5, "Automatic crafting machine").getStackForm(1L)); + GregtechItemList.GT4_Electric_Auto_Workbench_LuV.set(new GT_MetaTileEntity_ElectricAutoWorkbench(31096, 6, "Automatic crafting machine").getStackForm(1L)); + GregtechItemList.GT4_Electric_Auto_Workbench_ZPM.set(new GT_MetaTileEntity_ElectricAutoWorkbench(31097, 7, "Automatic crafting machine").getStackForm(1L)); + GregtechItemList.GT4_Electric_Auto_Workbench_UV.set(new GT_MetaTileEntity_ElectricAutoWorkbench(31098, 8, "Automatic crafting machine").getStackForm(1L)); + + GregtechItemList.GT4_Electric_Inventory_Manager_LV.set(new GT_MetaTileEntity_ElectricInventoryManager(31101, 1, "Manages your inventory and stuff").getStackForm(1L)); + GregtechItemList.GT4_Electric_Inventory_Manager_MV.set(new GT_MetaTileEntity_ElectricInventoryManager(31102, 2, "Manages your inventory and stuff").getStackForm(1L)); + GregtechItemList.GT4_Electric_Inventory_Manager_HV.set(new GT_MetaTileEntity_ElectricInventoryManager(31103, 3, "Manages your inventory and stuff").getStackForm(1L)); + GregtechItemList.GT4_Electric_Inventory_Manager_EV.set(new GT_MetaTileEntity_ElectricInventoryManager(31104, 4, "Manages your inventory and stuff").getStackForm(1L)); + GregtechItemList.GT4_Electric_Inventory_Manager_IV.set(new GT_MetaTileEntity_ElectricInventoryManager(31105, 5, "Manages your inventory and stuff").getStackForm(1L)); + GregtechItemList.GT4_Electric_Inventory_Manager_LuV.set(new GT_MetaTileEntity_ElectricInventoryManager(31106, 6, "Manages your inventory and stuff").getStackForm(1L)); + GregtechItemList.GT4_Electric_Inventory_Manager_ZPM.set(new GT_MetaTileEntity_ElectricInventoryManager(31107, 7, "Manages your inventory and stuff").getStackForm(1L)); + GregtechItemList.GT4_Electric_Inventory_Manager_UV.set(new GT_MetaTileEntity_ElectricInventoryManager(31108, 8, "Manages your inventory and stuff").getStackForm(1L)); + } + + private static void basic() { + GregtechItemList.GT4_Crop_Harvester_LV.set(new GT_MetaTileEntity_CropHarvestor(31111, 1, "Harvests the Cropsticks in front of it").getStackForm(1L)); + GregtechItemList.GT4_Crop_Harvester_MV.set(new GT_MetaTileEntity_CropHarvestor(31112, 2, "Harvests the Cropsticks in front of it").getStackForm(1L)); + GregtechItemList.GT4_Crop_Harvester_HV.set(new GT_MetaTileEntity_CropHarvestor(31113, 3, "Harvests the Cropsticks in front of it").getStackForm(1L)); + GregtechItemList.GT4_Crop_Harvester_EV.set(new GT_MetaTileEntity_CropHarvestor(31114, 4, "Harvests the Cropsticks in front of it").getStackForm(1L)); + GregtechItemList.GT4_Crop_Harvester_IV.set(new GT_MetaTileEntity_CropHarvestor(31115, 5, "Harvests the Cropsticks in front of it").getStackForm(1L)); + GregtechItemList.GT4_Crop_Harvester_LuV.set(new GT_MetaTileEntity_CropHarvestor(31116, 6, "Harvests the Cropsticks in front of it").getStackForm(1L)); + GregtechItemList.GT4_Crop_Harvester_ZPM.set(new GT_MetaTileEntity_CropHarvestor(31117, 7, "Harvests the Cropsticks in front of it").getStackForm(1L)); + GregtechItemList.GT4_Crop_Harvester_UV.set(new GT_MetaTileEntity_CropHarvestor(31118, 8, "Harvests the Cropsticks in front of it").getStackForm(1L)); + } private static void tesseracts() { // Gregtech 4 Tesseracts |