mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-20 04:09:43 +00:00
Started work on the still.
This commit is contained in:
1 parent
2379d12230
commit
66544c83f8
27 files changed
+684
-37
No files matched your search
@@ -60,6 +60,8 @@ import crazypants.enderio.machine.painter.BlockPainter;
|
||||
import crazypants.enderio.machine.power.BlockCapacitorBank;
|
||||
import crazypants.enderio.machine.reservoir.BlockReservoir;
|
||||
import crazypants.enderio.machine.solar.BlockSolarPanel;
|
||||
import crazypants.enderio.machine.still.BlockStill;
|
||||
import crazypants.enderio.machine.still.StillRecipeManager;
|
||||
import crazypants.enderio.material.Alloy;
|
||||
import crazypants.enderio.material.BlockFusedQuartz;
|
||||
import crazypants.enderio.material.ItemAlloy;
|
||||
@@ -132,6 +134,7 @@ public class EnderIO {
|
||||
public static BlockCrusher blockCrusher;
|
||||
public static BlockHyperCube blockHyperCube;
|
||||
public static BlockPowerMonitor blockPowerMonitor;
|
||||
public static BlockStill blockStill;
|
||||
|
||||
public static BlockElectricLight blockElectricLight;
|
||||
public static BlockLightNode blockLightNode;
|
||||
@@ -174,6 +177,7 @@ public class EnderIO {
|
||||
|
||||
blockCrusher = BlockCrusher.create();
|
||||
blockAlloySmelter = BlockAlloySmelter.create();
|
||||
blockStill = BlockStill.create();
|
||||
blockPowerMonitor = BlockPowerMonitor.create();
|
||||
blockCapacitorBank = BlockCapacitorBank.create();
|
||||
|
||||
@@ -295,6 +299,7 @@ public class EnderIO {
|
||||
|
||||
CrusherRecipeManager.getInstance().loadRecipesFromConfig();
|
||||
AlloyRecipeManager.getInstance().loadRecipesFromConfig();
|
||||
StillRecipeManager.getInstance().loadRecipesFromConfig();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package crazypants.enderio;
|
||||
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
||||
public class GuiHandler implements IGuiHandler {
|
||||
|
||||
public static final int GUI_ID_ENDERFACE = 1;
|
||||
@@ -32,6 +32,7 @@ public class GuiHandler implements IGuiHandler {
|
||||
|
||||
public static final int GUI_ID_TRAVEL_ACCESSABLE = 18;
|
||||
public static final int GUI_ID_TRAVEL_AUTH = 19;
|
||||
public static final int GUI_ID_STILL = 20;
|
||||
|
||||
protected final Map<Integer, IGuiHandler> guiHandlers = new HashMap<Integer, IGuiHandler>();
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ public enum ModObject {
|
||||
blockSagMill,
|
||||
blockHyperCube,
|
||||
blockPowerMonitor,
|
||||
blockStill,
|
||||
|
||||
blockElectricLight,
|
||||
blockLightNode,
|
||||
|
||||
@@ -15,12 +15,14 @@ public abstract class AbstractMachineContainer extends Container {
|
||||
|
||||
addMachineSlots(playerInv);
|
||||
|
||||
addSlotToContainer(new Slot(te, te.getSlotDefinition().getMinUpgradeSlot(), 12, 60) {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack) {
|
||||
return tileEntity.isItemValidForSlot(tileEntity.getSlotDefinition().getMinUpgradeSlot(), itemStack);
|
||||
}
|
||||
});
|
||||
if(te.getSlotDefinition().getNumInputSlots() == 1) {
|
||||
addSlotToContainer(new Slot(te, te.getSlotDefinition().getMinUpgradeSlot(), 12, 60) {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack) {
|
||||
return tileEntity.isItemValidForSlot(tileEntity.getSlotDefinition().getMinUpgradeSlot(), itemStack);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// add players inventory
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
@@ -75,7 +77,7 @@ public abstract class AbstractMachineContainer extends Container {
|
||||
//Check from inv->input then inv->upgrade then inv->hotbar or hotbar->inv
|
||||
if(slotIndex >= startPlayerSlot) {
|
||||
if(!mergeItemStack(origStack, slotDef.getMinInputSlot(), slotDef.getMaxInputSlot() + 1, false)) {
|
||||
if(!mergeItemStack(origStack, slotDef.getMinUpgradeSlot(), slotDef.getMaxUpgradeSlot() + 1, false)) {
|
||||
if(slotDef.getNumOutputSlots() > 0 && !mergeItemStack(origStack, slotDef.getMinUpgradeSlot(), slotDef.getMaxUpgradeSlot() + 1, false)) {
|
||||
if(slotIndex <= endPlayerSlot) {
|
||||
if(!mergeItemStack(origStack, startHotBarSlot, endHotBarSlot, false)) {
|
||||
return null;
|
||||
|
||||
@@ -30,7 +30,7 @@ public abstract class GuiMachineBase extends GuiContainerBase {
|
||||
public GuiMachineBase(AbstractMachineEntity machine, Container container) {
|
||||
super(container);
|
||||
tileEntity = machine;
|
||||
addToolTip(new GuiToolTip(new Rectangle(POWER_X, POWER_Y, POWER_WIDTH, POWER_HEIGHT), "") {
|
||||
addToolTip(new GuiToolTip(new Rectangle(getPowerX(), getPowerY(), getPowerWidth(), getPowerHeight()), "") {
|
||||
|
||||
@Override
|
||||
protected void updateText() {
|
||||
@@ -45,6 +45,22 @@ public abstract class GuiMachineBase extends GuiContainerBase {
|
||||
redstoneButton = new RedstoneModeButton(this, -1, x, y, tileEntity, new BlockCoord(tileEntity));
|
||||
}
|
||||
|
||||
protected int getPowerX() {
|
||||
return POWER_X;
|
||||
}
|
||||
|
||||
protected int getPowerY() {
|
||||
return POWER_Y;
|
||||
}
|
||||
|
||||
protected int getPowerWidth() {
|
||||
return POWER_WIDTH;
|
||||
}
|
||||
|
||||
protected int getPowerHeight() {
|
||||
return POWER_HEIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
@@ -56,9 +72,9 @@ public abstract class GuiMachineBase extends GuiContainerBase {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int k = (width - xSize) / 2;
|
||||
int l = (height - ySize) / 2;
|
||||
int i1 = tileEntity.getEnergyStoredScaled(POWER_HEIGHT);
|
||||
int i1 = tileEntity.getEnergyStoredScaled(getPowerHeight());
|
||||
// x, y, u, v, width, height
|
||||
drawTexturedModalRect(k + POWER_X, l + BOTTOM_POWER_Y - i1, 176, 31, POWER_WIDTH, i1);
|
||||
drawTexturedModalRect(k + getPowerX(), l + (getPowerY() + getPowerHeight()) - i1, 176, 31, getPowerWidth(), i1);
|
||||
|
||||
for (int i = 0; i < buttonList.size(); ++i) {
|
||||
GuiButton guibutton = (GuiButton) this.buttonList.get(i);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package crazypants.enderio.machine;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class MachineRecipeInput {
|
||||
|
||||
@@ -20,10 +21,18 @@ public class MachineRecipeInput {
|
||||
public final int slotNumber;
|
||||
public final ItemStack item;
|
||||
|
||||
public final FluidStack fluid;
|
||||
|
||||
public MachineRecipeInput(int slotNumber, ItemStack item) {
|
||||
super();
|
||||
this.slotNumber = slotNumber;
|
||||
this.item = item;
|
||||
this.fluid = null;
|
||||
}
|
||||
|
||||
public MachineRecipeInput(int slotNumber, FluidStack fluid) {
|
||||
this.slotNumber = slotNumber;
|
||||
this.item = null;
|
||||
this.fluid = fluid;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,14 +42,23 @@ public class SlotDefinition {
|
||||
}
|
||||
|
||||
public int getNumUpgradeSlots() {
|
||||
if(minUpgradeSlot < 0) {
|
||||
return 0;
|
||||
}
|
||||
return Math.max(0, maxUpgradeSlot - minUpgradeSlot + 1);
|
||||
}
|
||||
|
||||
public int getNumInputSlots() {
|
||||
if(minInputSlot < 0) {
|
||||
return 0;
|
||||
}
|
||||
return Math.max(0, maxInputSlot - minInputSlot + 1);
|
||||
}
|
||||
|
||||
public int getNumOutputSlots() {
|
||||
if(minOutputSlot < 0) {
|
||||
return 0;
|
||||
}
|
||||
return Math.max(0, maxOutputSlot - minOutputSlot + 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class AlloyMachineRecipe extends AbstractMachineRecipe {
|
||||
stacks.add(mi.item);
|
||||
}
|
||||
}
|
||||
return AlloyRecipeManager.instance.getRecipeForInputs(stacks.toArray(new ItemStack[stacks.size()]));
|
||||
return AlloyRecipeManager.instance.getRecipeForInputs(stacks);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package crazypants.enderio.machine.alloy;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -100,7 +101,7 @@ public class AlloyRecipeManager {
|
||||
Log.debug("Could not add invalid recipe: " + recipe);
|
||||
return;
|
||||
}
|
||||
IRecipe rec = getRecipeForInputs(recipe.getInputStacks());
|
||||
IRecipe rec = getRecipeForInputs(Arrays.asList(recipe.getInputStacks()));
|
||||
if(rec != null) {
|
||||
Log.warn("Not adding supplied recipe as a recipe already exists for the input: " + recipe);
|
||||
return;
|
||||
@@ -108,7 +109,7 @@ public class AlloyRecipeManager {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
IRecipe getRecipeForInputs(ItemStack[] inputs) {
|
||||
IRecipe getRecipeForInputs(List<ItemStack> inputs) {
|
||||
for (IAlloyRecipe rec : recipes) {
|
||||
if(rec.isInputForRecipe(inputs)) {
|
||||
return rec;
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.crafting.IEnderIoRecipe;
|
||||
import crazypants.enderio.crafting.IRecipeComponent;
|
||||
@@ -108,13 +109,17 @@ public class BasicAlloyRecipe implements IAlloyRecipe {
|
||||
return new ItemStack[] { output.copy() };
|
||||
}
|
||||
|
||||
//@Override
|
||||
@Override
|
||||
public boolean isValidInput(MachineRecipeInput input) {
|
||||
public boolean isValidInput(ItemStack input) {
|
||||
if(input == null) {
|
||||
return false;
|
||||
}
|
||||
return getRecipeComponentFromInput(input.item) != null;
|
||||
return getRecipeComponentFromInput(input) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidInput(FluidStack fluid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//@Override
|
||||
@@ -223,13 +228,18 @@ public class BasicAlloyRecipe implements IAlloyRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputForRecipe(ItemStack[] test) {
|
||||
public boolean isInputForRecipe(List<ItemStack> test) {
|
||||
if(test == null) {
|
||||
return false;
|
||||
}
|
||||
return recipe.isInputForRecipe(test);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputForRecipe(List<ItemStack> test, List<FluidStack> testFluids) {
|
||||
return (testFluids == null || testFluids.isEmpty()) && isInputForRecipe(test);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeInput[] getInputs() {
|
||||
return recipe.getInputs();
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
package crazypants.enderio.machine.alloy;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import crazypants.enderio.machine.MachineRecipeInput;
|
||||
import crazypants.enderio.machine.recipe.IRecipe;
|
||||
|
||||
public interface IAlloyRecipe extends IRecipe {
|
||||
|
||||
boolean isValidRecipeComponents(ItemStack... items);
|
||||
|
||||
boolean isValidInput(MachineRecipeInput input);
|
||||
|
||||
ItemStack getOutput();
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package crazypants.enderio.machine.crusher;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -68,7 +69,7 @@ public class CrusherRecipeManager {
|
||||
return null;
|
||||
}
|
||||
for (Recipe recipe : recipes) {
|
||||
if(recipe.isInputForRecipe(new ItemStack[] { input })) {
|
||||
if(recipe.isInputForRecipe(Collections.singletonList(input))) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
@@ -84,10 +85,10 @@ public class CrusherRecipeManager {
|
||||
}
|
||||
|
||||
List<Recipe> newRecipes = config.getRecipes(true);
|
||||
Log.info("Found " + newRecipes.size() + " valid SAG Mill recipes in config.");
|
||||
Log.info("Found " + newRecipes.size() + " valid SAG Mill recipes in config.");
|
||||
for (Recipe rec : newRecipes) {
|
||||
addRecipe(rec);
|
||||
}
|
||||
}
|
||||
Log.info("Finished processing Alloy Smelter recipes. " + recipes.size() + " recipes avaliable.");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,28 @@
|
||||
package crazypants.enderio.machine.recipe;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public interface IRecipe {
|
||||
|
||||
public abstract boolean isValid();
|
||||
boolean isValid();
|
||||
|
||||
public abstract float getEnergyRequired();
|
||||
float getEnergyRequired();
|
||||
|
||||
public abstract RecipeOutput[] getOutputs();
|
||||
RecipeOutput[] getOutputs();
|
||||
|
||||
public abstract RecipeInput[] getInputs();
|
||||
RecipeInput[] getInputs();
|
||||
|
||||
public abstract ItemStack[] getInputStacks();
|
||||
ItemStack[] getInputStacks();
|
||||
|
||||
public abstract boolean isInputForRecipe(ItemStack[] test);
|
||||
boolean isInputForRecipe(List<ItemStack> test);
|
||||
|
||||
boolean isInputForRecipe(List<ItemStack> test, List<FluidStack> testFluids);
|
||||
|
||||
boolean isValidInput(ItemStack item);
|
||||
|
||||
boolean isValidInput(FluidStack fluid);
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class Recipe implements IRecipe {
|
||||
|
||||
@@ -27,11 +28,16 @@ public class Recipe implements IRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputForRecipe(ItemStack[] test) {
|
||||
public boolean isInputForRecipe(List<ItemStack> test) {
|
||||
return isInputForRecipe(test, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputForRecipe(List<ItemStack> test, List<FluidStack> testFluids) {
|
||||
if(test == null) {
|
||||
return false;
|
||||
}
|
||||
if(test.length != inputs.length) {
|
||||
if(test.size() != inputs.length) {
|
||||
return false;
|
||||
}
|
||||
List<RecipeInput> recIns = new ArrayList<RecipeInput>(Arrays.asList(inputs));
|
||||
@@ -47,9 +53,42 @@ public class Recipe implements IRecipe {
|
||||
recIns.remove(ri);
|
||||
}
|
||||
}
|
||||
if(testFluids != null) {
|
||||
for (FluidStack input : testFluids) {
|
||||
if(input != null) {
|
||||
RecipeInput ri = getInputForStack(input);
|
||||
if(ri == null || ri.getInput() == null) {
|
||||
return false;
|
||||
}
|
||||
if(input.amount < ri.getFluidInput().amount) {
|
||||
return false;
|
||||
}
|
||||
recIns.remove(ri);
|
||||
}
|
||||
}
|
||||
}
|
||||
return recIns.size() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidInput(ItemStack item) {
|
||||
return getInputForStack(item) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidInput(FluidStack fluid) {
|
||||
return getInputForStack(fluid) != null;
|
||||
}
|
||||
|
||||
private RecipeInput getInputForStack(FluidStack input) {
|
||||
for (RecipeInput ri : inputs) {
|
||||
if(ri.isInput(input)) {
|
||||
return ri;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private RecipeInput getInputForStack(ItemStack input) {
|
||||
for (RecipeInput ri : inputs) {
|
||||
if(ri.isInput(input)) {
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package crazypants.enderio.machine.recipe;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class RecipeInput {
|
||||
|
||||
private final ItemStack input;
|
||||
private final boolean useMeta;
|
||||
|
||||
private final FluidStack fluid;
|
||||
|
||||
public RecipeInput(ItemStack input) {
|
||||
this(input, true);
|
||||
}
|
||||
@@ -14,19 +17,45 @@ public class RecipeInput {
|
||||
public RecipeInput(ItemStack input, boolean useMeta) {
|
||||
this.input = input;
|
||||
this.useMeta = useMeta;
|
||||
this.fluid = null;
|
||||
}
|
||||
|
||||
public RecipeInput(FluidStack fluid) {
|
||||
this.input = null;
|
||||
this.useMeta = false;
|
||||
this.fluid = fluid;
|
||||
}
|
||||
|
||||
public boolean isFluid() {
|
||||
return fluid != null;
|
||||
}
|
||||
|
||||
public ItemStack getInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
public FluidStack getFluidInput() {
|
||||
return fluid;
|
||||
}
|
||||
|
||||
public boolean isInput(ItemStack test) {
|
||||
if(test == null || input == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(useMeta) {
|
||||
return test.getItem() == input.getItem() && test.getItemDamage() == input.getItemDamage();
|
||||
}
|
||||
return test.getItem() == input.getItem();
|
||||
}
|
||||
|
||||
public boolean isInput(FluidStack test) {
|
||||
if(test == null || fluid == null) {
|
||||
return false;
|
||||
}
|
||||
return test.isFluidEqual(fluid);
|
||||
}
|
||||
|
||||
public ItemStack[] getEquivelentInputs() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,11 @@ package crazypants.enderio.machine.recipe;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class RecipeOutput {
|
||||
|
||||
private final FluidStack outputFluid;
|
||||
private final ItemStack output;
|
||||
private final float chance;
|
||||
private float exp;
|
||||
@@ -38,6 +40,14 @@ public class RecipeOutput {
|
||||
this.output = output.copy();
|
||||
this.chance = chance;
|
||||
this.exp = exp;
|
||||
outputFluid = null;
|
||||
}
|
||||
|
||||
public RecipeOutput(FluidStack output) {
|
||||
this.outputFluid = output;
|
||||
this.output = null;
|
||||
chance = 1;
|
||||
exp = 0;
|
||||
}
|
||||
|
||||
public float getChance() {
|
||||
@@ -52,4 +62,8 @@ public class RecipeOutput {
|
||||
return output;
|
||||
}
|
||||
|
||||
public FluidStack getFluidOutput() {
|
||||
return outputFluid;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package crazypants.enderio.machine.still;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.AbstractMachineBlock;
|
||||
|
||||
public class BlockStill extends AbstractMachineBlock<TileStill> {
|
||||
|
||||
public static BlockStill create() {
|
||||
BlockStill res = new BlockStill();
|
||||
res.init();
|
||||
return res;
|
||||
}
|
||||
|
||||
public BlockStill() {
|
||||
super(ModObject.blockStill, TileStill.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
// The server needs the container as it manages the adding and removing of
|
||||
// items, which are then sent to the client for display
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileStill) {
|
||||
return new ContainerStill(player.inventory, (TileStill) te);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileStill) {
|
||||
return new GuiStill(player.inventory, (TileStill) te);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getGuiId() {
|
||||
return GuiHandler.GUI_ID_STILL;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getMachineFrontIconKey(boolean active) {
|
||||
if(active) {
|
||||
return "enderio:stillFrontOn";
|
||||
}
|
||||
return "enderio:stillFront";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package crazypants.enderio.machine.still;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import crazypants.enderio.machine.AbstractMachineContainer;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
|
||||
public class ContainerStill extends AbstractMachineContainer {
|
||||
|
||||
public ContainerStill(InventoryPlayer playerInv, AbstractMachineEntity te) {
|
||||
super(playerInv, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addMachineSlots(InventoryPlayer playerInv) {
|
||||
addSlotToContainer(new Slot(tileEntity, 0, 56, 12) {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack) {
|
||||
return tileEntity.isItemValidForSlot(0, itemStack);
|
||||
}
|
||||
});
|
||||
addSlotToContainer(new Slot(tileEntity, 1, 105, 12) {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack) {
|
||||
return tileEntity.isItemValidForSlot(1, itemStack);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package crazypants.enderio.machine.still;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import crazypants.enderio.machine.GuiMachineBase;
|
||||
import crazypants.render.RenderUtil;
|
||||
|
||||
public class GuiStill extends GuiMachineBase {
|
||||
|
||||
private final TileStill still;
|
||||
|
||||
public GuiStill(InventoryPlayer inventory, TileStill te) {
|
||||
super(te, new ContainerStill(inventory, te));
|
||||
still = te;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the background layer for the GuiContainer (everything behind the
|
||||
* items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderUtil.bindTexture("enderio:textures/gui/still.png");
|
||||
int guiLeft = (width - xSize) / 2;
|
||||
int guiTop = (height - ySize) / 2;
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
// int i1 = tileEntity.getProgressScaled(24);
|
||||
// drawTexturedModalRect(guiLeft + 79, guiTop + 31, 200, 0, 18, i1 + 1);
|
||||
|
||||
if(still.getProgress() < 1 && still.getProgress() > 0) {
|
||||
int scaled = still.getProgressScaled(12);
|
||||
drawTexturedModalRect(guiLeft + 89, guiTop + 76 - scaled, 176, 12 - scaled, 14, scaled + 2);
|
||||
}
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPowerX() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPowerY() {
|
||||
return 13;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPowerHeight() {
|
||||
return 60;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package crazypants.enderio.machine.still;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.crafting.IEnderIoRecipe;
|
||||
import crazypants.enderio.machine.MachineRecipeInput;
|
||||
import crazypants.enderio.machine.recipe.AbstractMachineRecipe;
|
||||
import crazypants.enderio.machine.recipe.IRecipe;
|
||||
|
||||
public class StillMachineRecipe extends AbstractMachineRecipe {
|
||||
|
||||
private StillRecipe nutDistRecipe = new StillRecipe(new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME), new FluidStack(
|
||||
EnderIO.fluidNutrientDistillation, FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(Items.rotten_flesh), new ItemStack(Items.nether_wart));
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
return "StillRecipe";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipe getRecipeForInputs(MachineRecipeInput[] inputs) {
|
||||
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
List<FluidStack> fluids = new ArrayList<FluidStack>();
|
||||
for (MachineRecipeInput mi : inputs) {
|
||||
if(mi != null) {
|
||||
if(mi.item != null) {
|
||||
items.add(mi.item);
|
||||
} else if(mi.fluid != null) {
|
||||
fluids.add(mi.fluid);
|
||||
}
|
||||
}
|
||||
}
|
||||
return StillRecipeManager.instance.getRecipeForInput(items, fluids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidInput(MachineRecipeInput input) {
|
||||
if(input == null) {
|
||||
return false;
|
||||
}
|
||||
return StillRecipeManager.instance.isValidInput(input);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMachineName() {
|
||||
return ModObject.blockStill.unlocalisedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExperianceForOutput(ItemStack output) {
|
||||
// //return AlloyRecipeManager.instance.getExperianceForOutput(output);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IEnderIoRecipe> getAllRecipes() {
|
||||
List<IEnderIoRecipe> result = new ArrayList<IEnderIoRecipe>();
|
||||
// List<IAlloyRecipe> recipes = AlloyRecipeManager.getInstance().getRecipes();
|
||||
// for (IRecipe cr : recipes) {
|
||||
// List<IRecipeComponent> components = new ArrayList<IRecipeComponent>();
|
||||
// for (crazypants.enderio.machine.recipe.RecipeInput ri : cr.getInputs()) {
|
||||
// if(ri.getInput() != null) {
|
||||
// IRecipeInput input = new RecipeInput(ri.getInput(), -1, ri.getEquivelentInputs());
|
||||
// components.add(input);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (RecipeOutput co : cr.getOutputs()) {
|
||||
// IRecipeOutput output = new crazypants.enderio.crafting.impl.RecipeOutput(co.getOutput(), co.getChance());
|
||||
// components.add(output);
|
||||
// }
|
||||
// result.add(new EnderIoRecipe(IEnderIoRecipe.ALLOY_SMELTER_ID, cr.getEnergyRequired(), components));
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package crazypants.enderio.machine.still;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import crazypants.enderio.machine.recipe.IRecipe;
|
||||
import crazypants.enderio.machine.recipe.RecipeInput;
|
||||
import crazypants.enderio.machine.recipe.RecipeOutput;
|
||||
|
||||
public class StillRecipe implements IRecipe {
|
||||
|
||||
protected final FluidStack inputFluidStack;
|
||||
protected final ItemStack[] inputStacks;
|
||||
protected final FluidStack outputFluidStack;
|
||||
|
||||
protected final RecipeInput[] inputs;
|
||||
protected final RecipeOutput[] output;
|
||||
|
||||
public StillRecipe(FluidStack inputFluid, FluidStack outputFluid, ItemStack... inputStacks) {
|
||||
this.inputFluidStack = inputFluid;
|
||||
this.inputStacks = inputStacks;
|
||||
this.outputFluidStack = outputFluid;
|
||||
|
||||
List<RecipeInput> inputList = new ArrayList<RecipeInput>(3);
|
||||
if(inputFluidStack != null) {
|
||||
inputList.add(new RecipeInput(inputFluid));
|
||||
}
|
||||
if(inputStacks != null) {
|
||||
for (ItemStack in : inputStacks) {
|
||||
if(in != null) {
|
||||
inputList.add(new RecipeInput(in));
|
||||
}
|
||||
}
|
||||
}
|
||||
inputs = inputList.toArray(new RecipeInput[inputList.size()]);
|
||||
output = new RecipeOutput[] { new RecipeOutput(outputFluidStack) };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return inputFluidStack != null && inputStacks != null && inputStacks.length > 0 && inputStacks.length < 3 && outputFluidStack != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEnergyRequired() {
|
||||
return 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeOutput[] getOutputs() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeInput[] getInputs() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getInputStacks() {
|
||||
return inputStacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidInput(ItemStack item) {
|
||||
if(item == null) {
|
||||
return false;
|
||||
}
|
||||
for (RecipeInput ri : inputs) {
|
||||
if(item != null && ri.isInput(item)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidInput(FluidStack item) {
|
||||
if(item == null) {
|
||||
return false;
|
||||
}
|
||||
for (RecipeInput ri : inputs) {
|
||||
if(item.getFluid() != null && item.isFluidEqual(ri.getFluidInput())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputForRecipe(List<ItemStack> test) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputForRecipe(List<ItemStack> test, List<FluidStack> testFluids) {
|
||||
if(!isValid() || test == null || test.size() != 2 || testFluids == null || testFluids.size() != 1 || testFluids.get(0) == null) {
|
||||
return false;
|
||||
}
|
||||
boolean validFluid = inputFluidStack.isFluidEqual(testFluids.get(0)) && inputFluidStack.amount <= testFluids.get(0).amount;
|
||||
if(!validFluid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
if(!containsInput(inputs[i], test)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean containsInput(RecipeInput recipeInput, List<ItemStack> test) {
|
||||
for (ItemStack stack : test) {
|
||||
if(recipeInput.isInput(stack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package crazypants.enderio.machine.still;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.Log;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.MachineRecipeInput;
|
||||
import crazypants.enderio.machine.MachineRecipeRegistry;
|
||||
import crazypants.enderio.machine.recipe.IRecipe;
|
||||
import crazypants.enderio.machine.recipe.RecipeConfig;
|
||||
|
||||
public class StillRecipeManager {
|
||||
|
||||
private static final String CORE_FILE_NAME = "StillRecipes_Core.xml";
|
||||
private static final String CUSTOM_FILE_NAME = "StillRecipes_User.xml";
|
||||
|
||||
static final StillRecipeManager instance = new StillRecipeManager();
|
||||
|
||||
public static StillRecipeManager getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private final List<IRecipe> recipes = new ArrayList<IRecipe>();
|
||||
|
||||
public StillRecipeManager() {
|
||||
}
|
||||
|
||||
public void loadRecipesFromConfig() {
|
||||
// RecipeConfig config = RecipeConfig.loadRecipeConfig(CORE_FILE_NAME, CUSTOM_FILE_NAME, null);
|
||||
// if(config != null) {
|
||||
// processConfig(config);
|
||||
// } else {
|
||||
// Log.error("Could not load recipes for SAG Mill.");
|
||||
// }
|
||||
MachineRecipeRegistry.instance.registerRecipe(ModObject.blockStill.unlocalisedName, new StillMachineRecipe());
|
||||
addRecipe(new StillRecipe(new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME), new FluidStack(
|
||||
EnderIO.fluidNutrientDistillation, FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(Items.rotten_flesh), new ItemStack(Items.nether_wart)));
|
||||
}
|
||||
|
||||
public void addCustumRecipes(String xmlDef) {
|
||||
// RecipeConfig config;
|
||||
// try {
|
||||
// config = RecipeConfigParser.parse(xmlDef, null);
|
||||
// } catch (Exception e) {
|
||||
// Log.error("Error parsing custom xml");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if(config == null) {
|
||||
// Log.error("Could process custom XML");
|
||||
// return;
|
||||
// }
|
||||
// processConfig(config);
|
||||
}
|
||||
|
||||
public IRecipe getRecipeForInput(List<ItemStack> input, List<FluidStack> inputFluids) {
|
||||
if(input == null || inputFluids == null) {
|
||||
return null;
|
||||
}
|
||||
for (IRecipe recipe : recipes) {
|
||||
if(recipe.isInputForRecipe(input, inputFluids)) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void processConfig(RecipeConfig config) {
|
||||
// if(config.isDumpItemRegistery()) {
|
||||
// Util.dumpModObjects(new File(Config.configDirectory, "modObjectsRegistery.txt"));
|
||||
// }
|
||||
// if(config.isDumpOreDictionary()) {
|
||||
// Util.dumpOreNames(new File(Config.configDirectory, "oreDictionaryRegistery.txt"));
|
||||
// }
|
||||
//
|
||||
// List<Recipe> newRecipes = config.getRecipes(true);
|
||||
// Log.info("Found " + newRecipes.size() + " valid SAG Mill recipes in config.");
|
||||
// for (Recipe rec : newRecipes) {
|
||||
// addRecipe(rec);
|
||||
// }
|
||||
// Log.info("Finished processing Alloy Smelter recipes. " + recipes.size() + " recipes avaliable.");
|
||||
}
|
||||
|
||||
public void addRecipe(IRecipe recipe) {
|
||||
if(recipe == null || !recipe.isValid()) {
|
||||
Log.debug("Could not add invalid recipe: " + recipe);
|
||||
return;
|
||||
}
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
public List<IRecipe> getRecipes() {
|
||||
return recipes;
|
||||
}
|
||||
|
||||
public boolean isValidInput(MachineRecipeInput input) {
|
||||
for (IRecipe recipe : recipes) {
|
||||
if(input.item != null && recipe.isValidInput(input.item)) {
|
||||
return true;
|
||||
} else if(input.fluid != null && recipe.isValidInput(input.fluid)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package crazypants.enderio.machine.still;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.AbstractPoweredTaskEntity;
|
||||
import crazypants.enderio.machine.MachineRecipeInput;
|
||||
import crazypants.enderio.machine.SlotDefinition;
|
||||
|
||||
public class TileStill extends AbstractPoweredTaskEntity {
|
||||
|
||||
public TileStill() {
|
||||
super(new SlotDefinition(0, 1, -1, -1, -1, -1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return ModObject.blockStill.unlocalisedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMachineName() {
|
||||
return ModObject.blockStill.unlocalisedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isMachineItemValidForSlot(int i, ItemStack itemstack) {
|
||||
return StillRecipeManager.getInstance().isValidInput(new MachineRecipeInput(i, itemstack));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user