mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-22 13:10:13 +00:00
Added NEI plugin for the Slice'N'Splice
This commit is contained in:
1 parent
05f7beb67f
commit
a47e42bb9c
5 files changed
+160
-12
No files matched your search
@@ -10,7 +10,7 @@ import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
|
||||
public class ContainerSliceAndSplice extends AbstractMachineContainer {
|
||||
|
||||
private static final Point[] inputLocs = new Point[] {
|
||||
public static final Point[] INPUT_SLOTS = new Point[] {
|
||||
new Point(44,40),
|
||||
new Point(62,40),
|
||||
new Point(80,40),
|
||||
@@ -21,6 +21,8 @@ public class ContainerSliceAndSplice extends AbstractMachineContainer {
|
||||
new Point(72,16)
|
||||
};
|
||||
|
||||
public static final Point OUTPUT_SLOT = new Point(134, 48);
|
||||
|
||||
public ContainerSliceAndSplice(InventoryPlayer playerInv, AbstractMachineEntity te) {
|
||||
super(playerInv, te);
|
||||
}
|
||||
@@ -28,8 +30,8 @@ public class ContainerSliceAndSplice extends AbstractMachineContainer {
|
||||
@Override
|
||||
protected void addMachineSlots(InventoryPlayer playerInv) {
|
||||
|
||||
for(int i=0;i<inputLocs.length;i++) {
|
||||
Point p = inputLocs[i];
|
||||
for(int i=0;i<INPUT_SLOTS.length;i++) {
|
||||
Point p = INPUT_SLOTS[i];
|
||||
final int slot = i;
|
||||
addSlotToContainer(new Slot(tileEntity, i, p.x, p.y) {
|
||||
@Override
|
||||
@@ -40,7 +42,7 @@ public class ContainerSliceAndSplice extends AbstractMachineContainer {
|
||||
}
|
||||
|
||||
|
||||
addSlotToContainer(new Slot(tileEntity, 8, 134, 48) {
|
||||
addSlotToContainer(new Slot(tileEntity, 8, OUTPUT_SLOT.x, OUTPUT_SLOT.y) {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
|
||||
@@ -38,9 +38,4 @@ public class GuiSliceAndSplice extends GuiMachineBase {
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean showRecipeButton() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,6 +23,9 @@ public class NEIEnderIOConfig implements IConfigureNEI {
|
||||
|
||||
API.registerRecipeHandler(new EnchanterRecipeHandler());
|
||||
API.registerUsageHandler(new EnchanterRecipeHandler());
|
||||
|
||||
API.registerRecipeHandler(new SliceAndSpliceRecipeHandler());
|
||||
API.registerUsageHandler(new SliceAndSpliceRecipeHandler());
|
||||
|
||||
API.hideItem(new ItemStack(EnderIO.blockConduitFacade));
|
||||
API.hideItem(new ItemStack(EnderIO.itemEnderface));
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
package crazypants.enderio.nei;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import crazypants.enderio.machine.power.PowerDisplayUtil;
|
||||
import crazypants.enderio.machine.recipe.IRecipe;
|
||||
import crazypants.enderio.machine.recipe.RecipeInput;
|
||||
import crazypants.enderio.machine.slicensplice.ContainerSliceAndSplice;
|
||||
import crazypants.enderio.machine.slicensplice.GuiSliceAndSplice;
|
||||
import crazypants.enderio.machine.slicensplice.SliceAndSpliceRecipeManager;
|
||||
|
||||
public class SliceAndSpliceRecipeHandler extends TemplateRecipeHandler {
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return "Slice'N'Splice";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "enderio:textures/gui/sliceAndSplice.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiContainer> getGuiClass() {
|
||||
return GuiSliceAndSplice.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier() {
|
||||
return "EnderIOSliceAndSplice";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(149, 32, 16, 16), "EnderIOSliceAndSplice", new Object[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
|
||||
if(result == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<IRecipe> recipes = new ArrayList<IRecipe>(SliceAndSpliceRecipeManager.getInstance().getRecipes());
|
||||
for (IRecipe recipe : recipes) {
|
||||
ItemStack output = recipe.getOutputs()[0].getOutput();
|
||||
if(result.getItem() == output.getItem() && result.getItemDamage() == output.getItemDamage()) {
|
||||
SliceAndSpliceRecipe res = new SliceAndSpliceRecipe(recipe);
|
||||
arecipes.add(res);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results) {
|
||||
if(outputId.equals("EnderIOSliceAndSplice") && getClass() == SliceAndSpliceRecipeHandler.class) {
|
||||
List<IRecipe> recipes = new ArrayList<IRecipe>(SliceAndSpliceRecipeManager.getInstance().getRecipes());
|
||||
for (IRecipe recipe : recipes) {
|
||||
SliceAndSpliceRecipe res = new SliceAndSpliceRecipe(recipe);
|
||||
arecipes.add(res);
|
||||
}
|
||||
} else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
List<IRecipe> recipes = new ArrayList<IRecipe>(SliceAndSpliceRecipeManager.getInstance().getRecipes());
|
||||
for (IRecipe recipe : recipes) {
|
||||
if(recipe.isValidInput(0, ingredient)) {
|
||||
SliceAndSpliceRecipe res = new SliceAndSpliceRecipe(recipe);
|
||||
arecipes.add(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipeIndex) {
|
||||
SliceAndSpliceRecipe recipe = (SliceAndSpliceRecipe) arecipes.get(recipeIndex);
|
||||
String energyString = PowerDisplayUtil.formatPower(recipe.getEnergy()) + " " + PowerDisplayUtil.abrevation();
|
||||
Minecraft.getMinecraft().fontRenderer.drawString(energyString, 100, 58, 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
public List<ItemStack> getInputs(RecipeInput input) {
|
||||
List<ItemStack> result = new ArrayList<ItemStack>();
|
||||
result.add(input.getInput());
|
||||
ItemStack[] equivs = input.getEquivelentInputs();
|
||||
if(equivs != null) {
|
||||
for (ItemStack st : equivs) {
|
||||
result.add(st);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public class SliceAndSpliceRecipe extends TemplateRecipeHandler.CachedRecipe {
|
||||
|
||||
private ArrayList<PositionedStack> input;
|
||||
private PositionedStack output;
|
||||
private int energy;
|
||||
|
||||
public int getEnergy() {
|
||||
return energy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
return getCycledIngredients(cycleticks / 20, input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
return output;
|
||||
}
|
||||
|
||||
public SliceAndSpliceRecipe(IRecipe recipe) {
|
||||
int recipeSize = recipe.getInputs().length;
|
||||
input = new ArrayList<PositionedStack>();
|
||||
int yOff = 11;
|
||||
int xOff = 5;
|
||||
|
||||
for(RecipeInput recipeInput : recipe.getInputs()) {
|
||||
if(recipeInput != null) {
|
||||
Point pos = ContainerSliceAndSplice.INPUT_SLOTS[recipeInput.getSlotNumber()];
|
||||
input.add(new PositionedStack(getInputs(recipeInput), pos.x - xOff, pos.y - yOff));
|
||||
}
|
||||
}
|
||||
|
||||
if(recipe.getOutputs()[0] != null) {
|
||||
output = new PositionedStack(recipe.getOutputs()[0].getOutput(), ContainerSliceAndSplice.OUTPUT_SLOT.x - xOff, ContainerSliceAndSplice.OUTPUT_SLOT.y - yOff);
|
||||
}
|
||||
energy = recipe.getEnergyRequired();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user