use of net.minecraftforge.fluids.FluidStack 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();
}
}
}
use of net.minecraftforge.fluids.FluidStack in project Railcraft by Railcraft.
the class DetectorTank method testCarts.
@Override
public int testCarts(List<EntityMinecart> carts) {
for (EntityMinecart cart : carts) {
IFluidHandler fluidHandler = FluidTools.getFluidHandler(null, cart);
if (fluidHandler != null) {
AdvancedFluidHandler tank = new AdvancedFluidHandler(fluidHandler);
boolean liquidMatches = false;
Fluid filterFluid = getFilterFluid();
FluidStack tankLiquid = tank.drain(1, false);
if (filterFluid == null)
liquidMatches = true;
else if (Fluids.areEqual(filterFluid, tankLiquid))
liquidMatches = true;
else if (tank.canPutFluid(new FluidStack(filterFluid, 1)))
liquidMatches = true;
boolean quantityMatches = false;
ButtonState state = buttonController.getButtonState();
switch(state) {
case VOID:
quantityMatches = true;
break;
case EMPTY:
if (filterFluid != null && tank.isTankEmpty(filterFluid))
quantityMatches = true;
else if (filterFluid == null && tank.areTanksEmpty())
quantityMatches = true;
break;
case NOT_EMPTY:
if (filterFluid != null && tank.getFluidQty(filterFluid) > 0)
quantityMatches = true;
else if (filterFluid == null && tank.isFluidInTank())
quantityMatches = true;
break;
case FULL:
if (filterFluid != null && tank.isTankFull(filterFluid))
quantityMatches = true;
else if (filterFluid == null && tank.areTanksFull())
quantityMatches = true;
break;
default:
float level = filterFluid != null ? tank.getFluidLevel(filterFluid) : tank.getFluidLevel();
switch(state) {
case ANALOG:
return (int) (FULL_POWER * level);
case QUARTER:
quantityMatches = level >= 0.25f;
break;
case HALF:
quantityMatches = level >= 0.5f;
break;
case MOST:
quantityMatches = level >= 0.75f;
break;
case LESS_THAN_QUARTER:
quantityMatches = level < 0.25f;
break;
case LESS_THAN_HALF:
quantityMatches = level < 0.5f;
break;
case LESS_THAN_MOST:
quantityMatches = level < 0.75f;
break;
case LESS_THAN_FULL:
quantityMatches = level < 1f;
break;
}
}
return liquidMatches && quantityMatches ? FULL_POWER : NO_POWER;
}
}
return NO_POWER;
}
use of net.minecraftforge.fluids.FluidStack in project Railcraft by Railcraft.
the class TrainTransferHelper method canAcceptPushedFluid.
private boolean canAcceptPushedFluid(EntityMinecart requester, EntityMinecart cart, Fluid fluid) {
IFluidHandler fluidHandler = FluidTools.getFluidHandler(EnumFacing.UP, cart);
if (fluidHandler == null)
return false;
if (cart instanceof IFluidCart)
return ((IFluidCart) cart).canAcceptPushedFluid(requester, fluid);
AdvancedFluidHandler advancedFluidHandler = new AdvancedFluidHandler(fluidHandler);
return advancedFluidHandler.canPutFluid(new FluidStack(fluid, 1));
}
use of net.minecraftforge.fluids.FluidStack in project Railcraft by Railcraft.
the class FluidFuelProvider method getMoreFuel.
@Override
public double getMoreFuel() {
FluidStack fuel = fuelTank.drain(FluidTools.BUCKET_VOLUME, false);
if (fuel == null)
return 0;
double heatValue = FuelManager.getBoilerFuelValue(fuel.getFluid());
if (heatValue > 0) {
fuelTank.drain(FluidTools.BUCKET_VOLUME, true);
if (fuel.amount < FluidTools.BUCKET_VOLUME)
heatValue *= (double) fuel.amount / (double) FluidTools.BUCKET_VOLUME;
}
return heatValue;
}
use of net.minecraftforge.fluids.FluidStack in project Railcraft by Railcraft.
the class IBoilerContainer method onFillWater.
static void onFillWater(IBoilerContainer tileBoiler) {
SteamBoiler boiler = tileBoiler.getBoiler();
if (boiler != null && boiler.isSuperHeated() && Steam.BOILERS_EXPLODE) {
FluidStack water = boiler.getTankWater().getFluid();
if (Fluids.isEmpty(water)) {
boiler.setHeat(Steam.SUPER_HEATED - 1);
tileBoiler.explode();
}
}
}
Aggregations