diff --git a/src/main/java/com/hbm/handler/nei/SILEXRecipeHandler.java b/src/main/java/com/hbm/handler/nei/SILEXRecipeHandler.java index cc1dba5b5..dd624fc18 100644 --- a/src/main/java/com/hbm/handler/nei/SILEXRecipeHandler.java +++ b/src/main/java/com/hbm/handler/nei/SILEXRecipeHandler.java @@ -48,7 +48,7 @@ public class SILEXRecipeHandler extends TemplateRecipeHandler { this.outputs = new ArrayList(); this.chances = new ArrayList(); this.produced = recipe.fluidProduced / recipe.fluidConsumed; - this.crystalStrength = EnumWavelengths.values()[recipe.laserStrength]; + this.crystalStrength = recipe.laserStrength; double weight = 0; diff --git a/src/main/java/com/hbm/interfaces/IFluidContainer.java b/src/main/java/com/hbm/interfaces/IFluidContainer.java index 34e2ed77f..04a0905c6 100644 --- a/src/main/java/com/hbm/interfaces/IFluidContainer.java +++ b/src/main/java/com/hbm/interfaces/IFluidContainer.java @@ -1,8 +1,5 @@ package com.hbm.interfaces; -import java.util.List; - -import com.hbm.inventory.FluidTank; import com.hbm.inventory.fluid.FluidType; public interface IFluidContainer { diff --git a/src/main/java/com/hbm/inventory/FluidTank.java b/src/main/java/com/hbm/inventory/FluidTank.java index eaad80666..5f0a0b41c 100644 --- a/src/main/java/com/hbm/inventory/FluidTank.java +++ b/src/main/java/com/hbm/inventory/FluidTank.java @@ -90,7 +90,7 @@ public class FluidTank { } //Fills tank from canisters - public void loadTank(int in, int out, ItemStack[] slots) { + public boolean loadTank(int in, int out, ItemStack[] slots) { FluidType inType = Fluids.NONE; if(slots[in] != null) { @@ -101,27 +101,27 @@ public class FluidTank { if(slots[in].getItem() == ModItems.fluid_barrel_infinite && type != Fluids.NONE) { this.fluid = this.maxFluid; - return; + return true; } if(slots[in].getItem() == ModItems.inf_water && this.type == Fluids.WATER) { this.fluid += 50; if(this.fluid > this.maxFluid) this.fluid = this.maxFluid; - return; + return true; } if(slots[in].getItem() == ModItems.inf_water_mk2 && this.type == Fluids.WATER) { this.fluid += 500; if(this.fluid > this.maxFluid) this.fluid = this.maxFluid; - return; + return true; } if(FluidContainerRegistry.getFluidContent(slots[in], type) <= 0) - return; + return false; } else { - return; + return false; } if(slots[in] != null && inType.getName().equals(type.getName()) && fluid + FluidContainerRegistry.getFluidContent(slots[in], type) <= maxFluid) { @@ -141,7 +141,11 @@ public class FluidTank { if(slots[in].stackSize <= 0) slots[in] = null; } + + return true; } + + return false; } //Fills canisters from tank diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplantNew.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplantNew.java index 51bf6bed4..adc336064 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplantNew.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplantNew.java @@ -1,7 +1,9 @@ package com.hbm.tileentity.machine; +import java.util.ArrayList; import java.util.List; +import com.hbm.blocks.BlockDummyable; import com.hbm.interfaces.IFluidAcceptor; import com.hbm.interfaces.IFluidSource; import com.hbm.inventory.FluidTank; @@ -13,12 +15,14 @@ import com.hbm.inventory.recipes.ChemplantRecipes; import com.hbm.inventory.recipes.ChemplantRecipes.ChemRecipe; import com.hbm.items.ModItems; import com.hbm.items.machine.ItemMachineUpgrade.UpgradeType; +import com.hbm.lib.Library; import com.hbm.tileentity.TileEntityMachineBase; import com.hbm.util.InventoryUtil; import api.hbm.energy.IEnergyUser; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; public class TileEntityMachineChemplantNew extends TileEntityMachineBase implements IEnergyUser, IFluidSource, IFluidAcceptor { @@ -63,6 +67,22 @@ public class TileEntityMachineChemplantNew extends TileEntityMachineBase impleme if(!worldObj.isRemote) { + this.power = Library.chargeTEFromItems(slots, 0, power, maxPower); + + if(!tanks[0].loadTank(17, 19, slots)) tanks[0].unloadTank(17, 19, slots); + if(!tanks[1].loadTank(18, 20, slots)) tanks[1].unloadTank(18, 20, slots); + + tanks[2].unloadTank(9, 11, slots); + tanks[3].unloadTank(10, 12, slots); + + if(worldObj.getTotalWorldTime() % 10 == 0) { + this.fillFluidInit(tanks[2].getTankType()); + this.fillFluidInit(tanks[3].getTankType()); + } + if(worldObj.getTotalWorldTime() % 20 == 0) { + this.updateConnections(); + } + UpgradeManager.eval(slots, 1, 3); int speedLevel = Math.min(UpgradeManager.getLevel(UpgradeType.SPEED), 3); @@ -104,6 +124,17 @@ public class TileEntityMachineChemplantNew extends TileEntityMachineBase impleme } } + private void updateConnections() { + + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset); + ForgeDirection rot = dir.getRotation(ForgeDirection.DOWN); + + this.trySubscribe(worldObj, xCoord + rot.offsetX * 3, yCoord, zCoord + rot.offsetZ * 3, rot); + this.trySubscribe(worldObj, xCoord - rot.offsetX * 2, yCoord, zCoord - rot.offsetZ * 2, rot.getOpposite()); + this.trySubscribe(worldObj, xCoord + rot.offsetX * 3 + dir.offsetX, yCoord, zCoord + rot.offsetZ * 3 + dir.offsetZ, rot); + this.trySubscribe(worldObj, xCoord - rot.offsetX * 2 + dir.offsetX, yCoord, zCoord - rot.offsetZ * 2 + dir.offsetZ, rot.getOpposite()); + } + private boolean canProcess() { if(slots[4] == null || slots[4].getItem() != ModItems.chemistry_template) @@ -195,79 +226,116 @@ public class TileEntityMachineChemplantNew extends TileEntityMachineBase impleme @Override public long getPower() { - // TODO Auto-generated method stub - return 0; + return this.power; + } + + @Override + public void setPower(long power) { + this.power = power; } @Override public long getMaxPower() { - // TODO Auto-generated method stub - return 0; + return this.maxPower; } @Override public void setFillForSync(int fill, int index) { - // TODO Auto-generated method stub - + if(index >= 0 && index < tanks.length) tanks[index].setFill(fill); } @Override public void setFillForTransfer(int fill, FluidType type) { - // TODO Auto-generated method stub + for(FluidTank tank : tanks) { + if(tank.getTankType() == type) { + tank.setFill(fill); + return; + } + } } @Override public void setTypeForSync(FluidType type, int index) { - // TODO Auto-generated method stub - + if(index >= 0 && index < tanks.length) tanks[index].setTankType(type); } @Override public int getFluidFill(FluidType type) { - // TODO Auto-generated method stub + + for(FluidTank tank : tanks) { + if(tank.getTankType() == type) { + return tank.getFill(); + } + } + return 0; } @Override public int getMaxFillForReceive(FluidType type) { - // TODO Auto-generated method stub + + for(FluidTank tank : tanks) { + if(tank.getTankType() == type) { + return tank.getMaxFill(); + } + } + return 0; } @Override public void fillFluidInit(FluidType type) { - // TODO Auto-generated method stub + /* + * #### + * X####X + * X##O#X + * #### + */ + + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset); + ForgeDirection rot = dir.getRotation(ForgeDirection.DOWN); + + fillFluid(xCoord + rot.offsetX * 3, yCoord, zCoord + rot.offsetZ * 3, this.getTact(), type); + fillFluid(xCoord - rot.offsetX * 2, yCoord, zCoord - rot.offsetZ * 2, this.getTact(), type); + fillFluid(xCoord + rot.offsetX * 3 + dir.offsetX, yCoord, zCoord + rot.offsetZ * 3 + dir.offsetZ, this.getTact(), type); + fillFluid(xCoord - rot.offsetX * 2 + dir.offsetX, yCoord, zCoord - rot.offsetZ * 2 + dir.offsetZ, this.getTact(), type); } @Override public void fillFluid(int x, int y, int z, boolean newTact, FluidType type) { - // TODO Auto-generated method stub - + Library.transmitFluid(x, y, z, newTact, this, worldObj, type); } @Override public boolean getTact() { - // TODO Auto-generated method stub - return false; + return worldObj.getTotalWorldTime() % 20 < 10; } + + List[] lists = new List[] { + new ArrayList(), new ArrayList(), new ArrayList(), new ArrayList() + }; @Override public List getFluidList(FluidType type) { - // TODO Auto-generated method stub - return null; + + for(int i = 0; i < tanks.length; i++) { + if(tanks[i].getTankType() == type) { + return lists[i]; + } + } + + return new ArrayList(); } @Override public void clearFluidList(FluidType type) { - // TODO Auto-generated method stub - - } - - @Override - public void setPower(long power) { - // TODO Auto-generated method stub + for(int i = 0; i < tanks.length; i++) { + if(tanks[i].getTankType() == type) { + lists[i].clear(); + } + } } } diff --git a/src/main/resources/assets/hbm/textures/gui/processing/gui_chemfac.png b/src/main/resources/assets/hbm/textures/gui/processing/gui_chemfac.png new file mode 100755 index 000000000..3ec12aba3 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/gui/processing/gui_chemfac.png differ