diff --git a/src/main/java/api/hbm/energy/IPowerNet.java b/src/main/java/api/hbm/energy/IPowerNet.java index 4b82df2e9..eb9848226 100644 --- a/src/main/java/api/hbm/energy/IPowerNet.java +++ b/src/main/java/api/hbm/energy/IPowerNet.java @@ -1,5 +1,6 @@ package api.hbm.energy; +import java.math.BigInteger; import java.util.List; /** @@ -32,4 +33,5 @@ public interface IPowerNet { public List getSubscribers(); public long transferPower(long power); + public BigInteger getTotalTransfer(); } diff --git a/src/main/java/api/hbm/energy/PowerNet.java b/src/main/java/api/hbm/energy/PowerNet.java index f9025201b..172e22dde 100644 --- a/src/main/java/api/hbm/energy/PowerNet.java +++ b/src/main/java/api/hbm/energy/PowerNet.java @@ -1,5 +1,6 @@ package api.hbm.energy; +import java.math.BigInteger; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -20,6 +21,9 @@ public class PowerNet implements IPowerNet { private HashMap links = new HashMap(); private HashMap proxies = new HashMap(); private List subscribers = new ArrayList(); + + public static List trackingInstances = null; + protected BigInteger totalTransfer = BigInteger.ZERO; @Override public void joinNetworks(IPowerNet network) { @@ -119,6 +123,11 @@ public class PowerNet implements IPowerNet { public boolean isValid() { return this.valid; } + + @Override + public BigInteger getTotalTransfer() { + return this.totalTransfer; + } public long lastCleanup = System.currentTimeMillis(); @@ -129,7 +138,9 @@ public class PowerNet implements IPowerNet { cleanup(this.subscribers); lastCleanup = System.currentTimeMillis(); }*/ - + + trackingInstances = new ArrayList(); + trackingInstances.add(this); return fairTransfer(this.subscribers, power); } @@ -149,6 +160,8 @@ public class PowerNet implements IPowerNet { ConnectionPriority[] priorities = new ConnectionPriority[] {ConnectionPriority.HIGH, ConnectionPriority.NORMAL, ConnectionPriority.LOW}; + long totalTransfer = 0; + for(ConnectionPriority p : priorities) { List subList = new ArrayList(); @@ -186,6 +199,15 @@ public class PowerNet implements IPowerNet { } power -= totalGiven; + totalTransfer += totalGiven; + } + + if(trackingInstances != null) { + + for(int i = 0; i < trackingInstances.size(); i++) { + PowerNet net = trackingInstances.get(i); + net.totalTransfer = net.totalTransfer.add(BigInteger.valueOf(totalTransfer)); + } } return power; diff --git a/src/main/java/com/hbm/lib/HbmChestContents.java b/src/main/java/com/hbm/lib/HbmChestContents.java index 8698ace37..343a46e75 100644 --- a/src/main/java/com/hbm/lib/HbmChestContents.java +++ b/src/main/java/com/hbm/lib/HbmChestContents.java @@ -165,6 +165,7 @@ public class HbmChestContents { public static WeightedRandomChestContent[] nuclear = new WeightedRandomChestContent[] { new WeightedRandomChestContent(ModItems.nugget_u235, 0, 3, 12, 5), new WeightedRandomChestContent(ModItems.nugget_pu238, 0, 3, 12, 5), + new WeightedRandomChestContent(ModItems.nugget_ra226, 0, 3, 6, 5), new WeightedRandomChestContent(ModItems.rod, BreedingRodType.U235.ordinal(), 1, 1, 3), new WeightedRandomChestContent(ModItems.rod_dual, BreedingRodType.U235.ordinal(), 1, 1, 3), new WeightedRandomChestContent(ModItems.rod_quad, BreedingRodType.U235.ordinal(), 1, 1, 3), diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityDeuteriumExtractor.java b/src/main/java/com/hbm/tileentity/machine/TileEntityDeuteriumExtractor.java index 6258575a7..1996b4bec 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityDeuteriumExtractor.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityDeuteriumExtractor.java @@ -1,14 +1,7 @@ package com.hbm.tileentity.machine; -import java.util.ArrayList; -import java.util.List; - -import com.hbm.interfaces.IFluidAcceptor; -import com.hbm.interfaces.IFluidSource; -import com.hbm.inventory.fluid.FluidType; import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.tank.FluidTank; -import com.hbm.lib.Library; import com.hbm.tileentity.TileEntityMachineBase; import api.hbm.energy.IEnergyUser; @@ -16,17 +9,16 @@ import api.hbm.fluid.IFluidStandardTransceiver; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityDeuteriumExtractor extends TileEntityMachineBase implements IFluidAcceptor, IFluidSource, IEnergyUser, IFluidStandardTransceiver { +public class TileEntityDeuteriumExtractor extends TileEntityMachineBase implements IEnergyUser, IFluidStandardTransceiver { public long power = 0; public FluidTank[] tanks; - public List list = new ArrayList(); public TileEntityDeuteriumExtractor() { super(0); tanks = new FluidTank[2]; - tanks[0] = new FluidTank(Fluids.WATER, 1000, 0); - tanks[1] = new FluidTank(Fluids.HEAVYWATER, 100, 1); + tanks[0] = new FluidTank(Fluids.WATER, 1000); + tanks[1] = new FluidTank(Fluids.HEAVYWATER, 100); } @Override @@ -52,7 +44,6 @@ public class TileEntityDeuteriumExtractor extends TileEntityMachineBase implemen this.subscribeToAllAround(tanks[0].getTankType(), this); this.sendFluidToAll(tanks[1].getTankType(), this); - fillFluidInit(tanks[1].getTankType()); NBTTagCompound data = new NBTTagCompound(); data.setLong("power", power); @@ -99,66 +90,6 @@ public class TileEntityDeuteriumExtractor extends TileEntityMachineBase implemen tanks[1].writeToNBT(nbt, "heavyWater"); } - - @Override - public void fillFluidInit(FluidType type) { - - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) - fillFluid(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, getTact(), type); - } - - @Override - public void fillFluid(int x, int y, int z, boolean newTact, FluidType type) { - Library.transmitFluid(x, y, z, newTact, this, worldObj, type); - } - - @Override - public boolean getTact() { - return worldObj.getTotalWorldTime() % 20 < 10; - } - - @Override - public void setFluidFill(int i, FluidType type) { - if(type == tanks[0].getTankType()) - tanks[0].setFill(i); - else if(type == tanks[1].getTankType()) - tanks[1].setFill(i); - } - - @Override - public int getFluidFill(FluidType type) { - if(type == tanks[0].getTankType()) - return tanks[0].getFill(); - else if(type == tanks[1].getTankType()) - return tanks[1].getFill(); - - return 0; - } - - @Override - public int getMaxFluidFill(FluidType type) { - if(type == tanks[0].getTankType()) - return tanks[0].getMaxFill(); - - return 0; - } - - @Override - public void setFillForSync(int fill, int index) { } - - @Override - public void setTypeForSync(FluidType type, int index) { } - - @Override - public List getFluidList(FluidType type) { - return list; - } - - @Override - public void clearFluidList(FluidType type) { - list.clear(); - } - @Override public void setPower(long i) { power = i; @@ -171,7 +102,7 @@ public class TileEntityDeuteriumExtractor extends TileEntityMachineBase implemen @Override public long getMaxPower() { - return 100000; + return 10_000; } @Override diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityDeuteriumTower.java b/src/main/java/com/hbm/tileentity/machine/TileEntityDeuteriumTower.java index 3afa73370..8cc2e93c9 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityDeuteriumTower.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityDeuteriumTower.java @@ -20,56 +20,6 @@ public class TileEntityDeuteriumTower extends TileEntityDeuteriumExtractor { tanks[0] = new FluidTank(Fluids.WATER, 50000, 0); tanks[1] = new FluidTank(Fluids.HEAVYWATER, 5000, 1); } - - public void fillFluidInit(FluidType type) { - - int offsetX = 0; - int offsetZ = 0; - - ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset); - ForgeDirection rot = dir.getRotation(ForgeDirection.DOWN); - offsetX = -dir.offsetX; - offsetZ = -rot.offsetZ; - - if(dir == ForgeDirection.NORTH || dir == ForgeDirection.SOUTH) { - offsetX = rot.offsetX; - offsetZ = dir.offsetZ; - } - - /*fillFluid(this.xCoord + rot.offsetX * 2, this.yCoord, this.zCoord - dir.offsetZ * 1, getTact(), type); - fillFluid(this.xCoord + rot.offsetX * 2, this.yCoord, this.zCoord - dir.offsetZ * 0, getTact(), type); - fillFluid(this.xCoord + rot.offsetX * 1, this.yCoord, this.zCoord - dir.offsetZ * 2, getTact(), type); - fillFluid(this.xCoord + rot.offsetX * 0, this.yCoord, this.zCoord - dir.offsetZ * 2, getTact(), type); - fillFluid(this.xCoord + rot.offsetX * 1, this.yCoord, this.zCoord + dir.offsetZ * 1, getTact(), type); - fillFluid(this.xCoord + rot.offsetX * 0, this.yCoord, this.zCoord + dir.offsetZ * 1, getTact(), type); - fillFluid(this.xCoord - rot.offsetX * 1, this.yCoord, this.zCoord + dir.offsetZ * 0, getTact(), type); - fillFluid(this.xCoord - rot.offsetX * 1, this.yCoord, this.zCoord - dir.offsetZ * 1, getTact(), type);*/ - - /*worldObj.setBlock(this.xCoord + rot.offsetX * 2, this.yCoord, this.zCoord - dir.offsetZ * 1, Blocks.dirt); - worldObj.setBlock(this.xCoord + rot.offsetX * 2, this.yCoord, this.zCoord - dir.offsetZ * 0, Blocks.dirt); - worldObj.setBlock(this.xCoord + rot.offsetX * 1, this.yCoord, this.zCoord - dir.offsetZ * 2, Blocks.dirt); - worldObj.setBlock(this.xCoord + rot.offsetX * 0, this.yCoord, this.zCoord - dir.offsetZ * 2, Blocks.dirt); - worldObj.setBlock(this.xCoord + rot.offsetX * 1, this.yCoord, this.zCoord + dir.offsetZ * 1, Blocks.dirt); - worldObj.setBlock(this.xCoord + rot.offsetX * 0, this.yCoord, this.zCoord + dir.offsetZ * 1, Blocks.dirt); - worldObj.setBlock(this.xCoord - rot.offsetX * 1, this.yCoord, this.zCoord + dir.offsetZ * 0, Blocks.dirt); - worldObj.setBlock(this.xCoord - rot.offsetX * 1, this.yCoord, this.zCoord - dir.offsetZ * 1, Blocks.dirt);*/ - - /* I'm never doing an even sided fluid machine ever again - * - * this was pain - * - * - pheo */ - - - fillFluid(this.xCoord + offsetX * 2, this.yCoord, this.zCoord - offsetZ * 1, getTact(), type); - fillFluid(this.xCoord + offsetX * 2, this.yCoord, this.zCoord - offsetZ * 0, getTact(), type); - fillFluid(this.xCoord + offsetX * 1, this.yCoord, this.zCoord - offsetZ * 2, getTact(), type); - fillFluid(this.xCoord + offsetX * 0, this.yCoord, this.zCoord - offsetZ * 2, getTact(), type); - fillFluid(this.xCoord + offsetX * 1, this.yCoord, this.zCoord + offsetZ * 1, getTact(), type); - fillFluid(this.xCoord + offsetX * 0, this.yCoord, this.zCoord + offsetZ * 1, getTact(), type); - fillFluid(this.xCoord - offsetX * 1, this.yCoord, this.zCoord + offsetZ * 0, getTact(), type); - fillFluid(this.xCoord - offsetX * 1, this.yCoord, this.zCoord - offsetZ * 1, getTact(), type); - } protected void updateConnections() { @@ -139,6 +89,6 @@ public class TileEntityDeuteriumTower extends TileEntityDeuteriumExtractor { @Override public long getMaxPower() { - return 1000000; + return 100_000; } } \ No newline at end of file diff --git a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineBattery.java b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineBattery.java index a0463756c..594fec515 100644 --- a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineBattery.java +++ b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineBattery.java @@ -227,6 +227,16 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I if(this.power > 0 && (mode == mode_buffer || mode == mode_output)) { List con = new ArrayList(); con.addAll(consumers); + + if(PowerNet.trackingInstances == null) { + PowerNet.trackingInstances = new ArrayList(); + } + PowerNet.trackingInstances.clear(); + + nets.forEach(x -> { + if(x instanceof PowerNet) PowerNet.trackingInstances.add((PowerNet) x); + }); + this.power = PowerNet.fairTransfer(con, this.power); } @@ -256,9 +266,17 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I if(mode == mode_buffer || mode == mode_output) { if(te instanceof IEnergyConnector) { IEnergyConnector con = (IEnergyConnector) te; + + long max = getMaxTransfer(); + long toTransfer = Math.min(max, this.power); + long remainder = this.power - toTransfer; + this.power = toTransfer; + long oldPower = this.power; long transfer = this.power - con.transferPower(this.power); this.power = oldPower - transfer; + + power += remainder; } } @@ -278,6 +296,10 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I } } } + + public long getMaxTransfer() { + return this.getMaxPower(); + } @Override public void networkUnpack(NBTTagCompound nbt) { diff --git a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineFENSU.java b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineFENSU.java index 541e4c9ad..46770f2a6 100644 --- a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineFENSU.java +++ b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineFENSU.java @@ -1,12 +1,9 @@ package com.hbm.tileentity.machine.storage; -import com.hbm.lib.Library; - import api.hbm.energy.IEnergyConductor; import api.hbm.energy.IEnergyConnector; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraftforge.common.util.ForgeDirection; @@ -20,21 +17,9 @@ public class TileEntityMachineFENSU extends TileEntityMachineBattery { @Override public void updateEntity() { + super.updateEntity(); - if(!worldObj.isRemote) { - - this.transmitPower(); - - power = Library.chargeTEFromItems(slots, 0, power, getMaxPower()); - power = Library.chargeItemsFromTE(slots, 1, power, getMaxPower()); - - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setLong("power", power); - nbt.setShort("redLow", redLow); - nbt.setShort("redHigh", redHigh); - nbt.setByte("priority", (byte) this.priority.ordinal()); - this.networkPack(nbt, 250); - } else { + if(worldObj.isRemote) { this.prevRotation = this.rotation; this.rotation += this.getSpeed(); @@ -42,16 +27,10 @@ public class TileEntityMachineFENSU extends TileEntityMachineBattery { rotation -= 360; prevRotation -= 360; } - - for(int i = 1; i < this.log.length; i++) { - this.log[i - 1] = this.log[i]; - } - - this.log[19] = this.power; } } - protected void transmitPower() { + @Deprecated protected void transmitPower() { short mode = (short) this.getRelevantMode(); @@ -127,8 +106,7 @@ public class TileEntityMachineFENSU extends TileEntityMachineBattery { @Override @SideOnly(Side.CLIENT) - public double getMaxRenderDistanceSquared() - { + public double getMaxRenderDistanceSquared() { return 65536.0D; } }