Fixed NEI Ghost Overlays.
This commit is contained in:
parent
ca6cdf50c1
commit
d2e332eedb
5 changed files with 56 additions and 11 deletions
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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" );
|
||||
|
|
|
@ -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<PositionedStack> ingredients, boolean shift)
|
||||
{
|
||||
try
|
||||
|
|
|
@ -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<PositionedStack> positionStacks(ArrayList<PositionedStack> a)
|
||||
{
|
||||
for (PositionedStack ps : a)
|
||||
if ( ps != null )
|
||||
{
|
||||
ps.relx += GuiMEMonitorable.CraftingGridOffsetX;
|
||||
ps.rely += GuiMEMonitorable.CraftingGridOffsetY;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue