use of net.minecraftforge.liquids.LiquidStack in project MineFactoryReloaded by powercrystals.
the class GuiFactoryInventory method drawTank.
protected void drawTank(int xOffset, int yOffset, int liquidId, int liquidMeta, int level) {
LiquidStack stack = LiquidDictionary.getCanonicalLiquid(new LiquidStack(liquidId, 1, liquidMeta));
if (liquidId <= 0 || stack == null) {
return;
}
ItemStack itemStack = stack.asItemStack();
Icon icon = stack.getRenderingIcon();
if (icon == null) {
try {
icon = itemStack.getIconIndex();
} catch (Throwable _) {
}
if (icon == null)
icon = Block.lavaMoving.getIcon(0, 0);
}
int vertOffset = 0;
while (level > 0) {
int texHeight = 0;
if (level > 16) {
texHeight = 16;
level -= 16;
} else {
texHeight = level;
level = 0;
}
mc.renderEngine.bindTexture(stack.getTextureSheet());
drawTexturedModelRectFromIcon(xOffset, yOffset - texHeight - vertOffset, icon, 16, texHeight);
vertOffset = vertOffset + 16;
}
this.mc.renderEngine.bindTexture(MineFactoryReloadedCore.guiFolder + _tileEntity.getGuiBackground());
this.drawTexturedModalRect(xOffset, yOffset - 60, 176, 0, 16, 60);
}
use of net.minecraftforge.liquids.LiquidStack in project MineFactoryReloaded by powercrystals.
the class GuiLiquiCrafter method drawTank.
@Override
protected void drawTank(int xOffset, int yOffset, int liquidId, int liquidMeta, int level) {
LiquidStack stack = LiquidDictionary.getCanonicalLiquid(new LiquidStack(liquidId, 1, liquidMeta));
if (liquidId <= 0 || stack == null) {
return;
}
int vertOffset = 0;
while (level > 0) {
int texHeight = 0;
if (level > 16) {
texHeight = 16;
level -= 16;
} else {
texHeight = level;
level = 0;
}
mc.renderEngine.bindTexture(stack.getTextureSheet());
drawTexturedModelRectFromIcon(xOffset, yOffset - texHeight - vertOffset, stack.getRenderingIcon(), 16, texHeight);
vertOffset = vertOffset + 16;
}
this.mc.renderEngine.bindTexture(MineFactoryReloadedCore.guiFolder + _tileEntity.getGuiBackground());
this.drawTexturedModalRect(xOffset, yOffset - 33, 232, 0, 16, 33);
}
use of net.minecraftforge.liquids.LiquidStack in project MineFactoryReloaded by powercrystals.
the class TileEntityUnifier method fill.
@Override
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill) {
if (resource == null || resource.amount == 0)
return 0;
LiquidStack converted = unifierTransformLiquid(resource, doFill);
if (converted == null || converted.amount == 0)
return 0;
int filled = _tank.fill(converted, doFill);
if (filled == converted.amount) {
return resource.amount;
} else {
return filled * resource.amount / converted.amount + (resource.amount & _roundingCompensation);
}
}
use of net.minecraftforge.liquids.LiquidStack in project MineFactoryReloaded by powercrystals.
the class TileEntityFactoryInventory method writeToNBT.
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < _inventory.length; i++) {
if (_inventory[i] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte) i);
_inventory[i].writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
}
if (getTank() != null && getTank().getLiquid() != null) {
LiquidStack fluid = getTank().getLiquid();
nbttagcompound.setInteger("tankAmount", fluid.amount);
String name = LiquidDictionary.findLiquidName(fluid);
if (name != null) {
nbttagcompound.setString("tankFluidName", name);
}
nbttagcompound.setInteger("tankItemId", getTank().getLiquid().itemID);
nbttagcompound.setInteger("tankMeta", getTank().getLiquid().itemMeta);
}
if (this.isInvNameLocalized()) {
NBTTagCompound display = new NBTTagCompound();
display.setString("Name", getInvName());
nbttagcompound.setCompoundTag("display", display);
}
nbttagcompound.setTag("Items", nbttaglist);
}
use of net.minecraftforge.liquids.LiquidStack in project MineFactoryReloaded by powercrystals.
the class TileEntityFactoryInventory method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
_inventory = new ItemStack[getSizeInventory()];
for (int i = 0; i < nbttaglist.tagCount(); i++) {
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i);
int j = nbttagcompound1.getByte("Slot") & 0xff;
if (j >= 0 && j < _inventory.length) {
ItemStack s = new ItemStack(0, 0, 0);
s.readFromNBT(nbttagcompound1);
_inventory[j] = s;
}
}
onFactoryInventoryChanged();
boolean foundLiquid = false;
ILiquidTank tank = getTank();
int tankAmount = nbttagcompound.getInteger("tankAmount");
if (tank != null && nbttagcompound.hasKey("tankFluidName")) {
LiquidStack fluid = LiquidDictionary.getLiquid(nbttagcompound.getString("tankFluidName"), tankAmount);
if (fluid != null) {
if (fluid.amount > tank.getCapacity()) {
fluid.amount = tank.getCapacity();
}
((LiquidTank) tank).setLiquid(fluid);
foundLiquid = true;
}
}
if (!foundLiquid) {
int tankItemId = nbttagcompound.getInteger("tankItemId");
int tankItemMeta = nbttagcompound.getInteger("tankItemMeta");
if (tank != null && Item.itemsList[tankItemId] != null && LiquidContainerRegistry.isLiquid(new ItemStack(tankItemId, 1, tankItemMeta))) {
((LiquidTank) tank).setLiquid(new LiquidStack(tankItemId, tankAmount, tankItemMeta));
if (tank.getLiquid() != null && tank.getLiquid().amount > tank.getCapacity()) {
tank.getLiquid().amount = tank.getCapacity();
}
}
}
for (int i = 0; i < getSizeInventory(); i++) {
if (_inventory[i] != null && _inventory[i].getItem() == null) {
_inventory[i] = null;
}
}
if (nbttagcompound.hasKey("display")) {
NBTTagCompound display = nbttagcompound.getCompoundTag("display");
if (display.hasKey("Name")) {
this.setInvName(display.getString("Name"));
}
}
}
Aggregations