Search in sources :

Example 1 with LiquidStack

use of net.minecraftforge.liquids.LiquidStack in project MineFactoryReloaded by powercrystals.

the class MFRLiquidMover method manuallyFillTank.

/**
	 * Attempts to fill tank with the player's current item.
	 * @param	itcb			the tank the liquid is going into
	 * @param	entityplayer	the player trying to fill the tank
	 * @return	True if liquid was transferred to the tank.
	 */
public static boolean manuallyFillTank(ITankContainerBucketable itcb, EntityPlayer entityplayer) {
    ItemStack ci = entityplayer.inventory.getCurrentItem();
    LiquidStack liquid = LiquidContainerRegistry.getLiquidForFilledItem(ci);
    if (liquid != null) {
        if (itcb.fill(ForgeDirection.UNKNOWN, liquid, false) == liquid.amount) {
            itcb.fill(ForgeDirection.UNKNOWN, liquid, true);
            if (!entityplayer.capabilities.isCreativeMode) {
                entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, UtilInventory.consumeItem(ci));
            }
            return true;
        }
    }
    return false;
}
Also used : LiquidStack(net.minecraftforge.liquids.LiquidStack) ItemStack(net.minecraft.item.ItemStack)

Example 2 with LiquidStack

use of net.minecraftforge.liquids.LiquidStack in project MineFactoryReloaded by powercrystals.

the class MFRLiquidMover method manuallyDrainTank.

/**
	 * Attempts to drain tank into the player's current item.
	 * @param	itcb			the tank the liquid is coming from
	 * @param	entityplayer	the player trying to take liquid from the tank
	 * @return	True if liquid was transferred from the tank.
	 */
