Added simple ItemDistributor implementation, changed MoveOneItemStack
This commit is contained in:
parent
31516ba891
commit
22fdaed164
3 changed files with 32 additions and 14 deletions
|
@ -560,7 +560,10 @@ public class GT_Utility {
|
||||||
if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(tGrabSlots[i]), true, aInvertFilter)) {
|
if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(tGrabSlots[i]), true, aInvertFilter)) {
|
||||||
if (isAllowedToTakeFromSlot(aTileEntity1, tGrabSlots[i], aGrabFrom, aTileEntity1.getStackInSlot(tGrabSlots[i]))) {
|
if (isAllowedToTakeFromSlot(aTileEntity1, tGrabSlots[i], aGrabFrom, aTileEntity1.getStackInSlot(tGrabSlots[i]))) {
|
||||||
if (isAllowedToPutIntoSlot((IInventory) aTileEntity2, tPutSlots[j], aPutTo, aTileEntity1.getStackInSlot(tGrabSlots[i]), aMaxTargetStackSize)) {
|
if (isAllowedToPutIntoSlot((IInventory) aTileEntity2, tPutSlots[j], aPutTo, aTileEntity1.getStackInSlot(tGrabSlots[i]), aMaxTargetStackSize)) {
|
||||||
tMovedItemCount = moveStackFromSlotAToSlotB(aTileEntity1, (IInventory) aTileEntity2, tGrabSlots[i], tPutSlots[j], aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce);
|
tMovedItemCount += moveStackFromSlotAToSlotB(aTileEntity1, (IInventory) aTileEntity2, tGrabSlots[i], tPutSlots[j], aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItemCount), aMinMoveAtOnce);
|
||||||
|
if (tMovedItemCount >= aMaxMoveAtOnce) {
|
||||||
|
return tMovedItemCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,12 @@ import gregtech.api.util.GT_Utility;
|
||||||
import gregtech.common.gui.GT_Container_ChestBuffer;
|
import gregtech.common.gui.GT_Container_ChestBuffer;
|
||||||
import gregtech.common.gui.GT_GUIContainer_ChestBuffer;
|
import gregtech.common.gui.GT_GUIContainer_ChestBuffer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
public class GT_MetaTileEntity_ItemDistributor extends GT_MetaTileEntity_Buffer {
|
public class GT_MetaTileEntity_ItemDistributor extends GT_MetaTileEntity_Buffer {
|
||||||
|
private byte[] weights = {1, 1, 1, 1, 1, 1};
|
||||||
|
boolean onlyOutputToInventories = true;
|
||||||
|
|
||||||
public GT_MetaTileEntity_ItemDistributor(int aID, String aName, String aNameRegional, int aTier) {
|
public GT_MetaTileEntity_ItemDistributor(int aID, String aName, String aNameRegional, int aTier) {
|
||||||
super(aID, aName, aNameRegional, aTier, 28, "Buffering lots of incoming Items");
|
super(aID, aName, aNameRegional, aTier, 28, "Buffering lots of incoming Items");
|
||||||
}
|
}
|
||||||
|
@ -30,7 +34,7 @@ public class GT_MetaTileEntity_ItemDistributor extends GT_MetaTileEntity_Buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
|
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
|
||||||
return new GT_MetaTileEntity_ChestBuffer(this.mName, this.mTier, this.mInventory.length, this.mDescriptionArray, this.mTextures);
|
return new GT_MetaTileEntity_ItemDistributor(this.mName, this.mTier, this.mInventory.length, this.mDescriptionArray, this.mTextures);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITexture getOverlayIcon() {
|
public ITexture getOverlayIcon() {
|
||||||
|
@ -43,7 +47,18 @@ public class GT_MetaTileEntity_ItemDistributor extends GT_MetaTileEntity_Buffer
|
||||||
|
|
||||||
protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
|
protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
|
||||||
fillStacksIntoFirstSlots();
|
fillStacksIntoFirstSlots();
|
||||||
super.moveItems(aBaseMetaTileEntity, aTimer);
|
int tCost = 0;
|
||||||
|
for (byte side = 0; side < 6; side++) {
|
||||||
|
TileEntity adjacentTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(side);
|
||||||
|
if(!onlyOutputToInventories || adjacentTileEntity != null){
|
||||||
|
tCost = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, adjacentTileEntity,
|
||||||
|
side, GT_Utility.getOppositeSide(side), null, false, (byte) 64, (byte) 1, weights[side], weights[side]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) {
|
||||||
|
mSuccess = 50;
|
||||||
|
aBaseMetaTileEntity.decreaseStoredEnergyUnits(Math.abs(tCost), true);
|
||||||
|
}
|
||||||
fillStacksIntoFirstSlots();
|
fillStacksIntoFirstSlots();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1551,16 +1551,16 @@ public class GT_Loader_MetaTileEntities implements Runnable {
|
||||||
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_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});
|
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_ItemDistributor_ULV.set(new GT_MetaTileEntity_ItemDistributor(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_ItemDistributor_LV.set(new GT_MetaTileEntity_ItemDistributor(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_ItemDistributor_MV.set(new GT_MetaTileEntity_ItemDistributor(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_ItemDistributor_HV.set(new GT_MetaTileEntity_ItemDistributor(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_ItemDistributor_EV.set(new GT_MetaTileEntity_ItemDistributor(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_ItemDistributor_IV.set(new GT_MetaTileEntity_ItemDistributor(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_ItemDistributor_LuV.set(new GT_MetaTileEntity_ItemDistributor(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_ItemDistributor_ZPM.set(new GT_MetaTileEntity_ItemDistributor(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_ItemDistributor_UV.set(new GT_MetaTileEntity_ItemDistributor(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));
|
ItemList.Automation_ItemDistributor_MAX.set(new GT_MetaTileEntity_ItemDistributor(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) {
|
private static void makeWires(Materials aMaterial, int aStartID, long aLossInsulated, long aLoss, long aAmperage, long aVoltage, boolean aInsulatable, boolean aAutoInsulated) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue