2014-01-08 02:55:50 +01:00
|
|
|
package mekanism.common.tile;
|
2013-04-28 21:23:08 +02:00
|
|
|
|
2015-02-27 02:50:02 +01:00
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
import java.util.ArrayList;
|
2015-06-17 19:26:47 +02:00
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Set;
|
2013-04-28 21:23:08 +02:00
|
|
|
|
2013-12-20 22:09:09 +01:00
|
|
|
import mekanism.api.Coord4D;
|
2014-08-08 04:48:35 +02:00
|
|
|
import mekanism.api.Range4D;
|
2013-08-27 00:49:32 +02:00
|
|
|
import mekanism.common.Mekanism;
|
2014-08-10 04:20:49 +02:00
|
|
|
import mekanism.common.base.IFluidContainerManager;
|
2016-01-22 21:41:34 +01:00
|
|
|
import mekanism.common.block.BlockBasic;
|
2014-08-20 21:22:55 +02:00
|
|
|
import mekanism.common.content.tank.SynchronizedTankData;
|
|
|
|
import mekanism.common.content.tank.SynchronizedTankData.ValveData;
|
2015-03-26 02:49:07 +01:00
|
|
|
import mekanism.common.content.tank.TankCache;
|
2014-08-22 22:17:16 +02:00
|
|
|
import mekanism.common.content.tank.TankUpdateProtocol;
|
|
|
|
import mekanism.common.multiblock.MultiblockManager;
|
2014-06-11 11:57:49 +02:00
|
|
|
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
2014-07-11 00:08:53 +02:00
|
|
|
import mekanism.common.util.FluidContainerUtils;
|
2014-07-26 22:45:48 +02:00
|
|
|
import mekanism.common.util.FluidContainerUtils.ContainerEditMode;
|
2016-01-22 21:41:34 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2013-04-28 21:23:08 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
2014-04-20 04:44:06 +02:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2013-07-20 18:10:14 +02:00
|
|
|
import net.minecraftforge.fluids.FluidContainerRegistry;
|
|
|
|
import net.minecraftforge.fluids.FluidStack;
|
2014-07-11 00:08:53 +02:00
|
|
|
import net.minecraftforge.fluids.IFluidContainerItem;
|
2013-04-28 21:23:08 +02:00
|
|
|
|
2015-01-08 06:26:53 +01:00
|
|
|
public class TileEntityDynamicTank extends TileEntityMultiblock<SynchronizedTankData> implements IFluidContainerManager
|
2013-04-28 21:23:08 +02:00
|
|
|
{
|
2015-06-17 19:26:47 +02:00
|
|
|
/** A client-sided set of valves on this tank's structure that are currently active, used on the client for rendering fluids. */
|
|
|
|
public Set<ValveData> valveViewing = new HashSet<ValveData>();
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-05-03 02:12:51 +02:00
|
|
|
/** The capacity this tank has on the client-side. */
|
2013-04-28 21:23:08 +02:00
|
|
|
public int clientCapacity;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-12-13 04:31:27 +01:00
|
|
|
public float prevScale;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
public TileEntityDynamicTank()
|
|
|
|
{
|
2015-03-03 05:05:54 +01:00
|
|
|
super("DynamicTank");
|
2013-04-28 21:23:08 +02:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
public TileEntityDynamicTank(String name)
|
|
|
|
{
|
|
|
|
super(name);
|
|
|
|
inventory = new ItemStack[2];
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
@Override
|
|
|
|
public void onUpdate()
|
|
|
|
{
|
2014-08-22 22:17:16 +02:00
|
|
|
super.onUpdate();
|
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
if(worldObj.isRemote)
|
|
|
|
{
|
|
|
|
if(structure != null && clientHasStructure && isRendering)
|
|
|
|
{
|
2014-03-08 02:00:25 +01:00
|
|
|
float targetScale = (float)(structure.fluidStored != null ? structure.fluidStored.amount : 0)/clientCapacity;
|
|
|
|
|
|
|
|
if(Math.abs(prevScale - targetScale) > 0.01)
|
|
|
|
{
|
|
|
|
prevScale = (9*prevScale + targetScale)/10;
|
|
|
|
}
|
2013-04-28 21:23:08 +02:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
if(!clientHasStructure || !isRendering)
|
|
|
|
{
|
2015-06-17 19:26:47 +02:00
|
|
|
for(ValveData data : valveViewing)
|
2013-05-07 01:42:03 +02:00
|
|
|
{
|
|
|
|
TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)data.location.getTileEntity(worldObj);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-05-07 01:42:03 +02:00
|
|
|
if(tileEntity != null)
|
|
|
|
{
|
|
|
|
tileEntity.clientHasStructure = false;
|
|
|
|
}
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
valveViewing.clear();
|
|
|
|
}
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
if(!worldObj.isRemote)
|
|
|
|
{
|
|
|
|
if(structure != null)
|
|
|
|
{
|
2015-03-05 02:01:46 +01:00
|
|
|
if(structure.fluidStored != null && structure.fluidStored.amount <= 0)
|
|
|
|
{
|
|
|
|
structure.fluidStored = null;
|
2015-03-25 02:43:22 +01:00
|
|
|
markDirty();
|
2015-03-05 02:01:46 +01:00
|
|
|
}
|
|
|
|
|
2015-06-17 19:26:47 +02:00
|
|
|
if(isRendering)
|
|
|
|
{
|
|
|
|
boolean needsValveUpdate = false;
|
|
|
|
|
|
|
|
for(ValveData data : structure.valves)
|
|
|
|
{
|
|
|
|
if(data.activeTicks > 0)
|
|
|
|
{
|
|
|
|
data.activeTicks--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(data.activeTicks > 0 != data.prevActive)
|
|
|
|
{
|
|
|
|
needsValveUpdate = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
data.prevActive = data.activeTicks > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(needsValveUpdate || structure.needsRenderUpdate())
|
|
|
|
{
|
|
|
|
sendPacketToRenderer();
|
|
|
|
}
|
2015-06-17 21:54:01 +02:00
|
|
|
|
|
|
|
structure.prevFluid = structure.fluidStored;
|
2015-06-17 19:26:47 +02:00
|
|
|
}
|
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
manageInventory();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
public void manageInventory()
|
|
|
|
{
|
2015-01-08 06:26:53 +01:00
|
|
|
int max = structure.volume * TankUpdateProtocol.FLUID_PER_TANK;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
if(structure.inventory[0] != null)
|
|
|
|
{
|
2014-07-11 00:08:53 +02:00
|
|
|
if(structure.inventory[0].getItem() instanceof IFluidContainerItem)
|
|
|
|
{
|
2014-07-11 04:28:04 +02:00
|
|
|
if(structure.editMode == ContainerEditMode.FILL && structure.fluidStored != null)
|
2014-07-11 00:08:53 +02:00
|
|
|
{
|
2014-07-11 04:28:04 +02:00
|
|
|
int prev = structure.fluidStored.amount;
|
|
|
|
|
|
|
|
structure.fluidStored.amount -= FluidContainerUtils.insertFluid(structure.fluidStored, structure.inventory[0]);
|
|
|
|
|
|
|
|
if(prev == structure.fluidStored.amount || structure.fluidStored.amount == 0)
|
|
|
|
{
|
|
|
|
if(structure.inventory[1] == null)
|
|
|
|
{
|
|
|
|
structure.inventory[1] = structure.inventory[0].copy();
|
|
|
|
structure.inventory[0] = null;
|
|
|
|
|
|
|
|
markDirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(structure.fluidStored.amount == 0)
|
|
|
|
{
|
|
|
|
structure.fluidStored = null;
|
|
|
|
}
|
2014-07-11 00:08:53 +02:00
|
|
|
}
|
|
|
|
else if(structure.editMode == ContainerEditMode.EMPTY)
|
|
|
|
{
|
2014-07-11 04:28:04 +02:00
|
|
|
if(structure.fluidStored != null)
|
|
|
|
{
|
|
|
|
FluidStack received = FluidContainerUtils.extractFluid(max-structure.fluidStored.amount, structure.inventory[0], structure.fluidStored.getFluid());
|
|
|
|
|
|
|
|
if(received != null)
|
|
|
|
{
|
|
|
|
structure.fluidStored.amount += received.amount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
structure.fluidStored = FluidContainerUtils.extractFluid(max, structure.inventory[0], null);
|
|
|
|
}
|
|
|
|
|
|
|
|
int newStored = structure.fluidStored != null ? structure.fluidStored.amount : 0;
|
|
|
|
|
|
|
|
if(((IFluidContainerItem)structure.inventory[0].getItem()).getFluid(structure.inventory[0]) == null || newStored == max)
|
|
|
|
{
|
|
|
|
if(structure.inventory[1] == null)
|
|
|
|
{
|
|
|
|
structure.inventory[1] = structure.inventory[0].copy();
|
|
|
|
structure.inventory[0] = null;
|
|
|
|
|
|
|
|
markDirty();
|
|
|
|
}
|
|
|
|
}
|
2014-07-11 00:08:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(FluidContainerRegistry.isEmptyContainer(structure.inventory[0]) && (structure.editMode == ContainerEditMode.BOTH || structure.editMode == ContainerEditMode.FILL))
|
2013-04-28 21:23:08 +02:00
|
|
|
{
|
2013-07-20 18:10:14 +02:00
|
|
|
if(structure.fluidStored != null && structure.fluidStored.amount >= FluidContainerRegistry.BUCKET_VOLUME)
|
2013-04-28 21:23:08 +02:00
|
|
|
{
|
2013-07-20 18:10:14 +02:00
|
|
|
ItemStack filled = FluidContainerRegistry.fillFluidContainer(structure.fluidStored, structure.inventory[0]);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
if(filled != null)
|
|
|
|
{
|
|
|
|
if(structure.inventory[1] == null || (structure.inventory[1].isItemEqual(filled) && structure.inventory[1].stackSize+1 <= filled.getMaxStackSize()))
|
|
|
|
{
|
|
|
|
structure.inventory[0].stackSize--;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
if(structure.inventory[0].stackSize <= 0)
|
|
|
|
{
|
|
|
|
structure.inventory[0] = null;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
if(structure.inventory[1] == null)
|
|
|
|
{
|
|
|
|
structure.inventory[1] = filled;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
structure.inventory[1].stackSize++;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-04-20 22:15:44 +02:00
|
|
|
markDirty();
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-07-20 18:10:14 +02:00
|
|
|
structure.fluidStored.amount -= FluidContainerRegistry.getFluidForFilledItem(filled).amount;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-07-20 18:10:14 +02:00
|
|
|
if(structure.fluidStored.amount == 0)
|
2013-04-28 21:23:08 +02:00
|
|
|
{
|
2013-07-20 18:10:14 +02:00
|
|
|
structure.fluidStored = null;
|
2013-04-28 21:23:08 +02:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-08-08 04:48:35 +02:00
|
|
|
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
|
2013-04-28 21:23:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-07-11 00:08:53 +02:00
|
|
|
else if(FluidContainerRegistry.isFilledContainer(structure.inventory[0]) && (structure.editMode == ContainerEditMode.BOTH || structure.editMode == ContainerEditMode.EMPTY))
|
2013-04-28 21:23:08 +02:00
|
|
|
{
|
2013-07-20 18:10:14 +02:00
|
|
|
FluidStack itemFluid = FluidContainerRegistry.getFluidForFilledItem(structure.inventory[0]);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-07-20 18:10:14 +02:00
|
|
|
if((structure.fluidStored == null && itemFluid.amount <= max) || structure.fluidStored.amount+itemFluid.amount <= max)
|
2013-04-28 21:23:08 +02:00
|
|
|
{
|
2013-07-20 18:10:14 +02:00
|
|
|
if(structure.fluidStored != null && !structure.fluidStored.isFluidEqual(itemFluid))
|
2013-04-28 21:23:08 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-05-07 22:37:58 +02:00
|
|
|
ItemStack containerItem = structure.inventory[0].getItem().getContainerItem(structure.inventory[0]);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
boolean filled = false;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-11-28 22:01:23 +01:00
|
|
|
if(containerItem != null)
|
2013-04-28 21:23:08 +02:00
|
|
|
{
|
2013-11-28 22:01:23 +01:00
|
|
|
if(structure.inventory[1] == null || (structure.inventory[1].isItemEqual(containerItem) && structure.inventory[1].stackSize+1 <= containerItem.getMaxStackSize()))
|
2013-04-28 21:23:08 +02:00
|
|
|
{
|
|
|
|
structure.inventory[0] = null;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
if(structure.inventory[1] == null)
|
|
|
|
{
|
2013-11-28 22:01:23 +01:00
|
|
|
structure.inventory[1] = containerItem;
|
2013-04-28 21:23:08 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
structure.inventory[1].stackSize++;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
filled = true;
|
|
|
|
}
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
else {
|
2013-04-28 21:23:08 +02:00
|
|
|
structure.inventory[0].stackSize--;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
if(structure.inventory[0].stackSize == 0)
|
|
|
|
{
|
|
|
|
structure.inventory[0] = null;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
filled = true;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
if(filled)
|
|
|
|
{
|
2013-07-20 18:10:14 +02:00
|
|
|
if(structure.fluidStored == null)
|
2013-04-28 21:23:08 +02:00
|
|
|
{
|
2013-07-20 18:10:14 +02:00
|
|
|
structure.fluidStored = itemFluid.copy();
|
2013-04-28 21:23:08 +02:00
|
|
|
}
|
|
|
|
else {
|
2013-07-20 18:10:14 +02:00
|
|
|
structure.fluidStored.amount += itemFluid.amount;
|
2013-04-28 21:23:08 +02:00
|
|
|
}
|
2014-07-11 00:08:53 +02:00
|
|
|
|
|
|
|
markDirty();
|
2013-04-28 21:23:08 +02:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-08-08 04:48:35 +02:00
|
|
|
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
|
2013-04-28 21:23:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-08-22 22:17:16 +02:00
|
|
|
|
2016-01-22 21:41:34 +01:00
|
|
|
@Override
|
|
|
|
public boolean onActivate(EntityPlayer player)
|
|
|
|
{
|
|
|
|
if(!player.isSneaking() && structure != null)
|
|
|
|
{
|
|
|
|
if(!BlockBasic.manageInventory(player, this))
|
|
|
|
{
|
|
|
|
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
|
|
|
|
player.openGui(Mekanism.instance, 18, worldObj, xCoord, yCoord, zCoord);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
player.inventory.markDirty();
|
|
|
|
sendPacketToRenderer();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-08-22 22:17:16 +02:00
|
|
|
@Override
|
2014-08-23 00:34:19 +02:00
|
|
|
protected SynchronizedTankData getNewStructure()
|
2014-08-22 22:17:16 +02:00
|
|
|
{
|
|
|
|
return new SynchronizedTankData();
|
|
|
|
}
|
|
|
|
|
2015-03-26 02:49:07 +01:00
|
|
|
@Override
|
|
|
|
public TankCache getNewCache()
|
|
|
|
{
|
|
|
|
return new TankCache();
|
|
|
|
}
|
|
|
|
|
2014-08-23 05:12:01 +02:00
|
|
|
@Override
|
|
|
|
protected TankUpdateProtocol getProtocol()
|
|
|
|
{
|
|
|
|
return new TankUpdateProtocol(this);
|
|
|
|
}
|
|
|
|
|
2014-08-22 22:17:16 +02:00
|
|
|
@Override
|
|
|
|
public MultiblockManager<SynchronizedTankData> getManager()
|
|
|
|
{
|
|
|
|
return Mekanism.tankManager;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
@Override
|
|
|
|
public ArrayList getNetworkedData(ArrayList data)
|
|
|
|
{
|
|
|
|
super.getNetworkedData(data);
|
2014-07-10 23:51:26 +02:00
|
|
|
|
|
|
|
if(structure != null)
|
|
|
|
{
|
|
|
|
data.add(structure.volume*TankUpdateProtocol.FLUID_PER_TANK);
|
|
|
|
data.add(structure.editMode.ordinal());
|
2015-03-05 02:01:46 +01:00
|
|
|
|
|
|
|
if(structure.fluidStored != null)
|
2013-04-28 21:23:08 +02:00
|
|
|
{
|
2015-03-05 02:01:46 +01:00
|
|
|
data.add(1);
|
2015-07-14 23:22:27 +02:00
|
|
|
data.add(structure.fluidStored.getFluidID());
|
2015-03-05 02:01:46 +01:00
|
|
|
data.add(structure.fluidStored.amount);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
data.add(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(isRendering)
|
|
|
|
{
|
2015-06-17 19:26:47 +02:00
|
|
|
Set<ValveData> toSend = new HashSet<ValveData>();
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2015-03-05 02:01:46 +01:00
|
|
|
for(ValveData valveData : structure.valves)
|
2015-06-17 19:26:47 +02:00
|
|
|
{
|
|
|
|
if(valveData.activeTicks > 0)
|
|
|
|
{
|
|
|
|
toSend.add(valveData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
data.add(toSend.size());
|
|
|
|
|
|
|
|
for(ValveData valveData : toSend)
|
2015-03-05 02:01:46 +01:00
|
|
|
{
|
|
|
|
valveData.location.write(data);
|
|
|
|
data.add(valveData.side.ordinal());
|
|
|
|
}
|
2013-04-28 21:23:08 +02:00
|
|
|
}
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
return data;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
@Override
|
2014-06-02 16:52:13 +02:00
|
|
|
public void handlePacketData(ByteBuf dataStream)
|
2013-04-28 21:23:08 +02:00
|
|
|
{
|
|
|
|
super.handlePacketData(dataStream);
|
2014-07-10 23:51:26 +02:00
|
|
|
|
|
|
|
if(clientHasStructure)
|
|
|
|
{
|
|
|
|
clientCapacity = dataStream.readInt();
|
|
|
|
structure.editMode = ContainerEditMode.values()[dataStream.readInt()];
|
2015-03-05 02:01:46 +01:00
|
|
|
|
|
|
|
if(dataStream.readInt() == 1)
|
|
|
|
{
|
|
|
|
structure.fluidStored = new FluidStack(dataStream.readInt(), dataStream.readInt());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
structure.fluidStored = null;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2015-03-05 02:01:46 +01:00
|
|
|
if(isRendering)
|
2013-04-28 21:23:08 +02:00
|
|
|
{
|
2015-03-05 02:01:46 +01:00
|
|
|
int size = dataStream.readInt();
|
2015-06-17 19:26:47 +02:00
|
|
|
|
|
|
|
valveViewing.clear();
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2015-03-05 02:01:46 +01:00
|
|
|
for(int i = 0; i < size; i++)
|
2013-04-28 21:23:08 +02:00
|
|
|
{
|
2015-03-05 02:01:46 +01:00
|
|
|
ValveData data = new ValveData();
|
|
|
|
data.location = Coord4D.read(dataStream);
|
|
|
|
data.side = ForgeDirection.getOrientation(dataStream.readInt());
|
2015-06-17 19:26:47 +02:00
|
|
|
|
|
|
|
valveViewing.add(data);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2015-03-05 02:01:46 +01:00
|
|
|
TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)data.location.getTileEntity(worldObj);
|
|
|
|
|
|
|
|
if(tileEntity != null)
|
|
|
|
{
|
|
|
|
tileEntity.clientHasStructure = true;
|
|
|
|
}
|
2013-05-07 01:42:03 +02:00
|
|
|
}
|
2013-04-28 21:23:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-07-20 18:10:14 +02:00
|
|
|
public int getScaledFluidLevel(int i)
|
2013-04-28 21:23:08 +02:00
|
|
|
{
|
2013-07-20 18:10:14 +02:00
|
|
|
if(clientCapacity == 0 || structure.fluidStored == null)
|
2013-04-28 21:23:08 +02:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-07-20 18:10:14 +02:00
|
|
|
return structure.fluidStored.amount*i / clientCapacity;
|
2013-04-28 21:23:08 +02:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-07-10 23:51:26 +02:00
|
|
|
@Override
|
|
|
|
public ContainerEditMode getContainerEditMode()
|
|
|
|
{
|
|
|
|
if(structure != null)
|
|
|
|
{
|
|
|
|
return structure.editMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ContainerEditMode.BOTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setContainerEditMode(ContainerEditMode mode)
|
|
|
|
{
|
|
|
|
if(structure == null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
structure.editMode = mode;
|
|
|
|
}
|
2013-04-28 21:23:08 +02:00
|
|
|
}
|