Fixed issue with NEI and font size.
Added Crafting Terminal Integration for NEI. Added Inscriber Recipe Plugin for NEI.
This commit is contained in:
@@ -1,45 +1,64 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
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;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.integration.abstraction.INEI;
|
||||
import appeng.integration.modules.helpers.NEIAEShapedRecipeHandler;
|
||||
import appeng.integration.modules.helpers.NEIAEShapelessRecipeHandler;
|
||||
import appeng.integration.modules.helpers.NEICraftingHandler;
|
||||
import appeng.integration.modules.helpers.NEIInscriberRecipeHandler;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
|
||||
public class NEI implements IIntegrationModule
|
||||
public class NEI implements IIntegrationModule, INEI
|
||||
{
|
||||
|
||||
public static NEI instance;
|
||||
|
||||
Class API;
|
||||
|
||||
// recipe handler...
|
||||
Method registerRecipeHandler;
|
||||
Method registerUsageHandler;
|
||||
|
||||
public NEI() throws ClassNotFoundException {
|
||||
API = Class.forName( "codechicken.nei.api.API" );
|
||||
}
|
||||
|
||||
public void registerRecipeHandler(Object o) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
|
||||
{
|
||||
registerRecipeHandler.invoke( API, o );
|
||||
registerUsageHandler.invoke( API, o );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
Method registerRecipeHandler = API.getDeclaredMethod( "registerRecipeHandler", new Class[] { codechicken.nei.recipe.ICraftingHandler.class } );
|
||||
Method registerUsageHandler = API.getDeclaredMethod( "registerUsageHandler", new Class[] { codechicken.nei.recipe.IUsageHandler.class } );
|
||||
registerRecipeHandler = API.getDeclaredMethod( "registerRecipeHandler", new Class[] { codechicken.nei.recipe.ICraftingHandler.class } );
|
||||
registerUsageHandler = API.getDeclaredMethod( "registerUsageHandler", new Class[] { codechicken.nei.recipe.IUsageHandler.class } );
|
||||
|
||||
registerRecipeHandler.invoke( API, new NEIAEShapedRecipeHandler() );
|
||||
registerUsageHandler.invoke( API, new NEIAEShapedRecipeHandler() );
|
||||
registerRecipeHandler( new NEIAEShapedRecipeHandler() );
|
||||
registerRecipeHandler( new NEIAEShapelessRecipeHandler() );
|
||||
registerRecipeHandler( new NEIInscriberRecipeHandler() );
|
||||
|
||||
registerRecipeHandler.invoke( API, new NEIAEShapelessRecipeHandler() );
|
||||
registerUsageHandler.invoke( API, new NEIAEShapelessRecipeHandler() );
|
||||
// crafting terminal...
|
||||
Method registerGuiOverlay = API.getDeclaredMethod( "registerGuiOverlay", new Class[] { Class.class, String.class, int.class, int.class } );
|
||||
Class IOverlayHandler = Class.forName( "codechicken.nei.api.IOverlayHandler" );
|
||||
Class DefaultOverlayHandler = NEICraftingHandler.class;
|
||||
|
||||
/*
|
||||
* Method registerGuiOverlay = API.getDeclaredMethod( "registerGuiOverlay", new Class[] { Class.class,
|
||||
* String.class, int.class, int.class } ); Class IOverlayHandler = Class.forName(
|
||||
* "codechicken.nei.api.IOverlayHandler" ); Class DefaultOverlayHandler =
|
||||
* NEICraftingTerminalOverlayHandler.class; Method registerGuiOverlayHandler = API.getDeclaredMethod(
|
||||
* "registerGuiOverlayHandler", new Class[] { Class.class, IOverlayHandler, String.class } );
|
||||
* registerGuiOverlay.invoke( API, GuiCraftingTerminal.class, "crafting", 6, 75 ); Constructor
|
||||
* DefaultOverlayHandlerConstructor = DefaultOverlayHandler .getConstructor( new Class[] { int.class, int.class
|
||||
* } ); registerGuiOverlayHandler.invoke( API, GuiCraftingTerminal.class,
|
||||
* DefaultOverlayHandlerConstructor.newInstance( 6, 75 ), "crafting" );
|
||||
*/
|
||||
Method registerGuiOverlayHandler = API.getDeclaredMethod( "registerGuiOverlayHandler", new Class[] { Class.class, IOverlayHandler, String.class } );
|
||||
registerGuiOverlay.invoke( API, GuiCraftingTerm.class, "crafting", 6, 75 );
|
||||
|
||||
Constructor DefaultOverlayHandlerConstructor = DefaultOverlayHandler.getConstructor( new Class[] { int.class, int.class } );
|
||||
registerGuiOverlayHandler.invoke( API, GuiCraftingTerm.class, DefaultOverlayHandlerConstructor.newInstance( 6, 75 ), "crafting" );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,4 +67,32 @@ public class NEI implements IIntegrationModule
|
||||
|
||||
}
|
||||
|
||||
@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)
|
||||
{
|
||||
RenderItem ri = GuiContainerManager.drawItems;
|
||||
GuiContainerManager.drawItems = aeri2;
|
||||
return ri;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object[] results)
|
||||
public void loadCraftingRecipes(String outputId, Object... results)
|
||||
{
|
||||
if ( (outputId.equals( "crafting" )) && (getClass() == NEIAEShapedRecipeHandler.class) )
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object[] results)
|
||||
public void loadCraftingRecipes(String outputId, Object... results)
|
||||
{
|
||||
if ( (outputId.equals( "crafting" )) && (getClass() == NEIAEShapelessRecipeHandler.class) )
|
||||
{
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import appeng.client.gui.implementations.GuiCraftingTerm;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketNEIRecipe;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
|
||||
public class NEICraftingHandler implements IOverlayHandler
|
||||
{
|
||||
|
||||
public NEICraftingHandler(int x, int y) {
|
||||
offsetx = x;
|
||||
offsety = y;
|
||||
}
|
||||
|
||||
int offsetx;
|
||||
int offsety;
|
||||
|
||||
// @override
|
||||
public void overlayRecipe(GuiContainer gui, IRecipeHandler recipe, int recipeIndex, boolean shift)
|
||||
{
|
||||
try
|
||||
{
|
||||
List ingredients = recipe.getIngredientStacks( recipeIndex );
|
||||
overlayRecipe( gui, ingredients, shift );
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
}
|
||||
catch (Error err)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// @override
|
||||
public void overlayRecipe(GuiContainer gui, List<PositionedStack> ingredients, boolean shift)
|
||||
{
|
||||
try
|
||||
{
|
||||
NBTTagCompound recipe = new NBTTagCompound();
|
||||
|
||||
if ( gui instanceof GuiCraftingTerm )
|
||||
{
|
||||
for (int i = 0; i < ingredients.size(); i++)// identify slots
|
||||
{
|
||||
PositionedStack pstack = ingredients.get( i );
|
||||
int col = (pstack.relx - 25) / 18;
|
||||
int row = (pstack.rely - 6) / 18;
|
||||
if ( pstack.item != null )
|
||||
{
|
||||
for (Slot slot : (List<Slot>) gui.inventorySlots.inventorySlots)
|
||||
{
|
||||
if ( slot instanceof SlotCraftingMatrix )
|
||||
{
|
||||
SlotCraftingMatrix ctSlot = (SlotCraftingMatrix) slot;
|
||||
if ( ctSlot.getSlotIndex() == col + row * 3 )
|
||||
{
|
||||
NBTTagCompound inbt = new NBTTagCompound();
|
||||
pstack.item.writeToNBT( inbt );
|
||||
recipe.setTag( "#" + ((SlotCraftingMatrix) slot).getSlotIndex(), inbt );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NetworkHandler.instance.sendToServer( new PacketNEIRecipe( recipe ) );
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
}
|
||||
catch (Error err)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.changeTexture;
|
||||
import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.client.gui.implementations.GuiInscriber;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.recipes.handlers.Inscribe;
|
||||
import appeng.recipes.handlers.Inscribe.InscriberRecipe;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.api.IRecipeOverlayRenderer;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class NEIInscriberRecipeHandler extends TemplateRecipeHandler
|
||||
{
|
||||
|
||||
public void drawBackground(int recipe)
|
||||
{
|
||||
GL11.glColor4f( 1, 1, 1, 1 );
|
||||
changeTexture( getGuiTexture() );
|
||||
drawTexturedModalRect( 0, 0, 5, 11, 166, 75 );
|
||||
}
|
||||
|
||||
public void loadTransferRects()
|
||||
{
|
||||
this.transferRects.add( new TemplateRecipeHandler.RecipeTransferRect( new Rectangle( 84, 23, 24, 18 ), "inscriber", new Object[0] ) );
|
||||
}
|
||||
|
||||
public Class<? extends GuiContainer> getGuiClass()
|
||||
{
|
||||
return GuiInscriber.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return GuiText.Inscriber.getLocal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results)
|
||||
{
|
||||
if ( (outputId.equals( "inscriber" )) && (getClass() == NEIInscriberRecipeHandler.class) )
|
||||
{
|
||||
for (InscriberRecipe irecipe : Inscribe.recipes)
|
||||
{
|
||||
CachedInscriberRecipe recipe = new CachedInscriberRecipe( irecipe );
|
||||
if ( recipe != null )
|
||||
{
|
||||
recipe.computeVisuals();
|
||||
this.arecipes.add( recipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.loadCraftingRecipes( outputId, results );
|
||||
}
|
||||
}
|
||||
|
||||
public void loadCraftingRecipes(ItemStack result)
|
||||
{
|
||||
for (InscriberRecipe irecipe : Inscribe.recipes)
|
||||
{
|
||||
if ( NEIServerUtils.areStacksSameTypeCrafting( irecipe.output, result ) )
|
||||
{
|
||||
CachedInscriberRecipe recipe = new CachedInscriberRecipe( irecipe );
|
||||
recipe.computeVisuals();
|
||||
this.arecipes.add( recipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadUsageRecipes(ItemStack ingredient)
|
||||
{
|
||||
for (InscriberRecipe irecipe : Inscribe.recipes)
|
||||
{
|
||||
CachedInscriberRecipe recipe = new CachedInscriberRecipe( irecipe );
|
||||
|
||||
if ( (recipe != null) && (recipe.contains( recipe.ingredients, ingredient.getItem() )) )
|
||||
{
|
||||
recipe.computeVisuals();
|
||||
if ( recipe.contains( recipe.ingredients, ingredient ) )
|
||||
{
|
||||
recipe.setIngredientPermutation( recipe.ingredients, ingredient );
|
||||
this.arecipes.add( recipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getGuiTexture()
|
||||
{
|
||||
ResourceLocation loc = new ResourceLocation( "appliedenergistics2", "textures/guis/inscriber.png" );
|
||||
String f = loc.toString();
|
||||
return f;
|
||||
}
|
||||
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "inscriber";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlay(GuiContainer gui, Container container, int recipe)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeOverlayRenderer getOverlayRenderer(GuiContainer gui, int recipe)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOverlayHandler getOverlayHandler(GuiContainer gui, int recipe)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public class CachedInscriberRecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
|
||||
public ArrayList<PositionedStack> ingredients;
|
||||
public PositionedStack result;
|
||||
|
||||
public CachedInscriberRecipe(InscriberRecipe irecipe) {
|
||||
result = new PositionedStack( irecipe.output, 108, 29 );
|
||||
ingredients = new ArrayList<PositionedStack>();
|
||||
|
||||
if ( irecipe.plateA != null )
|
||||
ingredients.add( new PositionedStack( irecipe.plateA, 40, 5 ) );
|
||||
|
||||
if ( irecipe.imprintable != null )
|
||||
ingredients.add( new PositionedStack( irecipe.imprintable, 40 + 18, 28 ) );
|
||||
|
||||
if ( irecipe.plateB != null )
|
||||
ingredients.add( new PositionedStack( irecipe.plateB, 40, 51 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients()
|
||||
{
|
||||
return getCycledIngredients( cycleticks / 20, this.ingredients );
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return this.result;
|
||||
}
|
||||
|
||||
public void computeVisuals()
|
||||
{
|
||||
for (PositionedStack p : this.ingredients)
|
||||
{
|
||||
p.generatePermutations();
|
||||
}
|
||||
this.result.generatePermutations();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.GuiText;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.api.IRecipeOverlayRenderer;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.ICraftingHandler;
|
||||
import codechicken.nei.recipe.IUsageHandler;
|
||||
|
||||
public class NEIWorldCraftingHandler implements ICraftingHandler, IUsageHandler
|
||||
{
|
||||
|
||||
HashMap<AEItemDefinition, String> details = new HashMap<AEItemDefinition, String>();
|
||||
List<AEItemDefinition> offsets = new LinkedList();
|
||||
|
||||
private void addRecipe(AEItemDefinition def, String msg)
|
||||
{
|
||||
offsets.add( def );
|
||||
details.put( def, msg );
|
||||
}
|
||||
|
||||
public NEIWorldCraftingHandler() {
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.inWorldFluix ) )
|
||||
addRecipe( AEApi.instance().materials().materialFluixCrystal, GuiText.inWorldFluix.getLocal() );
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.inWorldSingularity ) )
|
||||
addRecipe( AEApi.instance().materials().materialQESingularity, GuiText.inWorldSingularity.getLocal() );
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.inWorldPurification ) )
|
||||
{
|
||||
addRecipe( AEApi.instance().materials().materialPureifiedCertusQuartzCrystal, GuiText.inWorldPurification.getLocal() );
|
||||
addRecipe( AEApi.instance().materials().materialPureifiedNetherQuartzCrystal, GuiText.inWorldPurification.getLocal() );
|
||||
addRecipe( AEApi.instance().materials().materialPureifiedFluixCrystal, GuiText.inWorldPurification.getLocal() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return GuiText.InWorldCrafting.getLocal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int numRecipes()
|
||||
{
|
||||
return offsets.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipe)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int recipe)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredientStacks(int recipe)
|
||||
{
|
||||
return new ArrayList<PositionedStack>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getOtherStacks(int recipetype)
|
||||
{
|
||||
return new ArrayList<PositionedStack>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResultStack(int recipe)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlay(GuiContainer gui, Container container, int recipe)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeOverlayRenderer getOverlayRenderer(GuiContainer gui, int recipe)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOverlayHandler getOverlayHandler(GuiContainer gui, int recipe)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(GuiRecipe gui, List<String> currenttip, int recipe)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemTooltip(GuiRecipe gui, ItemStack stack, List<String> currenttip, int recipe)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(GuiRecipe gui, int button, int recipe)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IUsageHandler getUsageHandler(String inputId, Object... ingredients)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftingHandler getRecipeHandler(String outputId, Object... results)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user