summaryrefslogtreecommitdiff
path: root/ihl/processing/metallurgy/VulcanizationExtrudingMoldTileEntity.java
diff options
context:
space:
mode:
Diffstat (limited to 'ihl/processing/metallurgy/VulcanizationExtrudingMoldTileEntity.java')
-rw-r--r--ihl/processing/metallurgy/VulcanizationExtrudingMoldTileEntity.java252
1 files changed, 115 insertions, 137 deletions
diff --git a/ihl/processing/metallurgy/VulcanizationExtrudingMoldTileEntity.java b/ihl/processing/metallurgy/VulcanizationExtrudingMoldTileEntity.java
index 40d44e4..e052ad7 100644
--- a/ihl/processing/metallurgy/VulcanizationExtrudingMoldTileEntity.java
+++ b/ihl/processing/metallurgy/VulcanizationExtrudingMoldTileEntity.java
@@ -9,6 +9,8 @@ import ic2.api.energy.event.EnergyTileLoadEvent;
import ic2.api.energy.event.EnergyTileUnloadEvent;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.network.INetworkDataProvider;
+import ic2.api.recipe.IRecipeInput;
+import ic2.api.recipe.RecipeInputItemStack;
import ic2.api.tile.IWrenchable;
import ic2.core.IC2;
import ihl.items_blocks.FlexibleCableItem;
@@ -28,144 +30,127 @@ import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
-public class VulcanizationExtrudingMoldTileEntity extends TileEntity implements IWrenchable, INetworkDataProvider, IEnergySink, IProductionLine, IFluidHandler{
+public class VulcanizationExtrudingMoldTileEntity extends TileEntity
+ implements IWrenchable, INetworkDataProvider, IEnergySink, IProductionLine, IFluidHandler {
- private short facing=2;
- private short lastFacing=2;
- public double energy;
- public int maxStorage=64;
- private double energyConsume=16D;
- private boolean addedToEnergyNet=false;
+ private short facing = 2;
+ private short lastFacing = 2;
+ public double energy;
+ public int maxStorage = 64;
+ private double energyConsume = 16D;
+ private boolean addedToEnergyNet = false;
private FluidTank fluidTank = new FluidTank(5000);
- protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("vulcanizationextrudingmold");
+ protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager(
+ "vulcanizationextrudingmold");
- public VulcanizationExtrudingMoldTileEntity()
- {
+ public VulcanizationExtrudingMoldTileEntity() {
super();
}
-
- public static void addRecipe(FluidStack inputFluid,ItemStack input,ItemStack output1)
- {
- recipeManager.addRecipe(new UniversalRecipeInput((new FluidStack[] {inputFluid}),(new ItemStack[] {input})),new UniversalRecipeOutput(null,(new ItemStack[] {output1}),200));
- }
-
- public boolean enableUpdateEntity()
- {
- return IC2.platform.isSimulating();
- }
-
- @Override
- public void invalidate()
- {
- if (IC2.platform.isSimulating()&&this.addedToEnergyNet)
- {
- MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
- this.addedToEnergyNet = false;
- }
- super.invalidate();
- }
-
+
+ public static void addRecipe(FluidStack inputFluid, ItemStack input, ItemStack output1) {
+ recipeManager.addRecipe(
+ new UniversalRecipeInput((new FluidStack[] { inputFluid }),
+ (new IRecipeInput[] { new RecipeInputItemStack(input) })),
+ new UniversalRecipeOutput(null, (new ItemStack[] { output1 }), 200));
+ }
+
+ public boolean enableUpdateEntity() {
+ return IC2.platform.isSimulating();
+ }
+
+ @Override
+ public void invalidate() {
+ if (IC2.platform.isSimulating() && this.addedToEnergyNet) {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
+ this.addedToEnergyNet = false;
+ }
+ super.invalidate();
+ }
+
@Override
- public List<String> getNetworkedFields()
- {
- List<String> fields = new ArrayList();
+ public List<String> getNetworkedFields() {
+ List<String> fields = new ArrayList<String>();
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<this.maxStorage)
- {
- this.energy+=amount;
- return 0.0D;
- }
- else
- {
- return amount;
- }
+ public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) {
+ if (this.energy < this.maxStorage) {
+ this.energy += amount;
+ return 0.0D;
+ } else {
+ return amount;
+ }
}
@Override
- public boolean acceptsEnergyFrom(TileEntity emitter,
- ForgeDirection direction)
- {
+ public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) {
return true;
}
private ItemStack processWire(ItemStack wire, boolean doProcess) {
- UniversalRecipeOutput rOutput = VulcanizationExtrudingMoldTileEntity.recipeManager.getOutputFor(Arrays.asList(new FluidStack[] {this.fluidTank.getFluid()}),Arrays.asList(new ItemStack[] {wire}), false, false);
- if(rOutput==null || !(wire.getItem() instanceof FlexibleCableItem) || this.energy<this.energyConsume)
- {
+ UniversalRecipeOutput rOutput = VulcanizationExtrudingMoldTileEntity.recipeManager.getOutputFor(
+ Arrays.asList(new FluidStack[] { this.fluidTank.getFluid() }), Arrays.asList(new ItemStack[] { wire }),
+ false, false);
+ if (rOutput == null || this.energy < this.energyConsume) {
return wire;
}
- UniversalRecipeInput rInput = VulcanizationExtrudingMoldTileEntity.recipeManager.getRecipeInput(Arrays.asList(new FluidStack[] {this.fluidTank.getFluid()}),Arrays.asList(new ItemStack[] {wire}));
+ UniversalRecipeInput rInput = VulcanizationExtrudingMoldTileEntity.recipeManager.getRecipeInput(
+ Arrays.asList(new FluidStack[] { this.fluidTank.getFluid() }), Arrays.asList(new ItemStack[] { wire }));
ItemStack cableAsRO = rOutput.getItemOutputs().get(0).itemStack;
ItemStack cable = wire.copy();
FlexibleCableItem fci = (FlexibleCableItem) cableAsRO.getItem();
cable.stackTagCompound.setString("insulationMaterial", fci.getInsulationMaterial(cableAsRO));
cable.stackTagCompound.setInteger("insulationThickness", fci.getInsulationThickness(cableAsRO));
- cable.stackTagCompound.setInteger("maxVoltage", IHLUtils.getInsulationMaxVoltage(fci.getInsulationMaterial(cableAsRO), fci.getInsulationThickness(cableAsRO)));
- if(doProcess)
- {
- this.energy-=this.energyConsume;
- this.fluidTank.drain(rInput.getFluidInputs().get(0).getAmount()*IHLUtils.getWireLength(cable), true);
+ cable.stackTagCompound.setInteger("maxVoltage", IHLUtils
+ .getInsulationMaxVoltage(fci.getInsulationMaterial(cableAsRO), fci.getInsulationThickness(cableAsRO)));
+ if (doProcess) {
+ this.energy -= this.energyConsume;
+ this.fluidTank.drain(rInput.getFluidInputs().get(0).getAmount() * IHLUtils.getWireLength(cable), true);
}
return cable;
}
-
+
@Override
public boolean canProcess(ItemStack wire) {
- ItemStack cable = this.processWire(wire,false);
+ ItemStack cable = this.processWire(wire, false);
ForgeDirection dir = ForgeDirection.getOrientation(getFacing()).getRotation(ForgeDirection.UP);
- TileEntity te = worldObj.getTileEntity(xCoord+dir.offsetX,yCoord+dir.offsetY,zCoord+dir.offsetZ);
- if(te instanceof IProductionLine)
- {
- if(ForgeDirection.getOrientation(((IProductionLine)te).getFacing()).equals(dir.getRotation(ForgeDirection.DOWN)))
- {
- return ((IProductionLine)te).canProcess(cable);
+ TileEntity te = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
+ if (te instanceof IProductionLine) {
+ if (ForgeDirection.getOrientation(((IProductionLine) te).getFacing())
+ .equals(dir.getRotation(ForgeDirection.DOWN))) {
+ return ((IProductionLine) te).canProcess(cable);
}
}
return false;
@@ -232,12 +212,12 @@ public class VulcanizationExtrudingMoldTileEntity extends TileEntity implements
@Override
public void process(ItemStack wire) {
- ItemStack cable = this.processWire(wire,true);
+ ItemStack cable = this.processWire(wire, true);
ForgeDirection dir = ForgeDirection.getOrientation(getFacing()).getRotation(ForgeDirection.UP);
- TileEntity te = worldObj.getTileEntity(xCoord+dir.offsetX,yCoord+dir.offsetY,zCoord+dir.offsetZ);
- if(te instanceof IProductionLine && ForgeDirection.getOrientation(((IProductionLine)te).getFacing()).equals(dir.getRotation(ForgeDirection.DOWN)))
- {
- ((IProductionLine)te).process(cable);
+ TileEntity te = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
+ if (te instanceof IProductionLine && ForgeDirection.getOrientation(((IProductionLine) te).getFacing())
+ .equals(dir.getRotation(ForgeDirection.DOWN))) {
+ ((IProductionLine) te).process(cable);
}
}
@@ -248,7 +228,7 @@ public class VulcanizationExtrudingMoldTileEntity extends TileEntity implements
@Override
public boolean canFill(ForgeDirection arg0, Fluid arg1) {
- return ForgeDirection.getOrientation(this.facing)==arg0;
+ return ForgeDirection.getOrientation(this.facing) == arg0;
}
@Override
@@ -268,12 +248,10 @@ public class VulcanizationExtrudingMoldTileEntity extends TileEntity implements
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection arg0) {
- // TODO Auto-generated method stub
- return null;
+ return new FluidTankInfo[] {this.fluidTank.getInfo()};
}
- public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes()
- {
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
return recipeManager.getRecipes();
}
}