fluid pressure stat

This commit is contained in:
Bob 2023-05-14 17:51:35 +02:00
parent d8e87453cb
commit a71d7972ec
67 changed files with 357 additions and 274 deletions

View File

@ -9,11 +9,11 @@ public interface IFluidConductor extends IFluidConnector {
public void setPipeNet(FluidType type, IPipeNet network);
@Override
public default long transferFluid(FluidType type, long amount) {
public default long transferFluid(FluidType type, int pressure, long amount) {
if(this.getPipeNet(type) == null)
return amount;
return this.getPipeNet(type).transferFluid(amount);
return this.getPipeNet(type).transferFluid(amount, pressure);
}
}

View File

@ -17,7 +17,7 @@ public interface IFluidConnector {
* @param power
* @return
*/
public long transferFluid(FluidType type, long fluid);
public long transferFluid(FluidType type, int pressure, long fluid);
/**
* Whether the given side can be connected to
@ -33,7 +33,7 @@ public interface IFluidConnector {
* @param type
* @return
*/
public long getDemand(FluidType type);
public long getDemand(FluidType type, int pressure);
/**
* Basic implementation of subscribing to a nearby power grid

View File

@ -14,10 +14,10 @@ import com.hbm.inventory.fluid.tank.FluidTank;
public interface IFluidStandardReceiver extends IFluidUser {
@Override
public default long transferFluid(FluidType type, long amount) {
public default long transferFluid(FluidType type, int pressure, long amount) {
for(FluidTank tank : getReceivingTanks()) {
if(tank.getTankType() == type) {
if(tank.getTankType() == type && tank.getPressure() == pressure) {
tank.setFill(tank.getFill() + (int) amount);
if(tank.getFill() > tank.getMaxFill()) {
@ -36,10 +36,10 @@ public interface IFluidStandardReceiver extends IFluidUser {
public FluidTank[] getReceivingTanks();
@Override
public default long getDemand(FluidType type) {
public default long getDemand(FluidType type, int pressure) {
for(FluidTank tank : getReceivingTanks()) {
if(tank.getTankType() == type) {
if(tank.getTankType() == type && tank.getPressure() == pressure) {
return tank.getMaxFill() - tank.getFill();
}
}

View File

@ -16,10 +16,10 @@ public interface IFluidStandardSender extends IFluidUser {
public FluidTank[] getSendingTanks();
@Override
public default long getTotalFluidForSend(FluidType type) {
public default long getTotalFluidForSend(FluidType type, int pressure) {
for(FluidTank tank : getSendingTanks()) {
if(tank.getTankType() == type) {
if(tank.getTankType() == type && tank.getPressure() == pressure) {
return tank.getFill();
}
}
@ -28,10 +28,10 @@ public interface IFluidStandardSender extends IFluidUser {
}
@Override
public default void removeFluidForTransfer(FluidType type, long amount) {
public default void removeFluidForTransfer(FluidType type, int pressure, long amount) {
for(FluidTank tank : getSendingTanks()) {
if(tank.getTankType() == type) {
if(tank.getTankType() == type && tank.getPressure() == pressure) {
tank.setFill(tank.getFill() - (int) amount);
return;
}
@ -39,12 +39,12 @@ public interface IFluidStandardSender extends IFluidUser {
}
@Override
public default long transferFluid(FluidType type, long fluid) {
public default long transferFluid(FluidType type, int pressure, long fluid) {
return fluid;
}
@Override
public default long getDemand(FluidType type) {
public default long getDemand(FluidType type, int pressure) {
return 0;
}
}

View File

@ -23,7 +23,7 @@ public interface IFluidStandardTransceiver extends IFluidUser {
public FluidTank[] getReceivingTanks();
@Override
public default long getTotalFluidForSend(FluidType type) {
public default long getTotalFluidForSend(FluidType type, int pressure) {
for(FluidTank tank : getSendingTanks()) {
if(tank.getTankType() == type) {
@ -35,7 +35,7 @@ public interface IFluidStandardTransceiver extends IFluidUser {
}
@Override
public default void removeFluidForTransfer(FluidType type, long amount) {
public default void removeFluidForTransfer(FluidType type, int pressure, long amount) {
for(FluidTank tank : getSendingTanks()) {
if(tank.getTankType() == type) {
@ -46,7 +46,7 @@ public interface IFluidStandardTransceiver extends IFluidUser {
}
@Override
public default long getDemand(FluidType type) {
public default long getDemand(FluidType type, int pressure) {
for(FluidTank tank : getReceivingTanks()) {
if(tank.getTankType() == type) {
@ -58,7 +58,7 @@ public interface IFluidStandardTransceiver extends IFluidUser {
}
@Override
public default long transferFluid(FluidType type, long amount) {
public default long transferFluid(FluidType type, int pressure, long amount) {
for(FluidTank tank : getReceivingTanks()) {
if(tank.getTankType() == type) {

View File

@ -13,7 +13,11 @@ import net.minecraftforge.common.util.ForgeDirection;
public interface IFluidUser extends IFluidConnector {
public default void sendFluid(FluidType type, World world, int x, int y, int z, ForgeDirection dir) {
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;
@ -32,9 +36,9 @@ public interface IFluidUser extends IFluidConnector {
IFluidConnector con = (IFluidConnector) te;
if(con.canConnect(type, dir.getOpposite())) {
long toSend = this.getTotalFluidForSend(type);
long transfer = toSend - con.transferFluid(type, toSend);
this.removeFluidForTransfer(type, transfer);
long toSend = this.getTotalFluidForSend(type, pressure);
long transfer = toSend - con.transferFluid(type, pressure, toSend);
this.removeFluidForTransfer(type, pressure, transfer);
red = true;
}
}
@ -77,15 +81,21 @@ public interface IFluidUser extends IFluidConnector {
return null;
}
public default void sendFluidToAll(FluidType type, TileEntity te) {
/** 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, te.getWorldObj(), te.xCoord + dir.offsetX, te.yCoord + dir.offsetY, te.zCoord + dir.offsetZ, dir);
sendFluid(type, pressure, te.getWorldObj(), te.xCoord + dir.offsetX, te.yCoord + dir.offsetY, te.zCoord + dir.offsetZ, dir);
}
}
public default long getTotalFluidForSend(FluidType type) { return 0; }
public default void removeFluidForTransfer(FluidType type, long amount) { }
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);

View File

@ -24,7 +24,7 @@ public interface IPipeNet {
public boolean isValid();
public long transferFluid(long fill);
public long transferFluid(long fill, int pressure);
public FluidType getType();
public BigInteger getTotalTransfer();
}

View File

@ -85,7 +85,7 @@ public class PipeNet implements IPipeNet {
}
@Override
public long transferFluid(long fill) {
public long transferFluid(long fill, int pressure) {
this.subscribers.removeIf(x ->
x == null || !(x instanceof TileEntity) || ((TileEntity)x).isInvalid()
@ -97,16 +97,16 @@ public class PipeNet implements IPipeNet {
trackingInstances = new ArrayList();
trackingInstances.add(this);
List<IFluidConnector> subList = new ArrayList(subscribers);
return fairTransfer(subList, type, fill);
return fairTransfer(subList, type, pressure, fill);
}
public static long fairTransfer(List<IFluidConnector> subList, FluidType type, long fill) {
public static long fairTransfer(List<IFluidConnector> subList, FluidType type, int pressure, long fill) {
List<Long> weight = new ArrayList();
long totalReq = 0;
for(IFluidConnector con : subList) {
long req = con.getDemand(type);
long req = con.getDemand(type, pressure);
weight.add(req);
totalReq += req;
}
@ -123,7 +123,7 @@ public class PipeNet implements IPipeNet {
long given = (long) Math.floor(fraction * fill);
totalGiven += (given - con.transferFluid(type, given));
totalGiven += (given - con.transferFluid(type, pressure, given));
}
if(trackingInstances != null) {

View File

@ -0,0 +1,112 @@
package com.hbm.commands;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
import net.minecraft.world.chunk.storage.IChunkLoader;
import net.minecraft.world.gen.ChunkProviderServer;
public class CommandDebugChunkLoad extends CommandBase {
@Override
public String getCommandName() {
return "ntmloadchunk";
}
@Override
public String getCommandUsage(ICommandSender sender) {
return "/ntmloadchunk <x> <z>";
}
@Override
public void processCommand(ICommandSender sender, String[] args) {
if(args.length != 2) {
return;
}
int x = this.parseInt(sender, args[0]);
int z = this.parseInt(sender, args[1]);
IChunkProvider prov = sender.getEntityWorld().getChunkProvider();
if(prov instanceof ChunkProviderServer) {
ChunkProviderServer serv = (ChunkProviderServer) prov;
IChunkLoader loader = serv.currentChunkLoader;
if(loader instanceof AnvilChunkLoader) {
AnvilChunkLoader anvil = (AnvilChunkLoader) loader;
try {
int cX = x >> 4;
int cZ = z >> 4;
if(prov.chunkExists(cX, cZ)) {
Chunk chunk = sender.getEntityWorld().getChunkFromChunkCoords(cX, cZ);
if(chunk.isChunkLoaded) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Chunk currently loaded."));
return;
}
}
Object[] data = anvil.loadChunk__Async(sender.getEntityWorld(), cX, cZ);
Chunk chunk = (Chunk) data[0];
NBTTagCompound nbt = (NBTTagCompound) data[1];
NBTTagCompound level = nbt.getCompoundTag("Level");
NBTTagList tagList = level.getTagList("TileEntities", 10);
if(tagList != null) {
if(tagList.tagCount() <= 0) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Tag list empty"));
}
for(int i1 = 0; i1 < tagList.tagCount(); ++i1) {
NBTTagCompound tileCompound = tagList.getCompoundTagAt(i1);
int tX = tileCompound.getInteger("x");
int tY = tileCompound.getInteger("y");
int tZ = tileCompound.getInteger("z");
String name = tileCompound.getString("id");
int i = tX - cX * 16;
int j = tY;
int k = tZ - cZ * 16;
EnumChatFormatting color = EnumChatFormatting.GREEN;
if(i < 0 || i > 15 || j < 0 || j > 255 || k < 0 || k > 15) {
color = EnumChatFormatting.RED;
}
sender.addChatMessage(new ChatComponentText(color + name + " " + i + " " + j + " " + k));
if(i < 0 || i > 15 || j < 0 || j > 255 || k < 0 || k > 15) {
tileCompound.setString("id", "INVALID_POS_" + name);
NBTTagCompound nbttagcompound = new NBTTagCompound();
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound.setTag("Level", nbttagcompound1);
// anvil.writeChunkToNBT(chunk, sender.getEntityWorld(), nbttagcompound1);
// anvil.addChunkToPending(chunk.getChunkCoordIntPair(), nbttagcompound);
}
}
} else {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Tag list null"));
}
} catch(Exception e) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "" + e.getLocalizedMessage()));
}
} else {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not AnvilChunkLoader"));
}
} else {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not ChunkProviderServer"));
}
}
}

View File

@ -41,7 +41,7 @@ public abstract class EntityRailCarBase extends Entity {
@Override protected void readEntityFromNBT(NBTTagCompound nbt) { }
@Override protected void writeEntityToNBT(NBTTagCompound nbt) { }
@Override
/*@Override
public boolean canBePushed() {
return true;
}
@ -49,7 +49,7 @@ public abstract class EntityRailCarBase extends Entity {
@Override
public boolean canBeCollidedWith() {
return !this.isDead;
}
}*/
@Override
public void onUpdate() {
@ -260,7 +260,7 @@ public abstract class EntityRailCarBase extends Entity {
}
@Override protected void entityInit() {
this.dataWatcher.addObject(3, new Integer(1));
this.dataWatcher.addObject(3, new Integer(0));
this.dataWatcher.addObject(4, new Float(1F));
this.dataWatcher.addObject(5, new Float(1F));
}
@ -276,7 +276,7 @@ public abstract class EntityRailCarBase extends Entity {
@Override public void onUpdate() {
if(!worldObj.isRemote) {
if(this.train.isDead) {
if(this.train == null || this.train.isDead) {
this.setDead();
}
} else {

View File

@ -2,6 +2,8 @@ package com.hbm.entity.train;
import com.hbm.util.BobMathUtil;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
@ -72,7 +74,7 @@ public abstract class EntityRailCarRidable extends EntityRailCarCargo {
if(nearestSeat == -1) {
player.mountEntity(this);
} else {
SeatDummyEntity dummySeat = new SeatDummyEntity(worldObj);
SeatDummyEntity dummySeat = new SeatDummyEntity(worldObj, this);
Vec3 passengerSeat = this.getPassengerSeats()[nearestSeat];
passengerSeat.rotateAroundY((float) (-this.rotationYaw * Math.PI / 180));
double x = posX + passengerSeat.xCoord;
@ -108,7 +110,6 @@ public abstract class EntityRailCarRidable extends EntityRailCarCargo {
double y = posY + rot.yCoord;
double z = posZ + rot.zCoord;
seat.setPosition(x, y - 1, z);
seat.updateRiderPosition();
}
}
}
@ -133,11 +134,51 @@ public abstract class EntityRailCarRidable extends EntityRailCarCargo {
/** Dynamic seats generated when a player clicks near a seat-spot, moves and rotates with the train as one would expect. */
public static class SeatDummyEntity extends Entity {
private int turnProgress;
private double trainX;
private double trainY;
private double trainZ;
public EntityRailCarBase train;
public SeatDummyEntity(World world) { super(world); this.setSize(0.5F, 0.1F);}
@Override protected void entityInit() { }
public SeatDummyEntity(World world, EntityRailCarBase train) {
this(world);
this.train = train;
if(train != null) this.dataWatcher.updateObject(3, train.getEntityId());
}
@Override protected void entityInit() { this.dataWatcher.addObject(3, new Integer(0)); }
@Override protected void writeEntityToNBT(NBTTagCompound nbt) { }
@Override public boolean writeToNBTOptional(NBTTagCompound nbt) { return false; }
@Override public void readEntityFromNBT(NBTTagCompound nbt) { this.setDead(); }
@Override public void onUpdate() {
if(!worldObj.isRemote) {
if(this.train == null || this.train.isDead) {
this.setDead();
}
} else {
if(this.turnProgress > 0) {
this.prevRotationYaw = this.rotationYaw;
double x = this.posX + (this.trainX - this.posX) / (double) this.turnProgress;
double y = this.posY + (this.trainY - this.posY) / (double) this.turnProgress;
double z = this.posZ + (this.trainZ - this.posZ) / (double) this.turnProgress;
--this.turnProgress;
this.setPosition(x, y, z);
} else {
this.setPosition(this.posX, this.posY, this.posZ);
}
}
}
@Override @SideOnly(Side.CLIENT) public void setPositionAndRotation2(double posX, double posY, double posZ, float yaw, float pitch, int turnProg) {
this.trainX = posX;
this.trainY = posY;
this.trainZ = posZ;
this.turnProgress = turnProg + 2;
}
@Override
public void updateRiderPosition() {

View File

@ -30,7 +30,7 @@ public class TrainCargoTram extends EntityRailCarRidable implements IGUIProvider
public TrainCargoTram(World world) {
super(world);
this.setSize(1F, 1F);
this.setSize(5F, 2F);
}
public double speed = 0;

View File

@ -1,6 +1,9 @@
package com.hbm.handler.nei;
import java.awt.Rectangle;
import com.hbm.blocks.ModBlocks;
import com.hbm.inventory.gui.GUIMachineCoker;
import com.hbm.inventory.recipes.CokerRecipes;
public class CokingHandler extends NEIUniversalHandler {
@ -13,4 +16,12 @@ public class CokingHandler extends NEIUniversalHandler {
public String getKey() {
return "ntmCoking";
}
@Override
public void loadTransferRects() {
super.loadTransferRects();
transferRectsGui.add(new RecipeTransferRect(new Rectangle(55, 15, 36, 18), "ntmCoking"));
guiGui.add(GUIMachineCoker.class);
RecipeTransferRectHandler.registerRectsToGuis(guiGui, transferRectsGui);
}
}

View File

@ -1,6 +1,9 @@
package com.hbm.handler.nei;
import java.awt.Rectangle;
import com.hbm.blocks.ModBlocks;
import com.hbm.inventory.gui.GUIFurnaceCombo;
import com.hbm.inventory.recipes.CombinationRecipes;
public class CombinationHandler extends NEIUniversalHandler {
@ -13,4 +16,12 @@ public class CombinationHandler extends NEIUniversalHandler {
public String getKey() {
return "ntmCombination";
}
@Override
public void loadTransferRects() {
super.loadTransferRects();
transferRectsGui.add(new RecipeTransferRect(new Rectangle(49, 44, 18, 18), "ntmCombination"));
guiGui.add(GUIFurnaceCombo.class);
RecipeTransferRectHandler.registerRectsToGuis(guiGui, transferRectsGui);
}
}

View File

@ -19,6 +19,7 @@ import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
public class FluidTank {
@ -34,12 +35,18 @@ public class FluidTank {
int fluid;
int maxFluid;
public int index = 0;
int pressure = 0;
public FluidTank(FluidType type, int maxFluid) {
this.type = type;
this.maxFluid = maxFluid;
}
public FluidTank withPressure(int pressure) {
this.pressure = pressure;
return this;
}
@Deprecated // indices are no longer needed
public FluidTank(FluidType type, int maxFluid, int index) {
this.type = type;
@ -76,6 +83,10 @@ public class FluidTank {
return maxFluid;
}
public int getPressure() {
return pressure;
}
public int changeTankSize(int size) {
maxFluid = size;
@ -108,6 +119,8 @@ public class FluidTank {
if(slots[in] == null)
return false;
if(this.pressure != 0) return false; //for now, canisters can only be loaded from high-pressure tanks, not unloaded
int prev = this.getFill();
for(FluidLoadingHandler handler : loadingHandlers) {
@ -223,6 +236,10 @@ public class FluidTank {
list.add(I18n.format(this.type.getUnlocalizedName()));
list.add(fluid + "/" + maxFluid + "mB");
if(this.pressure != 0) {
list.add(EnumChatFormatting.RED + "" + this.pressure + "mB/l");
}
type.addInfo(list);
gui.drawInfo(list.toArray(new String[0]), mouseX, mouseY);
}
@ -233,6 +250,7 @@ public class FluidTank {
nbt.setInteger(s, fluid);
nbt.setInteger(s + "_max", maxFluid);
nbt.setInteger(s + "_type", type.getID());
nbt.setShort(s + "_p", (short) pressure);
}
//Called by TE to load fillstate
@ -245,6 +263,8 @@ public class FluidTank {
type = Fluids.fromName(nbt.getString(s + "_type")); //compat
if(type == Fluids.NONE)
type = Fluids.fromID(nbt.getInteger(s + "_type"));
this.pressure = nbt.getShort(s + "_p");
}
}

View File

@ -47,6 +47,7 @@ import com.hbm.blocks.BlockEnums.EnumStoneType;
import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.generic.BlockMotherOfAllOres;
import com.hbm.blocks.generic.BlockToolConversion;
import com.hbm.commands.CommandDebugChunkLoad;
import com.hbm.commands.CommandReloadRecipes;
import com.hbm.config.*;
import com.hbm.crafting.RodRecipes;
@ -895,6 +896,7 @@ public class MainRegistry {
RBMKDials.createDials(world);
SiegeOrchestrator.createGameRules(world);
event.registerServerCommand(new CommandReloadRecipes());
event.registerServerCommand(new CommandDebugChunkLoad());
}
@EventHandler

View File

@ -427,25 +427,25 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy
}
@Override
public long transferFluid(FluidType type, long fluid) {
public long transferFluid(FluidType type, int pressure, long fluid) {
if(!this.fluid)
return fluid;
if(getTile() instanceof IFluidConnector) {
return ((IFluidConnector)getTile()).transferFluid(type, fluid);
return ((IFluidConnector)getTile()).transferFluid(type, pressure, fluid);
}
return fluid;
}
@Override
public long getDemand(FluidType type) {
public long getDemand(FluidType type, int pressure) {
if(!this.fluid)
return 0;
if(getTile() instanceof IFluidConnector) {
return ((IFluidConnector)getTile()).getDemand(type);
return ((IFluidConnector)getTile()).getDemand(type, pressure);
}
return 0;
}

View File

@ -81,7 +81,7 @@ public class TileEntityChungus extends TileEntityLoadedBase implements IFluidAcc
this.sendPower(worldObj, xCoord - dir.offsetX * 11, yCoord, zCoord - dir.offsetZ * 11, dir.getOpposite());
for(DirPos pos : this.getConPos()) {
this.sendFluid(tanks[1].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.sendFluid(tanks[1], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.trySubscribe(tanks[0].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}

View File

@ -60,7 +60,7 @@ public class TileEntityCondenser extends TileEntityLoadedBase implements IFluidA
}
this.subscribeToAllAround(tanks[0].getTankType(), this);
this.sendFluidToAll(tanks[1].getTankType(), this);
this.sendFluidToAll(tanks[1], this);
fillFluidInit(tanks[1].getTankType());

View File

@ -3,9 +3,7 @@ package com.hbm.tileentity.machine;
import api.hbm.block.ILaserable;
import api.hbm.energy.IEnergyUser;
import api.hbm.fluid.IFluidStandardReceiver;
import com.hbm.interfaces.IFluidAcceptor;
import com.hbm.inventory.container.ContainerCoreEmitter;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.inventory.gui.GUICoreEmitter;
@ -35,7 +33,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import java.util.List;
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
public class TileEntityCoreEmitter extends TileEntityMachineBase implements IEnergyUser, IFluidAcceptor, ILaserable, IFluidStandardReceiver, SimpleComponent, IGUIProvider {
public class TileEntityCoreEmitter extends TileEntityMachineBase implements IEnergyUser, ILaserable, IFluidStandardReceiver, SimpleComponent, IGUIProvider {
public long power;
public static final long maxPower = 1000000000L;
@ -198,38 +196,6 @@ public class TileEntityCoreEmitter extends TileEntityMachineBase implements IEne
return (watts * i) / 100;
}
@Override
public void setFluidFill(int i, FluidType type) {
if(type.name().equals(tank.getTankType().name()))
tank.setFill(i);
}
@Override
public int getFluidFill(FluidType type) {
if(type.name().equals(tank.getTankType().name()))
return tank.getFill();
else
return 0;
}
@Override
public int getMaxFluidFill(FluidType type) {
if(type.name().equals(tank.getTankType().name()))
return tank.getMaxFill();
else
return 0;
}
@Override
public void setFillForSync(int fill, int index) {
tank.setFill(fill);
}
@Override
public void setTypeForSync(FluidType type, int index) {
tank.setTankType(type);
}
@Override
public void setPower(long i) {
this.power = i;

View File

@ -43,7 +43,7 @@ public class TileEntityDeuteriumExtractor extends TileEntityMachineBase implemen
}
this.subscribeToAllAround(tanks[0].getTankType(), this);
this.sendFluidToAll(tanks[1].getTankType(), this);
this.sendFluidToAll(tanks[1], this);
NBTTagCompound data = new NBTTagCompound();
data.setLong("power", power);

View File

@ -20,7 +20,8 @@ public class TileEntityDeuteriumTower extends TileEntityDeuteriumExtractor {
tanks[0] = new FluidTank(Fluids.WATER, 50000, 0);
tanks[1] = new FluidTank(Fluids.HEAVYWATER, 5000, 1);
}
@Override
protected void updateConnections() {
for(DirPos pos : getConPos()) {
@ -28,17 +29,19 @@ public class TileEntityDeuteriumTower extends TileEntityDeuteriumExtractor {
}
}
@Override
public void subscribeToAllAround(FluidType type, World world, int x, int y, int z) {
for(DirPos pos : getConPos()) {
this.trySubscribe(type, world, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
}
public void sendFluidToAll(FluidType type, TileEntity te) {
@Override
public void sendFluidToAll(FluidTank tank, TileEntity te) {
for(DirPos pos : getConPos()) {
this.sendFluid(type, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.sendFluid(tank, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
}

View File

@ -62,14 +62,14 @@ public class TileEntityFurnaceCombination extends TileEntityMachineBase implemen
for(int y = yCoord; y <= yCoord + 1; y++) {
for(int j = -1; j <= 1; j++) {
if(tank.getFill() > 0) this.sendFluid(tank.getTankType(), worldObj, xCoord + dir.offsetX * 2 + rot.offsetX * j, y, zCoord + dir.offsetZ * 2 + rot.offsetZ * j, dir);
if(tank.getFill() > 0) this.sendFluid(tank, worldObj, xCoord + dir.offsetX * 2 + rot.offsetX * j, y, zCoord + dir.offsetZ * 2 + rot.offsetZ * j, dir);
}
}
}
for(int x = xCoord - 1; x <= xCoord + 1; x++) {
for(int z = zCoord - 1; z <= zCoord + 1; z++) {
if(tank.getFill() > 0) this.sendFluid(tank.getTankType(), worldObj, x, yCoord + 2, z, ForgeDirection.UP);
if(tank.getFill() > 0) this.sendFluid(tank, worldObj, x, yCoord + 2, z, ForgeDirection.UP);
}
}
}

View File

@ -193,7 +193,7 @@ public class TileEntityHeatBoiler extends TileEntityLoadedBase implements IFluid
private void sendFluid() {
for(DirPos pos : getConPos()) {
this.sendFluid(tanks[1].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir().getOpposite());
this.sendFluid(tanks[1], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir().getOpposite());
}
}

View File

@ -65,7 +65,7 @@ public class TileEntityHeaterHeatex extends TileEntityMachineBase implements IHe
INBTPacketReceiver.networkPack(this, data, 25);
for(DirPos pos : getConPos()) {
if(this.tanks[1].getFill() > 0) this.sendFluid(tanks[1].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(this.tanks[1].getFill() > 0) this.sendFluid(tanks[1], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
}
}

View File

@ -156,7 +156,7 @@ public class TileEntityITER extends TileEntityMachineBase implements IEnergyUser
for(DirPos pos : getConPos()) {
if(tanks[1].getFill() > 0) {
this.sendFluid(tanks[1].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.sendFluid(tanks[1], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
}

View File

@ -91,7 +91,7 @@ public class TileEntityMachineAssemfac extends TileEntityMachineAssemblerBase im
this.consumption *= (overLevel + 1);
for(DirPos pos : getConPos()) {
this.sendFluid(steam.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.sendFluid(steam, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
if(steam.getFill() > 0) {

View File

@ -218,7 +218,7 @@ public class TileEntityMachineBoiler extends TileEntityLoadedBase implements ISi
if(!worldObj.isRemote) {
this.subscribeToAllAround(tanks[0].getTankType(), this);
this.sendFluidToAll(tanks[1].getTankType(), this);
this.sendFluidToAll(tanks[1], this);
age++;
if(age >= 20)

View File

@ -233,7 +233,7 @@ public class TileEntityMachineBoilerElectric extends TileEntityLoadedBase implem
{
this.updateConnections();
this.subscribeToAllAround(tanks[0].getTankType(), this);
this.sendFluidToAll(tanks[1].getTankType(), this);
this.sendFluidToAll(tanks[1], this);
age++;
if(age >= 20)

View File

@ -1,15 +1,12 @@
package com.hbm.tileentity.machine;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import com.hbm.blocks.BlockDummyable;
import com.hbm.interfaces.IFluidAcceptor;
import com.hbm.inventory.UpgradeManager;
import com.hbm.inventory.container.ContainerChemfac;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.inventory.gui.GUIChemfac;
@ -76,7 +73,7 @@ public class TileEntityMachineChemfac extends TileEntityMachineChemplantBase {
for(DirPos pos : getConPos()) for(FluidTank tank : outTanks()) {
if(tank.getTankType() != Fluids.NONE && tank.getFill() > 0) {
this.sendFluid(tank.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.sendFluid(tank, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
}
@ -217,58 +214,6 @@ public class TileEntityMachineChemfac extends TileEntityMachineChemplantBase {
return conPos;
}
@Override
public void fillFluidInit(FluidType type) {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
for(int i = 0; i < 6; i++) {
fillFluid(xCoord + dir.offsetX * (2 - i) + rot.offsetX * 3, yCoord + 4, zCoord + dir.offsetZ * (2 - i) + rot.offsetZ * 3, this.getTact(), type);
fillFluid(xCoord + dir.offsetX * (2 - i) - rot.offsetX * 2, yCoord + 4, zCoord + dir.offsetZ * (2 - i) - rot.offsetZ * 2, this.getTact(), type);
for(int j = 0; j < 2; j++) {
fillFluid(xCoord + dir.offsetX * (2 - i) + rot.offsetX * 5, yCoord + 1 + j, zCoord + dir.offsetZ * (2 - i) + rot.offsetZ * 5, this.getTact(), type);
fillFluid(xCoord + dir.offsetX * (2 - i) - rot.offsetX * 4, yCoord + 1 + j, zCoord + dir.offsetZ * (2 - i) - rot.offsetZ * 4, this.getTact(), type);
}
}
}
@Override
public void fillFluid(int x, int y, int z, boolean newTact, FluidType type) {
Library.transmitFluid(x, y, z, newTact, this, worldObj, type);
}
@Override
public boolean getTact() {
return this.worldObj.getTotalWorldTime() % 20 < 10;
}
private HashMap<FluidType, List<IFluidAcceptor>> fluidMap = new HashMap();
@Override
public List<IFluidAcceptor> getFluidList(FluidType type) {
List<IFluidAcceptor> list = fluidMap.get(type);
if(list == null) {
list = new ArrayList();
fluidMap.put(type, list);
}
return list;
}
@Override
public void clearFluidList(FluidType type) {
List<IFluidAcceptor> list = fluidMap.get(type);
if(list != null) {
list.clear();
}
}
@Override
public int getRecipeCount() {
return 8;
@ -366,11 +311,6 @@ public class TileEntityMachineChemfac extends TileEntityMachineChemplantBase {
return outTanks;
}
@Override
public int getMaxFluidFillForReceive(FluidType type) {
return super.getMaxFluidFillForReceive(type);
}
AxisAlignedBB bb = null;

View File

@ -111,8 +111,8 @@ public class TileEntityMachineChemplant extends TileEntityMachineBase implements
}
for(DirPos pos : getConPos()) {
if(tanks[2].getFill() > 0) this.sendFluid(tanks[2].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(tanks[3].getFill() > 0) this.sendFluid(tanks[3].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(tanks[2].getFill() > 0) this.sendFluid(tanks[2], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(tanks[3].getFill() > 0) this.sendFluid(tanks[3], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
UpgradeManager.eval(slots, 1, 3);

View File

@ -34,7 +34,7 @@ import net.minecraft.util.ChunkCoordinates;
* Tanks follow the order R1(I1, I2, O1, O2), R2(I1, I2, O1, O2) ...
* @author hbm
*/
public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBase implements IEnergyUser, IFluidSource, IFluidAcceptor, IFluidUser, IGUIProvider {
public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBase implements IEnergyUser, IFluidUser, IGUIProvider {
public long power;
public int[] progress;
@ -74,15 +74,6 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa
loadItems(i);
unloadItems(i);
}
if(worldObj.getTotalWorldTime() % 10 == 0) {
for(FluidTank tank : this.outTanks()) {
if(tank.getTankType() != Fluids.NONE && tank.getFill() > 0) {
this.fillFluidInit(tank.getTankType());
}
}
}
for(int i = 0; i < count; i++) {
@ -322,17 +313,7 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa
this.power = power;
}
@Override
public void setFillForSync(int fill, int index) { }
@Override
public void setFluidFill(int fill, FluidType type) { }
@Override
public void setTypeForSync(FluidType type, int index) { }
@Override
public int getFluidFill(FluidType type) {
/*public int getFluidFill(FluidType type) {
int fill = 0;
@ -349,10 +330,9 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa
}
return fill;
}
}*/
/* For input only! */
@Override
public int getMaxFluidFill(FluidType type) {
int maxFill = 0;
@ -365,20 +345,6 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa
return maxFill;
}
@Override
public int getFluidFillForReceive(FluidType type) {
int fill = 0;
for(FluidTank tank : inTanks()) {
if(tank.getTankType() == type) {
fill += tank.getFill();
}
}
return fill;
}
protected List<FluidTank> inTanks() {
@ -394,8 +360,7 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa
return inTanks;
}
@Override
public void receiveFluid(int amount, FluidType type) {
/*public void receiveFluid(int amount, FluidType type) {
if(amount <= 0)
return;
@ -431,15 +396,14 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa
tank.setFill(tank.getFill() + part);
}
}
}*/
@Override
public int getFluidFillForTransfer(FluidType type) {
public int getFluidFillForTransfer(FluidType type, int pressure) {
int fill = 0;
for(FluidTank tank : outTanks()) {
if(tank.getTankType() == type) {
if(tank.getTankType() == type && tank.getPressure() == pressure) {
fill += tank.getFill();
}
}
@ -447,8 +411,7 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa
return fill;
}
@Override
public void transferFluid(int amount, FluidType type) {
public void transferFluid(int amount, FluidType type, int pressure) {
/*
* this whole new fluid mumbo jumbo extra abstraction layer might just be a bandaid
@ -462,7 +425,7 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa
List<FluidTank> send = new ArrayList();
for(FluidTank tank : outTanks()) {
if(tank.getTankType() == type) {
if(tank.getTankType() == type && tank.getPressure() == pressure) {
send.add(tank);
}
}
@ -524,7 +487,7 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa
}
@Override
public long transferFluid(FluidType type, long fluid) {
public long transferFluid(FluidType type, int pressure, long fluid) {
int amount = (int) fluid;
if(amount <= 0)
@ -533,7 +496,7 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa
List<FluidTank> rec = new ArrayList();
for(FluidTank tank : inTanks()) {
if(tank.getTankType() == type) {
if(tank.getTankType() == type && tank.getPressure() == pressure) {
rec.add(tank);
}
}
@ -567,18 +530,18 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa
}
@Override
public long getDemand(FluidType type) {
return getMaxFluidFill(type) - getFluidFillForTransfer(type);
public long getDemand(FluidType type, int pressure) {
return getMaxFluidFill(type) - getFluidFillForTransfer(type, pressure);
}
@Override
public long getTotalFluidForSend(FluidType type) {
return getFluidFillForTransfer(type);
public long getTotalFluidForSend(FluidType type, int pressure) {
return getFluidFillForTransfer(type, pressure);
}
@Override
public void removeFluidForTransfer(FluidType type, long amount) {
this.transferFluid((int) amount, type);
public void removeFluidForTransfer(FluidType type, int pressure, long amount) {
this.transferFluid((int) amount, type, pressure);
}
@Override

View File

@ -173,7 +173,7 @@ public class TileEntityMachineCyclotron extends TileEntityMachineBase implements
private void sendFluid() {
for(DirPos pos : getConPos()) {
this.sendFluid(amat.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.sendFluid(amat, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
}

View File

@ -72,7 +72,7 @@ public class TileEntityMachineHephaestus extends TileEntityLoadedBase implements
if(output.getFill() > 0) {
for(DirPos pos : getConPos()) {
this.sendFluid(output.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.sendFluid(output, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
}
data.setInteger("heat", this.getTotalHeat());

View File

@ -74,7 +74,7 @@ public class TileEntityMachineLargeTurbine extends TileEntityMachineBase impleme
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
this.sendPower(worldObj, xCoord + dir.offsetX * -4, yCoord, zCoord + dir.offsetZ * -4, dir.getOpposite());
for(DirPos pos : getConPos()) this.trySubscribe(tanks[0].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
for(DirPos pos : getConPos()) this.sendFluid(tanks[1].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
for(DirPos pos : getConPos()) this.sendFluid(tanks[1], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
tanks[0].setType(0, 1, slots);
tanks[0].loadTank(2, 3, slots);

View File

@ -99,10 +99,10 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
if (age == 9 || age == 19)
fillFluidInit(tank.getTankType());
this.sendFluid(tank.getTankType(), worldObj, xCoord + 2, yCoord, zCoord, Library.POS_X);
this.sendFluid(tank.getTankType(), worldObj, xCoord - 2, yCoord, zCoord, Library.NEG_X);
this.sendFluid(tank.getTankType(), worldObj, xCoord, yCoord + 2, zCoord, Library.POS_Z);
this.sendFluid(tank.getTankType(), worldObj, xCoord, yCoord - 2, zCoord, Library.NEG_Z);
this.sendFluid(tank, worldObj, xCoord + 2, yCoord, zCoord, Library.POS_X);
this.sendFluid(tank, worldObj, xCoord - 2, yCoord, zCoord, Library.NEG_X);
this.sendFluid(tank, worldObj, xCoord, yCoord + 2, zCoord, Library.POS_Z);
this.sendFluid(tank, worldObj, xCoord, yCoord - 2, zCoord, Library.NEG_Z);
power = Library.chargeTEFromItems(slots, 0, power, maxPower);
tank.updateTank(xCoord, yCoord, zCoord, this.worldObj.provider.dimensionId);

View File

@ -100,7 +100,7 @@ public class TileEntityMachineMixer extends TileEntityMachineBase implements INB
}
for(DirPos pos : getConPos()) {
if(tanks[2].getFill() > 0) this.sendFluid(tanks[2].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(tanks[2].getFill() > 0) this.sendFluid(tanks[2], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
NBTTagCompound data = new NBTTagCompound();

View File

@ -142,8 +142,8 @@ public class TileEntityMachineRadiolysis extends TileEntityMachineBase implement
for(DirPos pos : getConPos()) {
this.sendPower(worldObj, pos.getX(), pos.getY(),pos.getZ(), pos.getDir());
this.trySubscribe(tanks[0].getTankType(), worldObj, pos.getX(), pos.getY(),pos.getZ(), pos.getDir());
if(tanks[1].getFill() > 0) this.sendFluid(tanks[1].getTankType(), worldObj, pos.getX(), pos.getY(),pos.getZ(), pos.getDir());
if(tanks[2].getFill() > 0) this.sendFluid(tanks[2].getTankType(), worldObj, pos.getX(), pos.getY(),pos.getZ(), pos.getDir());
if(tanks[1].getFill() > 0) this.sendFluid(tanks[1], worldObj, pos.getX(), pos.getY(),pos.getZ(), pos.getDir());
if(tanks[2].getFill() > 0) this.sendFluid(tanks[2], worldObj, pos.getX(), pos.getY(),pos.getZ(), pos.getDir());
}
NBTTagCompound data = new NBTTagCompound();

View File

@ -771,7 +771,7 @@ public class TileEntityMachineReactorLarge extends TileEntityLoadedBase implemen
if(worldObj.getBlock(xCoord + dir.offsetX * 2, yCoord, zCoord + dir.offsetZ * 2) == ModBlocks.reactor_hatch) {
fillFluid(this.xCoord + dir.offsetX * 3, this.yCoord, this.zCoord + dir.offsetZ * 3, getTact(), type);
for(int i = 0; i < 2; i++) this.trySubscribe(tanks[i].getTankType(), worldObj, this.xCoord + dir.offsetX * 3, this.yCoord, this.zCoord + dir.offsetZ * 3, Library.NEG_X);
this.sendFluid(tanks[2].getTankType(), worldObj, this.xCoord + dir.offsetX * 3, this.yCoord, this.zCoord + dir.offsetZ * 3, Library.NEG_X);
this.sendFluid(tanks[2], worldObj, this.xCoord + dir.offsetX * 3, this.yCoord, this.zCoord + dir.offsetZ * 3, Library.NEG_X);
} else {
for(int i = 0; i < 2; i++) this.tryUnsubscribe(tanks[i].getTankType(), worldObj, this.xCoord + dir.offsetX * 3, this.yCoord, this.zCoord + dir.offsetZ * 3);
}
@ -780,8 +780,8 @@ public class TileEntityMachineReactorLarge extends TileEntityLoadedBase implemen
fillFluid(this.xCoord, this.yCoord + height + 1, this.zCoord, getTact(), type);
fillFluid(this.xCoord, this.yCoord - depth - 1, this.zCoord, getTact(), type);
this.sendFluid(tanks[2].getTankType(), worldObj, this.xCoord, this.yCoord + height + 1, this.zCoord, Library.POS_Y);
this.sendFluid(tanks[2].getTankType(), worldObj, this.xCoord, this.yCoord - depth - 1, this.zCoord, Library.NEG_Y);
this.sendFluid(tanks[2], worldObj, this.xCoord, this.yCoord + height + 1, this.zCoord, Library.POS_Y);
this.sendFluid(tanks[2], worldObj, this.xCoord, this.yCoord - depth - 1, this.zCoord, Library.NEG_Y);
}
@Override

View File

@ -261,7 +261,7 @@ public class TileEntityMachineTurbine extends TileEntityLoadedBase implements IS
if(!valid) tanks[1].setTankType(Fluids.NONE);
if(power > maxPower) power = maxPower;
this.sendFluidToAll(tanks[1].getTankType(), this);
this.sendFluidToAll(tanks[1], this);
tanks[1].unloadTank(5, 6, slots);

View File

@ -139,7 +139,7 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
this.trySubscribe(tanks[2].getTankType(), worldObj, xCoord - dir.offsetX * 2 + rot.offsetX * -4, yCoord, zCoord - dir.offsetZ * 2 + rot.offsetZ * -4, dir.getOpposite());
this.trySubscribe(tanks[2].getTankType(), worldObj, xCoord + dir.offsetX * 2 + rot.offsetX * -4, yCoord, zCoord + dir.offsetZ * 2 + rot.offsetZ * -4, dir);
//steam
this.sendFluid(tanks[3].getTankType(), worldObj, xCoord + dir.offsetZ * 6, yCoord + 1, zCoord - dir.offsetX * 6, rot.getOpposite());
this.sendFluid(tanks[3], worldObj, xCoord + dir.offsetZ * 6, yCoord + 1, zCoord - dir.offsetX * 6, rot.getOpposite());
//if(audio != null) // audio shouldn't even exist serverside
// audio.updatePitch((float) (0.45 + 0.05 * rpm / 10));

View File

@ -168,7 +168,7 @@ public class TileEntityMachineTurbofan extends TileEntityMachineBase implements
for(DirPos pos : getConPos()) {
this.sendPower(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.trySubscribe(tank.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(this.blood.getFill() > 0) this.sendFluid(blood.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(this.blood.getFill() > 0) this.sendFluid(blood, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
if(burnValue > 0 && amountToBurn > 0) {

View File

@ -230,7 +230,7 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IF
}
for(DirPos pos : getConPos()) {
this.sendFluid(steam.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.sendFluid(steam, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
checkIfMeltdown();

View File

@ -56,8 +56,8 @@ public class TileEntitySolarBoiler extends TileEntityLoadedBase implements IFlui
water.setFill(water.getFill() - process);
steam.setFill(steam.getFill() + process * 100);
this.sendFluid(steam.getTankType(), worldObj, xCoord, yCoord + 3, zCoord, Library.POS_Y);
this.sendFluid(steam.getTankType(), worldObj, xCoord, yCoord - 1, zCoord, Library.NEG_Y);
this.sendFluid(steam, worldObj, xCoord, yCoord + 3, zCoord, Library.POS_Y);
this.sendFluid(steam, worldObj, xCoord, yCoord - 1, zCoord, Library.NEG_Y);
heat = 0;
} else {

View File

@ -120,7 +120,7 @@ public class TileEntitySteamEngine extends TileEntityLoadedBase implements IFlui
if(this.powerBuffer > 0)
this.sendPower(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.trySubscribe(tanks[0].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.sendFluid(tanks[1].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.sendFluid(tanks[1], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
if(tanks[1].getFill() > 0) fillFluidInit(tanks[1].getTankType());

View File

@ -148,8 +148,8 @@ public class TileEntityStorageDrum extends TileEntityMachineBase implements IFlu
fillFluidInit(tanks[1].getTankType());
}
this.sendFluidToAll(tanks[0].getTankType(), this);
this.sendFluidToAll(tanks[1].getTankType(), this);
this.sendFluidToAll(tanks[0], this);
this.sendFluidToAll(tanks[1], this);
tanks[0].updateTank(xCoord, yCoord, zCoord, worldObj.provider.dimensionId);
tanks[1].updateTank(xCoord, yCoord, zCoord, worldObj.provider.dimensionId);

View File

@ -68,14 +68,14 @@ public class TileEntityTowerLarge extends TileEntityCondenser {
}
@Override
public void sendFluidToAll(FluidType type, TileEntity te) {
public void sendFluidToAll(FluidTank tank, TileEntity te) {
for(int i = 2; i < 6; i++) {
ForgeDirection dir = ForgeDirection.getOrientation(i);
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
this.sendFluid(this.tanks[1].getTankType(), worldObj, xCoord + dir.offsetX * 5, yCoord, zCoord + dir.offsetZ * 5, dir);
this.sendFluid(this.tanks[1].getTankType(), worldObj, xCoord + dir.offsetX * 5 + rot.offsetX * 3, yCoord, zCoord + dir.offsetZ * 5 + rot.offsetZ * 3, dir);
this.sendFluid(this.tanks[1].getTankType(),worldObj, xCoord + dir.offsetX * 5 + rot.offsetX * -3, yCoord, zCoord + dir.offsetZ * 5 + rot.offsetZ * -3, dir);
this.sendFluid(this.tanks[1], worldObj, xCoord + dir.offsetX * 5, yCoord, zCoord + dir.offsetZ * 5, dir);
this.sendFluid(this.tanks[1], worldObj, xCoord + dir.offsetX * 5 + rot.offsetX * 3, yCoord, zCoord + dir.offsetZ * 5 + rot.offsetZ * 3, dir);
this.sendFluid(this.tanks[1], worldObj, xCoord + dir.offsetX * 5 + rot.offsetX * -3, yCoord, zCoord + dir.offsetZ * 5 + rot.offsetZ * -3, dir);
}
}

View File

@ -53,11 +53,11 @@ public class TileEntityTowerSmall extends TileEntityCondenser {
}
@Override
public void sendFluidToAll(FluidType type, TileEntity te) {
this.sendFluid(this.tanks[1].getTankType(), worldObj, xCoord + 3, yCoord, zCoord, Library.POS_X);
this.sendFluid(this.tanks[1].getTankType(), worldObj, xCoord - 3, yCoord, zCoord, Library.NEG_X);
this.sendFluid(this.tanks[1].getTankType(), worldObj, xCoord, yCoord, zCoord + 3, Library.POS_Z);
this.sendFluid(this.tanks[1].getTankType(), worldObj, xCoord, yCoord, zCoord - 3, Library.NEG_Z);
public void sendFluidToAll(FluidTank tank, TileEntity te) {
this.sendFluid(this.tanks[1], worldObj, xCoord + 3, yCoord, zCoord, Library.POS_X);
this.sendFluid(this.tanks[1], worldObj, xCoord - 3, yCoord, zCoord, Library.NEG_X);
this.sendFluid(this.tanks[1], worldObj, xCoord, yCoord, zCoord + 3, Library.POS_Z);
this.sendFluid(this.tanks[1], worldObj, xCoord, yCoord, zCoord - 3, Library.NEG_Z);
}
@Override

View File

@ -318,8 +318,8 @@ public class TileEntityWatz extends TileEntityMachineBase implements IFluidStand
protected void sendOutBottom() {
for(DirPos pos : getSendingPos()) {
if(tanks[1].getFill() > 0) this.sendFluid(tanks[1].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(tanks[2].getFill() > 0) this.sendFluid(tanks[2].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(tanks[1].getFill() > 0) this.sendFluid(tanks[1], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(tanks[2].getFill() > 0) this.sendFluid(tanks[2], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
}

View File

@ -565,10 +565,10 @@ public class TileEntityWatzCore extends TileEntityLoadedBase implements ISidedIn
this.sendPower(worldObj, xCoord, yCoord + 7, zCoord, ForgeDirection.UP);
this.sendPower(worldObj, xCoord, yCoord - 7, zCoord, ForgeDirection.DOWN);
this.sendFluid(tank.getTankType(), worldObj, xCoord + 4, yCoord, zCoord, Library.POS_X);
this.sendFluid(tank.getTankType(), worldObj, xCoord, yCoord, zCoord + 4, Library.POS_Z);
this.sendFluid(tank.getTankType(), worldObj, xCoord - 4, yCoord, zCoord, Library.NEG_X);
this.sendFluid(tank.getTankType(), worldObj, xCoord, yCoord, zCoord - 4, Library.NEG_Z);
this.sendFluid(tank, worldObj, xCoord + 4, yCoord, zCoord, Library.POS_X);
this.sendFluid(tank, worldObj, xCoord, yCoord, zCoord + 4, Library.POS_Z);
this.sendFluid(tank, worldObj, xCoord - 4, yCoord, zCoord, Library.NEG_X);
this.sendFluid(tank, worldObj, xCoord, yCoord, zCoord - 4, Library.NEG_Z);
if (age == 9 || age == 19) {
fillFluidInit(tank.getTankType());

View File

@ -49,7 +49,7 @@ public class TileEntityMachineCatalyticCracker extends TileEntityLoadedBase impl
for(DirPos pos : getConPos()) {
for(int i = 2; i <= 4; i++) {
if(tanks[i].getFill() > 0) this.sendFluid(tanks[i].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(tanks[i].getFill() > 0) this.sendFluid(tanks[i], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
}

View File

@ -69,7 +69,7 @@ public class TileEntityMachineCatalyticReformer extends TileEntityMachineBase im
for(DirPos pos : getConPos()) {
for(int i = 1; i < 4; i++) {
if(tanks[i].getFill() > 0) {
this.sendFluid(tanks[i].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.sendFluid(tanks[i], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
}
}

View File

@ -101,7 +101,7 @@ public class TileEntityMachineCoker extends TileEntityMachineBase implements IFl
}
for(DirPos pos : getConPos()) {
if(this.tanks[1].getFill() > 0) this.sendFluid(tanks[1].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(this.tanks[1].getFill() > 0) this.sendFluid(tanks[1], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
NBTTagCompound data = new NBTTagCompound();

View File

@ -104,8 +104,8 @@ public class TileEntityMachineFractionTower extends TileEntityLoadedBase impleme
private void sendFluid() {
for(DirPos pos : getConPos()) {
this.sendFluid(tanks[1].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.sendFluid(tanks[2].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.sendFluid(tanks[1], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.sendFluid(tanks[2], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
}

View File

@ -97,7 +97,7 @@ public class TileEntityMachineLiquefactor extends TileEntityMachineBase implemen
private void sendFluid() {
for(DirPos pos : getConPos()) {
this.sendFluid(tank.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.sendFluid(tank, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
}

View File

@ -174,7 +174,7 @@ public class TileEntityMachineRefinery extends TileEntityMachineBase implements
for(DirPos pos : getConPos()) {
for(int i = 1; i < 5; i++) {
if(tanks[i].getFill() > 0) {
this.sendFluid(tanks[i].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.sendFluid(tanks[i], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
}
}

View File

@ -66,7 +66,7 @@ public class TileEntityMachineVacuumDistill extends TileEntityMachineBase implem
for(DirPos pos : getConPos()) {
for(int i = 1; i < 5; i++) {
if(tanks[i].getFill() > 0) {
this.sendFluid(tanks[i].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.sendFluid(tanks[i], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
}
}

View File

@ -132,8 +132,8 @@ public abstract class TileEntityOilDrillBase extends TileEntityMachineBase imple
this.fillFluidInit(tanks[1].getTankType());
for(DirPos pos : getConPos()) {
if(tanks[0].getFill() > 0) this.sendFluid(tanks[0].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(tanks[1].getFill() > 0) this.sendFluid(tanks[1].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(tanks[0].getFill() > 0) this.sendFluid(tanks[0], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(tanks[1].getFill() > 0) this.sendFluid(tanks[1], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
if(this.power >= this.getPowerReqEff() && this.tanks[0].getFill() < this.tanks[0].getMaxFill() && this.tanks[1].getFill() < this.tanks[1].getMaxFill()) {

View File

@ -95,7 +95,7 @@ public class TileEntityRBMKBoiler extends TileEntityRBMKSlottedBase implements I
this.trySubscribe(feed.getTankType(), worldObj, xCoord, yCoord - 1, zCoord, Library.NEG_Y);
for(DirPos pos : getOutputPos()) {
if(this.steam.getFill() > 0) this.sendFluid(steam.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(this.steam.getFill() > 0) this.sendFluid(steam, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
}

View File

@ -86,7 +86,7 @@ public class TileEntityRBMKHeater extends TileEntityRBMKSlottedBase implements I
this.trySubscribe(feed.getTankType(), worldObj, xCoord, yCoord - 1, zCoord, Library.NEG_Y);
for(DirPos pos : getOutputPos()) {
if(this.steam.getFill() > 0) this.sendFluid(steam.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(this.steam.getFill() > 0) this.sendFluid(steam, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
}

View File

@ -54,7 +54,7 @@ public class TileEntityRBMKOutgasser extends TileEntityRBMKSlottedBase implement
}
for(DirPos pos : getOutputPos()) {
if(this.gas.getFill() > 0) this.sendFluid(gas.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(this.gas.getFill() > 0) this.sendFluid(gas, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
}

View File

@ -54,7 +54,7 @@ public class TileEntityRBMKOutlet extends TileEntityLoadedBase implements IFluid
}
fillFluidInit(this.steam.getTankType());
this.sendFluidToAll(steam.getTankType(), this);
this.sendFluidToAll(steam, this);
}
}

View File

@ -75,7 +75,7 @@ public class TileEntityBarrel extends TileEntityMachineBase implements IFluidAcc
tank.updateTank(xCoord, yCoord, zCoord, worldObj.provider.dimensionId);
this.sendingBrake = true;
tank.setFill(transmitFluidFairly(worldObj, tank.getTankType(), this, tank.getFill(), this.mode == 0 || this.mode == 1, this.mode == 1 || this.mode == 2, getConPos()));
tank.setFill(transmitFluidFairly(worldObj, tank, this, tank.getFill(), this.mode == 0 || this.mode == 1, this.mode == 1 || this.mode == 2, getConPos()));
this.sendingBrake = false;
age++;
@ -106,10 +106,12 @@ public class TileEntityBarrel extends TileEntityMachineBase implements IFluidAcc
};
}
protected static int transmitFluidFairly(World world, FluidType type, IFluidConnector that, int fill, boolean connect, boolean send, DirPos[] connections) {
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) {
@ -144,7 +146,7 @@ public class TileEntityBarrel extends TileEntityMachineBase implements IFluidAcc
if(x instanceof PipeNet) PipeNet.trackingInstances.add((PipeNet) x);
});
fill = (int) PipeNet.fairTransfer(con, type, fill);
fill = (int) PipeNet.fairTransfer(con, type, pressure, fill);
}
//resubscribe to buffered nets, if necessary

View File

@ -107,7 +107,7 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
age = 0;
this.sendingBrake = true;
tank.setFill(TileEntityBarrel.transmitFluidFairly(worldObj, tank.getTankType(), this, tank.getFill(), this.mode == 0 || this.mode == 1, this.mode == 1 || this.mode == 2, getConPos()));
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;
if((mode == 1 || mode == 2) && (age == 9 || age == 19))
@ -359,18 +359,20 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
}
@Override
public long transferFluid(FluidType type, long fluid) {
long toTransfer = Math.min(getDemand(type), fluid);
public long transferFluid(FluidType type, int pressure, long fluid) {
long toTransfer = Math.min(getDemand(type, pressure), fluid);
tank.setFill(tank.getFill() + (int) toTransfer);
return fluid - toTransfer;
}
@Override
public long getDemand(FluidType type) {
public long getDemand(FluidType type, int pressure) {
if(this.mode == 2 || this.mode == 3 || this.sendingBrake)
return 0;
if(tank.getPressure() != pressure) return 0;
return type == tank.getTankType() ? tank.getMaxFill() - tank.getFill() : 0;
}

View File

@ -107,16 +107,16 @@ public class TileEntityPipeBaseNT extends TileEntity implements IFluidConductor
}
@Override
public long transferFluid(FluidType type, long fluid) {
public long transferFluid(FluidType type, int pressure, long fluid) {
if(this.network == null)
return fluid;
return this.network.transferFluid(fluid);
return this.network.transferFluid(fluid, pressure);
}
@Override
public long getDemand(FluidType type) {
public long getDemand(FluidType type, int pressure) {
return 0;
}

View File

@ -11,8 +11,8 @@ public class Dummies {
public static class JarDummyConnector extends TileEntity implements IEnergyConnector, IFluidConnector {
@Override public boolean isLoaded() { return false; }
@Override public long transferFluid(FluidType type, long fluid) { return 0; }
@Override public long getDemand(FluidType type) { return 0; }
@Override public long transferFluid(FluidType type, int pressure, long fluid) { return 0; }
@Override public long getDemand(FluidType type, int pressure) { return 0; }
@Override public long transferPower(long power) { return 0; }
@Override public long getPower() { return 0; }
@Override public long getMaxPower() { return 0; }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB