2014-05-11 18:27:32 +02:00
|
|
|
package appeng.integration.modules.NEIHelpers;
|
2014-05-01 06:01:22 +02:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2014-05-01 07:32:58 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.gui.FontRenderer;
|
2014-05-01 06:01:22 +02:00
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
|
|
import net.minecraft.inventory.Container;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2014-05-01 07:32:58 +02:00
|
|
|
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
2014-05-01 06:01:22 +02:00
|
|
|
import appeng.api.AEApi;
|
|
|
|
import appeng.api.util.AEItemDefinition;
|
|
|
|
import appeng.core.AEConfig;
|
|
|
|
import appeng.core.features.AEFeature;
|
|
|
|
import appeng.core.localization.GuiText;
|
2014-05-01 07:32:58 +02:00
|
|
|
import codechicken.nei.NEIServerUtils;
|
2014-05-01 06:01:22 +02:00
|
|
|
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();
|
2014-05-01 07:32:58 +02:00
|
|
|
List<PositionedStack> outputs = new LinkedList();
|
|
|
|
|
|
|
|
ItemStack target;
|
2014-05-01 06:01:22 +02:00
|
|
|
|
|
|
|
private void addRecipe(AEItemDefinition def, String msg)
|
|
|
|
{
|
2014-05-01 07:32:58 +02:00
|
|
|
if ( NEIServerUtils.areStacksSameTypeCrafting( def.stack( 1 ), target ) )
|
|
|
|
{
|
|
|
|
offsets.add( def );
|
|
|
|
outputs.add( new PositionedStack( def.stack( 1 ), 75, 4 ) );
|
|
|
|
details.put( def, msg );
|
|
|
|
}
|
2014-05-01 06:01:22 +02:00
|
|
|
}
|
|
|
|
|
2014-05-01 07:32:58 +02:00
|
|
|
private void addRecipes()
|
|
|
|
{
|
2014-06-08 23:24:21 +02:00
|
|
|
addRecipe( AEApi.instance().materials().materialCertusQuartzCrystalCharged, GuiText.ChargedQuartz.getLocal() );
|
|
|
|
|
2014-05-01 06:01:22 +02:00
|
|
|
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 ) )
|
|
|
|
{
|
2014-06-01 03:56:55 +02:00
|
|
|
addRecipe( AEApi.instance().materials().materialPureifiedCertusQuartzCrystal, GuiText.inWorldPurificationCertus.getLocal() );
|
|
|
|
addRecipe( AEApi.instance().materials().materialPureifiedNetherQuartzCrystal, GuiText.inWorldPurificationNether.getLocal() );
|
|
|
|
addRecipe( AEApi.instance().materials().materialPureifiedFluixCrystal, GuiText.inWorldPurificationFluix.getLocal() );
|
2014-05-01 06:01:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getRecipeName()
|
|
|
|
{
|
|
|
|
return GuiText.InWorldCrafting.getLocal();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int numRecipes()
|
|
|
|
{
|
|
|
|
return offsets.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void drawBackground(int recipe)
|
|
|
|
{
|
2014-05-01 07:32:58 +02:00
|
|
|
GL11.glColor4f( 1, 1, 1, 1 );// nothing.
|
2014-05-01 06:01:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawForeground(int recipe)
|
|
|
|
{
|
2014-05-01 07:32:58 +02:00
|
|
|
if ( this.outputs.size() > recipe )
|
|
|
|
{
|
2014-05-02 04:49:19 +02:00
|
|
|
// PositionedStack cr = this.outputs.get( recipe );
|
2014-05-01 07:32:58 +02:00
|
|
|
String details = this.details.get( this.offsets.get( recipe ) );
|
2014-05-01 06:01:22 +02:00
|
|
|
|
2014-05-01 07:32:58 +02:00
|
|
|
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
|
|
|
fr.drawSplitString( details, 10, 25, 150, 0 );
|
|
|
|
}
|
2014-05-01 06:01:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@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)
|
|
|
|
{
|
2014-05-01 07:32:58 +02:00
|
|
|
return outputs.get( recipe );
|
2014-05-01 06:01:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@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)
|
|
|
|
{
|
2014-05-01 07:32:58 +02:00
|
|
|
return currenttip;
|
2014-05-01 06:01:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<String> handleItemTooltip(GuiRecipe gui, ItemStack stack, List<String> currenttip, int recipe)
|
|
|
|
{
|
2014-05-01 07:32:58 +02:00
|
|
|
return currenttip;
|
2014-05-01 06:01:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@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;
|
|
|
|
}
|
|
|
|
|
2014-05-01 07:32:58 +02:00
|
|
|
public NEIWorldCraftingHandler newInstance()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return getClass().newInstance();
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
throw new RuntimeException( e );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-01 06:01:22 +02:00
|
|
|
@Override
|
|
|
|
public IUsageHandler getUsageHandler(String inputId, Object... ingredients)
|
|
|
|
{
|
2014-05-01 07:32:58 +02:00
|
|
|
return this;
|
2014-05-01 06:01:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ICraftingHandler getRecipeHandler(String outputId, Object... results)
|
|
|
|
{
|
2014-05-01 07:32:58 +02:00
|
|
|
NEIWorldCraftingHandler g = newInstance();
|
|
|
|
if ( results.length > 0 && results[0] instanceof ItemStack )
|
|
|
|
{
|
|
|
|
g.target = (ItemStack) results[0];
|
|
|
|
g.addRecipes();
|
|
|
|
return g;
|
|
|
|
}
|
|
|
|
return this;
|
2014-05-01 06:01:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|