use of net.minecraftforge.fluids.IFluidTank in project ForestryMC by ForestryMC.
the class GuiForestry method getFluidStackAtPosition.
@Nullable
public FluidStack getFluidStackAtPosition(int mouseX, int mouseY) {
for (Widget widget : widgetManager.getWidgets()) {
if (widget instanceof TankWidget && widget.isMouseOver(mouseX - guiLeft, mouseY - guiTop)) {
TankWidget tankWidget = (TankWidget) widget;
IFluidTank tank = tankWidget.getTank();
if (tank != null) {
return tank.getFluid();
}
}
}
return null;
}
use of net.minecraftforge.fluids.IFluidTank in project Metalworks by canitzp.
the class TileBase method readCapabilities.
private void readCapabilities(NBTTagCompound nbt, @Nullable EnumFacing side) {
if (hasEnergyFluidInv().getRight()) {
IItemHandler inventory = this.getInventory(side);
if (inventory instanceof IItemHandlerModifiable && nbt.hasKey("Inventory")) {
for (int i = 0; i < inventory.getSlots(); i++) {
// clear the inventory, otherwise empty stacks doesn't get overridden while syncing. Forge Bug?
((IItemHandlerModifiable) inventory).setStackInSlot(i, ItemStack.EMPTY);
}
CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.readNBT(inventory, side, nbt.getTag("Inventory"));
}
}
if (hasEnergyFluidInv().getMiddle()) {
IFluidHandler tank = getTank(side);
if (tank instanceof IFluidTank && nbt.hasKey("FluidTank")) {
CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.readNBT(tank, side, nbt.getCompoundTag("FluidTank"));
}
}
if (hasEnergyFluidInv().getLeft()) {
IEnergyStorage energy = getEnergy(side);
if (energy instanceof CustomEnergyStorage && nbt.hasKey("Energy", Constants.NBT.TAG_COMPOUND)) {
NBTTagCompound energyTag = nbt.getCompoundTag("Energy");
((CustomEnergyStorage) energy).setValues(energyTag.getInteger("Stored"), energyTag.getInteger("Capacity"), energyTag.getInteger("MaxReceive"), energyTag.getInteger("MaxExtract"));
}
}
}
use of net.minecraftforge.fluids.IFluidTank in project Binnie by ForestryMC.
the class MachineUtil method spaceInTank.
public boolean spaceInTank(final int id, final int amount) {
final IFluidTank tank = this.getTank(id);
final int space = tank.getCapacity() - tank.getFluidAmount();
return amount <= space;
}
use of net.minecraftforge.fluids.IFluidTank in project Binnie by ForestryMC.
the class MachineUtil method fillTank.
public void fillTank(final int id, final FluidStack liquidStack) {
final IFluidTank tank = this.getTank(id);
tank.fill(liquidStack, true);
}
use of net.minecraftforge.fluids.IFluidTank in project GTplusplus by GTNewHorizons.
the class GUI_PestKiller method drawFluidTank.
private void drawFluidTank(IFluidTank tank, int x, int y) {
Color startGrad = new Color(50, 50, 50);
Color endGrad = new Color(20, 20, 20);
Container_PestKiller aCont = (Container_PestKiller) this.inventorySlots;
double aPercentage = 0;
double aDivisor = (100 / 16);
int aFrameHeight = 16;
boolean didRender = false;
if (aCont != null) {
TileEntityPestKiller aTile = mTileKiller;
if (aTile != null) {
FluidTank aTank = aTile.getTank();
int aTier = aTile.getTier();
drawGradientRect(x, y, x + 16, y + 16, startGrad.getRGB(), endGrad.getRGB());
if (aTier <= 0 || aTier > 2) {
if (aTank != null && aTank.getFluidAmount() > 0) {
aPercentage = MathUtils.findPercentage(aTank.getFluidAmount(), aTank.getCapacity());
// Logger.INFO("Percent = "+aPercentage);
aFrameHeight = (int) (aPercentage / aDivisor);
// Logger.INFO("Frame Height = "+aFrameHeight);
}
this.fontRendererObj.drawString("Tier: 0", 4, 18, 4210752);
this.fontRendererObj.drawString("Range: 1x1", 4, 30, 4210752);
this.fontRendererObj.drawString("Poison: None", 4, 42, 4210752);
this.fontRendererObj.drawString("Amount: 0", 4, 64, 4210752);
didRender = true;
} else if (aTier == 1) {
if (aTank != null && aTank.getFluidAmount() > 0) {
aPercentage = MathUtils.findPercentage(aTank.getFluidAmount(), aTank.getCapacity());
// Logger.INFO("Percent = "+aPercentage);
aFrameHeight = (int) (aPercentage / aDivisor);
// Logger.INFO("Frame Height = "+aFrameHeight);
}
startGrad = new Color(240, 50, 240);
endGrad = new Color(130, 30, 130);
drawGradientRect(x, y + (16 - aFrameHeight), x + 16, y + 16, startGrad.getRGB(), endGrad.getRGB());
this.fontRendererObj.drawString("Tier: 1", 4, 18, 4210752);
this.fontRendererObj.drawString("Range: 5x5", 4, 30, 4210752);
this.fontRendererObj.drawString("Poison: ", 4, 42, 4210752);
this.fontRendererObj.drawString("" + aTile.getTank().getFluid().getLocalizedName(), 4, 54, 4210752);
this.fontRendererObj.drawString("Amount: " + aTile.getTank().getFluidAmount(), 4, 64, 4210752);
didRender = true;
} else if (aTier == 2) {
if (aTank != null && aTank.getFluidAmount() > 0) {
aPercentage = MathUtils.findPercentage(aTank.getFluidAmount(), aTank.getCapacity());
// Logger.INFO("Percent = "+aPercentage);
aFrameHeight = (int) (aPercentage / aDivisor);
// Logger.INFO("Frame Height = "+aFrameHeight);
}
short[] aRGB = MISC_MATERIALS.HYDROGEN_CYANIDE.getRGB();
startGrad = new Color(aRGB[0], aRGB[1], aRGB[2]);
endGrad = new Color(Math.max(aRGB[0], 0), Math.max(aRGB[1], 0), Math.max(aRGB[2], 0));
drawGradientRect(x, y + (16 - aFrameHeight), x + 16, y + 16, startGrad.getRGB(), endGrad.getRGB());
this.fontRendererObj.drawString("Tier: 2", 4, 18, 4210752);
this.fontRendererObj.drawString("Range: 9x9", 4, 30, 4210752);
this.fontRendererObj.drawString("Poison: ", 4, 42, 4210752);
this.fontRendererObj.drawString("" + aTile.getTank().getFluid().getLocalizedName(), 4, 54, 4210752);
this.fontRendererObj.drawString("Amount: " + aTile.getTank().getFluidAmount(), 4, 64, 4210752);
didRender = true;
}
}
}
if (!didRender) {
startGrad = new Color(255, 30, 120);
endGrad = new Color(255, 0, 50);
drawGradientRect(x, y, x + 16, y + 16, startGrad.getRGB(), endGrad.getRGB());
this.fontRendererObj.drawString("Tier: 0", 4, 18, 4210752);
}
/*
* FluidStack fluid = tank.getFluid(); TextureManager manager =
* mc.getTextureManager(); if (fluid != null) {
* manager.bindTexture(manager.getResourceLocation(0)); float amount =
* fluid.amount; float capacity = tank.getCapacity(); float scale = amount /
* capacity; int fluidTankHeight = 60; int fluidAmount = (int) (scale *
* fluidTankHeight); drawFluid(x, y + fluidTankHeight - fluidAmount,
* fluid.getFluid().getIcon(fluid), 16, fluidAmount); }
*/
}
Aggregations