use of mods.railcraft.common.fluids.tanks.StandardTank in project Railcraft by Railcraft.
the class TileTankIronValve method update.
@Override
public void update() {
super.update();
if (Game.isClient(worldObj))
return;
decrementFilling();
if (isMaster) {
TileEntity tileBelow = tileCache.getTileOnSide(EnumFacing.DOWN);
TileTankIronValve valveBelow = null;
if (tileBelow instanceof TileTankIronValve) {
valveBelow = (TileTankIronValve) tileBelow;
if (valveBelow.isStructureValid() && valveBelow.getPatternMarker() == 'T') {
//noinspection ConstantConditions
StandardTank tankBelow = valveBelow.getTankManager().get(0);
assert tankBelow != null;
FluidStack liquid = tankBelow.getFluid();
if (liquid != null && liquid.amount >= tankBelow.getCapacity() - FluidTools.BUCKET_VOLUME) {
valveBelow = null;
FluidStack fillStack = liquid.copy();
fillStack.amount = FluidTools.BUCKET_VOLUME - (tankBelow.getCapacity() - liquid.amount);
if (fillStack.amount > 0) {
int used = tank.fill(fillStack, false);
if (used > 0) {
fillStack = tankBelow.drain(used, true);
tank.fill(fillStack, true);
}
}
}
} else
valveBelow = null;
}
if (valveBelow != null) {
FluidStack available = tankManager.drain(0, FluidTools.BUCKET_VOLUME, false);
if (available != null && available.amount > 0) {
int used = valveBelow.fill(available, true);
tankManager.drain(0, used, true);
}
}
}
if (getPatternPosition().getY() - getPattern().getMasterOffset().getY() == 0) {
TankManager tMan = getTankManager();
if (tMan != null)
tMan.push(tileCache, Predicates.notInstanceOf(TileTankBase.class), FLUID_OUTPUTS, 0, FLOW_RATE);
}
TileMultiBlock masterBlock = getMasterBlock();
if (masterBlock instanceof TileTankBase) {
TileTankBase masterTileTankBase = (TileTankBase) masterBlock;
int compValue = masterTileTankBase.getComparatorValue();
if (previousComparatorValue != compValue) {
previousComparatorValue = compValue;
getWorld().notifyNeighborsOfStateChange(getPos(), null);
}
}
if (previousStructureValidity != isStructureValid())
getWorld().notifyNeighborsOfStateChange(getPos(), null);
previousStructureValidity = isStructureValid();
}
use of mods.railcraft.common.fluids.tanks.StandardTank in project Railcraft by Railcraft.
the class TankManager method setCapacity.
public void setCapacity(int tankIndex, int capacity) {
StandardTank tank = get(tankIndex);
tank.setCapacity(capacity);
FluidStack fluidStack = tank.getFluid();
if (fluidStack != null && fluidStack.amount > capacity)
fluidStack.amount = capacity;
}
use of mods.railcraft.common.fluids.tanks.StandardTank in project Railcraft by Railcraft.
the class TankManager method writeTanksToNBT.
public void writeTanksToNBT(NBTTagCompound data) {
NBTTagList tagList = new NBTTagList();
for (byte slot = 0; slot < tanks.size(); slot++) {
StandardTank tank = tanks.get(slot);
if (tank.getFluid() != null) {
NBTTagCompound tag = new NBTTagCompound();
tag.setByte("tank", slot);
tank.writeToNBT(tag);
tagList.appendTag(tag);
}
}
data.setTag("tanks", tagList);
}
use of mods.railcraft.common.fluids.tanks.StandardTank in project Railcraft by Railcraft.
the class TileBoiler method update.
@Override
public void update() {
super.update();
if (Game.isHost(worldObj)) {
if (explode) {
worldObj.createExplosion(null, getX(), getY(), getZ(), 5f + 0.1f * getNumTanks(), true);
explode = false;
return;
}
TileBoilerFirebox mBlock = (TileBoilerFirebox) getMasterBlock();
if (mBlock != null) {
StandardTank tank = mBlock.tankManager.get(TANK_STEAM);
FluidStack steam = tank.getFluid();
if (steam != null && (!mBlock.boiler.isBoiling() || steam.amount >= tank.getCapacity() / 2))
mBlock.tankManager.push(tileCache, getOutputFilter(), EnumFacing.VALUES, TANK_STEAM, TRANSFER_RATE);
}
}
}
use of mods.railcraft.common.fluids.tanks.StandardTank in project Railcraft by Railcraft.
the class CartContentRendererTank method renderTank.
private void renderTank(RenderCart renderer, EntityCartTank cart, float light, float partialTicks, int x, int y, int z) {
StandardTank tank = cart.getTankManager().get(0);
if (tank != null) {
FluidStack fluidStack = tank.getFluid();
float cap = tank.getCapacity();
if (cap > 0 && fluidStack != null && fluidStack.amount > 0) {
OpenGL.glPushMatrix();
OpenGL.glPushAttrib(GL11.GL_ENABLE_BIT);
OpenGL.glEnable(GL11.GL_BLEND);
OpenGL.glDisable(GL11.GL_LIGHTING);
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
OpenGL.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
OpenGL.glTranslatef(-0.5F, -0.501F + 0.0625f, -0.5F);
float level = Math.min(fluidStack.amount / cap, cap);
FluidModelRenderer.INSTANCE.renderFluid(fluidStack, Math.min(16, (int) Math.ceil(level * 16F)));
if (cart.isFilling()) {
float scale = 6F / 16F;
OpenGL.glTranslatef(0.5F, 0F, 0.5F);
OpenGL.glScalef(scale, 1F, scale);
OpenGL.glTranslatef(-0.5F, 0F, -0.5F);
FluidModelRenderer.INSTANCE.renderFluid(fluidStack, 16);
}
OpenGL.glDisable(GL11.GL_BLEND);
OpenGL.glEnable(GL11.GL_LIGHTING);
OpenGL.glPopAttrib();
OpenGL.glPopMatrix();
}
}
}
Aggregations