Some code, it does not work
This commit is contained in:
parent
d27993ba5f
commit
7315e23864
4 changed files with 218 additions and 6 deletions
|
@ -5,6 +5,9 @@ import codechicken.nei.recipe.TemplateRecipeHandler;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import scala.tools.nsc.backend.icode.analysis.TypeFlowAnalysis;
|
||||
import techreborn.compat.nei.recipes.GenericRecipeHander;
|
||||
import techreborn.compat.nei.recipes.ImplosionCompressorRecipeHandler;
|
||||
import techreborn.lib.ModInfo;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IConfigureNEI;
|
||||
|
@ -31,6 +34,10 @@ public class NEIConfig implements IConfigureNEI {
|
|||
ShapelessRollingMachineHandler shapelessRollingMachineHandler = new ShapelessRollingMachineHandler();
|
||||
NEIConfig.blastFurnaceRecipeHandle = new BlastFurnaceRecipeHandler();
|
||||
|
||||
ImplosionCompressorRecipeHandler implosion = new ImplosionCompressorRecipeHandler();
|
||||
API.registerUsageHandler(implosion);
|
||||
API.registerRecipeHandler(implosion);
|
||||
|
||||
API.registerRecipeHandler(centrifugeRecipeHandler);
|
||||
API.registerUsageHandler(centrifugeRecipeHandler);
|
||||
|
||||
|
|
|
@ -1,7 +1,161 @@
|
|||
package techreborn.compat.nei.recipes;
|
||||
|
||||
/**
|
||||
* Created by mark on 08/05/15.
|
||||
*/
|
||||
public class GenericRecipeHander {
|
||||
}
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import techreborn.api.recipe.IBaseRecipeType;
|
||||
import techreborn.api.recipe.RecipeHanderer;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class GenericRecipeHander extends TemplateRecipeHandler {
|
||||
|
||||
public INeiBaseRecipe getNeiBaseRecipe(){
|
||||
return null;
|
||||
}
|
||||
|
||||
public class CachedGenericRecipe extends CachedRecipe {
|
||||
|
||||
private List<PositionedStack> input = new ArrayList<PositionedStack>();
|
||||
private List<PositionedStack> outputs = new ArrayList<PositionedStack>();
|
||||
public Point focus;
|
||||
public IBaseRecipeType recipie;
|
||||
public INeiBaseRecipe neiBaseRecipe;
|
||||
|
||||
public CachedGenericRecipe(IBaseRecipeType recipe, INeiBaseRecipe neiBaseRecipe)
|
||||
{
|
||||
this.recipie = recipe;
|
||||
this.neiBaseRecipe = neiBaseRecipe;
|
||||
neiBaseRecipe.addPositionedStacks(input, outputs, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients()
|
||||
{
|
||||
return this.getCycledIngredients(cycleticks / 20, this.input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getOtherStacks()
|
||||
{
|
||||
return this.outputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return getNeiBaseRecipe().getRecipeName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return getNeiBaseRecipe().getGuiTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiContainer> getGuiClass()
|
||||
{
|
||||
return getNeiBaseRecipe().getGuiClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipeIndex)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GuiDraw.changeTexture(getGuiTexture());
|
||||
GuiDraw.drawTexturedModalRect(0, 0, 4, 4, 166, 78);
|
||||
GuiDraw.drawTooltipBox(10, 80, 145, 50);
|
||||
GuiDraw.drawString("Info:", 14, 84, -1);
|
||||
CachedRecipe recipe = arecipes.get(recipeIndex);
|
||||
if (recipe instanceof CachedGenericRecipe)
|
||||
{
|
||||
CachedGenericRecipe genericRecipe = (CachedGenericRecipe) recipe;
|
||||
GuiDraw.drawString(
|
||||
"EU needed: "
|
||||
+ (ConfigTechReborn.CentrifugeInputTick * genericRecipe.recipie
|
||||
.tickTime()), 14, 94, -1);
|
||||
GuiDraw.drawString("Ticks to smelt: "
|
||||
+ genericRecipe.recipie.tickTime(), 14,
|
||||
104, -1);
|
||||
GuiDraw.drawString("Time to smelt: "
|
||||
+ genericRecipe.recipie.tickTime() / 20
|
||||
+ " seconds", 14, 114, -1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void loadTransferRects(INeiBaseRecipe recipe)
|
||||
{
|
||||
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(
|
||||
new Rectangle(0, 0, 20, 20), recipe.getRecipeName(), new Object[0]));
|
||||
}
|
||||
|
||||
public void loadCraftingRecipes(String outputId, Object... results)
|
||||
{
|
||||
if (outputId.equals(getNeiBaseRecipe().getRecipeName()))
|
||||
{
|
||||
for (IBaseRecipeType recipeType : RecipeHanderer.getRecipeClassFromName(getNeiBaseRecipe().getRecipeName()))
|
||||
{
|
||||
addCached(recipeType);
|
||||
}
|
||||
} else
|
||||
{
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result)
|
||||
{
|
||||
for (IBaseRecipeType recipeType : RecipeHanderer.getRecipeClassFromName(getNeiBaseRecipe().getRecipeName()))
|
||||
{
|
||||
for(ItemStack output : recipeType.getOutputs()){
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(output, result))
|
||||
{
|
||||
addCached(recipeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient)
|
||||
{
|
||||
for (IBaseRecipeType recipeType : RecipeHanderer.getRecipeClassFromName(getNeiBaseRecipe().getRecipeName()))
|
||||
{
|
||||
for(ItemStack input : recipeType.getInputs()){
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(input, ingredient))
|
||||
{
|
||||
addCached(recipeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addCached(IBaseRecipeType recipie)
|
||||
{
|
||||
this.arecipes.add(new CachedGenericRecipe(recipie, getNeiBaseRecipe()));
|
||||
}
|
||||
|
||||
}
|
|
@ -2,6 +2,7 @@ package techreborn.compat.nei.recipes;
|
|||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import techreborn.api.recipe.IBaseRecipeType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -15,7 +16,7 @@ public interface INeiBaseRecipe {
|
|||
* @param input add the input stacks to this
|
||||
* @param outputs add this output stacks to this
|
||||
*/
|
||||
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs);
|
||||
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType);
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package techreborn.compat.nei.recipes;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import techreborn.api.recipe.IBaseRecipeType;
|
||||
import techreborn.client.gui.GuiImplosionCompressor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ImplosionCompressorRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe {
|
||||
@Override
|
||||
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) {
|
||||
int offset = 4;
|
||||
PositionedStack pStack = new PositionedStack(recipeType.getInputs().get(0), 34 - offset, 16 - offset);
|
||||
pStack.setMaxSize(1);
|
||||
input.add(pStack);
|
||||
|
||||
PositionedStack pStack2 = new PositionedStack(recipeType.getInputs().get(1), 34 - offset, 34 - offset);
|
||||
pStack2.setMaxSize(1);
|
||||
input.add(pStack2);
|
||||
|
||||
PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 86 - offset, 25 - offset);
|
||||
pStack3.setMaxSize(1);
|
||||
outputs.add(pStack3);
|
||||
|
||||
PositionedStack pStack4 = new PositionedStack(recipeType.getOutputs().get(1), 104 - offset, 25 - offset);
|
||||
pStack4.setMaxSize(1);
|
||||
outputs.add(pStack4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return "implosionCompressorRecipe";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "techreborn:textures/gui/implosion_compressor.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiContainer> getGuiClass() {
|
||||
return GuiImplosionCompressor.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public INeiBaseRecipe getNeiBaseRecipe() {
|
||||
return this;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue