Search in sources :

Example 6 with LiquidStack

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

the class TileEntityRancher method activateMachine.

@Override
public boolean activateMachine() {
    MFRLiquidMover.pumpLiquid(_tank, this);
    boolean didDrop = false;
    List<?> entities = worldObj.getEntitiesWithinAABB(EntityLiving.class, _areaManager.getHarvestArea().toAxisAlignedBB());
    for (Object o : entities) {
        EntityLiving e = (EntityLiving) o;
        if (MFRRegistry.getRanchables().containsKey(e.getClass())) {
            IFactoryRanchable r = MFRRegistry.getRanchables().get(e.getClass());
            List<ItemStack> drops = r.ranch(worldObj, e, this);
            if (drops != null) {
                for (ItemStack s : drops) {
                    if (LiquidContainerRegistry.isLiquid(s)) {
                        _tank.fill(new LiquidStack(s.itemID, LiquidContainerRegistry.BUCKET_VOLUME, s.getItemDamage()), true);
                        didDrop = true;
                        continue;
                    }
                    doDrop(s);
                    didDrop = true;
                }
                if (didDrop) {
                    setIdleTicks(20);
                    return true;
                }
            }
        }
    }
    setIdleTicks(getIdleTicksMax());
    return false;
}
Also used : LiquidStack(net.minecraftforge.liquids.LiquidStack) EntityLiving(net.minecraft.entity.EntityLiving) ItemStack(net.minecraft.item.ItemStack) IFactoryRanchable(powercrystals.minefactoryreloaded.api.IFactoryRanchable)

Example 7 with LiquidStack

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

the class TileEntityWeather method activateMachine.

@Override
public boolean activateMachine() {
    MFRLiquidMover.pumpLiquid(_tank, this);
    if (worldObj.getWorldInfo().isRaining() && canSeeSky()) {
        BiomeGenBase bgb = worldObj.getBiomeGenForCoords(this.xCoord, this.zCoord);
        if (!bgb.canSpawnLightningBolt() && !bgb.getEnableSnow()) {
            setIdleTicks(getIdleTicksMax());
            return false;
        }
        setWorkDone(getWorkDone() + 1);
        if (getWorkDone() >= getWorkMax()) {
            if (bgb.getFloatTemperature() >= 0.15F) {
                if (_tank.fill(new LiquidStack(Block.waterStill.blockID, LiquidContainerRegistry.BUCKET_VOLUME), true) > 0) {
                    setWorkDone(0);
                    return true;
                } else {
                    setWorkDone(getWorkMax());
                    return false;
                }
            } else {
                doDrop(new ItemStack(Item.snowball));
                setWorkDone(0);
            }
        }
        return true;
    }
    setIdleTicks(getIdleTicksMax());
    return false;
}
Also used : LiquidStack(net.minecraftforge.liquids.LiquidStack) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase) ItemStack(net.minecraft.item.ItemStack)

Example 8 with LiquidStack

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

the class TileEntityLiquidRouter method weightedRouteLiquid.

private int weightedRouteLiquid(LiquidStack resource, int[] routes, int amountRemaining, boolean doFill) {
    if (amountRemaining >= totalWeight(routes)) {
        int startingAmount = amountRemaining;
        for (int i = 0; i < routes.length; i++) {
            TileEntity te = BlockPosition.getAdjacentTileEntity(this, _outputDirections[i]);
            int amountForThisRoute = startingAmount * routes[i] / totalWeight(routes);
            if (te instanceof ITankContainer && amountForThisRoute > 0) {
                amountRemaining -= ((ITankContainer) te).fill(_outputDirections[i].getOpposite(), new LiquidStack(resource.itemID, amountForThisRoute, resource.itemMeta), doFill);
                if (amountRemaining <= 0) {
                    break;
                }
            }
        }
    }
    if (0 < amountRemaining && amountRemaining < totalWeight(routes)) {
        int outdir = weightedRandomSide(routes);
        TileEntity te = BlockPosition.getAdjacentTileEntity(this, _outputDirections[outdir]);
        if (te instanceof ITankContainer) {
            amountRemaining -= ((ITankContainer) te).fill(_outputDirections[outdir].getOpposite(), new LiquidStack(resource.itemID, amountRemaining, resource.itemMeta), doFill);
        }
    }
    return amountRemaining;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) LiquidStack(net.minecraftforge.liquids.LiquidStack) ITankContainer(net.minecraftforge.liquids.ITankContainer)

Example 9 with LiquidStack

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

the class Forestry method postInit.

@PostInit
public static void postInit(FMLPostInitializationEvent e) {
    if (!Loader.isModLoaded("Forestry")) {
        return;
    }
    LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getOrCreateLiquid("milk", new LiquidStack(MineFactoryReloadedCore.milkLiquid, LiquidContainerRegistry.BUCKET_VOLUME)), new ItemStack(Item.bucketMilk), new ItemStack(Item.bucketEmpty)));
    LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getOrCreateLiquid("sludge", new LiquidStack(MineFactoryReloadedCore.sludgeLiquid, LiquidContainerRegistry.BUCKET_VOLUME)), new ItemStack(MineFactoryReloadedCore.sludgeBucketItem), new ItemStack(Item.bucketEmpty)));
    LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getOrCreateLiquid("sewage", new LiquidStack(MineFactoryReloadedCore.sewageLiquid, LiquidContainerRegistry.BUCKET_VOLUME)), new ItemStack(MineFactoryReloadedCore.sewageBucketItem), new ItemStack(Item.bucketEmpty)));
    LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getOrCreateLiquid("mobEssence", new LiquidStack(MineFactoryReloadedCore.essenceLiquid, LiquidContainerRegistry.BUCKET_VOLUME)), new ItemStack(MineFactoryReloadedCore.mobEssenceBucketItem), new ItemStack(Item.bucketEmpty)));
    LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getOrCreateLiquid("biofuel", new LiquidStack(MineFactoryReloadedCore.biofuelLiquid, LiquidContainerRegistry.BUCKET_VOLUME)), new ItemStack(MineFactoryReloadedCore.bioFuelBucketItem), new ItemStack(Item.bucketEmpty)));
    MineFactoryReloadedCore.proxy.onPostTextureStitch(null);
    ForestryUtils.setTreeRoot();
    TileEntityUnifier.updateUnifierLiquids();
}
Also used : LiquidStack(net.minecraftforge.liquids.LiquidStack) LiquidContainerData(net.minecraftforge.liquids.LiquidContainerData) ItemStack(net.minecraft.item.ItemStack) PostInit(cpw.mods.fml.common.Mod.PostInit)

Example 10 with LiquidStack

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

the class ForestryPre method init.

@Init
public static void init(FMLInitializationEvent e) {
    if (!Loader.isModLoaded("Forestry")) {
        return;
    }
    LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getOrCreateLiquid("milk", new LiquidStack(MineFactoryReloadedCore.milkLiquid, LiquidContainerRegistry.BUCKET_VOLUME)), new ItemStack(Item.bucketMilk), new ItemStack(Item.bucketEmpty)));
    LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getOrCreateLiquid("sludge", new LiquidStack(MineFactoryReloadedCore.sludgeLiquid, LiquidContainerRegistry.BUCKET_VOLUME)), new ItemStack(MineFactoryReloadedCore.sludgeBucketItem), new ItemStack(Item.bucketEmpty)));
    LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getOrCreateLiquid("sewage", new LiquidStack(MineFactoryReloadedCore.sewageLiquid, LiquidContainerRegistry.BUCKET_VOLUME)), new ItemStack(MineFactoryReloadedCore.sewageBucketItem), new ItemStack(Item.bucketEmpty)));
    LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getOrCreateLiquid("mobEssence", new LiquidStack(MineFactoryReloadedCore.essenceLiquid, LiquidContainerRegistry.BUCKET_VOLUME)), new ItemStack(MineFactoryReloadedCore.mobEssenceBucketItem), new ItemStack(Item.bucketEmpty)));
    LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getOrCreateLiquid("biofuel", new LiquidStack(MineFactoryReloadedCore.biofuelLiquid, LiquidContainerRegistry.BUCKET_VOLUME)), new ItemStack(MineFactoryReloadedCore.bioFuelBucketItem), new ItemStack(Item.bucketEmpty)));
    LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getOrCreateLiquid("meat", new LiquidStack(MineFactoryReloadedCore.meatLiquid, LiquidContainerRegistry.BUCKET_VOLUME)), new ItemStack(MineFactoryReloadedCore.meatBucketItem), new ItemStack(Item.bucketEmpty)));
    LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getOrCreateLiquid("pinkslime", new LiquidStack(MineFactoryReloadedCore.pinkSlimeLiquid, LiquidContainerRegistry.BUCKET_VOLUME)), new ItemStack(MineFactoryReloadedCore.pinkSlimeBucketItem), new ItemStack(Item.bucketEmpty)));
    LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getOrCreateLiquid("chocolatemilk", new LiquidStack(MineFactoryReloadedCore.chocolateMilkLiquid, LiquidContainerRegistry.BUCKET_VOLUME)), new ItemStack(MineFactoryReloadedCore.chocolateMilkBucketItem), new ItemStack(Item.bucketEmpty)));
    LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getOrCreateLiquid("mushroomsoup", new LiquidStack(MineFactoryReloadedCore.mushroomSoupLiquid, LiquidContainerRegistry.BUCKET_VOLUME)), new ItemStack(MineFactoryReloadedCore.mushroomSoupBucketItem), new ItemStack(Item.bucketEmpty)));
    LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getOrCreateLiquid("mushroomsoup", new LiquidStack(MineFactoryReloadedCore.mushroomSoupLiquid, LiquidContainerRegistry.BUCKET_VOLUME)), new ItemStack(Item.bowlSoup), new ItemStack(Item.bowlEmpty)));
}
Also used : LiquidStack(net.minecraftforge.liquids.LiquidStack) LiquidContainerData(net.minecraftforge.liquids.LiquidContainerData) ItemStack(net.minecraft.item.ItemStack) Init(cpw.mods.fml.common.Mod.Init)

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