diff options
19 files changed, 532 insertions, 10 deletions
diff --git a/src/main/java/gregtech/api/enums/ItemList.java b/src/main/java/gregtech/api/enums/ItemList.java index 59641d16d7..483d5c3f99 100644 --- a/src/main/java/gregtech/api/enums/ItemList.java +++ b/src/main/java/gregtech/api/enums/ItemList.java @@ -1898,7 +1898,11 @@ public enum ItemList implements IItemContainer { Circuit_Parts_InductorASMD, Circuit_Parts_InductorXSMD, - VOLUMETRIC_FLASK; + VOLUMETRIC_FLASK, + + Hatch_Input_Bus_ME, + Hatch_CraftingInput_Bus_ME + ; public static final ItemList[] DYE_ONLY_ITEMS = { diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java index 08beb1a25d..54727ea269 100644 --- a/src/main/java/gregtech/api/enums/Textures.java +++ b/src/main/java/gregtech/api/enums/Textures.java @@ -1262,7 +1262,14 @@ public class Textures { LARGETURBINE_ADVGAS_EMPTY6, LARGETURBINE_ADVGAS_EMPTY7, LARGETURBINE_ADVGAS_EMPTY8, - LARGETURBINE_ADVGAS_EMPTY9; + LARGETURBINE_ADVGAS_EMPTY9, + + OVERLAY_ME_HATCH_ACTIVE, + OVERLAY_ME_INPUT_HATCH, + OVERLAY_ME_INPUT_HATCH_ACTIVE, + OVERLAY_ME_CRAFTING_HATCH, + OVERLAY_ME_CRAFTING_HATCH_ACTIVE + ; /** * Icon for Fresh CFoam diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java index 6d99a24347..82dbc3afd9 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java @@ -179,4 +179,6 @@ public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTan } //To change to other page -> use the setter method -> updateTexture + + public int getCircuitSlot() { return -1; } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java index 039c35c268..fb5eec7880 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java @@ -1,5 +1,6 @@ package gregtech.api.metatileentity.implementations; +import appeng.util.Platform; import gregtech.GT_Mod; import gregtech.api.gui.*; import gregtech.api.interfaces.ITexture; @@ -34,6 +35,10 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { this(id, name, nameRegional, tier, getSlots(tier)); } + protected GT_MetaTileEntity_Hatch_InputBus(int id, String name, String nameRegional, int tier, int slots, String[] description) { + super(id, name, nameRegional, tier, slots, description); + } + public GT_MetaTileEntity_Hatch_InputBus(int id, String name, String nameRegional, int tier, int slots) { super(id, name, nameRegional, tier, slots, ArrayExt.of( "Item Input for Multiblocks", @@ -248,4 +253,10 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { return i == aIndex; return mInventory[aIndex] == null; } + + public void startRecipeProcessing() { + } + + public void endRecipeProcessing() { + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index a31be046b3..e29499b0b1 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -350,6 +350,14 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } } + protected boolean checkRecipe() + { + startRecipeProcessing(); + boolean result = checkRecipe(mInventory[1]); + endRecipeProcessing(); + return result; + } + protected void runMachine(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (mMaxProgresstime > 0 && doRandomMaintenanceDamage()) { if (onRunningTick(mInventory[1])) { @@ -375,7 +383,9 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { mProgresstime = 0; mMaxProgresstime = 0; mEfficiencyIncrease = 0; - if (aBaseMetaTileEntity.isAllowedToWork()) checkRecipe(mInventory[1]); + if (aBaseMetaTileEntity.isAllowedToWork()) { + checkRecipe(); + } if (mOutputFluids != null && mOutputFluids.length > 0) { if (mOutputFluids.length > 1) { try { @@ -390,7 +400,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified()) { if (aBaseMetaTileEntity.isAllowedToWork()) { - if(checkRecipe(mInventory[1])) { + if (checkRecipe()) { markDirty(); } } @@ -906,6 +916,18 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); } + protected void startRecipeProcessing() + { + for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) + if (isValidMetaTileEntity(tHatch)) tHatch.startRecipeProcessing(); + } + + protected void endRecipeProcessing() + { + for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) + if (isValidMetaTileEntity(tHatch)) tHatch.endRecipeProcessing(); + } + protected static <T extends GT_MetaTileEntity_Hatch> T identifyHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex, Class<T> clazz) { if (aTileEntity == null) return null; IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); diff --git a/src/main/java/gregtech/api/net/GT_Packet_SetConfigurationCircuit_Bus.java b/src/main/java/gregtech/api/net/GT_Packet_SetConfigurationCircuit_Bus.java new file mode 100644 index 0000000000..06344f1656 --- /dev/null +++ b/src/main/java/gregtech/api/net/GT_Packet_SetConfigurationCircuit_Bus.java @@ -0,0 +1,61 @@ +package gregtech.api.net; + +import com.google.common.io.ByteArrayDataInput; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import net.minecraftforge.common.DimensionManager; + +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.ISerializableObject; +import gregtech.common.gui.GT_Container_InputBus_ME; + +public class GT_Packet_SetConfigurationCircuit_Bus extends GT_Packet_SetConfigurationCircuit { + public GT_Packet_SetConfigurationCircuit_Bus() { + super(); + } + + public GT_Packet_SetConfigurationCircuit_Bus(IGregTechTileEntity tile, ItemStack circuit) { + super(tile, circuit); + } + + public GT_Packet_SetConfigurationCircuit_Bus(int x, short y, int z, ItemStack circuit) { + super(x, y, z, circuit); + } + + @Override + public byte getPacketID() { + return 18; + } + @Override + public void process(IBlockAccess aWorld) { + World world = DimensionManager.getWorld(dimId); + if (world == null) return; + TileEntity tile = world.getTileEntity(mX, mY, mZ); + if (!(tile instanceof IGregTechTileEntity) || ((IGregTechTileEntity) tile).isDead()) + return; + IMetaTileEntity mte = ((IGregTechTileEntity) tile).getMetaTileEntity(); + if (!(mte instanceof GT_MetaTileEntity_Hatch)) return; + GT_MetaTileEntity_Hatch hatch = (GT_MetaTileEntity_Hatch) mte; + GregTech_API.getConfigurationCircuitList(hatch.mTier).stream() + .filter(stack -> GT_Utility.areStacksEqual(stack, circuit)) + .findFirst() + .ifPresent(stack -> ((IGregTechTileEntity) tile).setInventorySlotContents(hatch.getCircuitSlot(), stack)); + } + + @Override + public GT_Packet_New decode(ByteArrayDataInput aData) { + return new GT_Packet_SetConfigurationCircuit_Bus( + aData.readInt(), + aData.readShort(), + aData.readInt(), + ISerializableObject.readItemStackFromGreggyByteBuf(aData)); + } +} diff --git a/src/main/java/gregtech/common/GT_Network.java b/src/main/java/gregtech/common/GT_Network.java index 8db38d86f7..3dfc7b8f84 100644 --- a/src/main/java/gregtech/common/GT_Network.java +++ b/src/main/java/gregtech/common/GT_Network.java @@ -53,7 +53,8 @@ public class GT_Network extends MessageToMessageCodec<FMLProxyPacket, GT_Packet> new GT_Packet_SetLockedFluid(), new GT_Packet_GtTileEntityGuiRequest(), new GT_Packet_SendCoverData(), - new GT_Packet_RequestCoverData() + new GT_Packet_RequestCoverData(), + new GT_Packet_SetConfigurationCircuit_Bus() ); } diff --git a/src/main/java/gregtech/common/gui/GT_Container_InputBus_ME.java b/src/main/java/gregtech/common/gui/GT_Container_InputBus_ME.java new file mode 100644 index 0000000000..ae018657c4 --- /dev/null +++ b/src/main/java/gregtech/common/gui/GT_Container_InputBus_ME.java @@ -0,0 +1,92 @@ +package gregtech.common.gui; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +import gregtech.api.GregTech_API; +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.gui.GT_Slot_Holo; +import gregtech.api.gui.GT_Slot_Render; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Utility; + +public class GT_Container_InputBus_ME extends GT_ContainerMetaTile_Machine { + private static final int LEFT_OFFSET = 8; + private static final int TOP_OFFSET = 10; + private static final int SLOT_SIZE = 18; + public static final int CIRCUIT_SLOT = 32; + private Runnable circuitSlotClickCallback; + GT_Slot_Render slotCircuit; + public GT_Container_InputBus_ME(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + for (int z = 0; z < 2; ++z) + for (int y = 0; y < 4; ++y) + for (int x = 0; x < 4; ++x) + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, x + y * 4 + z * 16, + LEFT_OFFSET + x * SLOT_SIZE + z * 90, TOP_OFFSET + y * SLOT_SIZE, false, true, 1)); + addSlotToContainer(slotCircuit = new GT_Slot_Render(mTileEntity, CIRCUIT_SLOT, 153, 63)); + } + + @Override + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + if (aSlotIndex >= 0 && aSlotIndex < 16) { + Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); + if (tSlot != null) { + if (this.mTileEntity.getMetaTileEntity() == null) + return null; + ItemStack tStack = aPlayer.inventory.getItemStack(); + if (tStack == null) { + tSlot.putStack(null); + } + else { + tSlot.putStack(GT_Utility.copyAmount(1L, new Object[] {tStack})); + } + return null; + } + } + + else if (aSlotIndex == CIRCUIT_SLOT && aMouseclick < 2) { + ItemStack newCircuit; + if (aShifthold == 1) { + if (aMouseclick == 0) { + if (circuitSlotClickCallback != null) + circuitSlotClickCallback.run(); + return null; + } else { + // clear + newCircuit = null; + } + } else { + ItemStack cursorStack = aPlayer.inventory.getItemStack(); + List<ItemStack> tCircuits = GregTech_API.getConfigurationCircuitList(1); + int index = GT_Utility.findMatchingStackInList(tCircuits, cursorStack); + if (index < 0) { + int curIndex = GT_Utility.findMatchingStackInList(tCircuits, mTileEntity.getStackInSlot(CIRCUIT_SLOT)) + 1; + if (aMouseclick == 0) { + curIndex += 1; + } else { + curIndex -= 1; + } + curIndex = Math.floorMod(curIndex, tCircuits.size() + 1) - 1; + newCircuit = curIndex < 0 ? null : tCircuits.get(curIndex); + } else { + // set to whatever it is + newCircuit = tCircuits.get(index); + } + } + mTileEntity.setInventorySlotContents(CIRCUIT_SLOT, newCircuit); + return newCircuit; + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + public void setCircuitSlotClickCallback(Runnable circuitSlotClickCallback) { + this.circuitSlotClickCallback = circuitSlotClickCallback; + } +} diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_InputBus_ME.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_InputBus_ME.java new file mode 100644 index 0000000000..5aefb98e55 --- /dev/null +++ b/src/main/java/gregtech/common/gui/GT_GUIContainer_InputBus_ME.java @@ -0,0 +1,53 @@ +package gregtech.common.gui; + +import java.util.List; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.gui.GT_GUIDialogSelectItem; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.net.GT_Packet_SetConfigurationCircuit_Bus; +import gregtech.api.util.GT_Utility; + +public class GT_GUIContainer_InputBus_ME extends GT_GUIContainerMetaTile_Machine { + + public GT_GUIContainer_InputBus_ME(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(new GT_Container_InputBus_ME(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/InputBusME.png"); + getContainer().setCircuitSlotClickCallback(this::openSelectCircuitDialog); + } + + private GT_Container_InputBus_ME getContainer() { + return (GT_Container_InputBus_ME) mContainer; + } + + @Override + protected void drawGuiContainerBackgroundLayer(float parTicks, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(parTicks, mouseX, mouseY); + int x = (this.width - this.xSize) / 2; + int y = (this.height - this.ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } + + private void onCircuitSelected(ItemStack selected) { + GT_Values.NW.sendToServer(new GT_Packet_SetConfigurationCircuit_Bus(mContainer.mTileEntity, selected)); + // we will not do any validation on client side + // it doesn't get to actually decide what inventory contains anyway + mContainer.mTileEntity.setInventorySlotContents(GT_Container_InputBus_ME.CIRCUIT_SLOT, selected); + } + private void openSelectCircuitDialog() { + List<ItemStack> circuits = GregTech_API.getConfigurationCircuitList(1); + mc.displayGuiScreen(new GT_GUIDialogSelectItem( + StatCollector.translateToLocal("GT5U.machines.select_circuit"), + mContainer.mTileEntity.getMetaTileEntity().getStackForm(0), + this, + this::onCircuitSelected, + circuits, + GT_Utility.findMatchingStackInList(circuits, + mContainer.mTileEntity.getStackInSlot(GT_Container_InputBus_ME.CIRCUIT_SLOT)))); + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java new file mode 100644 index 0000000000..bb3655ddfe --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java @@ -0,0 +1,261 @@ +package gregtech.common.tileentities.machines; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import appeng.api.config.Actionable; +import appeng.api.networking.GridFlags; +import appeng.api.networking.security.BaseActionSource; +import appeng.api.networking.security.IActionHost; +import appeng.api.networking.security.MachineSource; +import appeng.api.storage.IMEMonitor; +import appeng.api.storage.data.IAEItemStack; +import appeng.api.util.AECableType; +import appeng.me.GridAccessException; +import appeng.me.helpers.AENetworkProxy; +import appeng.me.helpers.IGridProxyable; +import appeng.util.Platform; +import appeng.util.item.AEItemStack; +import cpw.mods.fml.common.Optional; +import gregtech.api.GregTech_API; +import gregtech.api.enums.ItemList; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.render.TextureFactory; +import gregtech.common.gui.GT_Container_InputBus_ME; +import gregtech.common.gui.GT_GUIContainer_InputBus_ME; +import gregtech.api.util.GT_Utility; + +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_INPUT_HATCH; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_INPUT_HATCH_ACTIVE; + +public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch_InputBus { + private static final int SLOT_COUNT = 16; + private BaseActionSource requestSource = null; + private AENetworkProxy gridProxy = null; + private ItemStack[] shadowInventory = new ItemStack[SLOT_COUNT]; + private int[] savedStackSizes = new int[SLOT_COUNT]; + private boolean processingRecipe = false; + public GT_MetaTileEntity_Hatch_InputBus_ME(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 1, SLOT_COUNT * 2 + 1, new String[] { + "Advanced item input for Multiblocks", + "Retrieves directly from ME", + "Keeps 16 item types in stock" + }); + disableSort = true; + } + + public GT_MetaTileEntity_Hatch_InputBus_ME(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, SLOT_COUNT * 2 + 1, aDescription, aTextures); + disableSort = true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_InputBus_ME(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_ME_INPUT_HATCH_ACTIVE)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_ME_INPUT_HATCH)}; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_InputBus_ME(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_InputBus_ME(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + getProxy().onReady(); + } + + @Override + @Optional.Method(modid = "appliedenergistics2") + public AECableType getCableConnectionType(ForgeDirection forgeDirection) { + return isOutputFacing((byte) forgeDirection.ordinal()) ? AECableType.SMART : AECableType.NONE; + } + + + @Override + @Optional.Method(modid = "appliedenergistics2") + public AENetworkProxy getProxy() { + if (gridProxy == null) { + if (getBaseMetaTileEntity() instanceof IGridProxyable) { + gridProxy = new AENetworkProxy((IGridProxyable) getBaseMetaTileEntity(), "proxy", ItemList.Hatch_Output_Bus_ME.get(1), true); + gridProxy.setFlags(GridFlags.REQUIRE_CHANNEL); + if (getBaseMetaTileEntity().getWorld() != null) + gridProxy.setOwner(getBaseMetaTileEntity().getWorld().getPlayerEntityByName(getBaseMetaTileEntity().getOwnerName())); + } + } + return this.gridProxy; + } + + @Override + @Optional.Method(modid = "appliedenergistics2") + public void gridChanged() { + if (getBaseMetaTileEntity() != null && getBaseMetaTileEntity().getTimer() > 1) { + gridProxy = null; + getProxy(); + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) + { + super.saveNBTData(aNBT); + if (GregTech_API.mAE2) { + gridProxy.writeToNBT(aNBT); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (GregTech_API.mAE2) { + getProxy().readFromNBT(aNBT); + } + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[]{ + "The bus is " + ((getProxy() != null && getProxy().isActive()) ? + EnumChatFormatting.GREEN + "online" : EnumChatFormatting.RED + "offline") + + EnumChatFormatting.RESET}; + } + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + } + + @Override + public void updateSlots() { + } + + @Override + public int getCircuitSlot() { return SLOT_COUNT * 2; } + + @Override + public ItemStack getStackInSlot(int aIndex) { + if (!processingRecipe) + return super.getStackInSlot(aIndex); + if (aIndex < 0 && aIndex > mInventory.length) + return null; + if (aIndex >= SLOT_COUNT && aIndex < SLOT_COUNT * 2) + //Display slots + return null; + if (aIndex == getCircuitSlot()) + return mInventory[aIndex]; + if (GregTech_API.mAE2 && mInventory[aIndex] != null) { + AENetworkProxy proxy = getProxy(); + if (proxy == null) { + return null; + } + try { + IMEMonitor<IAEItemStack> sg = proxy.getStorage().getItemInventory(); + IAEItemStack request = AEItemStack.create(mInventory[aIndex]); + request.setStackSize(Integer.MAX_VALUE); + IAEItemStack result = sg.extractItems(request, Actionable.SIMULATE, getRequestSource()); + if (result != null) { + this.shadowInventory[aIndex] = result.getItemStack(); + this.savedStackSizes[aIndex] = this.shadowInventory[aIndex].stackSize; + //Show that the request was successful + this.setInventorySlotContents(aIndex + SLOT_COUNT, GT_Utility.copyAmount( + this.shadowInventory[aIndex].stackSize > 64 ? 64 : this.shadowInventory[aIndex].stackSize, + new Object[] {result.getItemStack()})); + return this.shadowInventory[aIndex]; + } else { + //Request failed + this.setInventorySlotContents(aIndex + SLOT_COUNT, null); + return null; + } + } + catch( final GridAccessException ignored ) + { + } + return null; + } else { + //AE available but no items requested + this.setInventorySlotContents(aIndex + SLOT_COUNT, null); + } + return mInventory[aIndex]; + } + + @Optional.Method(modid = "appliedenergistics2") + private BaseActionSource getRequestSource() { + if (requestSource == null) + requestSource = new MachineSource((IActionHost)getBaseMetaTileEntity()); + return requestSource; + } + + @Override + public void onExplosion() { + for (int i = 0; i < SLOT_COUNT; i++) { + mInventory[i] = null; + } + } + + public void startRecipeProcessing() { + processingRecipe = true; + } + + public void endRecipeProcessing() { + if (GregTech_API.mAE2) { + for (int i = 0; i < SLOT_COUNT; ++i) { + if (savedStackSizes[i] != 0) { + if (shadowInventory[i] == null || shadowInventory[i].stackSize < savedStackSizes[i]) { + AENetworkProxy proxy = getProxy(); + try { + IMEMonitor<IAEItemStack> sg = proxy.getStorage().getItemInventory(); + IAEItemStack request = AEItemStack.create(mInventory[i]); + request.setStackSize(savedStackSizes[i] - shadowInventory[i].stackSize); + sg.extractItems(request, Actionable.MODULATE, getRequestSource()); + } + catch (final GridAccessException ignored) { + } + } + savedStackSizes[i] = 0; + shadowInventory[i] = null; + } + } + } + processingRecipe = false; + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java index d149f19565..f9b902e27a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java +++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java @@ -38,6 +38,7 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_HATCH; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_HATCH_ACTIVE; public class GT_MetaTileEntity_Hatch_OutputBus_ME extends GT_MetaTileEntity_Hatch_OutputBus { private BaseActionSource requestSource = null; @@ -67,7 +68,7 @@ public class GT_MetaTileEntity_Hatch_OutputBus_ME extends GT_MetaTileEntity_Hatc @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_ME_HATCH)}; + return new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_ME_HATCH_ACTIVE)}; } @Override @@ -146,6 +147,10 @@ public class GT_MetaTileEntity_Hatch_OutputBus_ME extends GT_MetaTileEntity_Hatc @Override @Optional.Method(modid = "appliedenergistics2") public void gridChanged() { + if (getBaseMetaTileEntity() != null && getBaseMetaTileEntity().getTimer() > 1) { + gridProxy = null; + getProxy(); + } } @Optional.Method(modid = "appliedenergistics2") diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java index 34a9b81012..30f8ff8746 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java @@ -358,7 +358,7 @@ public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity mEfficiency = 0; if (mRunningOnLoad && checkMachine(aBaseMetaTileEntity, mInventory[1])) { this.mEUStore = aBaseMetaTileEntity.getStoredEU(); - checkRecipe(mInventory[1]); + checkRecipe(); } if (mUpdated) { mUpdate = 50; @@ -403,14 +403,14 @@ public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity } this.mEUStore = aBaseMetaTileEntity.getStoredEU(); if (aBaseMetaTileEntity.isAllowedToWork()) - checkRecipe(mInventory[1]); + checkRecipe(); } } else { if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified()) { turnCasingActive(mMaxProgresstime > 0); if (aBaseMetaTileEntity.isAllowedToWork()) { this.mEUStore = aBaseMetaTileEntity.getStoredEU(); - if (checkRecipe(mInventory[1])) { + if (checkRecipe()) { if (this.mEUStore < this.mLastRecipe.mSpecialValue - this.mEUt) { criticalStopMachine(); } 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 9167a43105..81b5f9b47e 100644 --- a/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java +++ b/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java @@ -453,8 +453,11 @@ public class GT_Loader_MetaTileEntities implements Runnable {//TODO CHECK CIRCUI ItemList.Long_Distance_Pipeline_Fluid.set(new GT_MetaTileEntity_LongDistancePipelineFluid(2700, "long.distance.pipeline.fluid", "Long Distance Fluid Pipeline", 1).getStackForm(1L)); ItemList.Long_Distance_Pipeline_Item.set(new GT_MetaTileEntity_LongDistancePipelineItem(2701, "long.distance.pipeline.item", "Long Distance Item Pipeline", 1).getStackForm(1L)); - if (GregTech_API.mAE2) + if (GregTech_API.mAE2) { ItemList.Hatch_Output_Bus_ME.set(new GT_MetaTileEntity_Hatch_OutputBus_ME(2710, "hatch.output_bus.me", "Output Bus (ME)").getStackForm(1L)); + ItemList.Hatch_Input_Bus_ME.set(new GT_MetaTileEntity_Hatch_InputBus_ME(2711, "hatch.input_bus.me", "Stocking Input Bus (ME)").getStackForm(1L)); + //ItemList.Hatch_CraftingInput_Bus_ME.set(new GT_MetaTileEntity_Hatch_CraftingInputBus_ME(2712, "hatch.crafting_input_bus.me", "Crafting Input Bus (ME)").getStackForm(1L)); + } ItemList.Hatch_Input_Bus_ULV.set(new GT_MetaTileEntity_Hatch_InputBus(70, "hatch.input_bus.tier.00", "Input Bus (ULV)", 0).getStackForm(1L)); ItemList.Hatch_Input_Bus_LV.set(new GT_MetaTileEntity_Hatch_InputBus(71, "hatch.input_bus.tier.01", "Input Bus (LV)", 1).getStackForm(1L)); diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_CRAFTING_HATCH.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_CRAFTING_HATCH.png Binary files differnew file mode 100644 index 0000000000..ba901a1a25 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_CRAFTING_HATCH.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_CRAFTING_HATCH_ACTIVE.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_CRAFTING_HATCH_ACTIVE.png Binary files differnew file mode 100644 index 0000000000..ba901a1a25 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_CRAFTING_HATCH_ACTIVE.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_HATCH_ACTIVE.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_HATCH_ACTIVE.png Binary files differnew file mode 100644 index 0000000000..3a53c64792 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_HATCH_ACTIVE.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_INPUT_HATCH.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_INPUT_HATCH.png Binary files differnew file mode 100644 index 0000000000..ba901a1a25 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_INPUT_HATCH.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_INPUT_HATCH_ACTIVE.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_INPUT_HATCH_ACTIVE.png Binary files differnew file mode 100644 index 0000000000..ba901a1a25 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_INPUT_HATCH_ACTIVE.png diff --git a/src/main/resources/assets/gregtech/textures/gui/InputBusME.png b/src/main/resources/assets/gregtech/textures/gui/InputBusME.png Binary files differnew file mode 100644 index 0000000000..6198b5b607 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/gui/InputBusME.png |