diff --git a/client/gui/implementations/GuiMEMonitorable.java b/client/gui/implementations/GuiMEMonitorable.java index 3cf50b7b..3e7557df 100644 --- a/client/gui/implementations/GuiMEMonitorable.java +++ b/client/gui/implementations/GuiMEMonitorable.java @@ -5,6 +5,7 @@ import java.util.List; import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import org.lwjgl.input.Mouse; @@ -28,6 +29,8 @@ import appeng.client.me.InternalSlotME; import appeng.client.me.ItemRepo; import appeng.container.implementations.ContainerMEMonitorable; import appeng.container.slot.AppEngSlot; +import appeng.container.slot.SlotCraftingMatrix; +import appeng.container.slot.SlotFakeCraftingMatrix; import appeng.core.AEConfig; import appeng.core.AELog; import appeng.core.AppEng; @@ -46,6 +49,9 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi MEGuiTextField searchField; private static String memoryText = ""; + public static int CraftingGridOffsetX; + public static int CraftingGridOffsetY; + ItemRepo repo; GuiText myName; @@ -232,6 +238,9 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi setScrollBar(); } + CraftingGridOffsetX = Integer.MAX_VALUE; + CraftingGridOffsetY = Integer.MAX_VALUE; + for (Object s : inventorySlots.inventorySlots) { if ( s instanceof AppEngSlot ) @@ -239,8 +248,20 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi if ( ((AppEngSlot) s).xDisplayPosition < 197 ) repositionSlot( (AppEngSlot) s ); } + + if ( s instanceof SlotCraftingMatrix || s instanceof SlotFakeCraftingMatrix ) + { + Slot g = (Slot) s; + if ( g.xDisplayPosition > 0 && g.yDisplayPosition > 0 ) + { + CraftingGridOffsetX = Math.min( CraftingGridOffsetX, g.xDisplayPosition ); + CraftingGridOffsetY = Math.min( CraftingGridOffsetY, g.yDisplayPosition ); + } + } } + CraftingGridOffsetX -= 25; + CraftingGridOffsetY -= 6; } protected void repositionSlot(AppEngSlot s) diff --git a/core/WorldSettings.java b/core/WorldSettings.java index 9d541d6d..c6521a1d 100644 --- a/core/WorldSettings.java +++ b/core/WorldSettings.java @@ -5,11 +5,8 @@ import java.io.IOException; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; -import java.util.Map.Entry; import java.util.WeakHashMap; -import com.mojang.authlib.GameProfile; - import net.minecraft.entity.player.EntityPlayerMP; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.config.ConfigCategory; @@ -22,6 +19,8 @@ import appeng.me.GridStorage; import appeng.me.GridStorageSearch; import appeng.services.CompassService; +import com.mojang.authlib.GameProfile; + public class WorldSettings extends Configuration { @@ -240,12 +239,12 @@ public class WorldSettings extends Configuration public int getPlayerID(GameProfile profile) { ConfigCategory playerList = this.getCategory( "players" ); - + if ( playerList == null || profile == null || !profile.isComplete() ) return -1; - String uuid = profile.getId().toString(); - + String uuid = profile.getId().toString(); + Property prop = playerList.get( uuid ); if ( prop != null && prop.isIntValue() ) return prop.getInt(); diff --git a/integration/modules/NEI.java b/integration/modules/NEI.java index 2e32d799..2c3b79e1 100644 --- a/integration/modules/NEI.java +++ b/integration/modules/NEI.java @@ -20,6 +20,8 @@ import appeng.integration.modules.NEIHelpers.NEICraftingHandler; import appeng.integration.modules.NEIHelpers.NEIGrinderRecipeHandler; import appeng.integration.modules.NEIHelpers.NEIInscriberRecipeHandler; import appeng.integration.modules.NEIHelpers.NEIWorldCraftingHandler; +import appeng.integration.modules.NEIHelpers.TerminalCraftingSlotFinder; +import codechicken.nei.api.IStackPositioner; import codechicken.nei.guihook.GuiContainerManager; public class NEI extends BaseModule implements IIntegrationModule, INEI @@ -59,13 +61,13 @@ public class NEI extends BaseModule implements IIntegrationModule, INEI registerRecipeHandler( new NEIGrinderRecipeHandler() ); // crafting terminal... - Method registerGuiOverlay = API.getDeclaredMethod( "registerGuiOverlay", new Class[] { Class.class, String.class, int.class, int.class } ); + Method registerGuiOverlay = API.getDeclaredMethod( "registerGuiOverlay", new Class[] { Class.class, String.class, IStackPositioner.class } ); Class IOverlayHandler = Class.forName( "codechicken.nei.api.IOverlayHandler" ); Class DefaultOverlayHandler = NEICraftingHandler.class; Method registerGuiOverlayHandler = API.getDeclaredMethod( "registerGuiOverlayHandler", new Class[] { Class.class, IOverlayHandler, String.class } ); - registerGuiOverlay.invoke( API, GuiCraftingTerm.class, "crafting", 6, 75 ); - registerGuiOverlay.invoke( API, GuiPatternTerm.class, "crafting", 6, 75 ); + registerGuiOverlay.invoke( API, GuiCraftingTerm.class, "crafting", new TerminalCraftingSlotFinder() ); + registerGuiOverlay.invoke( API, GuiPatternTerm.class, "crafting", new TerminalCraftingSlotFinder() ); Constructor DefaultOverlayHandlerConstructor = DefaultOverlayHandler.getConstructor( new Class[] { int.class, int.class } ); registerGuiOverlayHandler.invoke( API, GuiCraftingTerm.class, DefaultOverlayHandlerConstructor.newInstance( 6, 75 ), "crafting" ); diff --git a/integration/modules/NEIHelpers/NEICraftingHandler.java b/integration/modules/NEIHelpers/NEICraftingHandler.java index 068c45a2..bef18379 100644 --- a/integration/modules/NEIHelpers/NEICraftingHandler.java +++ b/integration/modules/NEIHelpers/NEICraftingHandler.java @@ -26,7 +26,7 @@ public class NEICraftingHandler implements IOverlayHandler int offsetx; int offsety; - // @override + @Override public void overlayRecipe(GuiContainer gui, IRecipeHandler recipe, int recipeIndex, boolean shift) { try @@ -42,7 +42,6 @@ public class NEICraftingHandler implements IOverlayHandler } } - // @override public void overlayRecipe(GuiContainer gui, List ingredients, boolean shift) { try diff --git a/integration/modules/NEIHelpers/TerminalCraftingSlotFinder.java b/integration/modules/NEIHelpers/TerminalCraftingSlotFinder.java new file mode 100644 index 00000000..4a7747b7 --- /dev/null +++ b/integration/modules/NEIHelpers/TerminalCraftingSlotFinder.java @@ -0,0 +1,24 @@ +package appeng.integration.modules.NEIHelpers; + +import java.util.ArrayList; + +import appeng.client.gui.implementations.GuiMEMonitorable; +import codechicken.nei.PositionedStack; +import codechicken.nei.api.IStackPositioner; + +public class TerminalCraftingSlotFinder implements IStackPositioner +{ + + @Override + public ArrayList positionStacks(ArrayList a) + { + for (PositionedStack ps : a) + if ( ps != null ) + { + ps.relx += GuiMEMonitorable.CraftingGridOffsetX; + ps.rely += GuiMEMonitorable.CraftingGridOffsetY; + } + return a; + } + +}