public static boolean manuallyDrainTank(ITankContainerBucketable itcb, EntityPlayer entityplayer) {
    ItemStack ci = entityplayer.inventory.getCurrentItem();
    if (LiquidContainerRegistry.isEmptyContainer(ci)) {
        for (ILiquidTank tank : itcb.getTanks(ForgeDirection.UNKNOWN)) {
            LiquidStack tankLiquid = tank.getLiquid();
            ItemStack filledBucket = LiquidContainerRegistry.fillLiquidContainer(tankLiquid, ci);
            if (LiquidContainerRegistry.isFilledContainer(filledBucket)) {
                LiquidStack bucketLiquid = LiquidContainerRegistry.getLiquidForFilledItem(filledBucket);
                if (entityplayer.capabilities.isCreativeMode) {
                    tank.drain(bucketLiquid.amount, true);
                    return true;
                } else if (ci.stackSize == 1) {
                    tank.drain(bucketLiquid.amount, true);
                    entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, filledBucket);
                    return true;
                } else if (entityplayer.inventory.addItemStackToInventory(filledBucket)) {
                    tank.drain(bucketLiquid.amount, true);
                    ci.stackSize -= 1;
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : LiquidStack(net.minecraftforge.liquids.LiquidStack) ILiquidTank(net.minecraftforge.liquids.ILiquidTank) ItemStack(net.minecraft.item.ItemStack)

Example 3 with LiquidStack

use of net.minecraftforge.liquids.LiquidStack in project MineFactoryReloaded by powercrystals.

the class GuiLiquiCrafter method drawGuiContainerForegroundLayer.

@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
    super.drawGuiContainerForegroundLayer(mouseX, mouseY);
    fontRenderer.drawString("Template", 67, 27, 4210752);
    fontRenderer.drawString("Output", 128, 26, 4210752);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    for (int i = 0; i < 9; i++) {
        LiquidStack l = _crafter.getTanks(ForgeDirection.UNKNOWN)[i].getLiquid();
        if (l != null) {
            drawTank(-50 + (i % 3 * 18), 43 + (i / 3 * 35), l.itemID, l.itemMeta, l.amount * 33 / _crafter.getTanks(ForgeDirection.UNKNOWN)[i].getCapacity());
        }
    }
    this.mc.renderEngine.bindTexture(MineFactoryReloadedCore.guiFolder + "liquicrafter.png");
    for (int i = 0; i < 8; i++) {
        this.drawTexturedModalRect(-50 + (i % 3 * 18), 10 + (i / 3 * 35), 232, 0, 16, 33);
    }
}
Also used : LiquidStack(net.minecraftforge.liquids.LiquidStack)

Example 4 with LiquidStack

use of net.minecraftforge.liquids.LiquidStack in project MineFactoryReloaded by powercrystals.

the class ContainerLiquiCrafter method detectAndSendChanges.

@Override
public void detectAndSendChanges() {
    super.detectAndSendChanges();
    int tankIndex = (int) (_crafter.worldObj.getWorldTime() % 9);
    ILiquidTank tank = _crafter.getTanks(ForgeDirection.UNKNOWN)[tankIndex];
    LiquidStack l = tank.getLiquid();
    for (int i = 0; i < crafters.size(); i++) {
        ((ICrafting) crafters.get(i)).sendProgressBarUpdate(this, 0, tankIndex);
        if (l != null) {
            ((ICrafting) crafters.get(i)).sendProgressBarUpdate(this, 1, l.itemID);
            ((ICrafting) crafters.get(i)).sendProgressBarUpdate(this, 2, l.itemMeta);
            ((ICrafting) crafters.get(i)).sendProgressBarUpdate(this, 3, l.amount);
        } else {
            ((ICrafting) crafters.get(i)).sendProgressBarUpdate(this, 1, 0);
            ((ICrafting) crafters.get(i)).sendProgressBarUpdate(this, 2, 0);
            ((ICrafting) crafters.get(i)).sendProgressBarUpdate(this, 3, 0);
        }
    }
}
Also used : LiquidStack(net.minecraftforge.liquids.LiquidStack) ILiquidTank(net.minecraftforge.liquids.ILiquidTank) ICrafting(net.minecraft.inventory.ICrafting)

Example 5 with LiquidStack

use of net.minecraftforge.liquids.LiquidStack in project MineFactoryReloaded by powercrystals.

the class ItemFactoryCup method getItemDisplayName.

@Override
public String getItemDisplayName(ItemStack item) {
    int id = item.getItemDamage();
    if (id != 0) {
        String ret = getFluidName(item), t = getLocalizedName(ret);
        if (t != null && !t.isEmpty())
            return EnumChatFormatting.RESET + t + EnumChatFormatting.RESET;
        if (ret == null) {
            item.setItemDamage(0);
            return super.getItemDisplayName(item);
        }
        LiquidStack liquid = LiquidDictionary.getLiquid(ret, 0);
        if (liquid != null) {
            ItemStack q = liquid.asItemStack();
            Item temp = Item.itemsList[q.itemID];
            if (temp != null)
                ret = temp.getItemDisplayName(q);
        }
        _prefix = true;
        t = super.getItemDisplayName(item);
        _prefix = false;
        t = t != null ? t.trim() : "";
        ret = (t.isEmpty() ? "" : t + " ") + ret;
        t = super.getItemDisplayName(item);
        t = t != null ? t.trim() : "";
        ret += t.isEmpty() ? " Cup" : " " + t;
        return ret;
    }
    return super.getItemDisplayName(item);
}
Also used : LiquidStack(net.minecraftforge.liquids.LiquidStack) Item(net.minecraft.item.Item) ItemStack(net.minecraft.item.ItemStack)

Aggregations

LiquidStack (net.minecraftforge.liquids.LiquidStack)22 ItemStack (net.minecraft.item.ItemStack)13 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 NBTTagList (net.minecraft.nbt.NBTTagList)4 LinkedList (java.util.LinkedList)3 ILiquidTank (net.minecraftforge.liquids.ILiquidTank)3 LiquidContainerData (net.minecraftforge.liquids.LiquidContainerData)3 PostInit (cpw.mods.fml.common.Mod.PostInit)2 TileEntity (net.minecraft.tileentity.TileEntity)2 ITankContainer (net.minecraftforge.liquids.ITankContainer)2 IInventoryManager (powercrystals.core.inventory.IInventoryManager)2 Init (cpw.mods.fml.common.Mod.Init)1 EntityLiving (net.minecraft.entity.EntityLiving)1 ICrafting (net.minecraft.inventory.ICrafting)1 Item (net.minecraft.item.Item)1 Icon (net.minecraft.util.Icon)1 BiomeGenBase (net.minecraft.world.biome.BiomeGenBase)1 LiquidTank (net.minecraftforge.liquids.LiquidTank)1 BlockPosition (powercrystals.core.position.BlockPosition)1 IFactoryRanchable (powercrystals.minefactoryreloaded.api.IFactoryRanchable)1