2014-04-04 07:17:20 +02:00
|
|
|
package appeng.integration.modules;
|
2014-02-15 07:40:02 +01:00
|
|
|
|
2014-05-01 06:01:22 +02:00
|
|
|
import java.lang.reflect.Constructor;
|
|
|
|
import java.lang.reflect.InvocationTargetException;
|
2014-02-15 07:40:02 +01:00
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
2014-05-01 06:01:22 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.gui.FontRenderer;
|
|
|
|
import net.minecraft.client.renderer.entity.RenderItem;
|
|
|
|
import net.minecraft.inventory.Slot;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import appeng.client.gui.implementations.GuiCraftingTerm;
|
2014-07-06 08:52:29 +02:00
|
|
|
import appeng.client.gui.implementations.GuiPatternTerm;
|
2014-05-19 04:36:08 +02:00
|
|
|
import appeng.integration.BaseModule;
|
2014-02-15 07:40:02 +01:00
|
|
|
import appeng.integration.IIntegrationModule;
|
2014-05-01 06:01:22 +02:00
|
|
|
import appeng.integration.abstraction.INEI;
|
2014-05-11 18:27:32 +02:00
|
|
|
import appeng.integration.modules.NEIHelpers.NEIAEShapedRecipeHandler;
|
|
|
|
import appeng.integration.modules.NEIHelpers.NEIAEShapelessRecipeHandler;
|
|
|
|
import appeng.integration.modules.NEIHelpers.NEICraftingHandler;
|
|
|
|
import appeng.integration.modules.NEIHelpers.NEIGrinderRecipeHandler;
|
|
|
|
import appeng.integration.modules.NEIHelpers.NEIInscriberRecipeHandler;
|
|
|
|
import appeng.integration.modules.NEIHelpers.NEIWorldCraftingHandler;
|
2014-07-10 05:18:50 +02:00
|
|
|
import appeng.integration.modules.NEIHelpers.TerminalCraftingSlotFinder;
|
|
|
|
import codechicken.nei.api.IStackPositioner;
|
2014-05-01 06:01:22 +02:00
|
|
|
import codechicken.nei.guihook.GuiContainerManager;
|
2014-02-15 07:40:02 +01:00
|
|
|
|
2014-05-19 04:36:08 +02:00
|
|
|
public class NEI extends BaseModule implements IIntegrationModule, INEI
|
2014-02-15 07:40:02 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
public static NEI instance;
|
|
|
|
|
2014-04-06 10:20:30 +02:00
|
|
|
Class API;
|
|
|
|
|
2014-05-01 06:01:22 +02:00
|
|
|
// recipe handler...
|
|
|
|
Method registerRecipeHandler;
|
|
|
|
Method registerUsageHandler;
|
|
|
|
|
2014-04-06 10:20:30 +02:00
|
|
|
public NEI() throws ClassNotFoundException {
|
2014-05-19 04:36:08 +02:00
|
|
|
TestClass( GuiContainerManager.class );
|
|
|
|
TestClass( codechicken.nei.recipe.ICraftingHandler.class );
|
|
|
|
TestClass( codechicken.nei.recipe.IUsageHandler.class );
|
2014-04-06 10:20:30 +02:00
|
|
|
API = Class.forName( "codechicken.nei.api.API" );
|
|
|
|
}
|
|
|
|
|
2014-05-01 06:01:22 +02:00
|
|
|
public void registerRecipeHandler(Object o) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
|
|
|
|
{
|
|
|
|
registerRecipeHandler.invoke( API, o );
|
|
|
|
registerUsageHandler.invoke( API, o );
|
|
|
|
}
|
|
|
|
|
2014-02-15 07:40:02 +01:00
|
|
|
@Override
|
|
|
|
public void Init() throws Throwable
|
|
|
|
{
|
2014-05-01 06:01:22 +02:00
|
|
|
registerRecipeHandler = API.getDeclaredMethod( "registerRecipeHandler", new Class[] { codechicken.nei.recipe.ICraftingHandler.class } );
|
|
|
|
registerUsageHandler = API.getDeclaredMethod( "registerUsageHandler", new Class[] { codechicken.nei.recipe.IUsageHandler.class } );
|
|
|
|
|
|
|
|
registerRecipeHandler( new NEIAEShapedRecipeHandler() );
|
|
|
|
registerRecipeHandler( new NEIAEShapelessRecipeHandler() );
|
|
|
|
registerRecipeHandler( new NEIInscriberRecipeHandler() );
|
2014-05-01 07:32:58 +02:00
|
|
|
registerRecipeHandler( new NEIWorldCraftingHandler() );
|
|
|
|
registerRecipeHandler( new NEIGrinderRecipeHandler() );
|
2014-05-01 06:01:22 +02:00
|
|
|
|
|
|
|
// crafting terminal...
|
2014-07-10 05:18:50 +02:00
|
|
|
Method registerGuiOverlay = API.getDeclaredMethod( "registerGuiOverlay", new Class[] { Class.class, String.class, IStackPositioner.class } );
|
2014-05-01 06:01:22 +02:00
|
|
|
Class IOverlayHandler = Class.forName( "codechicken.nei.api.IOverlayHandler" );
|
|
|
|
Class DefaultOverlayHandler = NEICraftingHandler.class;
|
|
|
|
|
|
|
|
Method registerGuiOverlayHandler = API.getDeclaredMethod( "registerGuiOverlayHandler", new Class[] { Class.class, IOverlayHandler, String.class } );
|
2014-07-10 05:18:50 +02:00
|
|
|
registerGuiOverlay.invoke( API, GuiCraftingTerm.class, "crafting", new TerminalCraftingSlotFinder() );
|
|
|
|
registerGuiOverlay.invoke( API, GuiPatternTerm.class, "crafting", new TerminalCraftingSlotFinder() );
|
2014-05-01 06:01:22 +02:00
|
|
|
|
|
|
|
Constructor DefaultOverlayHandlerConstructor = DefaultOverlayHandler.getConstructor( new Class[] { int.class, int.class } );
|
|
|
|
registerGuiOverlayHandler.invoke( API, GuiCraftingTerm.class, DefaultOverlayHandlerConstructor.newInstance( 6, 75 ), "crafting" );
|
2014-07-06 08:52:29 +02:00
|
|
|
registerGuiOverlayHandler.invoke( API, GuiPatternTerm.class, DefaultOverlayHandlerConstructor.newInstance( 6, 75 ), "crafting" );
|
2014-02-15 07:40:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void PostInit() throws Throwable
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-01 06:01:22 +02:00
|
|
|
@Override
|
|
|
|
public void drawSlot(Slot s)
|
|
|
|
{
|
|
|
|
if ( s == null )
|
|
|
|
return;
|
|
|
|
|
|
|
|
ItemStack stack = s.getStack();
|
|
|
|
|
|
|
|
if ( stack == null )
|
|
|
|
return;
|
|
|
|
|
|
|
|
Minecraft mc = Minecraft.getMinecraft();
|
|
|
|
FontRenderer fontRenderer = mc.fontRenderer;
|
|
|
|
int x = s.xDisplayPosition;
|
|
|
|
int y = s.yDisplayPosition;
|
|
|
|
|
|
|
|
GuiContainerManager.drawItems.renderItemAndEffectIntoGUI( fontRenderer, mc.getTextureManager(), stack, x, y );
|
|
|
|
GuiContainerManager.drawItems.renderItemOverlayIntoGUI( fontRenderer, mc.getTextureManager(), stack, x, y, "" + stack.stackSize );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public RenderItem setItemRender(RenderItem aeri2)
|
|
|
|
{
|
2014-05-19 04:36:08 +02:00
|
|
|
try
|
|
|
|
{
|
|
|
|
RenderItem ri = GuiContainerManager.drawItems;
|
|
|
|
GuiContainerManager.drawItems = aeri2;
|
|
|
|
return ri;
|
|
|
|
}
|
|
|
|
catch (Throwable t)
|
|
|
|
{
|
|
|
|
throw new RuntimeException( "Invalid version of NEI, please update", t );
|
|
|
|
}
|
2014-05-01 06:01:22 +02:00
|
|
|
}
|
|
|
|
|
2014-02-15 07:40:02 +01:00
|
|
|
}
|