use of net.minecraftforge.fluids.FluidTankInfo in project PneumaticCraft by MineMaarten.
the class ModelPlasticMixer method renderStatic.
@Override
public void renderStatic(float size, TileEntity te) {
Shape2.render(size);
Shape3b.render(size);
Shape1.render(size);
Shape3.render(size);
Shape4b.render(size);
Shape4.render(size);
if (te != null) {
TileEntityPlasticMixer mixer = (TileEntityPlasticMixer) te;
FluidTankInfo info = mixer.getTankInfo(null)[0];
if (info.fluid != null && info.fluid.amount > 10) {
float percentageFull = (float) info.fluid.amount / info.capacity;
RenderInfo renderInfo = new RenderInfo(-6 / 16F + 0.01F, 22 / 16F - percentageFull * 13.999F / 16F, -6 / 16F + 0.01F, 6 / 16F - 0.01F, 22 / 16F, 6 / 16F - 0.01F);
RenderUtils.INSTANCE.renderLiquid(info, renderInfo, mixer.getWorldObj());
}
}
}
use of net.minecraftforge.fluids.FluidTankInfo in project PneumaticCraft by MineMaarten.
the class SemiBlockRequester method amountRequested.
@Override
public int amountRequested(FluidStack stack) {
int totalRequestingAmount = getTotalRequestedAmount(stack);
if (totalRequestingAmount > 0) {
TileEntity te = getTileEntity();
if (te instanceof IFluidHandler) {
int count = 0;
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
FluidTankInfo[] infos = ((IFluidHandler) te).getTankInfo(d);
if (infos != null) {
for (FluidTankInfo info : infos) {
if (info.fluid != null && info.fluid.getFluid() == stack.getFluid()) {
count += info.fluid.amount;
}
}
if (count > 0)
break;
}
}
count += getIncomingFluid(stack.getFluid());
int requested = Math.max(0, Math.min(stack.amount, totalRequestingAmount - count));
return requested;
}
}
return 0;
}
use of net.minecraftforge.fluids.FluidTankInfo in project PneumaticCraft by MineMaarten.
the class ProgWidgetLiquidInventoryCondition method getEvaluator.
@Override
protected DroneAIBlockCondition getEvaluator(IDroneBase drone, IProgWidget widget) {
return new DroneAIBlockCondition(drone, (ProgWidgetAreaItemBase) widget) {
@Override
protected boolean evaluate(ChunkPosition pos) {
TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
int count = 0;
if (te instanceof IFluidHandler) {
List<FluidStack> visitedStacks = new ArrayList<FluidStack>();
IFluidHandler inv = (IFluidHandler) te;
for (int i = 0; i < 6; i++) {
if (((ISidedWidget) widget).getSides()[i]) {
FluidTankInfo[] info = inv.getTankInfo(ForgeDirection.getOrientation(i));
if (info != null) {
for (FluidTankInfo inf : info) {
if (inf.fluid != null && !visitedStacks.contains(visitedStacks) && ProgWidgetLiquidFilter.isLiquidValid(inf.fluid.getFluid(), widget, 1)) {
visitedStacks.add(inf.fluid);
count += inf.fluid.amount;
}
}
}
}
}
} else {
Fluid fluid = FluidRegistry.lookupFluidForBlock(drone.getWorld().getBlock(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ));
if (fluid != null && ProgWidgetLiquidFilter.isLiquidValid(fluid, widget, 1) && FluidUtils.isSourceBlock(drone.getWorld(), pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ)) {
count += 1000;
}
}
return ((ICondition) widget).getOperator() == ICondition.Operator.EQUALS ? count == ((ICondition) widget).getRequiredCount() : count >= ((ICondition) widget).getRequiredCount();
}
};
}
use of net.minecraftforge.fluids.FluidTankInfo in project ImmersiveEngineering by BluSunrize.
the class MultiFluidTank method getInfo.
@Override
public FluidTankInfo getInfo() {
FluidStack fs = getFluid();
int capacity = this.capacity - getFluidAmount();
if (fs != null)
capacity += fs.amount;
return new FluidTankInfo(fs, capacity);
}
use of net.minecraftforge.fluids.FluidTankInfo in project PneumaticCraft by MineMaarten.
the class ModelLiquidHopper method renderMain.
@Override
protected void renderMain(TileEntityOmnidirectionalHopper hopper) {
if (hopper != null) {
TileEntityLiquidHopper liquidHopper = (TileEntityLiquidHopper) hopper;
FluidTankInfo info = liquidHopper.getTankInfo(null)[0];
int fluidAmount = info.fluid != null ? info.fluid.amount - info.capacity / 10 : 0;
if (fluidAmount > 10) {
GL11.glDisable(GL11.GL_LIGHTING);
float percentageFull = Math.min(1, fluidAmount / (info.capacity * 0.3F));
RenderInfo renderInfo = new RenderInfo(-4 / 16F + 0.001F, 12 / 16F + 0.001F, 4 / 16F - percentageFull * 5.999F / 16F, 4 / 16F - 0.001F, 20 / 16F - 0.001F, 4 / 16F - 0.001F);
RenderUtils.INSTANCE.renderLiquid(info, renderInfo, liquidHopper.getWorldObj());
fluidAmount -= info.capacity * 0.3F;
if (fluidAmount > 10) {
percentageFull = Math.min(1, fluidAmount / (info.capacity * 0.3F));
renderInfo = new RenderInfo(-6 / 16F + 0.001F, 10 / 16F + 0.001F, -2 / 16F - percentageFull * 0.999F / 16F, 6 / 16F - 0.001F, 22 / 16F - 0.001F, -2 / 16F - 0.001F);
RenderUtils.INSTANCE.renderLiquid(info, renderInfo, liquidHopper.getWorldObj());
fluidAmount -= info.capacity * 0.3F;
if (fluidAmount > 10) {
percentageFull = Math.min(1, fluidAmount / (info.capacity * 0.3F));
renderInfo = new RenderInfo(6 / 16F + 0.001F, 8 / 16F + 0.001F, -2 / 16F - percentageFull * 5.999F / 16F, 8 / 16F - 0.001F, 24 / 16F - 0.001F, -2 / 16F - 0.001F);
RenderUtils.INSTANCE.renderLiquid(info, renderInfo, liquidHopper.getWorldObj());
renderInfo = new RenderInfo(-8 / 16F + 0.001F, 8 / 16F + 0.001F, -2 / 16F - percentageFull * 5.999F / 16F, -6 / 16F - 0.001F, 24 / 16F - 0.001F, -2 / 16F - 0.001F);
RenderUtils.INSTANCE.renderLiquid(info, renderInfo, liquidHopper.getWorldObj());
renderInfo = new RenderInfo(-6 / 16F + 0.001F, 22 / 16F + 0.001F, -2 / 16F - percentageFull * 5.999F / 16F, 6 / 16F - 0.001F, 24 / 16F - 0.001F, -2 / 16F - 0.001F);
RenderUtils.INSTANCE.renderLiquid(info, renderInfo, liquidHopper.getWorldObj());
renderInfo = new RenderInfo(-6 / 16F + 0.001F, 8 / 16F + 0.001F, -2 / 16F - percentageFull * 5.999F / 16F, 6 / 16F - 0.001F, 10 / 16F - 0.001F, -2 / 16F - 0.001F);
RenderUtils.INSTANCE.renderLiquid(info, renderInfo, liquidHopper.getWorldObj());
}
}
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(getModelTexture(hopper));
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glColor4d(1, 1, 1, 1);
}
}
}
Aggregations