use of net.minecraftforge.fluids.FluidStack in project Railcraft by Railcraft.
the class AdvancedFluidHandler method getFluidLevel.
public float getFluidLevel() {
int amount = 0;
int capacity = 0;
for (IFluidTankProperties tank : getTankProperties()) {
FluidStack liquid = tank.getContents();
amount += liquid == null ? 0 : liquid.amount;
capacity += tank.getCapacity();
}
return capacity == 0 ? 0 : amount / capacity;
}
use of net.minecraftforge.fluids.FluidStack in project Railcraft by Railcraft.
the class StandardTank method refreshTooltip.
protected void refreshTooltip() {
toolTip.clear();
int amount = getFluidAmount();
FluidStack fluidStack = getFluid();
if (!Fluids.isEmpty(fluidStack)) {
toolTip.add(getFluidNameToolTip(fluidStack.getFluid()));
}
toolTip.add(new ToolTipLine(String.format(Locale.ENGLISH, "%,d / %,d", amount, getCapacity())));
}
use of net.minecraftforge.fluids.FluidStack 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 net.minecraftforge.fluids.FluidStack in project Railcraft by Railcraft.
the class FluidGaugeWidget method draw.
//TODO: test render
@Override
public void draw(GuiContainerRailcraft gui, int guiX, int guiY, int mouseX, int mouseY) {
if (tank == null)
return;
FluidStack fluidStack = tank.getFluid();
if (fluidStack == null || fluidStack.amount <= 0)
return;
TextureAtlasSprite fluidIcon = FluidRenderer.getFluidTexture(fluidStack, FluidRenderer.FlowState.STILL);
if (fluidIcon == null)
return;
float scale = Math.min(fluidStack.amount, tank.getCapacity()) / (float) tank.getCapacity();
gui.bindTexture(FluidRenderer.getFluidSheet(fluidStack));
FluidRenderer.setColorForFluid(fluidStack);
for (int col = 0; col < w / 16; col++) {
for (int row = 0; row <= h / 16; row++) {
gui.drawTexturedModalRect(guiX + x + col * 16, guiY + y + row * 16 - 1, fluidIcon, 16, 16);
}
}
OpenGL.glColor4f(1, 1, 1, 1);
gui.bindTexture(gui.texture);
gui.drawTexturedModalRect(guiX + x, guiY + y - 1, x, y - 1, w, h - (int) Math.floor(h * scale) + 1);
gui.drawTexturedModalRect(guiX + x, guiY + y, u, v, w, h);
}
use of net.minecraftforge.fluids.FluidStack in project Railcraft by Railcraft.
the class FluidGaugeWidget method writeServerSyncData.
@Override
public void writeServerSyncData(IContainerListener listener, RailcraftOutputStream data) throws IOException {
super.writeServerSyncData(listener, data);
FluidStack fluidStack = tank.getFluid();
// Game.log(Level.INFO, "fluid write {0}", tank.getFluidAmount());
lastSyncedFluidStack = fluidStack == null ? null : fluidStack.copy();
data.writeFluidStack(fluidStack);
}
Aggregations