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/BasicElectricMotorTileEntity.java | 373 ++++++++++----------- 1 file changed, 168 insertions(+), 205 deletions(-) (limited to 'ihl/processing/metallurgy/BasicElectricMotorTileEntity.java') diff --git a/ihl/processing/metallurgy/BasicElectricMotorTileEntity.java b/ihl/processing/metallurgy/BasicElectricMotorTileEntity.java index 47cfda9..a2fa219 100644 --- a/ihl/processing/metallurgy/BasicElectricMotorTileEntity.java +++ b/ihl/processing/metallurgy/BasicElectricMotorTileEntity.java @@ -21,125 +21,116 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; -public abstract class BasicElectricMotorTileEntity extends FlexibleCableHolderBaseTileEntity implements IHasGui, INetworkClientTileEntityEventListener, IEnergySink{ +public abstract class BasicElectricMotorTileEntity extends FlexibleCableHolderBaseTileEntity + implements IHasGui, INetworkClientTileEntityEventListener, IEnergySink { - public final IHLInvSlotDischarge dischargeSlot; + public final IHLInvSlotDischarge dischargeSlot; public short progress; - protected short operationLength=600; - protected final double energyConsume=0.1D; - public double energy; - public int maxStorage=128; - private boolean addedToEnergyNet=false; - - public BasicElectricMotorTileEntity() - { + protected short operationLength = 600; + protected double energyConsume = 1d; + public double energy; + public int maxStorage = 128; + private boolean addedToEnergyNet = false; + + public BasicElectricMotorTileEntity() { super(); dischargeSlot = new IHLInvSlotDischarge(this, 1, Access.IO, 4, InvSlot.InvSide.BOTTOM); } - @Override public String getInventoryName() { return "Lathe"; } - - public boolean enableUpdateEntity() - { - return IC2.platform.isSimulating(); - } - - @Override - public void onLoaded() - { - super.onLoaded(); - if (IC2.platform.isSimulating()&&!this.addedToEnergyNet) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); - this.addedToEnergyNet = true; - } - } - - @Override - public void onUnloaded() - { - if (IC2.platform.isSimulating()&&this.addedToEnergyNet) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); - this.addedToEnergyNet = false; - } - - super.onUnloaded(); - } - - + + public boolean enableUpdateEntity() { + return IC2.platform.isSimulating(); + } + + @Override + public void onLoaded() { + super.onLoaded(); + if (IC2.platform.isSimulating() && !this.addedToEnergyNet) { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; + } + } + + @Override + public void onUnloaded() { + if (IC2.platform.isSimulating() && this.addedToEnergyNet) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + this.addedToEnergyNet = false; + } + + super.onUnloaded(); + } + @SuppressWarnings("unchecked") @Override - public void setFacing(short facing1) - { + public void setFacing(short facing1) { short facing2 = (short) Math.max(facing1, 2); - double d=0.3D; - double f=-0.1D; - if (IC2.platform.isSimulating()&&this.addedToEnergyNet) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); - this.addedToEnergyNet = false; - } + double d = 0.3D; + double f = -0.1D; + if (IC2.platform.isSimulating() && this.addedToEnergyNet) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + this.addedToEnergyNet = false; + } double range = 2D; - AxisAlignedBB searchArea = AxisAlignedBB.getBoundingBox(connectionX-range,connectionY-range,connectionZ-range,connectionX+range,connectionY+range,connectionZ+range); + AxisAlignedBB searchArea = AxisAlignedBB.getBoundingBox(connectionX - range, connectionY - range, + connectionZ - range, connectionX + range, connectionY + range, connectionZ + range); List 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