Merge in Builder support.

This commit is contained in:
AlgorithmX2
2014-05-11 13:48:14 -05:00
31 changed files with 393 additions and 50 deletions
@@ -1,28 +0,0 @@
package appeng.integration.modules.helpers;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IExternalStorageHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.integration.modules.BC;
public class BCPipeHandler implements IExternalStorageHandler
{
@Override
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel chan)
{
return chan == StorageChannel.ITEMS && BC.instance.isPipe( te, d );
}
@Override
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource src)
{
if ( chan == StorageChannel.ITEMS )
return new BCPipeInventory( te, d );
return null;
}
}
@@ -1,57 +0,0 @@
package appeng.integration.modules.helpers;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.integration.modules.BC;
public class BCPipeInventory implements IMEInventory<IAEItemStack>
{
TileEntity te;
ForgeDirection dir;
public BCPipeInventory(TileEntity _te, ForgeDirection _dir) {
te = _te;
dir = _dir;
}
@Override
public StorageChannel getChannel()
{
return StorageChannel.ITEMS;
}
@Override
public IAEItemStack injectItems(IAEItemStack input, Actionable mode, BaseActionSource src)
{
if ( mode == Actionable.SIMULATE )
{
if ( BC.instance.canAddItemsToPipe( te, input.getItemStack(), dir ) )
return null;
return input;
}
if ( BC.instance.addItemsToPipe( te, input.getItemStack(), dir ) )
return null;
return input;
}
@Override
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src)
{
return null;
}
@Override
public IItemList<IAEItemStack> getAvailableItems(IItemList<IAEItemStack> out)
{
return out;
}
}
@@ -1,209 +0,0 @@
package appeng.integration.modules.helpers;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiCrafting;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import appeng.recipes.game.ShapedRecipe;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.api.DefaultOverlayRenderer;
import codechicken.nei.api.IOverlayHandler;
import codechicken.nei.api.IRecipeOverlayRenderer;
import codechicken.nei.api.IStackPositioner;
import codechicken.nei.recipe.RecipeInfo;
import codechicken.nei.recipe.TemplateRecipeHandler;
public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler
{
public void loadTransferRects()
{
this.transferRects.add( new TemplateRecipeHandler.RecipeTransferRect( new Rectangle( 84, 23, 24, 18 ), "crafting", new Object[0] ) );
}
public Class<? extends GuiContainer> getGuiClass()
{
return GuiCrafting.class;
}
@Override
public String getRecipeName()
{
return NEIClientUtils.translate( "recipe.shaped", new Object[0] );
}
@Override
public void loadCraftingRecipes(String outputId, Object... results)
{
if ( (outputId.equals( "crafting" )) && (getClass() == NEIAEShapedRecipeHandler.class) )
{
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
for (IRecipe irecipe : allrecipes)
{
CachedShapedRecipe recipe = null;
if ( (irecipe instanceof ShapedRecipe) )
recipe = new CachedShapedRecipe( (ShapedRecipe) irecipe );
if ( recipe != null )
{
recipe.computeVisuals();
this.arecipes.add( recipe );
}
}
}
else
{
super.loadCraftingRecipes( outputId, results );
}
}
public void loadCraftingRecipes(ItemStack result)
{
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
for (IRecipe irecipe : allrecipes)
{
if ( NEIServerUtils.areStacksSameTypeCrafting( irecipe.getRecipeOutput(), result ) )
{
CachedShapedRecipe recipe = null;
if ( (irecipe instanceof ShapedRecipe) )
recipe = new CachedShapedRecipe( (ShapedRecipe) irecipe );
if ( recipe != null )
{
recipe.computeVisuals();
this.arecipes.add( recipe );
}
}
}
}
public void loadUsageRecipes(ItemStack ingredient)
{
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
for (IRecipe irecipe : allrecipes)
{
CachedShapedRecipe recipe = null;
if ( (irecipe instanceof ShapedRecipe) )
recipe = new CachedShapedRecipe( (ShapedRecipe) 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()
{
return "textures/gui/container/crafting_table.png";
}
public String getOverlayIdentifier()
{
return "crafting";
}
@Override
public boolean hasOverlay(GuiContainer gui, Container container, int recipe)
{
return (super.hasOverlay( gui, container, recipe )) || ((isRecipe2x2( recipe )) && (RecipeInfo.hasDefaultOverlay( gui, "crafting2x2" )));
}
@Override
public IRecipeOverlayRenderer getOverlayRenderer(GuiContainer gui, int recipe)
{
IRecipeOverlayRenderer renderer = super.getOverlayRenderer( gui, recipe );
if ( renderer != null )
{
return renderer;
}
IStackPositioner positioner = RecipeInfo.getStackPositioner( gui, "crafting2x2" );
if ( positioner == null )
return null;
return new DefaultOverlayRenderer( getIngredientStacks( recipe ), positioner );
}
@Override
public IOverlayHandler getOverlayHandler(GuiContainer gui, int recipe)
{
IOverlayHandler handler = super.getOverlayHandler( gui, recipe );
if ( handler != null )
{
return handler;
}
return RecipeInfo.getOverlayHandler( gui, "crafting2x2" );
}
public boolean isRecipe2x2(int recipe)
{
for (PositionedStack stack : getIngredientStacks( recipe ))
{
if ( (stack.relx > 43) || (stack.rely > 24) )
return false;
}
return true;
}
public class CachedShapedRecipe extends TemplateRecipeHandler.CachedRecipe
{
public ArrayList<PositionedStack> ingredients;
public PositionedStack result;
public CachedShapedRecipe(ShapedRecipe irecipe) {
result = new PositionedStack( irecipe.getRecipeOutput(), 119, 24 );
ingredients = new ArrayList<PositionedStack>();
setIngredients( irecipe.getWidth(), irecipe.getHeight(), irecipe.getIngredients() );
}
public void setIngredients(int width, int height, Object[] items)
{
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
if ( items[(y * width + x)] != null )
{
PositionedStack stack = new PositionedStack( items[(y * width + x)], 25 + x * 18, 6 + y * 18, false );
stack.setMaxSize( 1 );
this.ingredients.add( stack );
}
}
}
}
@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();
}
}
}
@@ -1,209 +0,0 @@
package appeng.integration.modules.helpers;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiCrafting;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import appeng.recipes.game.ShapelessRecipe;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.api.DefaultOverlayRenderer;
import codechicken.nei.api.IOverlayHandler;
import codechicken.nei.api.IRecipeOverlayRenderer;
import codechicken.nei.api.IStackPositioner;
import codechicken.nei.recipe.RecipeInfo;
import codechicken.nei.recipe.TemplateRecipeHandler;
public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
{
public void loadTransferRects()
{
this.transferRects.add( new TemplateRecipeHandler.RecipeTransferRect( new Rectangle( 84, 23, 24, 18 ), "crafting", new Object[0] ) );
}
public Class<? extends GuiContainer> getGuiClass()
{
return GuiCrafting.class;
}
@Override
public String getRecipeName()
{
return NEIClientUtils.translate( "recipe.shapeless", new Object[0] );
}
@Override
public void loadCraftingRecipes(String outputId, Object... results)
{
if ( (outputId.equals( "crafting" )) && (getClass() == NEIAEShapelessRecipeHandler.class) )
{
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
for (IRecipe irecipe : allrecipes)
{
CachedShapelessRecipe recipe = null;
if ( (irecipe instanceof ShapelessRecipe) )
recipe = new CachedShapelessRecipe( (ShapelessRecipe) irecipe );
if ( recipe != null )
{
recipe.computeVisuals();
this.arecipes.add( recipe );
}
}
}
else
{
super.loadCraftingRecipes( outputId, results );
}
}
public void loadCraftingRecipes(ItemStack result)
{
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
for (IRecipe irecipe : allrecipes)
{
if ( NEIServerUtils.areStacksSameTypeCrafting( irecipe.getRecipeOutput(), result ) )
{
CachedShapelessRecipe recipe = null;
if ( (irecipe instanceof ShapelessRecipe) )
recipe = new CachedShapelessRecipe( (ShapelessRecipe) irecipe );
if ( recipe != null )
{
recipe.computeVisuals();
this.arecipes.add( recipe );
}
}
}
}
public void loadUsageRecipes(ItemStack ingredient)
{
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
for (IRecipe irecipe : allrecipes)
{
CachedShapelessRecipe recipe = null;
if ( (irecipe instanceof ShapelessRecipe) )
recipe = new CachedShapelessRecipe( (ShapelessRecipe) 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()
{
return "textures/gui/container/crafting_table.png";
}
public String getOverlayIdentifier()
{
return "crafting";
}
@Override
public boolean hasOverlay(GuiContainer gui, Container container, int recipe)
{
return (super.hasOverlay( gui, container, recipe )) || ((isRecipe2x2( recipe )) && (RecipeInfo.hasDefaultOverlay( gui, "crafting2x2" )));
}
@Override
public IRecipeOverlayRenderer getOverlayRenderer(GuiContainer gui, int recipe)
{
IRecipeOverlayRenderer renderer = super.getOverlayRenderer( gui, recipe );
if ( renderer != null )
{
return renderer;
}
IStackPositioner positioner = RecipeInfo.getStackPositioner( gui, "crafting2x2" );
if ( positioner == null )
return null;
return new DefaultOverlayRenderer( getIngredientStacks( recipe ), positioner );
}
@Override
public IOverlayHandler getOverlayHandler(GuiContainer gui, int recipe)
{
IOverlayHandler handler = super.getOverlayHandler( gui, recipe );
if ( handler != null )
{
return handler;
}
return RecipeInfo.getOverlayHandler( gui, "crafting2x2" );
}
public boolean isRecipe2x2(int recipe)
{
for (PositionedStack stack : getIngredientStacks( recipe ))
{
if ( (stack.relx > 43) || (stack.rely > 24) )
return false;
}
return true;
}
public class CachedShapelessRecipe extends TemplateRecipeHandler.CachedRecipe
{
public ArrayList<PositionedStack> ingredients;
public PositionedStack result;
public CachedShapelessRecipe(ShapelessRecipe irecipe) {
result = new PositionedStack( irecipe.getRecipeOutput(), 119, 24 );
ingredients = new ArrayList<PositionedStack>();
setIngredients( irecipe.getInput().toArray() );
}
public void setIngredients(Object[] items)
{
for (int x = 0; x < 3; x++)
{
for (int y = 0; y < 3; y++)
{
if ( items.length > (y * 3 + x) )
{
PositionedStack stack = new PositionedStack( items[(y * 3 + x)], 25 + x * 18, 6 + y * 18, false );
stack.setMaxSize( 1 );
this.ingredients.add( stack );
}
}
}
}
@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();
}
}
}
@@ -1,86 +0,0 @@
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)
{
}
}
}
@@ -1,208 +0,0 @@
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.Minecraft;
import net.minecraft.client.gui.FontRenderer;
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.api.AEApi;
import appeng.api.features.IGrinderEntry;
import appeng.client.gui.implementations.GuiInscriber;
import appeng.core.localization.GuiText;
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 NEIGrinderRecipeHandler extends TemplateRecipeHandler
{
public void drawBackground(int recipe)
{
GL11.glColor4f( 1, 1, 1, 1 );
changeTexture( getGuiTexture() );
drawTexturedModalRect( 40, 10, 75, 16 + 10, 90, 66 );
}
@Override
public void drawForeground(int recipe)
{
super.drawForeground( recipe );
if ( this.arecipes.size() > recipe )
{
CachedRecipe cr = this.arecipes.get( recipe );
if ( cr instanceof CachedGrindStoneRecipe )
{
CachedGrindStoneRecipe cgsr = (CachedGrindStoneRecipe) cr;
if ( cgsr.hasOptional )
{
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
int width = fr.getStringWidth( cgsr.Chance );
fr.drawString( cgsr.Chance, (168 - width) / 2, 5, 0 );
}
else
{
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
int width = fr.getStringWidth( GuiText.NoSecondOutput.getLocal() );
fr.drawString( GuiText.NoSecondOutput.getLocal(), (168 - width) / 2, 5, 0 );
}
}
}
}
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.GrindStone.getLocal();
}
@Override
public void loadCraftingRecipes(String outputId, Object... results)
{
if ( (outputId.equals( "grindstone" )) && (getClass() == NEIGrinderRecipeHandler.class) )
{
for (IGrinderEntry irecipe : AEApi.instance().registries().grinder().getRecipes())
{
CachedGrindStoneRecipe recipe = new CachedGrindStoneRecipe( irecipe );
if ( recipe != null )
{
recipe.computeVisuals();
this.arecipes.add( recipe );
}
}
}
else
{
super.loadCraftingRecipes( outputId, results );
}
}
public void loadCraftingRecipes(ItemStack result)
{
for (IGrinderEntry irecipe : AEApi.instance().registries().grinder().getRecipes())
{
if ( NEIServerUtils.areStacksSameTypeCrafting( irecipe.getOutput(), result ) )
{
CachedGrindStoneRecipe recipe = new CachedGrindStoneRecipe( irecipe );
recipe.computeVisuals();
this.arecipes.add( recipe );
}
}
}
public void loadUsageRecipes(ItemStack ingredient)
{
for (IGrinderEntry irecipe : AEApi.instance().registries().grinder().getRecipes())
{
CachedGrindStoneRecipe recipe = new CachedGrindStoneRecipe( 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/grinder.png" );
String f = loc.toString();
return f;
}
public String getOverlayIdentifier()
{
return "grindstone";
}
@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 CachedGrindStoneRecipe extends TemplateRecipeHandler.CachedRecipe
{
public ArrayList<PositionedStack> ingredients;
public PositionedStack result;
boolean hasOptional = false;
public String Chance;
public CachedGrindStoneRecipe(IGrinderEntry irecipe) {
result = new PositionedStack( irecipe.getOutput(), -30 + 107, 47 );
ingredients = new ArrayList<PositionedStack>();
if ( irecipe.getOptionalOutput() != null )
{
hasOptional = true;
Chance = ((int) (irecipe.getOptionalChance() * 100)) + GuiText.OfSecondOutput.getLocal();
ingredients.add( new PositionedStack( irecipe.getOptionalOutput(), -30 + 107 + 18, 47 ) );
}
if ( irecipe.getInput() != null )
ingredients.add( new PositionedStack( irecipe.getInput(), 45, 24 ) );
}
@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();
}
}
}
@@ -1,176 +0,0 @@
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();
}
}
}
@@ -1,197 +0,0 @@
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.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
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.NEIServerUtils;
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();
List<PositionedStack> outputs = new LinkedList();
ItemStack target;
private void addRecipe(AEItemDefinition def, String msg)
{
if ( NEIServerUtils.areStacksSameTypeCrafting( def.stack( 1 ), target ) )
{
offsets.add( def );
outputs.add( new PositionedStack( def.stack( 1 ), 75, 4 ) );
details.put( def, msg );
}
}
private void addRecipes()
{
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();
}
public void drawBackground(int recipe)
{
GL11.glColor4f( 1, 1, 1, 1 );// nothing.
}
@Override
public void drawForeground(int recipe)
{
if ( this.outputs.size() > recipe )
{
// PositionedStack cr = this.outputs.get( recipe );
String details = this.details.get( this.offsets.get( recipe ) );
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
fr.drawSplitString( details, 10, 25, 150, 0 );
}
}
@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 outputs.get( recipe );
}
@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 currenttip;
}
@Override
public List<String> handleItemTooltip(GuiRecipe gui, ItemStack stack, List<String> currenttip, int recipe)
{
return currenttip;
}
@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;
}
public NEIWorldCraftingHandler newInstance()
{
try
{
return getClass().newInstance();
}
catch (Exception e)
{
throw new RuntimeException( e );
}
}
@Override
public IUsageHandler getUsageHandler(String inputId, Object... ingredients)
{
return this;
}
@Override
public ICraftingHandler getRecipeHandler(String outputId, Object... results)
{
NEIWorldCraftingHandler g = newInstance();
if ( results.length > 0 && results[0] instanceof ItemStack )
{
g.target = (ItemStack) results[0];
g.addRecipes();
return g;
}
return this;
}
}