mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
some more fluid IO work
This commit is contained in:
parent
68efe9f28e
commit
2387cc13e7
@ -7,8 +7,8 @@ import com.hbm.inventory.fluid.FluidType;
|
||||
* 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 combinedradiotransmitter and receiver.
|
||||
* 3. A device that performs transmitting and receivingfunctions, especially if using commoncomponents.
|
||||
* 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.
|
||||
*
|
||||
|
||||
@ -64,12 +64,20 @@ public interface IFluidUser extends IFluidConnector {
|
||||
public default long getTotalFluidForSend(FluidType type) { return 0; }
|
||||
public default void removeFluidForTransfer(FluidType type, 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)
|
||||
|
||||
@ -233,12 +233,18 @@ public class FluidTank {
|
||||
}
|
||||
}
|
||||
|
||||
public void setType(int in, ItemStack[] slots) {
|
||||
setType(in, in, slots);
|
||||
public boolean setType(int in, ItemStack[] slots) {
|
||||
return setType(in, in, slots);
|
||||
}
|
||||
|
||||
//Changes tank type
|
||||
public void setType(int in, int out, ItemStack[] slots) {
|
||||
/**
|
||||
* Changes the tank type and returns true if successful
|
||||
* @param in
|
||||
* @param out
|
||||
* @param slots
|
||||
* @return
|
||||
*/
|
||||
public boolean setType(int in, int out, ItemStack[] slots) {
|
||||
|
||||
if(slots[in] != null && slots[in].getItem() instanceof ItemFluidIdentifier) {
|
||||
|
||||
@ -248,6 +254,7 @@ public class FluidTank {
|
||||
if(type != newType) {
|
||||
type = newType;
|
||||
fluid = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
} else if(slots[out] == null) {
|
||||
@ -257,9 +264,12 @@ public class FluidTank {
|
||||
slots[out] = slots[in].copy();
|
||||
slots[in] = null;
|
||||
fluid = 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -11,12 +11,13 @@ import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.main.ModEventHandler;
|
||||
|
||||
import api.hbm.fluid.IFluidStandardTransceiver;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityCondenser extends TileEntity implements IFluidAcceptor, IFluidSource {
|
||||
public class TileEntityCondenser extends TileEntity implements IFluidAcceptor, IFluidSource, IFluidStandardTransceiver {
|
||||
|
||||
public int age = 0;
|
||||
public FluidTank[] tanks;
|
||||
@ -53,6 +54,9 @@ public class TileEntityCondenser extends TileEntity implements IFluidAcceptor, I
|
||||
tanks[1].setFill(tanks[1].getFill() + convert);
|
||||
}
|
||||
|
||||
this.subscribeToAllAround(tanks[0].getTankType(), this);
|
||||
this.sendFluidToAll(tanks[1].getTankType(), this);
|
||||
|
||||
fillFluidInit(tanks[1].getTankType());
|
||||
|
||||
} else {
|
||||
@ -148,4 +152,14 @@ public class TileEntityCondenser extends TileEntity implements IFluidAcceptor, I
|
||||
public void clearFluidList(FluidType type) {
|
||||
list.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getSendingTanks() {
|
||||
return new FluidTank[] {tanks [1]};
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getReceivingTanks() {
|
||||
return new FluidTank[] {tanks [0]};
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,11 +14,13 @@ import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
import api.hbm.fluid.IFluidStandardTransceiver;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityDeuteriumExtractor extends TileEntityMachineBase implements IFluidAcceptor, IFluidSource, IEnergyUser {
|
||||
public class TileEntityDeuteriumExtractor extends TileEntityMachineBase implements IFluidAcceptor, IFluidSource, IEnergyUser, IFluidStandardTransceiver {
|
||||
|
||||
public int age = 0;
|
||||
public long power = 0;
|
||||
@ -61,8 +63,9 @@ public class TileEntityDeuteriumExtractor extends TileEntityMachineBase implemen
|
||||
data.setLong("power", power);
|
||||
this.networkPack(data, 25);
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.subscribeToAllAround(tanks[0].getTankType(), this);
|
||||
this.sendFluidToAll(tanks[1].getTankType(), this);
|
||||
|
||||
if(power < 0)
|
||||
power = 0;
|
||||
@ -196,4 +199,14 @@ public class TileEntityDeuteriumExtractor extends TileEntityMachineBase implemen
|
||||
public long getMaxPower() {
|
||||
return maxPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getSendingTanks() {
|
||||
return new FluidTank[] {tanks [1]};
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getReceivingTanks() {
|
||||
return new FluidTank[] {tanks [0]};
|
||||
}
|
||||
}
|
||||
@ -4,10 +4,13 @@ import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.inventory.FluidTank;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityDeuteriumTower extends TileEntityDeuteriumExtractor {
|
||||
@ -71,6 +74,27 @@ public class TileEntityDeuteriumTower extends TileEntityDeuteriumExtractor {
|
||||
}
|
||||
|
||||
protected void updateConnections() {
|
||||
|
||||
for(BlockPos pos : getConPos()) {
|
||||
this.trySubscribe(worldObj, pos.getX(), pos.getY(), pos.getZ(), ForgeDirection.UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
public void subscribeToAllAround(FluidType type, World world, int x, int y, int z) {
|
||||
|
||||
for(BlockPos pos : getConPos()) {
|
||||
this.trySubscribe(type, world, pos.getX(), pos.getY(), pos.getZ(), ForgeDirection.UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendFluidToAll(FluidType type, TileEntity te) {
|
||||
|
||||
for(BlockPos pos : getConPos()) {
|
||||
this.sendFluid(type, worldObj, pos.getX(), pos.getY(), pos.getZ(), ForgeDirection.UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
private BlockPos[] getConPos() {
|
||||
|
||||
int offsetX = 0;
|
||||
int offsetZ = 0;
|
||||
@ -85,14 +109,16 @@ public class TileEntityDeuteriumTower extends TileEntityDeuteriumExtractor {
|
||||
offsetZ = dir.offsetZ;
|
||||
}
|
||||
|
||||
this.trySubscribe(worldObj, this.xCoord + offsetX * 2, this.yCoord, this.zCoord - offsetZ * 1, ForgeDirection.UNKNOWN); //TODO: figure this one out without dying
|
||||
this.trySubscribe(worldObj, this.xCoord + offsetX * 2, this.yCoord, this.zCoord - offsetZ * 0, ForgeDirection.UNKNOWN);
|
||||
this.trySubscribe(worldObj, this.xCoord + offsetX * 1, this.yCoord, this.zCoord - offsetZ * 2, ForgeDirection.UNKNOWN);
|
||||
this.trySubscribe(worldObj, this.xCoord + offsetX * 0, this.yCoord, this.zCoord - offsetZ * 2, ForgeDirection.UNKNOWN);
|
||||
this.trySubscribe(worldObj, this.xCoord + offsetX * 1, this.yCoord, this.zCoord + offsetZ * 1, ForgeDirection.UNKNOWN);
|
||||
this.trySubscribe(worldObj, this.xCoord + offsetX * 0, this.yCoord, this.zCoord + offsetZ * 1, ForgeDirection.UNKNOWN);
|
||||
this.trySubscribe(worldObj, this.xCoord - offsetX * 1, this.yCoord, this.zCoord + offsetZ * 0, ForgeDirection.UNKNOWN);
|
||||
this.trySubscribe(worldObj, this.xCoord - offsetX * 1, this.yCoord, this.zCoord - offsetZ * 1, ForgeDirection.UNKNOWN);
|
||||
return new BlockPos[] {
|
||||
new BlockPos(this.xCoord + offsetX * 2, this.yCoord, this.zCoord - offsetZ * 1),
|
||||
new BlockPos(this.xCoord + offsetX * 2, this.yCoord, this.zCoord - offsetZ * 0),
|
||||
new BlockPos(this.xCoord + offsetX * 1, this.yCoord, this.zCoord - offsetZ * 2),
|
||||
new BlockPos(this.xCoord + offsetX * 0, this.yCoord, this.zCoord - offsetZ * 2),
|
||||
new BlockPos(this.xCoord + offsetX * 1, this.yCoord, this.zCoord + offsetZ * 1),
|
||||
new BlockPos(this.xCoord + offsetX * 0, this.yCoord, this.zCoord + offsetZ * 1),
|
||||
new BlockPos(this.xCoord - offsetX * 1, this.yCoord, this.zCoord + offsetZ * 0),
|
||||
new BlockPos(this.xCoord - offsetX * 1, this.yCoord, this.zCoord - offsetZ * 1)
|
||||
};
|
||||
}
|
||||
|
||||
AxisAlignedBB bb = null;
|
||||
|
||||
@ -101,13 +101,14 @@ public class TileEntityMachineDiesel extends TileEntityMachineBase implements IE
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
this.sendPower(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||
|
||||
this.subscribeToAllAround(Fluids.WATER, worldObj, xCoord, yCoord, zCoord);
|
||||
|
||||
//Tank Management
|
||||
tank.setType(3, 4, slots);
|
||||
FluidType last = tank.getTankType();
|
||||
if(tank.setType(3, 4, slots)) this.unsubscribeToAllAround(last, this);
|
||||
tank.loadTank(0, 1, slots);
|
||||
tank.updateTank(xCoord, yCoord, zCoord, worldObj.provider.dimensionId);
|
||||
|
||||
this.subscribeToAllAround(tank.getTankType(), this);
|
||||
|
||||
FluidType type = tank.getTankType();
|
||||
if(type == Fluids.NITAN)
|
||||
|
||||
BIN
src/main/resources/assets/hbm/textures/blocks/deep_cobble.png
Normal file
BIN
src/main/resources/assets/hbm/textures/blocks/deep_cobble.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 876 B |
Binary file not shown.
|
After Width: | Height: | Size: 958 B |
Loading…
x
Reference in New Issue
Block a user