Merge branch 'master' of https://bitbucket.org/calclavia/resonant-induction
This commit is contained in:
commit
f227c706da
10 changed files with 406 additions and 1 deletions
|
@ -56,6 +56,10 @@ public abstract class RecipeResource
|
|||
{
|
||||
return this.itemStack.isItemEqual(((ItemStackResource) obj).itemStack);
|
||||
}
|
||||
if (obj instanceof ItemStack)
|
||||
{
|
||||
return this.itemStack.isItemEqual((ItemStack) obj);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -65,6 +69,12 @@ public abstract class RecipeResource
|
|||
{
|
||||
return itemStack.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "[ItemStackResource {" + itemStack.toString() + "}]";
|
||||
}
|
||||
}
|
||||
|
||||
public static class OreDictResource extends RecipeResource
|
||||
|
@ -98,7 +108,14 @@ public abstract class RecipeResource
|
|||
|
||||
if (obj instanceof ItemStackResource)
|
||||
{
|
||||
return this.name.equals(OreDictionary.getOreName(OreDictionary.getOreID(((ItemStackResource) obj).itemStack)));
|
||||
return OreDictionary.getOres(name).contains(((ItemStackResource) obj).itemStack);
|
||||
}
|
||||
if (obj instanceof ItemStack)
|
||||
{
|
||||
for (ItemStack is : OreDictionary.getOres(name).toArray(new ItemStack[0]))
|
||||
if (is.isItemEqual((ItemStack) obj))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -109,6 +126,12 @@ public abstract class RecipeResource
|
|||
{
|
||||
return OreDictionary.getOres(name).get(0).copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "[OreDictResource {" + name.toString() + "}]";
|
||||
}
|
||||
}
|
||||
|
||||
public static class FluidStackResource extends RecipeResource
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package resonantinduction.core.nei;
|
||||
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IConfigureNEI;
|
||||
|
||||
public class NEIResonantInductionConfig implements IConfigureNEI
|
||||
{
|
||||
|
||||
@Override
|
||||
public void loadConfig()
|
||||
{
|
||||
API.registerRecipeHandler(new RIGrinderRecipeHandler());
|
||||
API.registerUsageHandler(new RIGrinderRecipeHandler());
|
||||
|
||||
API.registerRecipeHandler(new RICrusherRecipeHandler());
|
||||
API.registerUsageHandler(new RICrusherRecipeHandler());
|
||||
|
||||
API.registerRecipeHandler(new RIMixerRecipeHandler());
|
||||
API.registerUsageHandler(new RIMixerRecipeHandler());
|
||||
|
||||
API.registerRecipeHandler(new RISawmillRecipeHandler());
|
||||
API.registerUsageHandler(new RISawmillRecipeHandler());
|
||||
|
||||
API.registerRecipeHandler(new RISmelterRecipeHandler());
|
||||
API.registerUsageHandler(new RISmelterRecipeHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "Resonant Induction Plugin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion()
|
||||
{
|
||||
return "1.0";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package resonantinduction.core.nei;
|
||||
|
||||
import calclavia.lib.utility.LanguageUtility;
|
||||
import resonantinduction.api.recipe.MachineRecipes.RecipeType;
|
||||
|
||||
public class RICrusherRecipeHandler extends RITemplateRecipeHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return LanguageUtility.getLocal("resonantinduction.machine.crusher");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeType getMachine()
|
||||
{
|
||||
return RecipeType.CRUSHER;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package resonantinduction.core.nei;
|
||||
|
||||
import calclavia.lib.utility.LanguageUtility;
|
||||
import resonantinduction.api.recipe.MachineRecipes.RecipeType;
|
||||
|
||||
public class RIGrinderRecipeHandler extends RITemplateRecipeHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return LanguageUtility.getLocal("resonantinduction.machine.grinder");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeType getMachine()
|
||||
{
|
||||
return RecipeType.GRINDER;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package resonantinduction.core.nei;
|
||||
|
||||
import calclavia.lib.utility.LanguageUtility;
|
||||
import resonantinduction.api.recipe.MachineRecipes.RecipeType;
|
||||
|
||||
public class RIMixerRecipeHandler extends RITemplateRecipeHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return LanguageUtility.getLocal("resonantinduction.machine.mixer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeType getMachine()
|
||||
{
|
||||
return RecipeType.MIXER;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package resonantinduction.core.nei;
|
||||
|
||||
import calclavia.lib.utility.LanguageUtility;
|
||||
import resonantinduction.api.recipe.MachineRecipes.RecipeType;
|
||||
|
||||
public class RISawmillRecipeHandler extends RITemplateRecipeHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return LanguageUtility.getLocal("resonantinduction.machine.sawmill");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeType getMachine()
|
||||
{
|
||||
return RecipeType.SAWMILL;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package resonantinduction.core.nei;
|
||||
|
||||
import calclavia.lib.utility.LanguageUtility;
|
||||
import resonantinduction.api.recipe.MachineRecipes.RecipeType;
|
||||
|
||||
public class RISmelterRecipeHandler extends RITemplateRecipeHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return LanguageUtility.getLocal("resonantinduction.machine.smelter");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeType getMachine()
|
||||
{
|
||||
return RecipeType.SMELTER;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,207 @@
|
|||
package resonantinduction.core.nei;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import resonantinduction.api.recipe.MachineRecipes;
|
||||
import resonantinduction.api.recipe.RecipeResource;
|
||||
import resonantinduction.api.recipe.RecipeResource.FluidStackResource;
|
||||
import resonantinduction.api.recipe.RecipeResource.ItemStackResource;
|
||||
import resonantinduction.api.recipe.RecipeResource.OreDictResource;
|
||||
import resonantinduction.core.Reference;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public abstract class RITemplateRecipeHandler extends TemplateRecipeHandler
|
||||
{
|
||||
int[][] inputSlots = new int[][] {
|
||||
{11, 5}, {29, 5},
|
||||
{11, 23}, {29, 23},
|
||||
{11, 41}, {29, 41}
|
||||
};
|
||||
int[][] outputSlots = new int[][] {
|
||||
{121, 5}, {139, 5},
|
||||
{121, 23}, {139, 23},
|
||||
{121, 41}, {139, 41}
|
||||
};
|
||||
|
||||
@Override
|
||||
public abstract String getRecipeName();
|
||||
|
||||
public abstract MachineRecipes.RecipeType getMachine();
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return getMachine().name().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects()
|
||||
{
|
||||
//transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(57, 26, 52, 22), getMachine().name().toLowerCase(), new Object[0]));
|
||||
// No point, there is no GUI class to use it... :(
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return Reference.PREFIX + Reference.GUI_DIRECTORY + "gui_machine.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiContainer> getGuiClass()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result)
|
||||
{
|
||||
for (Map.Entry<RecipeResource[], RecipeResource[]> irecipe : MachineRecipes.INSTANCE.getRecipes(getMachine()).entrySet())
|
||||
{
|
||||
CachedRIRecipe recipe = new CachedRIRecipe(irecipe);
|
||||
if (recipe.canProduce(result))
|
||||
{
|
||||
this.arecipes.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient)
|
||||
{
|
||||
for (Map.Entry<RecipeResource[], RecipeResource[]> irecipe : MachineRecipes.INSTANCE.getRecipes(getMachine()).entrySet())
|
||||
{
|
||||
CachedRIRecipe recipe = new CachedRIRecipe(irecipe);
|
||||
if (recipe.doesUse(ingredient))
|
||||
{
|
||||
this.arecipes.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CachedRIRecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
// Raw
|
||||
private RecipeResource[] inputResources;
|
||||
private RecipeResource[] outputResources;
|
||||
|
||||
// Cache
|
||||
private List<PositionedStack> inputs = new ArrayList<PositionedStack>();
|
||||
private List<PositionedStack> outputs = new ArrayList<PositionedStack>();
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getOtherStacks()
|
||||
{
|
||||
if (outputs != null && !outputs.isEmpty())
|
||||
return outputs;
|
||||
|
||||
int i = 0;
|
||||
outputs = new ArrayList<PositionedStack>();
|
||||
for (RecipeResource output : outputResources)
|
||||
{
|
||||
if (output instanceof ItemStackResource)
|
||||
{
|
||||
this.outputs.add(new PositionedStack(((ItemStackResource) output).itemStack, outputSlots[i][0], outputSlots[i++][1]));
|
||||
} else if (output instanceof OreDictResource)
|
||||
{
|
||||
this.outputs.add(new PositionedStack(OreDictionary.getOres(((OreDictResource) output).name), outputSlots[i][0], outputSlots[i++][1]));
|
||||
} else if (output instanceof FluidStackResource)
|
||||
{
|
||||
//this.inputs.add(new PositionedStack(((FluidStackResource) output), outputSlots[i][0], outputSlots[i++][1]));
|
||||
// TODO fluidstack compatibility
|
||||
}
|
||||
this.outputs.get(this.outputs.size() - 1).generatePermutations();
|
||||
}
|
||||
return outputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients()
|
||||
{
|
||||
if (inputs != null && !inputs.isEmpty())
|
||||
return inputs;
|
||||
|
||||
int i = 0;
|
||||
inputs = new ArrayList<PositionedStack>();
|
||||
for (RecipeResource input : inputResources)
|
||||
{
|
||||
if (input instanceof ItemStackResource)
|
||||
{
|
||||
this.inputs.add(new PositionedStack(((ItemStackResource) input).itemStack, inputSlots[i][0], inputSlots[i++][1]));
|
||||
} else if (input instanceof OreDictResource)
|
||||
{
|
||||
this.inputs.add(new PositionedStack(OreDictionary.getOres(((OreDictResource) input).name), inputSlots[i][0], inputSlots[i++][1]));
|
||||
} else if (input instanceof FluidStackResource)
|
||||
{
|
||||
//this.inputs.add(new PositionedStack(((FluidStackResource) input), inputSlots[i][0], inputSlots[i++][1]));
|
||||
// TODO fluidstack compatibility
|
||||
}
|
||||
this.inputs.get(this.inputs.size() - 1).generatePermutations();
|
||||
}
|
||||
return inputs;
|
||||
}
|
||||
|
||||
public CachedRIRecipe(Map.Entry<RecipeResource[], RecipeResource[]> recipe)
|
||||
{
|
||||
|
||||
this.inputResources = recipe.getKey();
|
||||
this.outputResources = recipe.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean canProduce(ItemStack product)
|
||||
{
|
||||
boolean canProduce = false;
|
||||
this.getOtherStacks();
|
||||
|
||||
for (int i = 0; i < this.outputResources.length; i ++)
|
||||
{
|
||||
RecipeResource rStack = this.outputResources[i];
|
||||
if (rStack.equals(product))
|
||||
{
|
||||
this.outputs.get(i).item = product;
|
||||
canProduce = true;
|
||||
}
|
||||
}
|
||||
|
||||
return canProduce;
|
||||
}
|
||||
|
||||
public boolean doesUse(ItemStack input)
|
||||
{
|
||||
boolean doesUse = false;
|
||||
this.getIngredients();
|
||||
|
||||
for (int i = 0; i < this.inputResources.length; i++)
|
||||
{
|
||||
RecipeResource rStack = this.inputResources[i];
|
||||
if (rStack.equals(input))
|
||||
{
|
||||
this.inputs.get(i).item = input;
|
||||
doesUse = true;
|
||||
}
|
||||
}
|
||||
|
||||
return doesUse;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -104,6 +104,11 @@ tile.resonantinduction\:mixer.tooltip=The mixer mixes dusts with water to wash a
|
|||
tile.resonantinduction\:grindingWheel.name=Grinder Wheel
|
||||
tile.resonantinduction\:grindingWheel.tooltip=The grinding wheel grinds ores into rubble and dust. Larger torque allows faster grinding.
|
||||
tile.resonantinduction\:filter.name=Filter
|
||||
resonantinduction.machine.grinder=Grinder
|
||||
resonantinduction.machine.crusher=Crusher
|
||||
resonantinduction.machine.mixer=Mixer
|
||||
resonantinduction.machine.sawmill=Saw-mill
|
||||
resonantinduction.machine.smelter=Smelter
|
||||
|
||||
### Electrical Module
|
||||
## Blocks
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Loading…
Reference in a new issue