From 0953c48ad5e7c8c60f878f53adca35b4a285b5b2 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sun, 13 Jul 2014 01:45:16 -0500 Subject: [PATCH] Auto Starting a job that has no cpu now display the gui instead of just exiting like it started. --- .../ContainerCraftConfirm.java | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/container/implementations/ContainerCraftConfirm.java b/container/implementations/ContainerCraftConfirm.java index d0e88042..1026f3b0 100644 --- a/container/implementations/ContainerCraftConfirm.java +++ b/container/implementations/ContainerCraftConfirm.java @@ -9,6 +9,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; import appeng.api.AEApi; @@ -18,6 +19,7 @@ import appeng.api.networking.IGrid; import appeng.api.networking.crafting.ICraftingCPU; import appeng.api.networking.crafting.ICraftingGrid; import appeng.api.networking.crafting.ICraftingJob; +import appeng.api.networking.crafting.ICraftingLink; import appeng.api.networking.security.BaseActionSource; import appeng.api.networking.security.IActionHost; import appeng.api.networking.security.PlayerSource; @@ -29,8 +31,13 @@ import appeng.api.storage.data.IItemList; import appeng.container.AEBaseContainer; import appeng.container.guisync.GuiSync; import appeng.core.AELog; +import appeng.core.sync.GuiBridge; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketMEInventoryUpdate; +import appeng.helpers.WirelessTerminalGuiObject; +import appeng.parts.reporting.PartCraftingTerminal; +import appeng.parts.reporting.PartPatternTerminal; +import appeng.parts.reporting.PartTerminal; import appeng.util.ItemSorters; import appeng.util.Platform; @@ -287,11 +294,31 @@ public class ContainerCraftConfirm extends AEBaseContainer public void startJob() { + GuiBridge OriginalGui = null; + + IActionHost ah = getActionHost(); + if ( ah instanceof WirelessTerminalGuiObject ) + OriginalGui = GuiBridge.GUI_WIRELESS_TERM; + + if ( ah instanceof PartTerminal ) + OriginalGui = GuiBridge.GUI_ME; + + if ( ah instanceof PartCraftingTerminal ) + OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL; + + if ( ah instanceof PartPatternTerminal ) + OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL; + if ( result != null && simulation == false ) { ICraftingGrid cc = getGrid().getCache( ICraftingGrid.class ); - cc.submitJob( result, null, selectedCpu == -1 ? null : cpus.get( selectedCpu ).cpu, getActionSrc() ); - this.isContainerValid = false; + ICraftingLink g = cc.submitJob( result, null, selectedCpu == -1 ? null : cpus.get( selectedCpu ).cpu, getActionSrc() ); + autoStart = false; + if ( g != null && OriginalGui != null && openContext != null ) + { + TileEntity te = openContext.w.getTileEntity( openContext.x, openContext.y, openContext.z ); + Platform.openGUI( invPlayer.player, te, openContext.side, OriginalGui ); + } } }