mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
go go gadget: detonate nutsack
This commit is contained in:
parent
0ca1be3d6f
commit
565d5c1129
@ -2,8 +2,6 @@ package api.hbm.energymk2;
|
||||
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.toclient.AuxParticlePacketNT;
|
||||
import com.hbm.uninos.IGenProvider;
|
||||
import com.hbm.uninos.networkproviders.PowerNetProvider;
|
||||
import com.hbm.util.Compat;
|
||||
|
||||
import api.hbm.energymk2.Nodespace.PowerNode;
|
||||
@ -14,7 +12,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/** If it sends energy, use this */
|
||||
public interface IEnergyProviderMK2 extends IEnergyHandlerMK2, IGenProvider<PowerNetProvider> {
|
||||
public interface IEnergyProviderMK2 extends IEnergyHandlerMK2 {
|
||||
|
||||
/** Uses up available power, default implementation has no sanity checking, make sure that the requested power is lequal to the current power */
|
||||
public default void usePower(long power) {
|
||||
|
||||
@ -3,8 +3,6 @@ package api.hbm.energymk2;
|
||||
import com.hbm.interfaces.NotableComments;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.toclient.AuxParticlePacketNT;
|
||||
import com.hbm.uninos.IGenReceiver;
|
||||
import com.hbm.uninos.networkproviders.PowerNetProvider;
|
||||
import com.hbm.util.Compat;
|
||||
|
||||
import api.hbm.energymk2.Nodespace.PowerNode;
|
||||
@ -16,7 +14,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/** If it receives energy, use this */
|
||||
@NotableComments
|
||||
public interface IEnergyReceiverMK2 extends IEnergyHandlerMK2, IGenReceiver<PowerNetProvider> {
|
||||
public interface IEnergyReceiverMK2 extends IEnergyHandlerMK2 {
|
||||
|
||||
public default long transferPower(long power) {
|
||||
if(power + this.getPower() <= this.getMaxPower()) {
|
||||
@ -85,4 +83,8 @@ public interface IEnergyReceiverMK2 extends IEnergyHandlerMK2, IGenReceiver<Powe
|
||||
HIGH,
|
||||
HIGHEST
|
||||
}
|
||||
|
||||
public default ConnectionPriority getPriority() {
|
||||
return ConnectionPriority.NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,15 +37,19 @@ public class PowerNetMK2 extends NodeNet<IEnergyReceiverMK2, IEnergyProviderMK2,
|
||||
List<Pair<IEnergyProviderMK2, Long>> providers = new ArrayList();
|
||||
long powerAvailable = 0;
|
||||
|
||||
// sum up available power
|
||||
Iterator<Entry<IEnergyProviderMK2, Long>> provIt = providerEntries.entrySet().iterator();
|
||||
while(provIt.hasNext()) {
|
||||
Entry<IEnergyProviderMK2, Long> entry = provIt.next();
|
||||
if(timestamp - entry.getValue() > timeout) { provIt.remove(); continue; }
|
||||
long src = Math.min(entry.getKey().getPower(), entry.getKey().getProviderSpeed());
|
||||
providers.add(new Pair(entry.getKey(), src));
|
||||
powerAvailable += src;
|
||||
if(src > 0) {
|
||||
providers.add(new Pair(entry.getKey(), src));
|
||||
powerAvailable += src;
|
||||
}
|
||||
}
|
||||
|
||||
// sum up total demand, categorized by priority
|
||||
List<Pair<IEnergyReceiverMK2, Long>>[] receivers = new ArrayList[ConnectionPriority.values().length];
|
||||
for(int i = 0; i < receivers.length; i++) receivers[i] = new ArrayList();
|
||||
long[] demand = new long[ConnectionPriority.values().length];
|
||||
@ -57,15 +61,18 @@ public class PowerNetMK2 extends NodeNet<IEnergyReceiverMK2, IEnergyProviderMK2,
|
||||
Entry<IEnergyReceiverMK2, Long> entry = recIt.next();
|
||||
if(timestamp - entry.getValue() > timeout) { recIt.remove(); continue; }
|
||||
long rec = Math.min(entry.getKey().getMaxPower() - entry.getKey().getPower(), entry.getKey().getReceiverSpeed());
|
||||
int p = entry.getKey().getPriority().ordinal();
|
||||
receivers[p].add(new Pair(entry.getKey(), rec));
|
||||
demand[p] += rec;
|
||||
totalDemand += rec;
|
||||
if(rec > 0) {
|
||||
int p = entry.getKey().getPriority().ordinal();
|
||||
receivers[p].add(new Pair(entry.getKey(), rec));
|
||||
demand[p] += rec;
|
||||
totalDemand += rec;
|
||||
}
|
||||
}
|
||||
|
||||
long toTransfer = Math.min(powerAvailable, totalDemand);
|
||||
long energyUsed = 0;
|
||||
|
||||
// add power to receivers, ordered by priority
|
||||
for(int i = ConnectionPriority.values().length - 1; i >= 0; i--) {
|
||||
List<Pair<IEnergyReceiverMK2, Long>> list = receivers[i];
|
||||
long priorityDemand = demand[i];
|
||||
@ -82,6 +89,7 @@ public class PowerNetMK2 extends NodeNet<IEnergyReceiverMK2, IEnergyProviderMK2,
|
||||
this.energyTracker += energyUsed;
|
||||
long leftover = energyUsed;
|
||||
|
||||
// remove power from providers
|
||||
for(Pair<IEnergyProviderMK2, Long> entry : providers) {
|
||||
double weight = (double) entry.getValue() / (double) powerAvailable;
|
||||
long toUse = (long) Math.max(energyUsed * weight, 0D);
|
||||
@ -89,7 +97,7 @@ public class PowerNetMK2 extends NodeNet<IEnergyReceiverMK2, IEnergyProviderMK2,
|
||||
leftover -= toUse;
|
||||
}
|
||||
|
||||
//rounding error compensation, detects surplus that hasn't been used and removes it from random providers
|
||||
// rounding error compensation, detects surplus that hasn't been used and removes it from random providers
|
||||
int iterationsLeft = 100; // whiles without emergency brakes are a bad idea
|
||||
while(iterationsLeft > 0 && leftover > 0 && providers.size() > 0) {
|
||||
iterationsLeft--;
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
package api.hbm.fluid;
|
||||
|
||||
import com.hbm.uninos.NodeNet;
|
||||
|
||||
public class FluidNet extends NodeNet { // yeah i don't feel like it, gonna do that shit tomorrow or sth
|
||||
|
||||
public long tracker = 0L;
|
||||
|
||||
protected static int timeout = 3_000;
|
||||
|
||||
@Override public void resetTrackers() { this.tracker = 0; }
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
package api.hbm.fluid;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
|
||||
public interface IFluidConductor extends IFluidConnector {
|
||||
|
||||
public IPipeNet getPipeNet(FluidType type);
|
||||
|
||||
public void setPipeNet(FluidType type, IPipeNet network);
|
||||
|
||||
@Override
|
||||
public default long transferFluid(FluidType type, int pressure, long amount) {
|
||||
|
||||
if(this.getPipeNet(type) == null)
|
||||
return amount;
|
||||
|
||||
return this.getPipeNet(type).transferFluid(amount, pressure);
|
||||
}
|
||||
}
|
||||
@ -1,93 +1,6 @@
|
||||
package api.hbm.fluid;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.toclient.AuxParticlePacketNT;
|
||||
import com.hbm.util.Compat;
|
||||
import api.hbm.fluidmk2.IFluidConnectorMK2;
|
||||
|
||||
import api.hbm.tile.ILoadedTile;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IFluidConnector extends ILoadedTile {
|
||||
|
||||
/**
|
||||
* Returns the amount of fluid that remains
|
||||
* @param power
|
||||
* @return
|
||||
*/
|
||||
public long transferFluid(FluidType type, int pressure, long fluid);
|
||||
|
||||
/**
|
||||
* Whether the given side can be connected to
|
||||
* @param dir
|
||||
* @return
|
||||
*/
|
||||
public default boolean canConnect(FluidType type, ForgeDirection dir) {
|
||||
return dir != ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of fluid that this machine is able to receive
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public long getDemand(FluidType type, int pressure);
|
||||
|
||||
/**
|
||||
* Basic implementation of subscribing to a nearby power grid
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
*/
|
||||
public default void trySubscribe(FluidType type, World world, int x, int y, int z, ForgeDirection dir) {
|
||||
|
||||
TileEntity te = Compat.getTileStandard(world, x, y, z);
|
||||
boolean red = false;
|
||||
|
||||
if(te instanceof IFluidConductor) {
|
||||
IFluidConductor con = (IFluidConductor) te;
|
||||
|
||||
if(!con.canConnect(type, dir))
|
||||
return;
|
||||
|
||||
if(con.getPipeNet(type) != null && !con.getPipeNet(type).isSubscribed(this))
|
||||
con.getPipeNet(type).subscribe(this);
|
||||
|
||||
if(con.getPipeNet(type) != null)
|
||||
red = true;
|
||||
}
|
||||
|
||||
if(particleDebug) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setString("type", "network");
|
||||
data.setString("mode", "fluid");
|
||||
data.setInteger("color", type.getColor());
|
||||
double posX = x + 0.5 + dir.offsetX * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
|
||||
double posY = y + 0.5 + dir.offsetY * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
|
||||
double posZ = z + 0.5 + dir.offsetZ * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
|
||||
data.setDouble("mX", -dir.offsetX * (red ? 0.025 : 0.1));
|
||||
data.setDouble("mY", -dir.offsetY * (red ? 0.025 : 0.1));
|
||||
data.setDouble("mZ", -dir.offsetZ * (red ? 0.025 : 0.1));
|
||||
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, posX, posY, posZ), new TargetPoint(world.provider.dimensionId, posX, posY, posZ, 25));
|
||||
}
|
||||
}
|
||||
|
||||
public default void tryUnsubscribe(FluidType type, World world, int x, int y, int z) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(te instanceof IFluidConductor) {
|
||||
IFluidConductor con = (IFluidConductor) te;
|
||||
|
||||
if(con.getPipeNet(type) != null && con.getPipeNet(type).isSubscribed(this))
|
||||
con.getPipeNet(type).unsubscribe(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static final boolean particleDebug = false;
|
||||
}
|
||||
@Deprecated
|
||||
public interface IFluidConnector extends IFluidConnectorMK2 { }
|
||||
|
||||
@ -1,12 +1,6 @@
|
||||
package api.hbm.fluid;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import api.hbm.fluidmk2.IFluidConnectorBlockMK2;
|
||||
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IFluidConnectorBlock {
|
||||
|
||||
/** dir is the face that is connected to, the direction going outwards from the block */
|
||||
public boolean canConnect(FluidType type, IBlockAccess world, int x, int y, int z, ForgeDirection dir);
|
||||
}
|
||||
@Deprecated
|
||||
public interface IFluidConnectorBlock extends IFluidConnectorBlockMK2 { }
|
||||
|
||||
@ -1,49 +1,35 @@
|
||||
package api.hbm.fluid;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.uninos.GenNode;
|
||||
import com.hbm.uninos.UniNodespace;
|
||||
|
||||
/**
|
||||
* Uses default implementation to make the underlying interfaces easier to use for the most common fluid users.
|
||||
* Only handles a single input tank of the same type.
|
||||
* Uses standard FluidTanks which use int32.
|
||||
* Don't use this as part of the API!
|
||||
* @author hbm
|
||||
*
|
||||
*/
|
||||
public interface IFluidStandardReceiver extends IFluidUser {
|
||||
import api.hbm.fluidmk2.IFluidStandardReceiverMK2;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@Deprecated
|
||||
public interface IFluidStandardReceiver extends IFluidStandardReceiverMK2 {
|
||||
|
||||
@Override
|
||||
public default long transferFluid(FluidType type, int pressure, long amount) {
|
||||
|
||||
for(FluidTank tank : getReceivingTanks()) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
tank.setFill(tank.getFill() + (int) amount);
|
||||
|
||||
if(tank.getFill() > tank.getMaxFill()) {
|
||||
long overshoot = tank.getFill() - tank.getMaxFill();
|
||||
tank.setFill(tank.getMaxFill());
|
||||
return overshoot;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return amount;
|
||||
public default void subscribeToAllAround(FluidType type, TileEntity tile) {
|
||||
subscribeToAllAround(type, tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
}
|
||||
|
||||
public FluidTank[] getReceivingTanks();
|
||||
|
||||
@Override
|
||||
public default long getDemand(FluidType type, int pressure) {
|
||||
|
||||
for(FluidTank tank : getReceivingTanks()) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
return tank.getMaxFill() - tank.getFill();
|
||||
}
|
||||
|
||||
public default void subscribeToAllAround(FluidType type, World world, int x, int y, int z) {
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
trySubscribe(type, world, x, y, z, dir);
|
||||
}
|
||||
}
|
||||
|
||||
public default void tryUnsubscribe(FluidType type, World world, int x, int y, int z) {
|
||||
GenNode node = UniNodespace.getNode(world, x, y, z, type.getNetworkProvider());
|
||||
if(node != null && node.net != null) node.net.removeReceiver(this);
|
||||
}
|
||||
|
||||
public default void unsubscribeToAllAround(FluidType type, TileEntity tile) {
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
tryUnsubscribe(type, tile.getWorldObj(), tile.xCoord + dir.offsetX, tile.yCoord + dir.offsetY, tile.zCoord + dir.offsetZ);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,50 +1,22 @@
|
||||
package api.hbm.fluid;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
|
||||
/**
|
||||
* Uses default implementation to make the underlying interfaces easier to use for the most common fluid users.
|
||||
* Only handles a single output tank of the same type.
|
||||
* Uses standard FluidTanks which use int32.
|
||||
* Don't use this as part of the API!
|
||||
* @author hbm
|
||||
*
|
||||
*/
|
||||
public interface IFluidStandardSender extends IFluidUser {
|
||||
import api.hbm.fluidmk2.IFluidStandardSenderMK2;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public FluidTank[] getSendingTanks();
|
||||
|
||||
@Override
|
||||
public default long getTotalFluidForSend(FluidType type, int pressure) {
|
||||
|
||||
for(FluidTank tank : getSendingTanks()) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
return tank.getFill();
|
||||
}
|
||||
@Deprecated
|
||||
public interface IFluidStandardSender extends IFluidStandardSenderMK2 {
|
||||
|
||||
public default void sendFluid(FluidTank tank, World world, int x, int y, int z, ForgeDirection dir) {
|
||||
tryProvide(tank, world, x, y, z, dir);
|
||||
}
|
||||
|
||||
public default void sendFluidToAll(FluidTank tank, TileEntity tile) {
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
tryProvide(tank, tile.getWorldObj(), tile.xCoord + dir.offsetX, tile.yCoord + dir.offsetY, tile.zCoord + dir.offsetZ, dir);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public default void removeFluidForTransfer(FluidType type, int pressure, long amount) {
|
||||
|
||||
for(FluidTank tank : getSendingTanks()) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
tank.setFill(tank.getFill() - (int) amount);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public default long transferFluid(FluidType type, int pressure, long fluid) {
|
||||
return fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public default long getDemand(FluidType type, int pressure) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,79 +1,4 @@
|
||||
package api.hbm.fluid;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
|
||||
/**
|
||||
* transceiver [trăn-sē′vər], noun
|
||||
*
|
||||
* 1. A transmitter and receiver housed together in a single unit and having some circuits in common, often for portable or mobile use.
|
||||
* 2. A combined radio transmitter and receiver.
|
||||
* 3. A device that performs transmitting and receiving functions, especially if using common components.
|
||||
*
|
||||
* The American Heritage® Dictionary of the English Language, 5th Edition.
|
||||
*
|
||||
* Only supports one tank per type (for in- and output separately)
|
||||
*
|
||||
* @author hbm
|
||||
*
|
||||
*/
|
||||
public interface IFluidStandardTransceiver extends IFluidUser {
|
||||
|
||||
public FluidTank[] getSendingTanks();
|
||||
public FluidTank[] getReceivingTanks();
|
||||
|
||||
@Override
|
||||
public default long getTotalFluidForSend(FluidType type, int pressure) {
|
||||
|
||||
for(FluidTank tank : getSendingTanks()) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
return tank.getFill();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public default void removeFluidForTransfer(FluidType type, int pressure, long amount) {
|
||||
|
||||
for(FluidTank tank : getSendingTanks()) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
tank.setFill(tank.getFill() - (int) amount);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public default long getDemand(FluidType type, int pressure) {
|
||||
|
||||
for(FluidTank tank : getReceivingTanks()) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
return tank.getMaxFill() - tank.getFill();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public default long transferFluid(FluidType type, int pressure, long amount) {
|
||||
|
||||
for(FluidTank tank : getReceivingTanks()) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
tank.setFill(tank.getFill() + (int) amount);
|
||||
|
||||
if(tank.getFill() > tank.getMaxFill()) {
|
||||
long overshoot = tank.getFill() - tank.getMaxFill();
|
||||
tank.setFill(tank.getMaxFill());
|
||||
return overshoot;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
@Deprecated
|
||||
public interface IFluidStandardTransceiver extends IFluidStandardReceiver, IFluidStandardSender { }
|
||||
|
||||
@ -1,130 +0,0 @@
|
||||
package api.hbm.fluid;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.toclient.AuxParticlePacketNT;
|
||||
import com.hbm.util.Compat;
|
||||
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IFluidUser extends IFluidConnector {
|
||||
|
||||
public default void sendFluid(FluidTank tank, World world, int x, int y, int z, ForgeDirection dir) {
|
||||
sendFluid(tank.getTankType(), tank.getPressure(), world, x, y, z, dir);
|
||||
}
|
||||
|
||||
public default void sendFluid(FluidType type, int pressure, World world, int x, int y, int z, ForgeDirection dir) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
boolean wasSubscribed = false;
|
||||
boolean red = false;
|
||||
|
||||
if(te instanceof IFluidConductor) {
|
||||
IFluidConductor con = (IFluidConductor) te;
|
||||
|
||||
if(con.getPipeNet(type) != null && con.getPipeNet(type).isSubscribed(this)) {
|
||||
con.getPipeNet(type).unsubscribe(this);
|
||||
wasSubscribed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(te instanceof IFluidConnector) {
|
||||
IFluidConnector con = (IFluidConnector) te;
|
||||
|
||||
if(con.canConnect(type, dir.getOpposite())) {
|
||||
long toSend = this.getTotalFluidForSend(type, pressure);
|
||||
|
||||
if(toSend > 0) {
|
||||
long transfer = toSend - con.transferFluid(type, pressure, toSend);
|
||||
this.removeFluidForTransfer(type, pressure, transfer);
|
||||
}
|
||||
red = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(wasSubscribed && te instanceof IFluidConductor) {
|
||||
IFluidConductor con = (IFluidConductor) te;
|
||||
|
||||
if(con.getPipeNet(type) != null && !con.getPipeNet(type).isSubscribed(this)) {
|
||||
con.getPipeNet(type).subscribe(this);
|
||||
}
|
||||
}
|
||||
|
||||
if(particleDebug) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setString("type", "network");
|
||||
data.setString("mode", "fluid");
|
||||
data.setInteger("color", type.getColor());
|
||||
double posX = x + 0.5 - dir.offsetX * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
|
||||
double posY = y + 0.5 - dir.offsetY * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
|
||||
double posZ = z + 0.5 - dir.offsetZ * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
|
||||
data.setDouble("mX", dir.offsetX * (red ? 0.025 : 0.1));
|
||||
data.setDouble("mY", dir.offsetY * (red ? 0.025 : 0.1));
|
||||
data.setDouble("mZ", dir.offsetZ * (red ? 0.025 : 0.1));
|
||||
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, posX, posY, posZ), new TargetPoint(world.provider.dimensionId, posX, posY, posZ, 25));
|
||||
}
|
||||
}
|
||||
|
||||
public static IPipeNet getPipeNet(World world, int x, int y, int z, FluidType type) {
|
||||
|
||||
TileEntity te = Compat.getTileStandard(world, x, y, z);
|
||||
|
||||
if(te instanceof IFluidConductor) {
|
||||
IFluidConductor con = (IFluidConductor) te;
|
||||
|
||||
if(con.getPipeNet(type) != null) {
|
||||
return con.getPipeNet(type);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Use more common conPos method instead */
|
||||
@Deprecated public default void sendFluidToAll(FluidTank tank, TileEntity te) {
|
||||
sendFluidToAll(tank.getTankType(), tank.getPressure(), te);
|
||||
}
|
||||
|
||||
/** Use more common conPos method instead */
|
||||
@Deprecated public default void sendFluidToAll(FluidType type, int pressure, TileEntity te) {
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
sendFluid(type, pressure, te.getWorldObj(), te.xCoord + dir.offsetX, te.yCoord + dir.offsetY, te.zCoord + dir.offsetZ, dir);
|
||||
}
|
||||
}
|
||||
|
||||
public default long getTotalFluidForSend(FluidType type, int pressure) { return 0; }
|
||||
public default void removeFluidForTransfer(FluidType type, int pressure, long amount) { }
|
||||
|
||||
public default void subscribeToAllAround(FluidType type, TileEntity te) {
|
||||
subscribeToAllAround(type, te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord);
|
||||
}
|
||||
|
||||
public default void subscribeToAllAround(FluidType type, World world, int x, int y, int z) {
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
this.trySubscribe(type, world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir);
|
||||
}
|
||||
|
||||
public default void unsubscribeToAllAround(FluidType type, TileEntity te) {
|
||||
unsubscribeToAllAround(type, te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord);
|
||||
}
|
||||
|
||||
public default void unsubscribeToAllAround(FluidType type, World world, int x, int y, int z) {
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
this.tryUnsubscribe(type, world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all internal tanks of this tile. Not used by the fluid network, it should only be used for display purposes or edge cases that can't be solved otherwise.
|
||||
* The array is either composed of the original tank or outright the original tank array, so changes done to this array will extend to the IFluidUser.
|
||||
* @return
|
||||
*/
|
||||
public FluidTank[] getAllTanks();
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
package api.hbm.fluid;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
|
||||
public interface IPipeNet {
|
||||
|
||||
public void joinNetworks(IPipeNet network);
|
||||
|
||||
public List<IFluidConductor> getLinks();
|
||||
public HashSet<IFluidConnector> getSubscribers();
|
||||
|
||||
public IPipeNet joinLink(IFluidConductor conductor);
|
||||
public void leaveLink(IFluidConductor conductor);
|
||||
|
||||
public void subscribe(IFluidConnector connector);
|
||||
public void unsubscribe(IFluidConnector connector);
|
||||
public boolean isSubscribed(IFluidConnector connector);
|
||||
|
||||
public void destroy();
|
||||
|
||||
public boolean isValid();
|
||||
|
||||
public long transferFluid(long fill, int pressure);
|
||||
public FluidType getType();
|
||||
public BigInteger getTotalTransfer();
|
||||
}
|
||||
@ -1,205 +0,0 @@
|
||||
package api.hbm.fluid;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class PipeNet implements IPipeNet {
|
||||
|
||||
private boolean valid = true;
|
||||
private FluidType type;
|
||||
private List<IFluidConductor> links = new ArrayList();
|
||||
private HashSet<IFluidConnector> subscribers = new HashSet();
|
||||
|
||||
public static List<PipeNet> trackingInstances = null;
|
||||
protected BigInteger totalTransfer = BigInteger.ZERO;
|
||||
public List<String> debug = new ArrayList();
|
||||
|
||||
public PipeNet(FluidType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void joinNetworks(IPipeNet network) {
|
||||
|
||||
if(network == this)
|
||||
return;
|
||||
|
||||
for(IFluidConductor conductor : network.getLinks()) {
|
||||
conductor.setPipeNet(type, this);
|
||||
this.getLinks().add(conductor);
|
||||
}
|
||||
network.getLinks().clear();
|
||||
|
||||
for(IFluidConnector connector : network.getSubscribers()) {
|
||||
this.subscribe(connector);
|
||||
}
|
||||
|
||||
network.destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IFluidConductor> getLinks() {
|
||||
return links;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashSet<IFluidConnector> getSubscribers() {
|
||||
return subscribers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPipeNet joinLink(IFluidConductor conductor) {
|
||||
|
||||
if(conductor.getPipeNet(type) != null)
|
||||
conductor.getPipeNet(type).leaveLink(conductor);
|
||||
|
||||
conductor.setPipeNet(type, this);
|
||||
this.links.add(conductor);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void leaveLink(IFluidConductor conductor) {
|
||||
conductor.setPipeNet(type, null);
|
||||
this.links.remove(conductor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribe(IFluidConnector connector) {
|
||||
this.subscribers.add(connector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsubscribe(IFluidConnector connector) {
|
||||
this.subscribers.remove(connector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSubscribed(IFluidConnector connector) {
|
||||
return this.subscribers.contains(connector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long transferFluid(long fill, int pressure) {
|
||||
|
||||
subscribers.removeIf(x ->
|
||||
x == null || !(x instanceof TileEntity) || ((TileEntity)x).isInvalid() || !x.isLoaded()
|
||||
);
|
||||
|
||||
if(this.subscribers.isEmpty())
|
||||
return fill;
|
||||
|
||||
trackingInstances = new ArrayList();
|
||||
trackingInstances.add(this);
|
||||
List<IFluidConnector> subList = new ArrayList(subscribers);
|
||||
return fairTransfer(subList, type, pressure, fill);
|
||||
}
|
||||
|
||||
public static long fairTransfer(List<IFluidConnector> subList, FluidType type, int pressure, long fill) {
|
||||
|
||||
if(fill <= 0) return 0;
|
||||
|
||||
List<Long> weight = new ArrayList();
|
||||
long totalReq = 0;
|
||||
|
||||
for(IFluidConnector con : subList) {
|
||||
long req = con.getDemand(type, pressure);
|
||||
weight.add(req);
|
||||
totalReq += req;
|
||||
}
|
||||
|
||||
if(totalReq == 0)
|
||||
return fill;
|
||||
|
||||
long totalGiven = 0;
|
||||
|
||||
for(int i = 0; i < subList.size(); i++) {
|
||||
IFluidConnector con = subList.get(i);
|
||||
long req = weight.get(i);
|
||||
double fraction = (double)req / (double)totalReq;
|
||||
|
||||
long given = (long) Math.floor(fraction * fill);
|
||||
|
||||
if(given > 0) {
|
||||
|
||||
totalGiven += (given - con.transferFluid(type, pressure, given));
|
||||
|
||||
if(con instanceof TileEntity) {
|
||||
TileEntity tile = (TileEntity) con;
|
||||
tile.getWorldObj().markTileEntityChunkModified(tile.xCoord, tile.yCoord, tile.zCoord, tile);
|
||||
}
|
||||
|
||||
/* debug code
|
||||
if(trackingInstances != null) {
|
||||
for(int j = 0; j < trackingInstances.size(); j++) {
|
||||
PipeNet net = trackingInstances.get(j);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss:SSS");
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
log(net, sdf.format(new Date(System.currentTimeMillis())) + " Sending " + given + "mB to " + conToString(con));
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
if(trackingInstances != null) {
|
||||
|
||||
for(int i = 0; i < trackingInstances.size(); i++) {
|
||||
PipeNet net = trackingInstances.get(i);
|
||||
net.totalTransfer = net.totalTransfer.add(BigInteger.valueOf(totalGiven));
|
||||
}
|
||||
}
|
||||
|
||||
return fill - totalGiven;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
this.valid = false;
|
||||
this.subscribers.clear();
|
||||
|
||||
for(IFluidConductor con : this.links)
|
||||
con.setPipeNet(type, null);
|
||||
|
||||
this.links.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return this.valid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger getTotalTransfer() {
|
||||
return this.totalTransfer;
|
||||
}
|
||||
|
||||
public static void log(PipeNet net, String msg) {
|
||||
net.debug.add(msg);
|
||||
|
||||
while(net.debug.size() > 50) {
|
||||
net.debug.remove(0);
|
||||
}
|
||||
}
|
||||
|
||||
public static String conToString(IFluidConnector con) {
|
||||
|
||||
if(con instanceof TileEntity) {
|
||||
TileEntity tile = (TileEntity) con;
|
||||
return tile.getClass().getSimpleName() + " @ " + tile.xCoord + "/" + tile.yCoord + "/" + tile.zCoord;
|
||||
}
|
||||
|
||||
return "" + con;
|
||||
}
|
||||
}
|
||||
@ -2,8 +2,10 @@ package api.hbm.fluidmk2;
|
||||
|
||||
import com.hbm.uninos.NodeNet;
|
||||
|
||||
public class FluidNetMK2 extends NodeNet {
|
||||
public class FluidNetMK2 extends NodeNet<IFluidReceiverMK2, IFluidProviderMK2, FluidNode> {
|
||||
|
||||
public long fluidTracker = 0L;
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package api.hbm.fluid;
|
||||
package api.hbm.fluidmk2;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
package api.hbm.fluidmk2;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
|
||||
public interface IFluidConductorMK2 extends IFluidConnectorMK2 {
|
||||
|
||||
public FluidNetMK2 getPipeNet(FluidType type);
|
||||
public void setPipeNet(FluidType type, FluidNetMK2 network);
|
||||
}
|
||||
@ -7,7 +7,11 @@ import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public interface IFluidPipeMK2 {
|
||||
/**
|
||||
* IFluidConductorMK2 with added node creation method
|
||||
* @author hbm
|
||||
*/
|
||||
public interface IFluidPipeMK2 extends IFluidConnectorMK2 {
|
||||
|
||||
public default FluidNode createNode(FluidType type) {
|
||||
TileEntity tile = (TileEntity) this;
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
package api.hbm.fluidmk2;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.uninos.IGenProvider;
|
||||
import com.hbm.uninos.networkproviders.FluidNetProvider;
|
||||
|
||||
public interface IFluidProviderMK2 extends IFluidUserMK2, IGenProvider<FluidNetProvider> {
|
||||
public interface IFluidProviderMK2 extends IFluidUserMK2 {
|
||||
|
||||
public void useUpFluid(FluidType type, int pressure, long amount);
|
||||
public long getProviderSpeed(FluidType type, int pressure);
|
||||
public default long getProviderSpeed(FluidType type, int pressure) { return 1_000_000_000; }
|
||||
public long getFluidAvailable(FluidType type, int pressure);
|
||||
}
|
||||
|
||||
@ -1,13 +1,62 @@
|
||||
package api.hbm.fluidmk2;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.uninos.IGenReceiver;
|
||||
import com.hbm.uninos.networkproviders.FluidNetProvider;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.toclient.AuxParticlePacketNT;
|
||||
import com.hbm.uninos.GenNode;
|
||||
import com.hbm.uninos.UniNodespace;
|
||||
import com.hbm.util.Compat;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
public interface IFluidReceiverMK2 extends IFluidUserMK2, IGenReceiver<FluidNetProvider> {
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2.ConnectionPriority;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IFluidReceiverMK2 extends IFluidUserMK2 {
|
||||
|
||||
/** Sends fluid of the desired type and pressure to the receiver, returns the remainder */
|
||||
public long transferFluid(FluidType type, int pressure, long amount);
|
||||
public long getReceiverSpeed(FluidType type, int pressure);
|
||||
public default long getReceiverSpeed(FluidType type, int pressure) { return 1_000_000_000; }
|
||||
public long getDemand(FluidType type, int pressure);
|
||||
|
||||
public default void trySubscribe(FluidType type, World world, DirPos pos) { trySubscribe(type, world, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); }
|
||||
|
||||
public default void trySubscribe(FluidType type, World world, int x, int y, int z, ForgeDirection dir) {
|
||||
|
||||
TileEntity te = Compat.getTileStandard(world, x, y, z);
|
||||
boolean red = false;
|
||||
|
||||
if(te instanceof IFluidConnectorMK2) {
|
||||
IFluidConnectorMK2 con = (IFluidConnectorMK2) te;
|
||||
if(!con.canConnect(type, dir.getOpposite())) return;
|
||||
|
||||
GenNode node = UniNodespace.getNode(world, x, y, z, type.getNetworkProvider());
|
||||
|
||||
if(node != null && node.net != null) {
|
||||
node.net.addReceiver(this);
|
||||
red = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(particleDebug) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setString("type", "network");
|
||||
data.setString("mode", "fluid");
|
||||
data.setInteger("color", type.getColor());
|
||||
double posX = x + 0.5 + dir.offsetX * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
|
||||
double posY = y + 0.5 + dir.offsetY * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
|
||||
double posZ = z + 0.5 + dir.offsetZ * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
|
||||
data.setDouble("mX", -dir.offsetX * (red ? 0.025 : 0.1));
|
||||
data.setDouble("mY", -dir.offsetY * (red ? 0.025 : 0.1));
|
||||
data.setDouble("mZ", -dir.offsetZ * (red ? 0.025 : 0.1));
|
||||
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, posX, posY, posZ), new TargetPoint(world.provider.dimensionId, posX, posY, posZ, 25));
|
||||
}
|
||||
}
|
||||
|
||||
public default ConnectionPriority getFluidPriority() {
|
||||
return ConnectionPriority.NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,87 +0,0 @@
|
||||
package api.hbm.fluidmk2;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.toclient.AuxParticlePacketNT;
|
||||
import com.hbm.util.Compat;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IFluidStandardReceiver extends IFluidReceiverMK2 {
|
||||
|
||||
public default void trySubscribe(FluidType type, World world, DirPos pos) { trySubscribe(type, world, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); }
|
||||
|
||||
public default void trySubscribe(FluidType type, World world, int x, int y, int z, ForgeDirection dir) {
|
||||
|
||||
TileEntity te = Compat.getTileStandard(world, x, y, z);
|
||||
boolean red = false;
|
||||
|
||||
if(te instanceof IFluidConductorMK2) {
|
||||
IFluidConductorMK2 con = (IFluidConductorMK2) te;
|
||||
|
||||
if(!con.canConnect(type, dir)) return;
|
||||
|
||||
if(con.getPipeNet(type) != null && !con.getPipeNet(type).isSubscribed(this))
|
||||
con.getPipeNet(type).addReceiver(this);
|
||||
|
||||
if(con.getPipeNet(type) != null) red = true;
|
||||
}
|
||||
|
||||
if(particleDebug) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setString("type", "network");
|
||||
data.setString("mode", "fluid");
|
||||
data.setInteger("color", type.getColor());
|
||||
double posX = x + 0.5 + dir.offsetX * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
|
||||
double posY = y + 0.5 + dir.offsetY * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
|
||||
double posZ = z + 0.5 + dir.offsetZ * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
|
||||
data.setDouble("mX", -dir.offsetX * (red ? 0.025 : 0.1));
|
||||
data.setDouble("mY", -dir.offsetY * (red ? 0.025 : 0.1));
|
||||
data.setDouble("mZ", -dir.offsetZ * (red ? 0.025 : 0.1));
|
||||
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, posX, posY, posZ), new TargetPoint(world.provider.dimensionId, posX, posY, posZ, 25));
|
||||
}
|
||||
}
|
||||
|
||||
public FluidTank[] getReceivingTanks();
|
||||
|
||||
@Override
|
||||
public default long getDemand(FluidType type, int pressure) {
|
||||
long amount = 0;
|
||||
for(FluidTank tank : getReceivingTanks()) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) amount += (tank.getMaxFill() - tank.getFill());
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public default long transferFluid(FluidType type, int pressure, long amount) {
|
||||
int tanks = 0;
|
||||
for(FluidTank tank : getReceivingTanks()) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) tanks++;
|
||||
}
|
||||
if(tanks > 1) {
|
||||
int firstRound = (int) Math.floor((double) amount / (double) tanks);
|
||||
for(FluidTank tank : getReceivingTanks()) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
int toAdd = Math.min(firstRound, tank.getMaxFill() - tank.getFill());
|
||||
tank.setFill(tank.getFill() + toAdd);
|
||||
amount -= toAdd;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(amount > 0) for(FluidTank tank : getReceivingTanks()) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
int toAdd = (int) Math.min(amount, tank.getMaxFill() - tank.getFill());
|
||||
tank.setFill(tank.getFill() + toAdd);
|
||||
amount -= toAdd;
|
||||
}
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package api.hbm.fluidmk2;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
|
||||
/**
|
||||
* IFluidReceiverMK2 with standard implementation for transfer and demand getter.
|
||||
* @author hbm
|
||||
*/
|
||||
public interface IFluidStandardReceiverMK2 extends IFluidReceiverMK2 {
|
||||
|
||||
public FluidTank[] getReceivingTanks();
|
||||
|
||||
@Override
|
||||
public default long getDemand(FluidType type, int pressure) {
|
||||
long amount = 0;
|
||||
for(FluidTank tank : getReceivingTanks()) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) amount += (tank.getMaxFill() - tank.getFill());
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public default long transferFluid(FluidType type, int pressure, long amount) {
|
||||
int tanks = 0;
|
||||
for(FluidTank tank : getReceivingTanks()) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) tanks++;
|
||||
}
|
||||
if(tanks > 1) {
|
||||
int firstRound = (int) Math.floor((double) amount / (double) tanks);
|
||||
for(FluidTank tank : getReceivingTanks()) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
int toAdd = Math.min(firstRound, tank.getMaxFill() - tank.getFill());
|
||||
tank.setFill(tank.getFill() + toAdd);
|
||||
amount -= toAdd;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(amount > 0) for(FluidTank tank : getReceivingTanks()) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
int toAdd = (int) Math.min(amount, tank.getMaxFill() - tank.getFill());
|
||||
tank.setFill(tank.getFill() + toAdd);
|
||||
amount -= toAdd;
|
||||
}
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public default long getReceiverSpeed(FluidType type, int pressure) {
|
||||
return 1_000_000_000;
|
||||
}
|
||||
}
|
||||
@ -15,6 +15,10 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* IFluidProviderMK2 with standard implementation for fluid provision and fluid removal.
|
||||
* @author hbm
|
||||
*/
|
||||
public interface IFluidStandardSenderMK2 extends IFluidProviderMK2 {
|
||||
|
||||
public default void tryProvide(FluidTank tank, World world, DirPos pos) { tryProvide(tank.getTankType(), tank.getPressure(), world, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); }
|
||||
@ -29,8 +33,8 @@ public interface IFluidStandardSenderMK2 extends IFluidProviderMK2 {
|
||||
TileEntity te = Compat.getTileStandard(world, x, y, z);
|
||||
boolean red = false;
|
||||
|
||||
if(te instanceof IFluidConductorMK2) {
|
||||
IFluidConductorMK2 con = (IFluidConductorMK2) te;
|
||||
if(te instanceof IFluidConnectorMK2) {
|
||||
IFluidConnectorMK2 con = (IFluidConnectorMK2) te;
|
||||
if(con.canConnect(type, dir.getOpposite())) {
|
||||
|
||||
GenNode<FluidNetMK2> node = UniNodespace.getNode(world, x, y, z, type.getNetworkProvider());
|
||||
@ -103,4 +107,9 @@ public interface IFluidStandardSenderMK2 extends IFluidProviderMK2 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public default long getProviderSpeed(FluidType type, int pressure) {
|
||||
return 1_000_000_000;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
package api.hbm.fluidmk2;
|
||||
|
||||
public interface IFluidStandardTransceiverMK2 extends IFluidStandardReceiverMK2, IFluidStandardSenderMK2 {
|
||||
|
||||
}
|
||||
@ -18,7 +18,7 @@ import com.hbm.render.block.RenderBlockMultipass;
|
||||
import com.hbm.util.EnumUtil;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import api.hbm.fluid.IFillableItem;
|
||||
import api.hbm.fluidmk2.IFillableItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
|
||||
@ -4,13 +4,14 @@ import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.render.block.ct.CT;
|
||||
import com.hbm.render.block.ct.CTStitchReceiver;
|
||||
import com.hbm.render.block.ct.IBlockCT;
|
||||
import com.hbm.tileentity.machine.TileEntityPWRController;
|
||||
|
||||
import api.hbm.fluid.IFluidConnector;
|
||||
import api.hbm.fluidmk2.IFluidReceiverMK2;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
@ -97,7 +98,7 @@ public class BlockPWR extends BlockContainer implements IBlockCT {
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
}
|
||||
|
||||
public static class TileEntityBlockPWR extends TileEntity implements IFluidConnector, ISidedInventory {
|
||||
public static class TileEntityBlockPWR extends TileEntity implements IFluidReceiverMK2, ISidedInventory {
|
||||
|
||||
public Block block;
|
||||
public int coreX;
|
||||
@ -189,15 +190,22 @@ public class BlockPWR extends BlockContainer implements IBlockCT {
|
||||
|
||||
@Override
|
||||
public long getDemand(FluidType type, int pressure) {
|
||||
|
||||
if(this.getBlockMetadata() != 1) return 0;
|
||||
if(block == null) return 0;
|
||||
TileEntityPWRController controller = this.getCore();
|
||||
if(controller != null) return controller.getDemand(type, pressure);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getAllTanks() {
|
||||
if(this.getBlockMetadata() != 1) return FluidTank.EMPTY_ARRAY;
|
||||
if(block == null) return FluidTank.EMPTY_ARRAY;
|
||||
TileEntityPWRController controller = this.getCore();
|
||||
if(controller != null) return controller.getAllTanks();
|
||||
return FluidTank.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(FluidType type, ForgeDirection dir) {
|
||||
return this.getBlockMetadata() == 1;
|
||||
@ -316,18 +324,5 @@ public class BlockPWR extends BlockContainer implements IBlockCT {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isLoaded = true;
|
||||
|
||||
@Override
|
||||
public boolean isLoaded() {
|
||||
return isLoaded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
this.isLoaded = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
package com.hbm.blocks.network;
|
||||
|
||||
import api.hbm.fluid.IPipeNet;
|
||||
import api.hbm.fluid.PipeNet;
|
||||
import com.hbm.blocks.IAnalyzable;
|
||||
import com.hbm.extprop.HbmPlayerProps;
|
||||
import com.hbm.handler.HbmKeybinds;
|
||||
@ -9,6 +7,10 @@ import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.items.machine.IItemFluidIdentifier;
|
||||
import com.hbm.items.machine.ItemFluidIDMulti;
|
||||
import com.hbm.tileentity.network.TileEntityPipeBaseNT;
|
||||
import com.hbm.uninos.UniNodespace;
|
||||
|
||||
import api.hbm.fluidmk2.FluidNetMK2;
|
||||
import api.hbm.fluidmk2.FluidNode;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
@ -123,19 +125,17 @@ public class FluidDuctBase extends BlockContainer implements IBlockFluidDuct, IA
|
||||
FluidType type = pipe.getType();
|
||||
|
||||
if(type != null) {
|
||||
|
||||
IPipeNet net = pipe.getPipeNet(type);
|
||||
|
||||
if(net instanceof PipeNet) {
|
||||
PipeNet pipeNet = (PipeNet) net;
|
||||
|
||||
FluidNode node = (FluidNode) UniNodespace.getNode(world, x, y, z, type.getNetworkProvider());
|
||||
|
||||
if(node != null && node.net != null) {
|
||||
FluidNetMK2 net = node.net;
|
||||
|
||||
List<String> debug = new ArrayList();
|
||||
debug.add("=== DEBUG START ===");
|
||||
debug.addAll(pipeNet.debug);
|
||||
debug.add("=== DEBUG END ===");
|
||||
debug.add("Links: " + pipeNet.getLinks().size());
|
||||
debug.add("Subscribers: " + pipeNet.getSubscribers().size());
|
||||
debug.add("Transfer: " + pipeNet.getTotalTransfer());
|
||||
debug.add("Links: " + net.links.size());
|
||||
debug.add("Subscribers: " + net.receiverEntries.size());
|
||||
debug.add("Providers: " + net.providerEntries.size());
|
||||
debug.add("Transfer: " + net.fluidTracker);
|
||||
return debug;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.hbm.blocks.network;
|
||||
|
||||
import api.hbm.fluid.IPipeNet;
|
||||
import api.hbm.fluidmk2.FluidNetMK2;
|
||||
|
||||
import com.hbm.blocks.IBlockMultiPass;
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
import com.hbm.blocks.ITooltipProvider;
|
||||
@ -30,7 +31,6 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@ -109,7 +109,6 @@ public class FluidDuctGauge extends FluidDuctBase implements IBlockMultiPass, IL
|
||||
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
|
||||
public static class TileEntityPipeGauge extends TileEntityPipeBaseNT implements SimpleComponent, CompatHandler.OCComponent {
|
||||
|
||||
private BigInteger lastMeasurement = BigInteger.valueOf(10);
|
||||
private long deltaTick = 0;
|
||||
private long deltaSecond = 0;
|
||||
private long deltaLastSecond = 0;
|
||||
@ -120,22 +119,14 @@ public class FluidDuctGauge extends FluidDuctBase implements IBlockMultiPass, IL
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
IPipeNet net = this.getPipeNet(this.getType());
|
||||
if(this.node != null && this.node.net != null && this.getType() != Fluids.NONE) {
|
||||
|
||||
if(net != null && this.getType() != Fluids.NONE) {
|
||||
BigInteger total = net.getTotalTransfer();
|
||||
BigInteger delta = total.subtract(this.lastMeasurement);
|
||||
this.lastMeasurement = total;
|
||||
|
||||
try {
|
||||
this.deltaTick = delta.longValueExact();
|
||||
if(worldObj.getTotalWorldTime() % 20 == 0) {
|
||||
this.deltaLastSecond = this.deltaSecond;
|
||||
this.deltaSecond = 0;
|
||||
}
|
||||
this.deltaSecond += deltaTick;
|
||||
|
||||
} catch(Exception ex) { }
|
||||
this.deltaTick = ((FluidNetMK2) this.node.net).fluidTracker;
|
||||
if(worldObj.getTotalWorldTime() % 20 == 0) {
|
||||
this.deltaLastSecond = this.deltaSecond;
|
||||
this.deltaSecond = 0;
|
||||
}
|
||||
this.deltaSecond += deltaTick;
|
||||
}
|
||||
|
||||
networkPackNT(25);
|
||||
|
||||
@ -14,6 +14,7 @@ import com.hbm.inventory.fluid.trait.FluidTraitSimple.*;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.render.util.EnumSymbol;
|
||||
import com.hbm.uninos.INetworkProvider;
|
||||
import com.hbm.uninos.networkproviders.FluidNetProvider;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import api.hbm.fluidmk2.FluidNetMK2;
|
||||
@ -255,7 +256,9 @@ public class FluidType {
|
||||
return this.stringId;
|
||||
}
|
||||
|
||||
protected INetworkProvider<FluidNetMK2> NETWORK_PROVIDER = new FluidNetProvider();
|
||||
|
||||
public INetworkProvider<FluidNetMK2> getNetworkProvider() {
|
||||
return null; //TBI
|
||||
return NETWORK_PROVIDER;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ package com.hbm.inventory.fluid.tank;
|
||||
import com.hbm.handler.ArmorModHandler;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
|
||||
import api.hbm.fluid.IFillableItem;
|
||||
import api.hbm.fluidmk2.IFillableItem;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
@ -26,6 +26,8 @@ import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
public class FluidTank {
|
||||
|
||||
public static final FluidTank[] EMPTY_ARRAY = new FluidTank[0];
|
||||
|
||||
public static final List<FluidLoadingHandler> loadingHandlers = new ArrayList<FluidLoadingHandler>();
|
||||
public static final Set<Item> noDualUnload = new HashSet<Item>();
|
||||
|
||||
@ -5,7 +5,7 @@ import java.util.List;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
|
||||
import api.hbm.fluid.IFillableItem;
|
||||
import api.hbm.fluidmk2.IFillableItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
@ -5,7 +5,7 @@ import java.util.List;
|
||||
import com.hbm.handler.ArmorModHandler;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
|
||||
import api.hbm.fluid.IFillableItem;
|
||||
import api.hbm.fluidmk2.IFillableItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@ -12,7 +12,7 @@ import com.hbm.items.weapon.ItemGunBase;
|
||||
import com.hbm.lib.ModDamageSource;
|
||||
import com.hbm.potion.HbmPotion;
|
||||
|
||||
import api.hbm.fluid.IFillableItem;
|
||||
import api.hbm.fluidmk2.IFillableItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
||||
@ -13,7 +13,7 @@ import com.hbm.packet.toclient.AuxParticlePacketNT;
|
||||
|
||||
import api.hbm.block.IToolable;
|
||||
import api.hbm.block.IToolable.ToolType;
|
||||
import api.hbm.fluid.IFillableItem;
|
||||
import api.hbm.fluidmk2.IFillableItem;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@ -1,12 +1,11 @@
|
||||
package com.hbm.items.tool;
|
||||
|
||||
import api.hbm.fluid.IFillableItem;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import api.hbm.fluidmk2.IFillableItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ import java.util.List;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
|
||||
import api.hbm.fluid.IFillableItem;
|
||||
import api.hbm.fluidmk2.IFillableItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
@ -91,7 +91,7 @@ public class GunFactory {
|
||||
COIL_TUNGSTEN, COIL_FERROURANIUM,
|
||||
NUKE_STANDARD, NUKE_DEMO, NUKE_HIGH, NUKE_TOTS, NUKE_HIVE,
|
||||
G10, G10_SHRAPNEL, G10_DU, G10_SLUG,
|
||||
R762_HE,
|
||||
R762_HE, BMG50_HE
|
||||
|
||||
//ONLY ADD NEW ENTRIES AT THE BOTTOM TO AVOID SHIFTING!
|
||||
;
|
||||
@ -105,7 +105,7 @@ public class GunFactory {
|
||||
P9_SP, P9_FMJ, P9_JHP, P9_AP,
|
||||
R556_SP, R556_FMJ, R556_JHP, R556_AP,
|
||||
R762_SP, R762_FMJ, R762_JHP, R762_AP, R762_DU, R762_HE,
|
||||
BMG50_SP, BMG50_FMJ, BMG50_JHP, BMG50_AP, BMG50_DU,
|
||||
BMG50_SP, BMG50_FMJ, BMG50_JHP, BMG50_AP, BMG50_DU, BMG50_HE,
|
||||
B75, B75_INC, B75_EXP,
|
||||
G12_BP, G12_BP_MAGNUM, G12_BP_SLUG, G12, G12_SLUG, G12_FLECHETTE, G12_MAGNUM, G12_EXPLOSIVE, G12_PHOSPHORUS,
|
||||
G10, G10_SHRAPNEL, G10_DU, G10_SLUG,
|
||||
|
||||
@ -139,6 +139,7 @@ public class GunFactoryClient {
|
||||
bmg50_jhp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
|
||||
bmg50_ap.setRenderer(LegoClient.RENDER_AP_BULLET);
|
||||
bmg50_du.setRenderer(LegoClient.RENDER_DU_BULLET);
|
||||
bmg50_he.setRenderer(LegoClient.RENDER_HE_BULLET);
|
||||
|
||||
b75.setRenderer(LegoClient.RENDER_AP_BULLET);
|
||||
b75_inc.setRenderer(LegoClient.RENDER_AP_BULLET);
|
||||
|
||||
@ -3,6 +3,7 @@ package com.hbm.items.weapon.sedna.factory;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import com.hbm.entity.projectile.EntityBulletBaseMK4;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.ItemEnums.EnumCasingType;
|
||||
import com.hbm.items.weapon.sedna.BulletConfig;
|
||||
@ -22,6 +23,7 @@ import com.hbm.render.anim.BusAnimationKeyframe.IType;
|
||||
import com.hbm.render.anim.HbmAnimations.AnimType;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
|
||||
public class XFactory50 {
|
||||
|
||||
@ -30,6 +32,12 @@ public class XFactory50 {
|
||||
public static BulletConfig bmg50_jhp;
|
||||
public static BulletConfig bmg50_ap;
|
||||
public static BulletConfig bmg50_du;
|
||||
public static BulletConfig bmg50_he;
|
||||
|
||||
public static BiConsumer<EntityBulletBaseMK4, MovingObjectPosition> LAMBDA_STANDARD_EXPLODE = (bullet, mop) -> {
|
||||
if(mop.typeOfHit == mop.typeOfHit.ENTITY && bullet.ticksExisted < 3 && mop.entityHit == bullet.getThrower()) return;
|
||||
Lego.tinyExplode(bullet, mop, 3.5F); bullet.setDead();
|
||||
};
|
||||
|
||||
public static void init() {
|
||||
SpentCasing casing762 = new SpentCasing(CasingType.BOTTLENECK).setColor(SpentCasing.COLOR_CASE_BRASS).setScale(1.5F);
|
||||
@ -43,12 +51,14 @@ public class XFactory50 {
|
||||
.setCasing(casing762.clone().setColor(SpentCasing.COLOR_CASE_44).register("bmg50ap"));
|
||||
bmg50_du = new BulletConfig().setItem(EnumAmmo.BMG50_DU).setCasing(EnumCasingType.LARGE_STEEL, 12).setDoesPenetrate(true).setDamageFalloutByPen(false).setDamage(2.5F).setThresholdNegation(21F).setArmorPiercing(0.25F)
|
||||
.setCasing(casing762.clone().setColor(SpentCasing.COLOR_CASE_44).register("bmg50du"));
|
||||
bmg50_he = new BulletConfig().setItem(EnumAmmo.BMG50_HE).setCasing(EnumCasingType.LARGE_STEEL, 12).setDoesPenetrate(true).setDamageFalloutByPen(false).setDamage(2F).setOnImpact(LAMBDA_STANDARD_EXPLODE)
|
||||
.setCasing(casing762.clone().setColor(SpentCasing.COLOR_CASE_44).register("bmg50he"));
|
||||
|
||||
ModItems.gun_m2 = new ItemGunBaseNT(WeaponQuality.A_SIDE, new GunConfig()
|
||||
.dura(3_000).draw(10).inspect(31).crosshair(Crosshair.L_CIRCLE).smoke(LAMBDA_SMOKE)
|
||||
.rec(new Receiver(0)
|
||||
.dmg(7.5F).delay(2).dry(10).auto(true).spread(0.005F).sound("hbm:turret.chekhov_fire", 1.0F, 1.0F)
|
||||
.mag(new MagazineBelt().addConfigs(bmg50_sp, bmg50_fmj, bmg50_jhp, bmg50_ap, bmg50_du))
|
||||
.mag(new MagazineBelt().addConfigs(bmg50_sp, bmg50_fmj, bmg50_jhp, bmg50_ap, bmg50_du, bmg50_he))
|
||||
.offset(1, -0.0625 * 2.5, -0.25D)
|
||||
.setupStandardFire().recoil(LAMBDA_RECOIL_M2))
|
||||
.setupStandardConfiguration()
|
||||
|
||||
@ -13,7 +13,7 @@ import com.hbm.items.weapon.sedna.mags.IMagazine;
|
||||
import com.hbm.items.weapon.sedna.mags.MagazineFluid;
|
||||
import com.hbm.render.anim.HbmAnimations.AnimType;
|
||||
|
||||
import api.hbm.fluid.IFillableItem;
|
||||
import api.hbm.fluidmk2.IFillableItem;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
package com.hbm.tileentity;
|
||||
|
||||
import api.hbm.fluid.IFluidStandardTransceiver;
|
||||
import api.hbm.fluid.IFluidUser;
|
||||
import com.hbm.interfaces.ICopiable;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
|
||||
import api.hbm.fluidmk2.IFluidStandardTransceiverMK2;
|
||||
import api.hbm.fluidmk2.IFluidUserMK2;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@ -20,7 +21,7 @@ public interface IFluidCopiable extends ICopiable {
|
||||
* none if there is no alt paste support
|
||||
*/
|
||||
default int[] getFluidIDToCopy() {
|
||||
IFluidUser tile = (IFluidUser) this;
|
||||
IFluidUserMK2 tile = (IFluidUserMK2) this;
|
||||
ArrayList<Integer> types = new ArrayList<>();
|
||||
|
||||
for(FluidTank tank : tile.getAllTanks()) {
|
||||
@ -33,8 +34,8 @@ public interface IFluidCopiable extends ICopiable {
|
||||
|
||||
default FluidTank getTankToPaste() {
|
||||
TileEntity te = (TileEntity) this;
|
||||
if(te instanceof IFluidStandardTransceiver) {
|
||||
IFluidStandardTransceiver tile = (IFluidStandardTransceiver) this;
|
||||
if(te instanceof IFluidStandardTransceiverMK2) { // why are we using the transceiver here?
|
||||
IFluidStandardTransceiverMK2 tile = (IFluidStandardTransceiverMK2) this;
|
||||
return tile.getReceivingTanks() != null ? tile.getReceivingTanks()[0] : null;
|
||||
}
|
||||
return null;
|
||||
|
||||
@ -6,7 +6,8 @@ import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
|
||||
import api.hbm.fluid.IFluidUser;
|
||||
import api.hbm.fluid.IFluidStandardSender;
|
||||
|
||||
import com.hbm.inventory.fluid.trait.FT_Polluting;
|
||||
import com.hbm.inventory.fluid.trait.FluidTrait;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@ -15,7 +16,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class TileEntityMachinePolluting extends TileEntityMachineBase implements IFluidUser {
|
||||
public abstract class TileEntityMachinePolluting extends TileEntityMachineBase implements IFluidStandardSender {
|
||||
|
||||
public FluidTank smoke;
|
||||
public FluidTank smoke_leaded;
|
||||
|
||||
@ -4,9 +4,11 @@ import api.hbm.block.ICrucibleAcceptor;
|
||||
import com.hbm.handler.CompatHandler;
|
||||
import com.hbm.handler.CompatHandler.OCComponent;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2;
|
||||
import api.hbm.fluid.IFluidConnector;
|
||||
import api.hbm.fluidmk2.IFluidConnectorMK2;
|
||||
import api.hbm.fluidmk2.IFluidReceiverMK2;
|
||||
import api.hbm.tile.IHeatSource;
|
||||
import com.hbm.inventory.material.Mats;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
@ -26,7 +28,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
@Optional.Interface(iface = "com.hbm.handler.CompatHandler.OCComponent", modid = "opencomputers"),
|
||||
@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "opencomputers")
|
||||
})
|
||||
public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergyReceiverMK2, ISidedInventory, IFluidConnector, IHeatSource, ICrucibleAcceptor, SimpleComponent, OCComponent {
|
||||
public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergyReceiverMK2, ISidedInventory, IFluidReceiverMK2, IHeatSource, ICrucibleAcceptor, SimpleComponent, OCComponent {
|
||||
|
||||
TileEntity tile;
|
||||
boolean inventory;
|
||||
@ -143,6 +145,53 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy
|
||||
return true;
|
||||
}
|
||||
|
||||
public static final FluidTank[] EMPTY_TANKS = new FluidTank[0];
|
||||
|
||||
@Override
|
||||
public FluidTank[] getAllTanks() {
|
||||
if(!fluid) return EMPTY_TANKS;
|
||||
|
||||
if(getTile() instanceof IFluidReceiverMK2) {
|
||||
return ((IFluidReceiverMK2)getTile()).getAllTanks();
|
||||
}
|
||||
|
||||
return EMPTY_TANKS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long transferFluid(FluidType type, int pressure, long amount) {
|
||||
if(!fluid) return amount;
|
||||
|
||||
if(getTile() instanceof IFluidReceiverMK2) {
|
||||
return ((IFluidReceiverMK2)getTile()).transferFluid(type, pressure, amount);
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDemand(FluidType type, int pressure) {
|
||||
if(!fluid) return 0;
|
||||
|
||||
if(getTile() instanceof IFluidReceiverMK2) {
|
||||
return ((IFluidReceiverMK2)getTile()).getDemand(type, pressure);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(FluidType type, ForgeDirection dir) {
|
||||
|
||||
if(!this.fluid)
|
||||
return false;
|
||||
|
||||
if(getTile() instanceof IFluidConnectorMK2) {
|
||||
return ((IFluidConnectorMK2) getTile()).canConnect(type, dir);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
|
||||
@ -368,42 +417,6 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy
|
||||
nbt.setString("ocname", componentName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long transferFluid(FluidType type, int pressure, long fluid) {
|
||||
|
||||
if(!this.fluid)
|
||||
return fluid;
|
||||
|
||||
if(getTile() instanceof IFluidConnector) {
|
||||
return ((IFluidConnector)getTile()).transferFluid(type, pressure, fluid);
|
||||
}
|
||||
return fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDemand(FluidType type, int pressure) {
|
||||
|
||||
if(!this.fluid)
|
||||
return 0;
|
||||
|
||||
if(getTile() instanceof IFluidConnector) {
|
||||
return ((IFluidConnector)getTile()).getDemand(type, pressure);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(FluidType type, ForgeDirection dir) {
|
||||
|
||||
if(!this.fluid)
|
||||
return false;
|
||||
|
||||
if(getTile() instanceof IFluidConnector) {
|
||||
return ((IFluidConnector)getTile()).canConnect(type, dir);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeatStored() {
|
||||
|
||||
|
||||
@ -9,12 +9,12 @@ import com.hbm.lib.Library;
|
||||
import com.hbm.tileentity.IBufPacketReceiver;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
|
||||
import api.hbm.fluid.IFluidUser;
|
||||
import api.hbm.fluidmk2.IFluidReceiverMK2;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public abstract class TileEntityChimneyBase extends TileEntityLoadedBase implements IFluidUser, IBufPacketReceiver {
|
||||
public abstract class TileEntityChimneyBase extends TileEntityLoadedBase implements IFluidReceiverMK2, IBufPacketReceiver {
|
||||
|
||||
public long ashTick = 0;
|
||||
public long sootTick = 0;
|
||||
|
||||
@ -81,7 +81,7 @@ public class TileEntityMachineChemfac extends TileEntityMachineChemplantBase imp
|
||||
|
||||
for(DirPos pos : getConPos()) for(FluidTank tank : outTanks()) {
|
||||
if(tank.getTankType() != Fluids.NONE && tank.getFill() > 0) {
|
||||
this.sendFluid(tank, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||
this.tryProvide(tank, worldObj, pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.inventory.RecipesCommon.AStack;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.inventory.recipes.ChemplantRecipes;
|
||||
@ -19,7 +18,7 @@ import com.hbm.util.ItemStackUtil;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2;
|
||||
import api.hbm.fluid.IFluidUser;
|
||||
import api.hbm.fluidmk2.IFluidStandardTransceiverMK2;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@ -34,7 +33,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
* Tanks follow the order R1(I1, I2, O1, O2), R2(I1, I2, O1, O2) ...
|
||||
* @author hbm
|
||||
*/
|
||||
public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBase implements IEnergyReceiverMK2, IFluidUser, IGUIProvider {
|
||||
public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBase implements IEnergyReceiverMK2, IFluidStandardTransceiverMK2, IGUIProvider {
|
||||
|
||||
public long power;
|
||||
public int[] progress;
|
||||
@ -344,39 +343,6 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa
|
||||
this.power = power;
|
||||
}
|
||||
|
||||
/*public int getFluidFill(FluidType type) {
|
||||
|
||||
int fill = 0;
|
||||
|
||||
for(FluidTank tank : inTanks()) {
|
||||
if(tank.getTankType() == type) {
|
||||
fill += tank.getFill();
|
||||
}
|
||||
}
|
||||
|
||||
for(FluidTank tank : outTanks()) {
|
||||
if(tank.getTankType() == type) {
|
||||
fill += tank.getFill();
|
||||
}
|
||||
}
|
||||
|
||||
return fill;
|
||||
}*/
|
||||
|
||||
/* For input only! */
|
||||
public int getMaxFluidFill(FluidType type) {
|
||||
|
||||
int maxFill = 0;
|
||||
|
||||
for(FluidTank tank : inTanks()) {
|
||||
if(tank.getTankType() == type) {
|
||||
maxFill += tank.getMaxFill();
|
||||
}
|
||||
}
|
||||
|
||||
return maxFill;
|
||||
}
|
||||
|
||||
protected List<FluidTank> inTanks() {
|
||||
|
||||
List<FluidTank> inTanks = new ArrayList();
|
||||
@ -391,113 +357,6 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa
|
||||
return inTanks;
|
||||
}
|
||||
|
||||
/*public void receiveFluid(int amount, FluidType type) {
|
||||
|
||||
if(amount <= 0)
|
||||
return;
|
||||
|
||||
List<FluidTank> rec = new ArrayList();
|
||||
|
||||
for(FluidTank tank : inTanks()) {
|
||||
if(tank.getTankType() == type) {
|
||||
rec.add(tank);
|
||||
}
|
||||
}
|
||||
|
||||
if(rec.size() == 0)
|
||||
return;
|
||||
|
||||
int demand = 0;
|
||||
List<Integer> weight = new ArrayList();
|
||||
|
||||
for(FluidTank tank : rec) {
|
||||
int fillWeight = tank.getMaxFill() - tank.getFill();
|
||||
demand += fillWeight;
|
||||
weight.add(fillWeight);
|
||||
}
|
||||
|
||||
for(int i = 0; i < rec.size(); i++) {
|
||||
|
||||
if(demand <= 0)
|
||||
break;
|
||||
|
||||
FluidTank tank = rec.get(i);
|
||||
int fillWeight = weight.get(i);
|
||||
int part = (int) (Math.min((long)amount, (long)demand) * (long)fillWeight / (long)demand);
|
||||
|
||||
tank.setFill(tank.getFill() + part);
|
||||
}
|
||||
}*/
|
||||
|
||||
public int getFluidFillForTransfer(FluidType type, int pressure) {
|
||||
|
||||
int fill = 0;
|
||||
|
||||
for(FluidTank tank : outTanks()) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
fill += tank.getFill();
|
||||
}
|
||||
}
|
||||
|
||||
return fill;
|
||||
}
|
||||
|
||||
public void transferFluid(int amount, FluidType type, int pressure) {
|
||||
|
||||
/*
|
||||
* this whole new fluid mumbo jumbo extra abstraction layer might just be a bandaid
|
||||
* on the gushing wound that is the current fluid systemm but i'll be damned if it
|
||||
* didn't at least do what it's supposed to. half a decade and we finally have multi
|
||||
* tank support for tanks with matching fluid types!!
|
||||
*/
|
||||
if(amount <= 0)
|
||||
return;
|
||||
|
||||
List<FluidTank> send = new ArrayList();
|
||||
|
||||
for(FluidTank tank : outTanks()) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
send.add(tank);
|
||||
}
|
||||
}
|
||||
|
||||
if(send.size() == 0)
|
||||
return;
|
||||
|
||||
int offer = 0;
|
||||
List<Integer> weight = new ArrayList();
|
||||
|
||||
for(FluidTank tank : send) {
|
||||
int fillWeight = tank.getFill();
|
||||
offer += fillWeight;
|
||||
weight.add(fillWeight);
|
||||
}
|
||||
|
||||
int tracker = amount;
|
||||
|
||||
for(int i = 0; i < send.size(); i++) {
|
||||
|
||||
FluidTank tank = send.get(i);
|
||||
int fillWeight = weight.get(i);
|
||||
int part = amount * fillWeight / offer;
|
||||
|
||||
tank.setFill(tank.getFill() - part);
|
||||
tracker -= part;
|
||||
}
|
||||
|
||||
//making sure to properly deduct even the last mB lost by rounding errors
|
||||
for(int i = 0; i < 100 && tracker > 0; i++) {
|
||||
|
||||
FluidTank tank = send.get(i % send.size());
|
||||
|
||||
if(tank.getFill() > 0) {
|
||||
int total = Math.min(tank.getFill(), tracker);
|
||||
tracker -= total;
|
||||
tank.setFill(tank.getFill() - total);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected List<FluidTank> outTanks() {
|
||||
|
||||
List<FluidTank> outTanks = new ArrayList();
|
||||
@ -512,69 +371,21 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa
|
||||
return outTanks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getReceivingTanks() {
|
||||
return this.inTanks().toArray(new FluidTank[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getSendingTanks() {
|
||||
return this.outTanks().toArray(new FluidTank[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getAllTanks() {
|
||||
return tanks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long transferFluid(FluidType type, int pressure, long fluid) {
|
||||
int amount = (int) fluid;
|
||||
|
||||
if(amount <= 0)
|
||||
return 0;
|
||||
|
||||
List<FluidTank> rec = new ArrayList();
|
||||
|
||||
for(FluidTank tank : inTanks()) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
rec.add(tank);
|
||||
}
|
||||
}
|
||||
|
||||
if(rec.size() == 0)
|
||||
return fluid;
|
||||
|
||||
int demand = 0;
|
||||
List<Integer> weight = new ArrayList();
|
||||
|
||||
for(FluidTank tank : rec) {
|
||||
int fillWeight = tank.getMaxFill() - tank.getFill();
|
||||
demand += fillWeight;
|
||||
weight.add(fillWeight);
|
||||
}
|
||||
|
||||
for(int i = 0; i < rec.size(); i++) {
|
||||
|
||||
if(demand <= 0)
|
||||
break;
|
||||
|
||||
FluidTank tank = rec.get(i);
|
||||
int fillWeight = weight.get(i);
|
||||
int part = (int) (Math.min((long)amount, (long)demand) * (long)fillWeight / (long)demand);
|
||||
|
||||
tank.setFill(tank.getFill() + part);
|
||||
fluid -= part;
|
||||
}
|
||||
|
||||
return fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDemand(FluidType type, int pressure) {
|
||||
return getMaxFluidFill(type) - getFluidFillForTransfer(type, pressure);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalFluidForSend(FluidType type, int pressure) {
|
||||
return getFluidFillForTransfer(type, pressure);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFluidForTransfer(FluidType type, int pressure, long amount) {
|
||||
this.transferFluid((int) amount, type, pressure);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
@ -10,8 +10,8 @@ import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
|
||||
import api.hbm.fluid.IFillableItem;
|
||||
import api.hbm.fluid.IFluidStandardReceiver;
|
||||
import api.hbm.fluidmk2.IFillableItem;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
package com.hbm.tileentity.machine.rbmk;
|
||||
|
||||
import api.hbm.fluid.IFluidConductor;
|
||||
import api.hbm.fluid.IFluidConnector;
|
||||
import api.hbm.fluid.IPipeNet;
|
||||
import api.hbm.fluidmk2.FluidNetMK2;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.blocks.machine.rbmk.RBMKBase;
|
||||
import com.hbm.entity.effect.EntitySpear;
|
||||
@ -422,7 +421,7 @@ public abstract class TileEntityRBMKBase extends TileEntityLoadedBase {
|
||||
}
|
||||
|
||||
public static HashSet<TileEntityRBMKBase> columns = new HashSet<>();
|
||||
public static HashSet<IPipeNet> pipes = new HashSet<>();
|
||||
public static HashSet<FluidNetMK2> pipes = new HashSet<>();
|
||||
|
||||
//assumes that !worldObj.isRemote
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -489,22 +488,22 @@ public abstract class TileEntityRBMKBase extends TileEntityLoadedBase {
|
||||
|
||||
/* Hanlde overpressure event */
|
||||
if(RBMKDials.getOverpressure(worldObj) && !pipes.isEmpty()) {
|
||||
HashSet<IFluidConductor> pipeBlocks = new HashSet<>();
|
||||
HashSet<IFluidConnector> pipeReceivers = new HashSet<>();
|
||||
HashSet pipeBlocks = new HashSet<>();
|
||||
HashSet pipeReceivers = new HashSet<>();
|
||||
|
||||
//unify all parts into single sets to prevent redundancy
|
||||
pipes.forEach(x -> {
|
||||
pipeBlocks.addAll(x.getLinks());
|
||||
pipeReceivers.addAll(x.getSubscribers());
|
||||
pipeBlocks.addAll(x.links);
|
||||
pipeReceivers.addAll(x.receiverEntries.entrySet());
|
||||
});
|
||||
|
||||
int count = 0;
|
||||
int max = Math.min(pipeBlocks.size() / 5, 100);
|
||||
Iterator<IFluidConductor> itPipes = pipeBlocks.iterator();
|
||||
Iterator<IFluidConnector> itReceivers = pipeReceivers.iterator();
|
||||
Iterator itPipes = pipeBlocks.iterator();
|
||||
Iterator itReceivers = pipeReceivers.iterator();
|
||||
|
||||
while(itPipes.hasNext() && count < max) {
|
||||
IFluidConductor pipe = itPipes.next();
|
||||
Object pipe = itPipes.next();
|
||||
if(pipe instanceof TileEntity) {
|
||||
TileEntity tile = (TileEntity) pipe;
|
||||
worldObj.setBlock(tile.xCoord, tile.yCoord, tile.zCoord, Blocks.air);
|
||||
@ -513,7 +512,7 @@ public abstract class TileEntityRBMKBase extends TileEntityLoadedBase {
|
||||
}
|
||||
|
||||
while(itReceivers.hasNext()) {
|
||||
IFluidConnector con = itReceivers.next();
|
||||
Object con = itReceivers.next();
|
||||
if(con instanceof TileEntity) {
|
||||
TileEntity tile = (TileEntity) con;
|
||||
if(con instanceof IOverpressurable) {
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
package com.hbm.tileentity.machine.rbmk;
|
||||
|
||||
import api.hbm.fluid.IFluidStandardTransceiver;
|
||||
import api.hbm.fluid.IFluidUser;
|
||||
import api.hbm.fluid.IPipeNet;
|
||||
import api.hbm.fluidmk2.FluidNode;
|
||||
import api.hbm.tile.IInfoProviderEC;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
@ -16,6 +15,7 @@ import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.inventory.gui.GUIRBMKBoiler;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole.ColumnType;
|
||||
import com.hbm.uninos.UniNodespace;
|
||||
import com.hbm.util.CompatEnergyControl;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
@ -212,9 +212,9 @@ public class TileEntityRBMKBoiler extends TileEntityRBMKSlottedBase implements I
|
||||
|
||||
if(RBMKDials.getOverpressure(worldObj)) {
|
||||
for(DirPos pos : getOutputPos()) {
|
||||
IPipeNet net = IFluidUser.getPipeNet(worldObj, pos.getX(), pos.getY(), pos.getZ(), steam.getTankType());
|
||||
if(net != null) {
|
||||
this.pipes.add(net);
|
||||
FluidNode node = (FluidNode) UniNodespace.getNode(worldObj, pos.getX(), pos.getY(), pos.getZ(), steam.getTankType().getNetworkProvider());
|
||||
if(node.net != null) {
|
||||
this.pipes.add(node.net);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.hbm.tileentity.machine.storage;
|
||||
|
||||
import api.hbm.fluid.*;
|
||||
import api.hbm.fluidmk2.IFluidStandardTransceiverMK2;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.handler.CompatHandler;
|
||||
import com.hbm.inventory.FluidContainerRegistry;
|
||||
@ -32,24 +33,17 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "opencomputers")})
|
||||
public class TileEntityBarrel extends TileEntityMachineBase implements SimpleComponent, IFluidStandardTransceiver, IPersistentNBT, IGUIProvider, CompatHandler.OCComponent, IFluidCopiable {
|
||||
public class TileEntityBarrel extends TileEntityMachineBase implements SimpleComponent, IFluidStandardTransceiverMK2, IPersistentNBT, IGUIProvider, CompatHandler.OCComponent, IFluidCopiable {
|
||||
|
||||
public FluidTank tank;
|
||||
public short mode = 0;
|
||||
public static final short modes = 4;
|
||||
public int age = 0;
|
||||
protected boolean sendingBrake = false;
|
||||
public byte lastRedstone = 0;
|
||||
|
||||
public TileEntityBarrel() {
|
||||
@ -75,23 +69,11 @@ public class TileEntityBarrel extends TileEntityMachineBase implements SimpleCom
|
||||
|
||||
@Override
|
||||
public long getDemand(FluidType type, int pressure) {
|
||||
|
||||
if(this.mode == 2 || this.mode == 3 || this.sendingBrake)
|
||||
return 0;
|
||||
|
||||
if(this.mode == 2 || this.mode == 3) return 0;
|
||||
if(tank.getPressure() != pressure) return 0;
|
||||
|
||||
return type == tank.getTankType() ? tank.getMaxFill() - tank.getFill() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long transferFluid(FluidType type, int pressure, long fluid) {
|
||||
long toTransfer = Math.min(getDemand(type, pressure), fluid);
|
||||
tank.setFill(tank.getFill() + (int) toTransfer);
|
||||
this.markChanged();
|
||||
return fluid - toTransfer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
@ -107,10 +89,11 @@ public class TileEntityBarrel extends TileEntityMachineBase implements SimpleCom
|
||||
tank.setType(0, 1, slots);
|
||||
tank.loadTank(2, 3, slots);
|
||||
tank.unloadTank(4, 5, slots);
|
||||
|
||||
this.sendingBrake = true;
|
||||
tank.setFill(transmitFluidFairly(worldObj, tank, this, tank.getFill(), this.mode == 0 || this.mode == 1, this.mode == 1 || this.mode == 2, getConPos()));
|
||||
this.sendingBrake = false;
|
||||
|
||||
for(DirPos pos : getConPos()) {
|
||||
if(mode == 0 || mode == 2) this.trySubscribe(tank.getTankType(), worldObj, pos);
|
||||
if(mode == 1 || mode == 2) this.tryProvide(tank, worldObj, pos);
|
||||
}
|
||||
|
||||
if(tank.getFill() > 0) {
|
||||
checkFluidInteraction();
|
||||
@ -145,59 +128,6 @@ public class TileEntityBarrel extends TileEntityMachineBase implements SimpleCom
|
||||
};
|
||||
}
|
||||
|
||||
protected static int transmitFluidFairly(World world, FluidTank tank, IFluidConnector that, int fill, boolean connect, boolean send, DirPos[] connections) {
|
||||
|
||||
Set<IPipeNet> nets = new HashSet<>();
|
||||
Set<IFluidConnector> consumers = new HashSet<>();
|
||||
FluidType type = tank.getTankType();
|
||||
int pressure = tank.getPressure();
|
||||
|
||||
for(DirPos pos : connections) {
|
||||
|
||||
TileEntity te = world.getTileEntity(pos.getX(), pos.getY(), pos.getZ());
|
||||
|
||||
if(te instanceof IFluidConductor) {
|
||||
IFluidConductor con = (IFluidConductor) te;
|
||||
if(con.getPipeNet(type) != null) {
|
||||
nets.add(con.getPipeNet(type));
|
||||
con.getPipeNet(type).unsubscribe(that);
|
||||
consumers.addAll(con.getPipeNet(type).getSubscribers());
|
||||
}
|
||||
|
||||
//if it's just a consumer, buffer it as a subscriber
|
||||
} else if(te instanceof IFluidConnector) {
|
||||
consumers.add((IFluidConnector) te);
|
||||
}
|
||||
}
|
||||
|
||||
consumers.remove(that);
|
||||
|
||||
if(fill > 0 && send) {
|
||||
List<IFluidConnector> con = new ArrayList<>();
|
||||
con.addAll(consumers);
|
||||
|
||||
con.removeIf(x -> x == null || !(x instanceof TileEntity) || ((TileEntity)x).isInvalid());
|
||||
|
||||
if(PipeNet.trackingInstances == null) {
|
||||
PipeNet.trackingInstances = new ArrayList<>();
|
||||
}
|
||||
|
||||
PipeNet.trackingInstances.clear();
|
||||
nets.forEach(x -> {
|
||||
if(x instanceof PipeNet) PipeNet.trackingInstances.add((PipeNet) x);
|
||||
});
|
||||
|
||||
fill = (int) PipeNet.fairTransfer(con, type, pressure, fill);
|
||||
}
|
||||
|
||||
//resubscribe to buffered nets, if necessary
|
||||
if(connect) {
|
||||
nets.forEach(x -> x.subscribe(that));
|
||||
}
|
||||
|
||||
return fill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemStack) {
|
||||
ItemStack full = FluidContainerRegistry.getFullContainer(itemStack, tank.getTankType());
|
||||
@ -296,7 +226,7 @@ public class TileEntityBarrel extends TileEntityMachineBase implements SimpleCom
|
||||
|
||||
@Override
|
||||
public FluidTank[] getReceivingTanks() {
|
||||
return (mode == 0 || mode == 1) && !sendingBrake ? new FluidTank[] {tank} : new FluidTank[0];
|
||||
return (mode == 0 || mode == 1) ? new FluidTank[] {tank} : new FluidTank[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -106,9 +106,10 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
|
||||
this.markChanged();
|
||||
}
|
||||
|
||||
this.sendingBrake = true;
|
||||
tank.setFill(TileEntityBarrel.transmitFluidFairly(worldObj, tank, this, tank.getFill(), this.mode == 0 || this.mode == 1, this.mode == 1 || this.mode == 2, getConPos()));
|
||||
this.sendingBrake = false;
|
||||
for(DirPos pos : getConPos()) {
|
||||
if(mode == 0 || mode == 2) this.trySubscribe(tank.getTankType(), worldObj, pos);
|
||||
if(mode == 1 || mode == 2) this.tryProvide(tank, worldObj, pos);
|
||||
}
|
||||
|
||||
tank.loadTank(2, 3, slots);
|
||||
tank.setType(0, 1, slots);
|
||||
|
||||
@ -33,10 +33,6 @@ public class TileEntityCableBaseNT extends TileEntityLoadedBase implements IEner
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onNodeDestroyedCallback() {
|
||||
this.node = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
|
||||
@ -3,11 +3,6 @@ package com.hbm.tileentity.network;
|
||||
import api.hbm.energymk2.Nodespace;
|
||||
|
||||
public class TileEntityCableSwitch extends TileEntityCableBaseNT {
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return super.canUpdate();
|
||||
}
|
||||
|
||||
public void updateState() {
|
||||
|
||||
|
||||
@ -1,31 +1,23 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import api.hbm.fluid.PipeNet;
|
||||
import api.hbm.energymk2.Nodespace;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileEntityFluidValve extends TileEntityPipeBaseNT {
|
||||
|
||||
@Override
|
||||
public boolean shouldConnect() {
|
||||
return this.worldObj != null && this.getBlockMetadata() == 1 && super.canUpdate();
|
||||
public boolean shouldCreateNode() {
|
||||
return this.getBlockMetadata() == 1;
|
||||
}
|
||||
|
||||
public void updateState() {
|
||||
|
||||
this.blockMetadata = -1; // delete cache
|
||||
|
||||
if(this.getBlockMetadata() == 0 && this.network != null) {
|
||||
this.network.destroy();
|
||||
this.network = null;
|
||||
}
|
||||
|
||||
if(this.getBlockMetadata() == 1) {
|
||||
this.connect();
|
||||
|
||||
if(this.getPipeNet(type) == null) {
|
||||
new PipeNet(type).joinLink(this);
|
||||
}
|
||||
if(this.getBlockMetadata() == 0 && this.node != null) {
|
||||
Nodespace.destroyNode(worldObj, xCoord, yCoord, zCoord);
|
||||
this.node = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,27 +6,26 @@ import com.hbm.handler.HbmKeybinds;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
|
||||
import api.hbm.fluid.IFluidConductor;
|
||||
import api.hbm.fluid.IPipeNet;
|
||||
import api.hbm.fluid.PipeNet;
|
||||
import api.hbm.fluidmk2.FluidNode;
|
||||
import api.hbm.fluidmk2.IFluidPipeMK2;
|
||||
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.tileentity.IFluidCopiable;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
import com.hbm.util.Compat;
|
||||
import com.hbm.uninos.UniNodespace;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityPipeBaseNT extends TileEntityLoadedBase implements IFluidConductor, IFluidCopiable {
|
||||
public class TileEntityPipeBaseNT extends TileEntityLoadedBase implements IFluidPipeMK2, IFluidCopiable {
|
||||
|
||||
protected IPipeNet network;
|
||||
protected FluidNode node;
|
||||
protected FluidType type = Fluids.NONE;
|
||||
protected FluidType lastType = Fluids.NONE;
|
||||
|
||||
@ -38,19 +37,26 @@ public class TileEntityPipeBaseNT extends TileEntityLoadedBase implements IFluid
|
||||
lastType = type;
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote && shouldConnect()) {
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
//we got here either because the net doesn't exist or because it's not valid, so that's safe to assume
|
||||
this.setPipeNet(type, null);
|
||||
if(this.node == null || this.node.expired) {
|
||||
|
||||
this.connect();
|
||||
if(this.shouldCreateNode()) {
|
||||
this.node = (FluidNode) UniNodespace.getNode(worldObj, xCoord, yCoord, zCoord, type.getNetworkProvider());
|
||||
|
||||
if(this.getPipeNet(type) == null) {
|
||||
this.setPipeNet(type, new PipeNet(type).joinLink(this));
|
||||
if(this.node == null || this.node.expired) {
|
||||
this.node = this.createNode(type);
|
||||
UniNodespace.createNode(worldObj, this.node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean shouldCreateNode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public FluidType getType() {
|
||||
return this.type;
|
||||
}
|
||||
@ -64,8 +70,10 @@ public class TileEntityPipeBaseNT extends TileEntityLoadedBase implements IFluid
|
||||
world.getPlayerManager().markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
if(this.network != null)
|
||||
this.network.destroy();
|
||||
if(this.node != null) {
|
||||
UniNodespace.destroyNode(worldObj, xCoord, yCoord, zCoord, type.getNetworkProvider());
|
||||
this.node = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -73,72 +81,17 @@ public class TileEntityPipeBaseNT extends TileEntityLoadedBase implements IFluid
|
||||
return dir != ForgeDirection.UNKNOWN && type == this.type;
|
||||
}
|
||||
|
||||
protected void connect() {
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
|
||||
TileEntity te = Compat.getTileStandard(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||
|
||||
if(te instanceof IFluidConductor) {
|
||||
|
||||
IFluidConductor conductor = (IFluidConductor) te;
|
||||
|
||||
if(!conductor.canConnect(type, dir.getOpposite()))
|
||||
continue;
|
||||
|
||||
if(this.getPipeNet(type) == null && conductor.getPipeNet(type) != null) {
|
||||
conductor.getPipeNet(type).joinLink(this);
|
||||
}
|
||||
|
||||
if(this.getPipeNet(type) != null && conductor.getPipeNet(type) != null && this.getPipeNet(type) != conductor.getPipeNet(type)) {
|
||||
conductor.getPipeNet(type).joinNetworks(this.getPipeNet(type));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
if(this.network != null) {
|
||||
this.network.destroy();
|
||||
if(this.node != null) {
|
||||
UniNodespace.destroyNode(worldObj, xCoord, yCoord, zCoord, type.getNetworkProvider());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only update until a power net is formed, in >99% of the cases it should be the first tick. Everything else is handled by neighbors and the net itself.
|
||||
*/
|
||||
public boolean shouldConnect() {
|
||||
return (this.network == null || !this.network.isValid()) && !this.isInvalid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long transferFluid(FluidType type, int pressure, long fluid) {
|
||||
|
||||
if(this.network == null)
|
||||
return fluid;
|
||||
|
||||
return this.network.transferFluid(fluid, pressure);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDemand(FluidType type, int pressure) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPipeNet getPipeNet(FluidType type) {
|
||||
return type == this.type ? this.network : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPipeNet(FluidType type, IPipeNet network) {
|
||||
this.network = network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
|
||||
@ -2,58 +2,35 @@ package com.hbm.tileentity.network;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.util.Compat;
|
||||
import com.hbm.uninos.UniNodespace;
|
||||
|
||||
import api.hbm.fluid.IFluidConductor;
|
||||
import api.hbm.fluid.IPipeNet;
|
||||
import api.hbm.fluid.PipeNet;
|
||||
import api.hbm.fluidmk2.FluidNode;
|
||||
import api.hbm.fluidmk2.IFluidPipeMK2;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityPipeExhaust extends TileEntity implements IFluidConductor {
|
||||
public class TileEntityPipeExhaust extends TileEntity implements IFluidPipeMK2 {
|
||||
|
||||
public IPipeNet[] nets = new IPipeNet[3];
|
||||
protected FluidNode[] nodes = new FluidNode[3];
|
||||
protected FluidType[] smokes = new FluidType[] {Fluids.SMOKE, Fluids.SMOKE_LEADED, Fluids.SMOKE_POISON};
|
||||
|
||||
public FluidType[] getSmokes() {
|
||||
return new FluidType[] {Fluids.SMOKE, Fluids.SMOKE_LEADED, Fluids.SMOKE_POISON};
|
||||
return smokes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote && canUpdate()) {
|
||||
|
||||
for(int i = 0; i < 3; i++) nets[i] = null;
|
||||
|
||||
for(FluidType type : getSmokes()) {
|
||||
this.connect(type);
|
||||
|
||||
if(this.getPipeNet(type) == null) {
|
||||
this.setPipeNet(type, new PipeNet(type).joinLink(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void connect(FluidType type) {
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
|
||||
TileEntity te = Compat.getTileStandard(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||
|
||||
if(te instanceof IFluidConductor) {
|
||||
|
||||
IFluidConductor conductor = (IFluidConductor) te;
|
||||
|
||||
if(!conductor.canConnect(type, dir.getOpposite()))
|
||||
continue;
|
||||
|
||||
if(this.getPipeNet(type) == null && conductor.getPipeNet(type) != null) {
|
||||
conductor.getPipeNet(type).joinLink(this);
|
||||
}
|
||||
|
||||
if(this.getPipeNet(type) != null && conductor.getPipeNet(type) != null && this.getPipeNet(type) != conductor.getPipeNet(type)) {
|
||||
conductor.getPipeNet(type).joinNetworks(this.getPipeNet(type));
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
for(int i = 0; i < getSmokes().length; i++) {
|
||||
if(this.nodes[i] == null || this.nodes[i].expired) {
|
||||
this.nodes[i] = (FluidNode) UniNodespace.getNode(worldObj, xCoord, yCoord, zCoord, getSmokes()[i].getNetworkProvider());
|
||||
|
||||
if(this.nodes[i] == null || this.nodes[i].expired) {
|
||||
this.nodes[i] = this.createNode(getSmokes()[i]);
|
||||
UniNodespace.createNode(worldObj, this.nodes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -62,67 +39,18 @@ public class TileEntityPipeExhaust extends TileEntity implements IFluidConductor
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
if(nets[i] != null) {
|
||||
nets[i].destroy();
|
||||
for(int i = 0; i < getSmokes().length; i++) {
|
||||
if(this.nodes[i] != null) {
|
||||
UniNodespace.destroyNode(worldObj, xCoord, yCoord, zCoord, getSmokes()[i].getNetworkProvider());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
|
||||
if(this.isInvalid()) return false;
|
||||
|
||||
for(IPipeNet net : nets) {
|
||||
if(net == null || !net.isValid()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(FluidType type, ForgeDirection dir) {
|
||||
return dir != ForgeDirection.UNKNOWN && (type == Fluids.SMOKE || type == Fluids.SMOKE_LEADED || type == Fluids.SMOKE_POISON);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDemand(FluidType type, int pressure) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPipeNet getPipeNet(FluidType type) {
|
||||
|
||||
if(type == Fluids.SMOKE) return nets[0];
|
||||
if(type == Fluids.SMOKE_LEADED) return nets[1];
|
||||
if(type == Fluids.SMOKE_POISON) return nets[2];
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPipeNet(FluidType type, IPipeNet network) {
|
||||
|
||||
if(type == Fluids.SMOKE) nets[0] = network;
|
||||
if(type == Fluids.SMOKE_LEADED) nets[1] = network;
|
||||
if(type == Fluids.SMOKE_POISON) nets[2] = network;
|
||||
}
|
||||
|
||||
public boolean isLoaded = true;
|
||||
|
||||
@Override
|
||||
public boolean isLoaded() {
|
||||
return isLoaded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
this.isLoaded = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
package com.hbm.uninos;
|
||||
|
||||
public interface IGenProvider<T extends INetworkProvider> {
|
||||
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
package com.hbm.uninos;
|
||||
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2.ConnectionPriority;
|
||||
|
||||
public interface IGenReceiver<T extends INetworkProvider> {
|
||||
|
||||
public default ConnectionPriority getPriority() {
|
||||
return ConnectionPriority.NORMAL;
|
||||
}
|
||||
}
|
||||
@ -7,7 +7,7 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class NodeNet<R extends IGenReceiver, P extends IGenProvider, L extends GenNode> {
|
||||
public abstract class NodeNet<R, P, L extends GenNode> {
|
||||
|
||||
/** Global random for figuring things out like random leftover distribution */
|
||||
public static Random rand = new Random();
|
||||
|
||||
@ -2,7 +2,7 @@ package com.hbm.util;
|
||||
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import api.hbm.energymk2.IEnergyHandlerMK2;
|
||||
import api.hbm.fluid.IFluidUser;
|
||||
import api.hbm.fluidmk2.IFluidUserMK2;
|
||||
import api.hbm.tile.IInfoProviderEC;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
@ -65,8 +65,8 @@ public class CompatEnergyControl {
|
||||
|
||||
List<Object[]> list = new ArrayList();
|
||||
|
||||
if(tile instanceof IFluidUser) {
|
||||
IFluidUser user = (IFluidUser) tile;
|
||||
if(tile instanceof IFluidUserMK2) {
|
||||
IFluidUserMK2 user = (IFluidUserMK2) tile;
|
||||
|
||||
for(FluidTank tank : user.getAllTanks()) {
|
||||
if(tank.getTankType() == Fluids.SMOKE || tank.getTankType() == Fluids.SMOKE_LEADED || tank.getTankType() == Fluids.SMOKE_POISON) continue;
|
||||
|
||||
@ -9,7 +9,7 @@ import java.util.function.Consumer;
|
||||
|
||||
import api.hbm.energymk2.IEnergyHandlerMK2;
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2;
|
||||
import api.hbm.fluid.IFluidUser;
|
||||
import api.hbm.fluidmk2.IFluidUserMK2;
|
||||
import api.hbm.recipe.IRecipeRegisterListener;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
@ -123,11 +123,11 @@ public class CompatExternal {
|
||||
public static ArrayList<Object[]> getFluidInfoFromTile(TileEntity tile) {
|
||||
ArrayList<Object[]> list = new ArrayList();
|
||||
|
||||
if(!(tile instanceof IFluidUser)) {
|
||||
if(!(tile instanceof IFluidUserMK2)) {
|
||||
return list;
|
||||
}
|
||||
|
||||
IFluidUser container = (IFluidUser) tile;
|
||||
IFluidUserMK2 container = (IFluidUserMK2) tile;
|
||||
|
||||
for(FluidTank tank : container.getAllTanks()) {
|
||||
FluidType type = tank.getTankType();
|
||||
|
||||
@ -1,168 +0,0 @@
|
||||
package com.hbm.util;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.entity.mob.EntityCreeperNuclear;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CompatNER {
|
||||
|
||||
/*
|
||||
* INIT
|
||||
*/
|
||||
|
||||
public static void init() {
|
||||
sendRegisterOre(new ItemStack(ModBlocks.ore_alexandrite), false, 0xff00ff, new ItemStack(ModItems.gem_alexandrite));
|
||||
sendRegisterMob(EntityCreeperNuclear.class, "-1", encodeDrops(
|
||||
new DropItem(new ItemStack(Blocks.tnt), 0, 2),
|
||||
new DropItem(new ItemStack(ModItems.coin_creeper), 1, 1, 0.33F)));
|
||||
}
|
||||
|
||||
/*
|
||||
* REGISTERS
|
||||
*/
|
||||
|
||||
public static void sendRegisterOre(ItemStack ore, boolean silk, int color, ItemStack... drops) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setTag(stack, ore.writeToNBT(new NBTTagCompound()));
|
||||
data.setBoolean(silkTouch, silk);
|
||||
data.setInteger(colour, color);
|
||||
data.setTag(addDrops, encodeStacks(drops));
|
||||
int[] distribution = new int[256];
|
||||
for(int i = 0; i < 256; i++) distribution[i] = 100;
|
||||
data.setIntArray("distribution", distribution);
|
||||
|
||||
NBTTagCompound res = new NBTTagCompound();
|
||||
NBTTagCompound block = new NBTTagCompound();
|
||||
block.setTag("stack", new ItemStack(Blocks.stone).writeToNBT(new NBTTagCompound()));
|
||||
res.setTag("block", block);
|
||||
data.setTag(restriction, res);
|
||||
|
||||
FMLInterModComms.sendMessage(notEnoughResources, registerOre, data);
|
||||
}
|
||||
|
||||
public static void sendRegisterMob(Class clazz, String light, NBTTagList drops) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setString(name, clazz.getName());
|
||||
data.setString(lightLevel, light);
|
||||
data.setTag(addDrops, drops);
|
||||
MainRegistry.logger.info("Sending " + registerMob + " to " + notEnoughResources);
|
||||
FMLInterModComms.sendMessage(notEnoughResources, registerMob, data);
|
||||
}
|
||||
|
||||
/*
|
||||
* ENCODERS
|
||||
*/
|
||||
|
||||
public static String encodeLightLevel(int level, boolean below) {
|
||||
return level + ":" + (below ? "b" : "a");
|
||||
}
|
||||
|
||||
public static NBTTagList encodeDrops(DropItem... stacks) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
for(DropItem stack : stacks) list.appendTag(stack.writeToNBT());
|
||||
return list;
|
||||
}
|
||||
|
||||
public static NBTTagList encodeStacks(ItemStack... stacks) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
for(ItemStack stack : stacks) list.appendTag(stack.writeToNBT(new NBTTagCompound()));
|
||||
return list;
|
||||
}
|
||||
|
||||
/*
|
||||
* DROP SYSTEM
|
||||
*/
|
||||
|
||||
public static class DropItem {
|
||||
public ItemStack drop;
|
||||
public int min = 1;
|
||||
public int max = 1;
|
||||
public float chance = 1F;
|
||||
List<String> conditionals = new ArrayList();
|
||||
|
||||
public DropItem(ItemStack stack) { this(stack, 1, 1, 1F); }
|
||||
public DropItem(ItemStack stack, int min, int max) { this(stack, min, max, 1F); }
|
||||
public DropItem(ItemStack stack, int min, int max, float chance) {
|
||||
this.drop = stack;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("stack", this.drop.writeToNBT(new NBTTagCompound()));
|
||||
compound.setInteger("min", this.min);
|
||||
compound.setInteger("max", this.max);
|
||||
compound.setFloat("chance", this.chance);
|
||||
NBTTagList conditionals = new NBTTagList();
|
||||
for(String condition : this.conditionals) conditionals.appendTag(new NBTTagString(condition));
|
||||
compound.setTag("conditionals", conditionals);
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* CONSTANTS
|
||||
*/
|
||||
|
||||
public static final String notEnoughResources = "neresources";
|
||||
public static final String registerDungeon = "registerDungeon";
|
||||
public static final String registerMob = "registerMob";
|
||||
public static final String registerOre = "registerOre";
|
||||
public static final String registerPlant = "registerPlant";
|
||||
public static final String addToRegistry = "add";
|
||||
public static final String modifyMob = "modifyMob";
|
||||
public static final String modifyOre = "modifyOre";
|
||||
public static final String modifyPlant = "modifyPlant";
|
||||
public static final String removeMob = "removeMob";
|
||||
public static final String removeOre = "removeOre";
|
||||
public static final String removePlant = "removePlant";
|
||||
public static final String distribution = "distribution";
|
||||
public static final String bestHeight = "bestHeight";
|
||||
public static final String stack = "stack";
|
||||
public static final String name = "name";
|
||||
public static final String lightLevel = "lightLevel";
|
||||
public static final String conditionals = "conditionals";
|
||||
public static final String colour = "colour";
|
||||
public static final String itemList = "itemList";
|
||||
public static final String chance = "chance";
|
||||
public static final String min = "min";
|
||||
public static final String max = "max";
|
||||
public static final String priority = "priority";
|
||||
public static final String addPriority = "addPriority";
|
||||
public static final String removePriority = "removePriority";
|
||||
public static final String addDrops = "addDrops";
|
||||
public static final String removeDrops = "removeDrops";
|
||||
public static final String silkTouch = "silkTouch";
|
||||
public static final String wither = "wither";
|
||||
public static final String strict = "strict";
|
||||
public static final String biomeArray = "biomeArray";
|
||||
public static final String type = "type";
|
||||
public static final String restriction = "restriction";
|
||||
public static final String blockRestriction = "block";
|
||||
public static final String dimensionRestriction = "dimension";
|
||||
public static final String biomeRestriction = "biome";
|
||||
|
||||
public static final String conditional_rareDrop = "ner.rareDrop.text";
|
||||
public static final String conditional_silkTouch = "ner.ore.silkTouch";
|
||||
public static final String conditional_equipmentDrop = "ner.equipmentDrop.text";
|
||||
public static final String conditional_burning = "ner.burning.text";
|
||||
public static final String conditional_notBurning = "ner.notBurning.text";
|
||||
public static final String conditional_playerKill = "ner.playerKill.text";
|
||||
public static final String conditional_notPlayerKill = "ner.notPlayerKill.text";
|
||||
public static final String conditional_aboveLooting = "ner.aboveLooting.text";
|
||||
public static final String conditional_belowLooting = "ner.belowLooting.text";
|
||||
public static final String conditional_killedBy = "ner.killedBy.text";
|
||||
public static final String conditional_notKilledBy = "ner.notKilledBy.text";
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
package com.hbm.wiaj.cannery;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
|
||||
import api.hbm.energymk2.IEnergyConnectorMK2;
|
||||
import api.hbm.fluid.IFluidConnector;
|
||||
@ -8,10 +7,5 @@ import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class Dummies {
|
||||
|
||||
public static class JarDummyConnector extends TileEntity implements IEnergyConnectorMK2, IFluidConnector {
|
||||
|
||||
@Override public boolean isLoaded() { return false; }
|
||||
@Override public long transferFluid(FluidType type, int pressure, long fluid) { return 0; }
|
||||
@Override public long getDemand(FluidType type, int pressure) { return 0; }
|
||||
}
|
||||
public static class JarDummyConnector extends TileEntity implements IEnergyConnectorMK2, IFluidConnector { }
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user