diff --git a/src/main/java/gregtech/api/enums/ItemList.java b/src/main/java/gregtech/api/enums/ItemList.java index c98515e0..ade0383c 100644 --- a/src/main/java/gregtech/api/enums/ItemList.java +++ b/src/main/java/gregtech/api/enums/ItemList.java @@ -544,6 +544,7 @@ public enum ItemList implements IItemContainer { Automation_ChestBuffer_ULV, Automation_ChestBuffer_LV, Automation_ChestBuffer_MV, Automation_ChestBuffer_HV, Automation_ChestBuffer_EV, Automation_ChestBuffer_IV, Automation_ChestBuffer_LuV, Automation_ChestBuffer_ZPM, Automation_ChestBuffer_UV, Automation_ChestBuffer_MAX, Automation_SuperBuffer_ULV, Automation_SuperBuffer_LV, Automation_SuperBuffer_MV, Automation_SuperBuffer_HV, Automation_SuperBuffer_EV, Automation_SuperBuffer_IV, Automation_SuperBuffer_LuV, Automation_SuperBuffer_ZPM, Automation_SuperBuffer_UV, Automation_SuperBuffer_MAX, Automation_Regulator_ULV, Automation_Regulator_LV, Automation_Regulator_MV, Automation_Regulator_HV, Automation_Regulator_EV, Automation_Regulator_IV, Automation_Regulator_LuV, Automation_Regulator_ZPM, Automation_Regulator_UV, Automation_Regulator_MAX, + Automation_ItemDistributor_ULV, Automation_ItemDistributor_LV, Automation_ItemDistributor_MV, Automation_ItemDistributor_HV, Automation_ItemDistributor_EV, Automation_ItemDistributor_IV, Automation_ItemDistributor_LuV, Automation_ItemDistributor_ZPM, Automation_ItemDistributor_UV, Automation_ItemDistributor_MAX, Hatch_Dynamo_ULV, Hatch_Dynamo_LV, Hatch_Dynamo_MV, Hatch_Dynamo_HV, Hatch_Dynamo_EV, Hatch_Dynamo_IV, Hatch_Dynamo_LuV, Hatch_Dynamo_ZPM, Hatch_Dynamo_UV, Hatch_Dynamo_MAX, Hatch_Energy_ULV, Hatch_Energy_LV, Hatch_Energy_MV, Hatch_Energy_HV, Hatch_Energy_EV, Hatch_Energy_IV, Hatch_Energy_LuV, Hatch_Energy_ZPM, Hatch_Energy_UV, Hatch_Energy_MAX, diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java new file mode 100644 index 00000000..a7d2d286 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java @@ -0,0 +1,69 @@ +package gregtech.common.tileentities.automation; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Buffer; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; +import gregtech.common.gui.GT_Container_ChestBuffer; +import gregtech.common.gui.GT_GUIContainer_ChestBuffer; +import net.minecraft.entity.player.InventoryPlayer; + +public class GT_MetaTileEntity_ItemDistributor extends GT_MetaTileEntity_Buffer { + public GT_MetaTileEntity_ItemDistributor(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 28, "Buffering lots of incoming Items"); + } + + public GT_MetaTileEntity_ItemDistributor(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, + String aDescription) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); + } + + public GT_MetaTileEntity_ItemDistributor(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + public GT_MetaTileEntity_ItemDistributor(String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_ChestBuffer(this.mName, this.mTier, this.mInventory.length, this.mDescriptionArray, this.mTextures); + } + + public ITexture getOverlayIcon() { + return new GT_RenderedTexture(Textures.BlockIcons.AUTOMATION_CHESTBUFFER); + } + + public boolean isValidSlot(int aIndex) { + return aIndex < this.mInventory.length - 1; + } + + protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + fillStacksIntoFirstSlots(); + super.moveItems(aBaseMetaTileEntity, aTimer); + fillStacksIntoFirstSlots(); + } + + protected void fillStacksIntoFirstSlots() { + for (int i = 0; i < this.mInventory.length - 1; i++) { + for (int j = i + 1; j < this.mInventory.length - 1; j++) { + if ((this.mInventory[j] != null) + && ((this.mInventory[i] == null) || (GT_Utility.areStacksEqual(this.mInventory[i], this.mInventory[j])))) { + GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, + (byte) 64, (byte) 1); + } + } + } + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_ChestBuffer(aPlayerInventory, aBaseMetaTileEntity); + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_ChestBuffer(aPlayerInventory, aBaseMetaTileEntity); + } +} diff --git a/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java b/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java index df3b80a9..84b0a242 100644 --- a/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java +++ b/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java @@ -1550,6 +1550,17 @@ public class GT_Loader_MetaTileEntities implements Runnable { GT_ModHandler.addCraftingRecipe(ItemList.Automation_SuperBuffer_ZPM.get(1L, new Object[0]), bitsd, new Object[]{"DMV", "DDD", 'M', ItemList.Hull_ZPM, 'V', ItemList.Conveyor_Module_ZPM, 'D', ItemList.Tool_DataStick}); GT_ModHandler.addCraftingRecipe(ItemList.Automation_SuperBuffer_UV.get(1L, new Object[0]), bitsd, new Object[]{"DMV", "DDD", 'M', ItemList.Hull_UV, 'V', ItemList.Conveyor_Module_UV, 'D', ItemList.Tool_DataStick}); GT_ModHandler.addCraftingRecipe(ItemList.Automation_SuperBuffer_MAX.get(1L, new Object[0]), bitsd, new Object[]{"DMV", "DDD", 'M', ItemList.Hull_MAX, 'V', ItemList.Conveyor_Module_UV, 'D', ItemList.Tool_DataStick}); + + ItemList.Automation_ChestBuffer_ULV.set(new GT_MetaTileEntity_ChestBuffer(9320, "automation.itemdistributor.tier.00", "Ultra Low Voltage Item Distributor", 0).getStackForm(1L)); + ItemList.Automation_ChestBuffer_LV.set(new GT_MetaTileEntity_ChestBuffer(9321, "automation.itemdistributor.tier.01", "Low Voltage Item Distributor", 1).getStackForm(1L)); + ItemList.Automation_ChestBuffer_MV.set(new GT_MetaTileEntity_ChestBuffer(9322, "automation.itemdistributor.tier.02", "Medium Voltage Item Distributor", 2).getStackForm(1L)); + ItemList.Automation_ChestBuffer_HV.set(new GT_MetaTileEntity_ChestBuffer(9323, "automation.itemdistributor.tier.03", "High Voltage Item Distributor", 3).getStackForm(1L)); + ItemList.Automation_ChestBuffer_EV.set(new GT_MetaTileEntity_ChestBuffer(9324, "automation.itemdistributor.tier.04", "Extreme Voltage Item Distributor", 4).getStackForm(1L)); + ItemList.Automation_ChestBuffer_IV.set(new GT_MetaTileEntity_ChestBuffer(9325, "automation.itemdistributor.tier.05", "Insane Voltage Item Distributor", 5).getStackForm(1L)); + ItemList.Automation_ChestBuffer_LuV.set(new GT_MetaTileEntity_ChestBuffer(9326, "automation.itemdistributor.tier.06", "Ludicrous Voltage Item Distributor", 6).getStackForm(1L)); + ItemList.Automation_ChestBuffer_ZPM.set(new GT_MetaTileEntity_ChestBuffer(9327, "automation.itemdistributor.tier.07", "ZPM Voltage Item Distributor", 7).getStackForm(1L)); + ItemList.Automation_ChestBuffer_UV.set(new GT_MetaTileEntity_ChestBuffer(9328, "automation.itemdistributor.tier.08", "Ultimate Voltage Item Distributor", 8).getStackForm(1L)); + ItemList.Automation_ChestBuffer_MAX.set(new GT_MetaTileEntity_ChestBuffer(9329, "automation.itemdistributor.tier.09", "MAX Voltage Item Distributor", 9).getStackForm(1L)); } private static void makeWires(Materials aMaterial, int aStartID, long aLossInsulated, long aLoss, long aAmperage, long aVoltage, boolean aInsulatable, boolean aAutoInsulated) {