From 2636ccdd67b5f33421ab7f9152021bc4ebc147b3 Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Tue, 7 Feb 2017 20:16:24 +0300 Subject: Fixed an ore dictionary recipes of Iron workbench which using wrong set of items. Fixed wire recipe input. All recipes of Iron workbench now use fluid container input and will drop an empty container. --- .../metallurgy/AchesonFurnanceTileEntity.java | 123 +++---- .../metallurgy/BasicElectricMotorTileEntity.java | 373 ++++++++++----------- .../VulcanizationExtrudingMoldTileEntity.java | 252 +++++++------- .../WoodenRollingMachinePart1TileEntity.java | 10 +- 4 files changed, 342 insertions(+), 416 deletions(-) (limited to 'ihl/processing/metallurgy') diff --git a/ihl/processing/metallurgy/AchesonFurnanceTileEntity.java b/ihl/processing/metallurgy/AchesonFurnanceTileEntity.java index 0c1b75f..5709cb9 100644 --- a/ihl/processing/metallurgy/AchesonFurnanceTileEntity.java +++ b/ihl/processing/metallurgy/AchesonFurnanceTileEntity.java @@ -20,28 +20,28 @@ import net.minecraft.item.ItemStack; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class AchesonFurnanceTileEntity extends MachineBaseTileEntity{ +public class AchesonFurnanceTileEntity extends MachineBaseTileEntity { - public final ApparatusProcessableInvSlot inputElectrode; + public final ApparatusProcessableInvSlot inputElectrode; protected static UniversalRecipeManager recipeManager = new UniversalRecipeManager("achesonfurnace"); - private final RecipeInputOreDict[] validElectrodeTypes=new RecipeInputOreDict[] {new RecipeInputOreDict("stickCoal"),new RecipeInputOreDict("stickGraphite"),new RecipeInputOreDict("plateCoal"),new RecipeInputOreDict("plateGraphite")}; - - public AchesonFurnanceTileEntity() - { + private final RecipeInputOreDict[] validElectrodeTypes = new RecipeInputOreDict[] { + new RecipeInputOreDict("stickCoal"), new RecipeInputOreDict("stickGraphite"), + new RecipeInputOreDict("plateCoal"), new RecipeInputOreDict("plateGraphite") }; + + public AchesonFurnanceTileEntity() { super(2); inputElectrode = new ApparatusProcessableInvSlot(this, "inputElectrode", 1, Access.IO, 2, 1); } - - public static void addRecipe(IRecipeInput input1, IRecipeInput input2, String output1) - { - recipeManager.addRecipe(new UniversalRecipeInput(null,new IRecipeInput [] {input1,input2}),new UniversalRecipeOutput(null,new ItemStack [] {IHLUtils.getThisModItemStack(output1)},20)); + + public static void addRecipe(IRecipeInput input1, IRecipeInput input2, String output1) { + recipeManager.addRecipe(new UniversalRecipeInput(null, new IRecipeInput[] { input1, input2 }), + new UniversalRecipeOutput(null, new ItemStack[] { IHLUtils.getThisModItemStack(output1) }, 20)); } @Override - public String getStartSoundFile() - { - return "Machines/Electro Furnace/ElectroFurnaceLoop.ogg"; - } + public String getStartSoundFile() { + return "Machines/Electro Furnace/ElectroFurnaceLoop.ogg"; + } @Override public String getLoopSoundFile() { @@ -68,80 +68,63 @@ public class AchesonFurnanceTileEntity extends MachineBaseTileEntity{ public ContainerBase getGuiContainer(EntityPlayer player) { return new AchesonFurnanceContainer(player, this); } - + @Override - public void operate() - { - List output = AchesonFurnanceTileEntity.recipeManager.getOutputFor(getInput(), true, true).getItemOutputs(); - for(int i=0; i output = AchesonFurnanceTileEntity.recipeManager + .getOutputFor(getInput(), true, true).getItemOutputs(); + for (int i = 0; i < this.inputElectrode.size(); i++) { ItemStack electrodeIS = this.inputElectrode.get(i); - if(this.validElectrodeTypes[0].matches(electrodeIS)) - { + if (this.validElectrodeTypes[0].matches(electrodeIS)) { this.inputElectrode.put(i, IHLUtils.getThisModItemStack("stickGraphite")); - } - else if(this.validElectrodeTypes[2].matches(electrodeIS)) - { + } else if (this.validElectrodeTypes[2].matches(electrodeIS)) { this.inputElectrode.put(i, IHLUtils.getThisModItemStack("plateGraphite")); } } - for(int i=0; ii) - { + for (int i = 0; i < this.input.size(); i++) { + if (output.size() > i) { ItemStack stack = output.get(i).itemStack.copy(); - stack.stackSize=Math.round(output.get(i).quantity); - this.input.put(i,stack); + stack.stackSize = Math.round(output.get(i).quantity); + this.input.put(i, stack); } - if(this.input.get(i)!=null && this.input.get(i).stackSize<=0) - { + if (this.input.get(i) != null && this.input.get(i).stackSize <= 0) { this.input.put(i, null); } } - ItemStack crucible = input.getItemStack(IHLMod.crucible); - if(crucible!=null) - { - ((Crucible)crucible.getItem()).processContent(crucible, this); - } + ItemStack crucible = input.getItemStack(IHLMod.crucible); + if (crucible != null) { + ((Crucible) crucible.getItem()).processContent(crucible, this); + } } - + @Override - public boolean canOperate() - { - return this.isValidElectrode(this.inputElectrode.get(0)) && - this.isValidElectrode(this.inputElectrode.get(1)) && - this.getOutput()!=null; + public boolean canOperate() { + return this.isValidElectrode(this.inputElectrode.get(0)) && this.isValidElectrode(this.inputElectrode.get(1)) + && this.getOutput() != null; } - + @Override - public List[] getInput() - { - return new List[] {null, this.input.getItemStackList()}; + public List[] getInput() { + return new List[] { null, this.input.getItemStackList() }; } - public static Map getRecipes() { return recipeManager.getRecipes(); } - - @Override - public UniversalRecipeOutput getOutput() - { - return AchesonFurnanceTileEntity.recipeManager.getOutputFor(this.getInput(), false, false); - } - - private boolean isValidElectrode(ItemStack stack) - { - if(stack!=null) - { - for(int i=0;i nodeList = worldObj.getEntitiesWithinAABB(NodeEntity.class, searchArea); super.setFacing(facing2); - switch(getFacing()) - { - case 4: - setConnectionX(this.xCoord+0.5D); - setConnectionY(this.yCoord+d); - setConnectionZ(this.zCoord+1D-f); - break; - case 5: - setConnectionX(this.xCoord+0.5D); - setConnectionY(this.yCoord+d); - setConnectionZ(this.zCoord+f); - break; - case 2: - setConnectionX(this.xCoord+1D-f); - setConnectionY(this.yCoord+d); - setConnectionZ(this.zCoord+0.5D); - break; - case 3: - setConnectionX(this.xCoord+f); - setConnectionY(this.yCoord+d); - setConnectionZ(this.zCoord+0.5D); - break; - default: - setConnectionX(this.xCoord+1D-f); - setConnectionY(this.yCoord+d); - setConnectionZ(this.zCoord+0.5D); - break; - + switch (getFacing()) { + case 4: + setConnectionX(this.xCoord + 0.5D); + setConnectionY(this.yCoord + d); + setConnectionZ(this.zCoord + 1D - f); + break; + case 5: + setConnectionX(this.xCoord + 0.5D); + setConnectionY(this.yCoord + d); + setConnectionZ(this.zCoord + f); + break; + case 2: + setConnectionX(this.xCoord + 1D - f); + setConnectionY(this.yCoord + d); + setConnectionZ(this.zCoord + 0.5D); + break; + case 3: + setConnectionX(this.xCoord + f); + setConnectionY(this.yCoord + d); + setConnectionZ(this.zCoord + 0.5D); + break; + default: + setConnectionX(this.xCoord + 1D - f); + setConnectionY(this.yCoord + d); + setConnectionZ(this.zCoord + 0.5D); + break; + } - if(!nodeList.isEmpty()) - { + if (!nodeList.isEmpty()) { Iterator ei = nodeList.iterator(); - while(ei.hasNext()) - { - NodeEntity ne= ei.next(); - if((ne.prevAnchorEntity==null||ne.nextAnchorEntity==null) && this.cableListContains(ne.getChainUniqueID())) - { - ne.setVirtualNodePos(connectionX,connectionY,connectionZ); - } - } + while (ei.hasNext()) { + NodeEntity ne = ei.next(); + if ((ne.prevAnchorEntity == null || ne.nextAnchorEntity == null) + && this.cableListContains(ne.getChainUniqueID())) { + ne.setVirtualNodePos(connectionX, connectionY, connectionZ); + } + } + } + if (IC2.platform.isSimulating() && !this.addedToEnergyNet) { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; } - if (IC2.platform.isSimulating()&&!this.addedToEnergyNet) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); - this.addedToEnergyNet = true; - } } - + @Override - public double getDemandedEnergy() - { - return this.maxStorage-this.energy; + public double getDemandedEnergy() { + if(this.maxStorage - this.energy <= 1d) + { + return 0d; + } + return this.maxStorage - this.energy; } @Override @@ -148,154 +139,126 @@ public abstract class BasicElectricMotorTileEntity extends FlexibleCableHolderBa } @Override - public double injectEnergy(ForgeDirection directionFrom, double amount, - double voltage) { - if(this.energy 1.0D) - { - double amount = this.dischargeSlot.discharge(this.getDemandedEnergy(), false); - this.energy += amount; - } - if(this.gridID!=-1 && this.getGrid().energy>0D && this.energy=this.energyConsume) - { - this.energy-=this.energyConsume; - if (this.progress == 0) - { - IC2.network.get().initiateTileEntityEvent(this, 0, true); - } - ++this.progress; - if (this.progress >= this.operationLength) - { - this.operate(); - this.progress = 0; - IC2.network.get().initiateTileEntityEvent(this, 2, true); - } - } - else - { - if (this.progress != 0 && this.getActive()) - { - IC2.network.get().initiateTileEntityEvent(this, 1, true); - } - if (!this.canOperate()) - { - this.progress = 0; - } - } - - } - + + @Override + public void updateEntityServer() { + if (this.getDemandedEnergy() > 1.0D) { + double amount = this.dischargeSlot.discharge(this.getDemandedEnergy(), false); + this.energy += amount; + } + if (this.gridID != -1 && this.getGrid().energy > 0D && this.energy < this.maxStorage) { + this.energy += energyConsume * 10D; + this.getGrid().drawEnergy(energyConsume * 10D, this); + } + if (this.canOperate() && this.energy >= this.energyConsume) { + this.energy -= this.energyConsume; + if (this.progress == 0) { + IC2.network.get().initiateTileEntityEvent(this, 0, true); + } + ++this.progress; + if (this.progress >= this.operationLength) { + this.operate(); + this.progress = 0; + IC2.network.get().initiateTileEntityEvent(this, 2, true); + } + } else { + if (this.progress != 0 && this.getActive()) { + IC2.network.get().initiateTileEntityEvent(this, 1, true); + } + if (!this.canOperate()) { + this.progress = 0; + } + } + + } + public abstract List[] getInput(); + public abstract boolean canOperate(); - @Override - public void onGuiClosed(EntityPlayer arg0) {} - public int getEnergy() - { - return (int)this.energy; + @Override + public void onGuiClosed(EntityPlayer arg0) { } + public int getEnergy() { + return (int) this.energy; + } public int getGUIEnergy(int i) { - if(this.energy getNetworkedFields() - { - List fields = new ArrayList(); + public List getNetworkedFields() { + List fields = new ArrayList(); fields.add("facing"); return fields; - } - - @Override - public void updateEntity() - { - super.updateEntity(); - if (IC2.platform.isSimulating()&&!this.addedToEnergyNet) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); - this.addedToEnergyNet = true; - } - - if(lastFacing!=facing) - { + } + + @Override + public void updateEntity() { + super.updateEntity(); + if (IC2.platform.isSimulating() && !this.addedToEnergyNet) { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; + } + + if (lastFacing != facing) { IC2.network.get().updateTileEntityField(this, "facing"); - lastFacing=facing; - } - } - + lastFacing = facing; + } + } @Override public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { - return this.getFacing()!=side; + return this.getFacing() != side; } - @Override public short getFacing() { return this.facing; } - @Override - public void setFacing(short facing1) - { - if (IC2.platform.isSimulating()&&this.addedToEnergyNet) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); - this.addedToEnergyNet = false; - } - facing=(short) Math.max(2,facing1); - if(IC2.platform.isSimulating()) - { + public void setFacing(short facing1) { + if (IC2.platform.isSimulating() && this.addedToEnergyNet) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + this.addedToEnergyNet = false; + } + facing = (short) Math.max(2, facing1); + if (IC2.platform.isSimulating()) { IC2.network.get().updateTileEntityField(this, "facing"); - lastFacing=facing; + lastFacing = facing; + } + if (IC2.platform.isSimulating() && !this.addedToEnergyNet) { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; } - if (IC2.platform.isSimulating()&&!this.addedToEnergyNet) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); - this.addedToEnergyNet = true; - } } - @Override public boolean wrenchCanRemove(EntityPlayer entityPlayer) { return true; } - @Override public float getWrenchDropRate() { return 1F; } - @Override public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { return IHLUtils.getThisModItemStack("vulcanizationExtrudingMold"); } - + @Override - public void readFromNBT(NBTTagCompound nbttagcompound) - { - super.readFromNBT(nbttagcompound); - this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank")); - facing=nbttagcompound.getShort("facing"); - energy=nbttagcompound.getDouble("energy"); - } + public void readFromNBT(NBTTagCompound nbttagcompound) { + super.readFromNBT(nbttagcompound); + this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank")); + facing = nbttagcompound.getShort("facing"); + energy = nbttagcompound.getDouble("energy"); + } @Override - public void writeToNBT(NBTTagCompound nbttagcompound) - { - super.writeToNBT(nbttagcompound); - NBTTagCompound fluidTankTag = new NBTTagCompound(); - this.fluidTank.writeToNBT(fluidTankTag); - nbttagcompound.setTag("fluidTank", fluidTankTag); - nbttagcompound.setShort("facing", facing); - nbttagcompound.setDouble("energy", this.energy); - } - + public void writeToNBT(NBTTagCompound nbttagcompound) { + super.writeToNBT(nbttagcompound); + NBTTagCompound fluidTankTag = new NBTTagCompound(); + this.fluidTank.writeToNBT(fluidTankTag); + nbttagcompound.setTag("fluidTank", fluidTankTag); + nbttagcompound.setShort("facing", facing); + nbttagcompound.setDouble("energy", this.energy); + } + @Override - public double getDemandedEnergy() - { - return this.maxStorage-this.energy; + public double getDemandedEnergy() { + return this.maxStorage - this.energy; } @Override @@ -174,57 +159,52 @@ public class VulcanizationExtrudingMoldTileEntity extends TileEntity implements } @Override - public double injectEnergy(ForgeDirection directionFrom, double amount, - double voltage) { - if(this.energy getRecipes() - { + public static Map getRecipes() { return recipeManager.getRecipes(); } } diff --git a/ihl/processing/metallurgy/WoodenRollingMachinePart1TileEntity.java b/ihl/processing/metallurgy/WoodenRollingMachinePart1TileEntity.java index 31b6386..5c786c5 100644 --- a/ihl/processing/metallurgy/WoodenRollingMachinePart1TileEntity.java +++ b/ihl/processing/metallurgy/WoodenRollingMachinePart1TileEntity.java @@ -4,6 +4,8 @@ import java.util.List; import java.util.Map; import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputItemStack; +import ic2.api.recipe.RecipeInputOreDict; import ic2.core.ContainerBase; import ic2.core.IC2; import ic2.core.block.invslot.InvSlot.Access; @@ -132,9 +134,9 @@ public class WoodenRollingMachinePart1TileEntity extends BasicElectricMotorTileE @Override public void onGuiClosed(EntityPlayer arg0) {} - public static void addRecipe(ItemStack input, ItemStack input2, ItemStack input3, ItemStack output) + public static void addRecipe(RecipeInputItemStack recipeInputItemStack, RecipeInputItemStack recipeInputItemStack2, RecipeInputOreDict recipeInputOreDict, ItemStack output) { - recipeManager.addRecipe(new UniversalRecipeInput(null, (new ItemStack[] {input,input2,input3})), new UniversalRecipeOutput(null,(new ItemStack[] {output}),20)); + recipeManager.addRecipe(new UniversalRecipeInput(null, (new IRecipeInput[] {recipeInputItemStack,recipeInputItemStack2,recipeInputOreDict})), new UniversalRecipeOutput(null,(new ItemStack[] {output}),20)); } @@ -142,9 +144,9 @@ public class WoodenRollingMachinePart1TileEntity extends BasicElectricMotorTileE return recipeManager.getRecipes(); } - public static void addRecipe(ItemStack input, ItemStack input3, ItemStack output) + public static void addRecipe(RecipeInputOreDict recipeInputOreDict, RecipeInputOreDict recipeInputOreDict2, ItemStack output) { - recipeManager.addRecipe(new UniversalRecipeInput(null, (new ItemStack[] {input,input3})), new UniversalRecipeOutput(null,(new ItemStack[] {output}),20)); + recipeManager.addRecipe(new UniversalRecipeInput(null, (new IRecipeInput[] {recipeInputOreDict,recipeInputOreDict2})), new UniversalRecipeOutput(null,(new ItemStack[] {output}),20)); } @Override -- cgit v1.2.3