Java 类net.minecraftforge.fluids.FluidContainerRegistry 实例源码

项目:CustomWorldGen    文件:FluidContainerRegistryWrapper.java   
@Nullable
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
    if (container.stackSize != 1 || resource == null)
    {
        return null;
    }

    FluidStack contained = FluidContainerRegistry.getFluidForFilledItem(container);
    if (contained != null && contained.isFluidEqual(resource))
    {
        return drain(resource.amount, doDrain);
    }

    return null;
}
项目:ExtraUtilities    文件:TileEntityGeneratorEnder.java   
@Override
public double getFuelBurn(final ItemStack item) {
    if (item != null) {
        if (item.getItem() == Items.ender_pearl) {
            return 750.0;
        }
        if (item.getItem() == Items.ender_eye) {
            return 3000.0;
        }
        if (item.getItem() == Item.getItemFromBlock((Block)ExtraUtils.enderLily)) {
            return 12000.0;
        }
        final FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(item);
        if (fluid != null && "ender".equals(fluid.getFluid().getName())) {
            return fluid.amount * 6;
        }
    }
    return 0.0;
}
项目:ExtraUtilities    文件:BlockGenerator.java   
public boolean onBlockActivated(final World worldObj, final int x, final int y, final int z, final EntityPlayer player, final int side, final float dx, final float dy, final float dz) {
    if (worldObj.isRemote) {
        return true;
    }
    final TileEntity tile = worldObj.getTileEntity(x, y, z);
    if (player.getCurrentEquippedItem() != null && tile instanceof IFluidHandler) {
        final ItemStack item = player.getCurrentEquippedItem();
        final FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(item);
        if (fluid != null && ((IFluidHandler)tile).fill(ForgeDirection.getOrientation(side), fluid, false) == fluid.amount) {
            ((IFluidHandler)tile).fill(ForgeDirection.getOrientation(side), fluid, true);
            if (!player.capabilities.isCreativeMode) {
                player.setCurrentItemOrArmor(0, item.getItem().getContainerItem(item));
            }
            return true;
        }
    }
    player.openGui((Object)ExtraUtilsMod.instance, 0, worldObj, x, y, z);
    return true;
}
项目:ExtraUtilities    文件:GuiFilter.java   
public List<String> getOveride(final ItemStack par1ItemStack, final int par2, final int par3) {
    int j1 = 0;
    while (j1 < this.inventorySlots.inventorySlots.size()) {
        final Slot slot = (Slot) this.inventorySlots.inventorySlots.get(j1);
        if (slot instanceof SlotGhostItemContainer && slot.getHasStack()) {
            if (!this.func_146978_c(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, par2, par3) || !slot.func_111238_b()) {
                return null;
            }
            final ItemStack filter = this.player.inventory.getStackInSlot(this.currentFilter);
            if (filter != null && filter.hasTagCompound() && filter.getTagCompound().hasKey("isLiquid_" + slot.slotNumber)) {
                final FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(slot.getStack());
                final List t = new ArrayList();
                t.add(XUHelper.getFluidName(liquid));
                return (List<String>)t;
            }
            return null;
        }
        else {
            ++j1;
        }
    }
    return null;
}
项目:4Space-5    文件:FluidUtil.java   
/**
 * Returns the used (empty) container, for example an empty bucket
 * Used, for example, in isItemValidForSlot() logic
 * @param slotItem
 * @return  True if it is a container; False if it is null or not a container 
 */
public static ItemStack getUsedContainer(ItemStack container)
{
       if (FluidContainerRegistry.isBucket(container) && FluidContainerRegistry.isFilledContainer(container))
       {
           return new ItemStack(Items.bucket, container.stackSize);
       }
       else
       {
           container.stackSize--;

           if (container.stackSize == 0)
           {
               return null;
           }

           return container;
       }
}
项目:4Space-5    文件:FluidUtils.java   
public static boolean fillTankWithContainer(IFluidHandler tank, EntityPlayer player)
{
    ItemStack stack = player.getCurrentEquippedItem();
    FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);

    if(liquid == null)
        return false;

    if(tank.fill(ForgeDirection.UNKNOWN, liquid, false) != liquid.amount && !player.capabilities.isCreativeMode)
        return false;

    tank.fill(ForgeDirection.UNKNOWN, liquid, true);

    if(!player.capabilities.isCreativeMode)
        InventoryUtils.consumeItem(player.inventory, player.inventory.currentItem);

    player.inventoryContainer.detectAndSendChanges();
    return true;
}
项目:TerraFirmaProgressivePack    文件:TFCPPFluids.java   
public static void registerFluidContainers()
    {

  //      if (FluidRegistry.getFluid("creosote")!= null)
                FluidContainerRegistry.registerFluidContainer(new FluidStack(FluidRegistry.getFluid("creosote"), 1000), new ItemStack(TFCPPItems.itemWoodenBucket_Creozote), new ItemStack(TFCItems.woodenBucketEmpty));

 //       if (FluidRegistry.getFluid("oil")!= null)
            FluidContainerRegistry.registerFluidContainer(new FluidStack(FluidRegistry.getFluid("oil"), 1000), new ItemStack(TFCPPItems.itemWoodenBucket_Oil), new ItemStack(TFCItems.woodenBucketEmpty));

        FluidContainerRegistry.registerFluidContainer(new FluidStack(fluidLeachedUrainite, 1000), new ItemStack(TFCPPItems.itemRedSteelBucket_LeachedUranite), new ItemStack(TFCItems.redSteelBucketEmpty));
        FluidContainerRegistry.registerFluidContainer(new FluidStack(solutionHydrochloricAcid, 1000), new ItemStack(TFCPPItems.itemRedSteelBucket_HydrochloricAcid), new ItemStack(TFCItems.redSteelBucketEmpty));

        FluidContainerRegistry.registerFluidContainer(new FluidStack(liquidWeakBlackSteel, 1000), new ItemStack(TFCPPItems.itemBlueSteelBucket_WeakBlackSteel), new ItemStack(TFCItems.blueSteelBucketEmpty));
        FluidContainerRegistry.registerFluidContainer(new FluidStack(liquidCarbonBlackSteel, 1000), new ItemStack(TFCPPItems.itemBlueSteelBucket_CarbonBlackSteel), new ItemStack(TFCItems.blueSteelBucketEmpty));
        // if (FluidRegistry.getFluid("liquidblacksteel")!= null)
        FluidContainerRegistry.registerFluidContainer(new FluidStack(liquidBlackSteel, 1000), new ItemStack(TFCPPItems.itemBlueSteelBucket_BlackSteel), new ItemStack(TFCItems.blueSteelBucketEmpty));
        FluidContainerRegistry.registerFluidContainer(new FluidStack(liquidPigIron, 1000), new ItemStack(TFCPPItems.itemBlueSteelBucket_PigIron), new ItemStack(TFCItems.blueSteelBucketEmpty));
//        if (FluidRegistry.getFluid("liquidsteel")!= null)
            FluidContainerRegistry.registerFluidContainer(new FluidStack(FluidRegistry.getFluid("liquidsteel"), 1000), new ItemStack(TFCPPItems.itemBlueSteelBucket_Steel), new ItemStack(TFCItems.blueSteelBucketEmpty));
        FluidContainerRegistry.registerFluidContainer(new FluidStack(fluidMundanePotion, 1000), new ItemStack(Items.potionitem,1,8192), new ItemStack(Items.glass_bottle));
        FluidContainerRegistry.registerFluidContainer(new FluidStack(fluidAwkwardPotion, 1000), new ItemStack(Items.potionitem,1,16), new ItemStack(Items.glass_bottle));

        //        FluidContainerRegistry.registerFluidContainer(new FluidStack(liquidPigIron, 1000), new ItemStack(TFCPPItems.itemBlueSteelBucket_PigIron), new ItemStack(TFCItems.blueSteelBucketEmpty));


    }
项目:TerrafirmaPunk-Tweaks    文件:CommonProxy.java   
public void setupFluids()
{
    FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluid(TFCFluids.OLIVEOIL.getName()), new ItemStack(TFPItems.CustomBucketOliveOil), new ItemStack(TFCItems.woodenBucketEmpty));

    if(Loader.isModLoaded("BuildCraft|Core"))
    {
        FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluid(BuildCraftEnergy.fluidOil.getName()), new ItemStack(TFPItems.CustomBucketOil), new ItemStack(TFCItems.woodenBucketEmpty));
    }

    if(Loader.isModLoaded("necromancy"))
    {
        FluidContainerRegistry.registerFluidContainer(new FluidStack(TFPFluids.tfpFluidBlood, 1000), new ItemStack(TFPItems.CustomBucketBlood), new ItemStack(TFCItems.woodenBucketEmpty));
        FluidContainerRegistry.registerFluidContainer(new FluidStack(TFPFluids.tfpFluidBlood, 250), ItemGeneric.getItemStackFromName("Jar of Blood"), new ItemStack(TFCItems.glassBottle));
    }

    if(Loader.isModLoaded("steamcraft2"))
    {
        FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluid(TFPFluids.tfpFluidWhaleOil.getName()), new ItemStack(TFPItems.CustomBucketWhaleOil), new ItemStack(TFCItems.woodenBucketEmpty));
    }
}
项目:DartCraft2    文件:ModItems.java   
public static void init() {
    GameRegistry.registerItem(forceGem, "forceGem");
    GameRegistry.registerItem(liquidForceBucket, "liquidForceBucket");
    FluidContainerRegistry.registerFluidContainer(ModFluids.liquidForce, new ItemStack(liquidForceBucket), new ItemStack(Items.bucket));
    BucketHandler.buckets.put(ModBlocks.liquidForce, liquidForceBucket);
    GameRegistry.registerItem(clipboard, "clipboard");
    GameRegistry.registerItem(forceIngot, "forceIngot");
    GameRegistry.registerItem(forceNugget, "forceNugget");
       GameRegistry.registerItem(forceRod, "forceRod");
    GameRegistry.registerItem(forceStick, "forceStick");
       GameRegistry.registerItem(forceBelt, "forceBelt");
    GameRegistry.registerItem(forceMitts, "forceMitts");
    GameRegistry.registerItem(goldenPowerSource, "goldenPowerSource");
    GameRegistry.registerFuelHandler(goldenPowerSource);
       GameRegistry.registerItem(forcePack, "forcePack");
    GameRegistry.registerItem(upgradeTome, "upgradeTome");
}
项目:EnderCore    文件:FluidUtil.java   
public static FluidStack getFluidFromItem(ItemStack stack) {
  if (stack != null) {
    FluidStack fluidStack = null;
    if (stack.getItem() instanceof IFluidContainerItem) {
      fluidStack = ((IFluidContainerItem) stack.getItem()).getFluid(stack);
    }
    if (fluidStack == null) {
      fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack);
    }
    if (fluidStack == null && Block.getBlockFromItem(stack.getItem()) instanceof IFluidBlock) {
      Fluid fluid = ((IFluidBlock) Block.getBlockFromItem(stack.getItem())).getFluid();
      if (fluid != null) {
        return new FluidStack(fluid, 1000);
      }
    }
    return fluidStack;
  }
  return null;
}
项目:ToggleBlocks    文件:BucketToggleAction.java   
@Override
public void placeBlock(World world, int x, int y, int z, ForgeDirection direction, EntityPlayer player,
                       ItemStack placing, IToggleController controller) // TODO: Add storage item index as parameter?
{
    if (FluidContainerRegistry.isFilledContainer(placing))
    {
        FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(placing);
        Fluid fluid = fluidStack.getFluid();
        if (fluidStack.getFluid().canBePlacedInWorld())
        {
            Block fluidBlock = fluid.getBlock();
            world.setBlock(x, y, z, fluidBlock);
            world.notifyBlockChange(x, y, z, fluidBlock);
            fluidBlock.onBlockAdded(world, x, y, z);
            ItemStack drainedContainer = FluidContainerRegistry.drainFluidContainer(placing);
            placing.stackSize--;
            controller.getStorageHandler().addItemStackToStorage(drainedContainer);
        }
    } else if (placing.getItem() instanceof ItemBucket)
    {
        ItemBucket item = (ItemBucket) placing.getItem();
        item.tryPlaceContainedLiquid(world, x, y, z);
    }
}
项目:ThermalRecycling    文件:FluidStackHelper.java   
public static boolean applyPlayerContainerInteraction(final World world, final TileEntity entity, final EntityPlayer player) {

        final ItemStack stack = player.getCurrentEquippedItem();
        if(stack == null || !FluidContainerRegistry.isContainer(stack))
            return false;

        boolean update = false;
        final IFluidHandler handler = (IFluidHandler)entity;

        // Get the fluid from the item.  If there is one they are trying
        // to fill.  Otherwise they are trying to remove.
        FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);
        if(liquid != null) {
            update = FluidHelper.fillHandlerWithContainer(world, handler, player);
        }
        else {
            liquid = handler.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid;
            update = FluidHelper.fillContainerFromHandler(world, handler, player, liquid);
        }

        if(update)
            world.markBlockForUpdate(entity.xCoord, entity.yCoord, entity.zCoord);

        return update;
    }
项目:amunra    文件:TileEntityMothershipEngineJet.java   
@Override
protected boolean isItemFuel(ItemStack itemstack) {

    FluidStack containedFluid = null;
    if(itemstack.getItem() instanceof IFluidContainerItem) {
        containedFluid = ((IFluidContainerItem)itemstack.getItem()).getFluid(itemstack);
    }
    if(containedFluid == null) {
        containedFluid = FluidContainerRegistry.getFluidForFilledItem(itemstack);
    }
    if(containedFluid != null) {
        if(containedFluid.getFluid() == fuel) {
            return true;
        }
        return FluidUtil.testFuel(FluidRegistry.getFluidName(containedFluid));
    }

    return false;
}
项目:amunra    文件:TileEntityMothershipEngineIon.java   
@Override
public boolean isItemValidForSlot(int slotID, ItemStack itemstack) {
    if(itemstack == null) return false;

    switch(slotID) {
    case 0:
        FluidStack containedFluid = FluidContainerRegistry.getFluidForFilledItem(itemstack);
        if(containedFluid != null && containedFluid.getFluid() == fuel) {
            return true;
        }
        break;
    case 1:
        return ItemElectricBase.isElectricItem(itemstack.getItem());
    }
    return false;

    // return (slotID == 0 && itemstack != null && itemstack.getItem() == GCItems.fuelCanister);
}
项目:TFCWaterCompatibility    文件:BarrelLiquidToLiquidRecipe.java   
@Override
public FluidStack getResultFluid(ItemStack inIS, FluidStack inFS, int sealedTime)
{
    if(recipeOutFluid != null)
    {
        FluidStack fs = recipeOutFluid.copy();
        FluidStack itemLiquid = FluidContainerRegistry.getFluidForFilledItem(inIS);
        if(!removesLiquid)
        {
            fs.amount = inFS.amount+itemLiquid.amount;
        }
        else
        {
            fs.amount = ( fs.amount * inFS.amount ) / recipeFluid.amount;
        }
        return fs;
    }
    return null;
}
项目:vsminecraft    文件:TileEntityElectricPump.java   
@Override
public boolean isItemValidForSlot(int slotID, ItemStack itemstack)
{
    if(slotID == 1)
    {
        return false;
    }
    else if(slotID == 0)
    {
        return FluidContainerRegistry.isEmptyContainer(itemstack);
    }
    else if(slotID == 2)
    {
        return ChargeUtils.canBeDischarged(itemstack);
    }

    return true;
}
项目:vsminecraft    文件:TileEntityFluidicPlenisher.java   
@Override
public boolean isItemValidForSlot(int slotID, ItemStack itemstack)
{
    if(slotID == 1)
    {
        return false;
    }
    else if(slotID == 0)
    {
        return FluidContainerRegistry.isFilledContainer(itemstack);
    }
    else if(slotID == 2)
    {
        return ChargeUtils.canBeDischarged(itemstack);
    }

    return false;
}
项目:vsminecraft    文件:TileEntityElectrolyticSeparator.java   
@Override
public boolean canExtractItem(int slotID, ItemStack itemstack, int side)
{
    if(slotID == 3)
    {
        return ChargeUtils.canBeOutputted(itemstack, false);
    }
    else if(slotID == 0)
    {
        return FluidContainerRegistry.isEmptyContainer(itemstack);
    }
    else if(slotID == 1 || slotID == 2)
    {
        return itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null &&
                ((IGasItem)itemstack.getItem()).getGas(itemstack).amount == ((IGasItem)itemstack.getItem()).getMaxGas(itemstack);
    }

    return false;
}
项目:vsminecraft    文件:MekanismGenerators.java   
@EventHandler
public void postInit(FMLPostInitializationEvent event)
{
    if(FuelHandler.BCPresent() && BuildcraftFuelRegistry.fuel != null)
    {
        for(IFuel s : BuildcraftFuelRegistry.fuel.getFuels())
        {
            if(!(s.getFluid() == null || GasRegistry.containsGas(s.getFluid().getName())))
            {
                GasRegistry.register(new Gas(s.getFluid()));
            }
        }

        BuildcraftFuelRegistry.fuel.addFuel(FluidRegistry.getFluid("ethene"), (int)(240 * general.TO_TE), 40 * FluidContainerRegistry.BUCKET_VOLUME);
    }

    for(ItemStack ore : OreDictionary.getOres("dustGold"))
    {
        RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("CARBON"), 10, MekanismUtils.size(ore, 4), GeneratorsItems.Hohlraum.getEmptyItem());
    }
}
项目:TechNodefirmacraftMod    文件:ModCommonProxy.java   
public void setupFluids()
{
    FluidContainerRegistry.registerFluidContainer(new FluidStack(ModFluids.OAKMIX, 250), new ItemStack(ModItems.BottleOakMix), new ItemStack(Items.glass_bottle));
    FluidContainerRegistry.registerFluidContainer(new FluidStack(ModFluids.BIRCHMIX, 250), new ItemStack(ModItems.BottleBirchMix), new ItemStack(Items.glass_bottle));
    FluidContainerRegistry.registerFluidContainer(new FluidStack(ModFluids.SPRUCEMIX, 250), new ItemStack(ModItems.BottleSpruceMix), new ItemStack(Items.glass_bottle));
    FluidContainerRegistry.registerFluidContainer(new FluidStack(ModFluids.JUNGLEMIX, 250), new ItemStack(ModItems.BottleJungleMix), new ItemStack(Items.glass_bottle));
    FluidContainerRegistry.registerFluidContainer(new FluidStack(ModFluids.ACACIAMIX, 250), new ItemStack(ModItems.BottleAcaciaMix), new ItemStack(Items.glass_bottle));
    FluidContainerRegistry.registerFluidContainer(new FluidStack(ModFluids.DARKOAKMIX, 250), new ItemStack(ModItems.BottleDarkOakMix), new ItemStack(Items.glass_bottle));


    FluidContainerRegistry.registerFluidContainer(new FluidStack(ModFluids.REGENPOT, 250), new ItemStack(ModItems.BottleRegenPot), new ItemStack(Items.glass_bottle));
    FluidContainerRegistry.registerFluidContainer(new FluidStack(ModFluids.SWIFTPOT, 250), new ItemStack(ModItems.BottleSwiftPot), new ItemStack(Items.glass_bottle));
    FluidContainerRegistry.registerFluidContainer(new FluidStack(ModFluids.FIRERESPOT, 250), new ItemStack(ModItems.BottleFireResPot), new ItemStack(Items.glass_bottle));
    FluidContainerRegistry.registerFluidContainer(new FluidStack(ModFluids.POISONPOT, 250), new ItemStack(ModItems.BottlePoisonPot), new ItemStack(Items.glass_bottle));
    FluidContainerRegistry.registerFluidContainer(new FluidStack(ModFluids.HEALTHPOT, 250), new ItemStack(ModItems.BottleHealthPot), new ItemStack(Items.glass_bottle));
    FluidContainerRegistry.registerFluidContainer(new FluidStack(ModFluids.NIGHTVISIONPOT, 250), new ItemStack(ModItems.BottleNightVisionPot), new ItemStack(Items.glass_bottle));
    FluidContainerRegistry.registerFluidContainer(new FluidStack(ModFluids.WEAKNESSPOT, 250), new ItemStack(ModItems.BottleWeaknessPot), new ItemStack(Items.glass_bottle));
    FluidContainerRegistry.registerFluidContainer(new FluidStack(ModFluids.STRPOT, 250), new ItemStack(ModItems.BottleStrPot), new ItemStack(Items.glass_bottle));
    FluidContainerRegistry.registerFluidContainer(new FluidStack(ModFluids.SLOWPOT, 250), new ItemStack(ModItems.BottleSlowPot), new ItemStack(Items.glass_bottle));
    FluidContainerRegistry.registerFluidContainer(new FluidStack(ModFluids.HARMPOT, 250), new ItemStack(ModItems.BottleHarmPot), new ItemStack(Items.glass_bottle));
    FluidContainerRegistry.registerFluidContainer(new FluidStack(ModFluids.WATERBREATHINGPOT, 250), new ItemStack(ModItems.BottleWaterBreathingPot), new ItemStack(Items.glass_bottle));
    FluidContainerRegistry.registerFluidContainer(new FluidStack(ModFluids.INVISIBILITYPOT, 250), new ItemStack(ModItems.BottleInvisibilityPot), new ItemStack(Items.glass_bottle));
    FluidContainerRegistry.registerFluidContainer(new FluidStack(ModFluids.ENERGIZINGFLUID, 250), new ItemStack(ModItems.BottleEnergizingFluid), new ItemStack(Items.glass_bottle));
    FluidContainerRegistry.registerFluidContainer(new FluidStack(ModFluids.EXTENDINGFLUID, 250), new ItemStack(ModItems.BottleExtendingFluid), new ItemStack(Items.glass_bottle));  }
项目:DecorationsTFC    文件:FluidList.java   
public static void registerFluidContainers()
{
    if(DecorationsMod.isLanternsEnabled)
    {
        for(int i = 0; i < Constants.Lanterns.length; i++)
        {
            Item core = ItemList.LanternCores[i]; 
            ItemStack coreEmpty = new ItemStack(core, 1, 0);

            for(int k = 0; k < FluidList.AlcoholFluids.length; k++)
            {
                FluidStack fluid = new FluidStack(AlcoholFluids[k], 2000);
                ItemStack coreFilled = new ItemStack(core, 1, k + 1);

                FluidContainerRegistry.registerFluidContainer(fluid, coreFilled, coreEmpty);
            }
        }
    }

    FluidContainerRegistry.registerFluidContainer(new FluidStack(Plaster, 1000), new ItemStack(ItemList.Plaster), new ItemStack(TFCItems.woodenBucketEmpty));

    for(int i = 0; i < LiquidDyes.length; i++)
        FluidContainerRegistry.registerFluidContainer(new FluidStack(LiquidDyes[i], 1000), new ItemStack(ItemList.LiquidDye, 1, i), new ItemStack(TFCItems.woodenBucketEmpty));
}
项目:Cooking-with-TFC    文件:CookingPotRecipeHandler.java   
@Override
  public void loadUsageRecipes(ItemStack ingredient)
  {
for (CookingPotRecipe recipe : recipeList)
{           
    if(recipe != null)
    {
        CachedCookingPotRecipe crecipe = new CachedCookingPotRecipe(recipe);
        if(crecipe.contains(crecipe.Ingredients, ingredient))
            arecipes.add(crecipe);

        FluidStack inputFluid = recipe.getInputFluid();
        FluidStack fluidstack = FluidContainerRegistry.getFluidForFilledItem(ingredient);

        if (inputFluid != null && inputFluid.isFluidEqual(fluidstack)) 
            arecipes.add(crecipe);
    }
}
  }
项目:Cooking-with-TFC    文件:TileCookingPot.java   
public ItemStack addLiquid(ItemStack is)
{
    if(is == null || is.stackSize > 1)
        return is;

    if(FluidContainerRegistry.isFilledContainer(is))
    {
        FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(is);
        if(addLiquid(fs))
        {
            worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
            return FluidContainerRegistry.drainFluidContainer(is);
        }
    }
    else if(is.getItem() instanceof IFluidContainerItem)
    {
        FluidStack isfs = ((IFluidContainerItem) is.getItem()).getFluid(is);
        if(isfs != null && addLiquid(isfs))
        {
            ((IFluidContainerItem) is.getItem()).drain(is, is.getMaxDamage(), true);
            worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
        }
    }
    return is;
}
项目:Cooking-with-TFC    文件:Helper.java   
public static ItemStack getItemStackForFluid(FluidStack fluidStack)
{
    if (fluidStack == null)
        return null;

    ItemStack fluidContainer = null;

    for (FluidContainerRegistry.FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData())
    {
        if (data.fluid.isFluidEqual(fluidStack))
        {
            fluidContainer = data.filledContainer.copy();

            int capacity = FluidContainerRegistry.getContainerCapacity(data.fluid, data.emptyContainer);

            if (capacity == 0) 
                fluidContainer.stackSize = 0;
            else 
                fluidContainer.stackSize = fluidStack.amount / capacity;

            break;
        }
    }

    return fluidContainer;
}
项目:AdvancedRocketry    文件:TileEntityFuelingStation.java   
private boolean useBucket( int slot, ItemStack stack) {
    if(slot == 0 && FluidContainerRegistry.isFilledContainer(stack) && FuelRegistry.instance.isFuel(FuelType.LIQUID,FluidContainerRegistry.getFluidForFilledItem(stack).getFluid()) && tank.getFluidAmount() + FluidContainerRegistry.getContainerCapacity(stack) <= tank.getCapacity()) {
        ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(stack);

        if(emptyContainer != null && inventory.getStackInSlot(1) == null || (emptyContainer.isItemEqual(inventory.getStackInSlot(1)) && inventory.getStackInSlot(1).stackSize < inventory.getStackInSlot(1).getMaxStackSize())) {
            tank.fill(FluidContainerRegistry.getFluidForFilledItem(stack), true);

            if(inventory.getStackInSlot(1) == null)
                super.setInventorySlotContents(1, emptyContainer);
            else
                inventory.getStackInSlot(1).stackSize++;
            decrStackSize(0, 1);
        }
        else
            return false;
    }
    else
        return false;

    return true;
}
项目:AdvancedRocketry    文件:RendererBucket.java   
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {

    // ====================== Render item texture ======================
    FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(item);
    int color = fluidStack.getFluid().getColor();

    IIcon fluidIcon = item.getIconIndex();
    IIcon bucketIcon = Items.bucket.getIconIndex(new ItemStack(Items.bucket));
    if(type == ItemRenderType.INVENTORY) {
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        RenderItem.getInstance().renderIcon(0, 0, bucketIcon, 16, 16);

        GL11.glColor3ub((byte)((color >>> 16) & 0xFF), (byte)((color >>> 8) & 0xFF), (byte)(color & 0xFF));

        RenderItem.getInstance().renderIcon(0, 0, fluidIcon, 16, 16);
        GL11.glColor3f(1f, 1f, 1f);
    }
    else {

        ItemRenderer.renderItemIn2D(Tessellator.instance, ((IIcon)bucketIcon).getMinU(), ((IIcon)bucketIcon).getMinV(), ((IIcon)bucketIcon).getMaxU(), ((IIcon)bucketIcon).getMaxV(), ((IIcon)bucketIcon).getIconWidth(), ((IIcon)bucketIcon).getIconHeight(), 0.1f);
        GL11.glColor3ub((byte)((color >>> 16) & 0xFF), (byte)((color >>> 8) & 0xFF), (byte)(color & 0xFF));
        ItemRenderer.renderItemIn2D(Tessellator.instance, ((IIcon)fluidIcon).getMinU(), ((IIcon)fluidIcon).getMinV(), ((IIcon)fluidIcon).getMaxU(), ((IIcon)fluidIcon).getMaxV(), ((IIcon)fluidIcon).getIconWidth(), ((IIcon)fluidIcon).getIconHeight(), 0.1f);
        GL11.glColor3f(1f, 1f, 1f);
    }
}
项目:EnderIOAddons    文件:TileVoidTank.java   
@Override
protected boolean isMachineItemValidForSlot(int i, @Nullable ItemStack item) {
  if (i == 0 && item != null) {
    FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(item);
    if (fluid != null) {
      return isValidFluid(fluid);
    }
    if (item.getItem() == Items.water_bucket) {
      return true;
    }
    if (item.getItem() == Items.lava_bucket) {
      return true;
    }
    if (item.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) item.getItem()).getFluid(item) != null) {
      return isValidFluid(((IFluidContainerItem) item.getItem()).getFluid(item));
    }
    return false;
  }
  return false;
}
项目:EnderIOAddons    文件:TileNiard.java   
@Override
protected boolean isMachineItemValidForSlot(int i, @Nullable ItemStack item) {
  if (i == 0 && item != null) {
    FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(item);
    if (fluid != null) {
      return isValidFluid(fluid);
    }
    if (item.getItem() == Items.water_bucket) {
      return true;
    }
    if (item.getItem() == Items.lava_bucket) {
      return true;
    }
    if (item.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) item.getItem()).getFluid(item) != null) {
      return isValidFluid(((IFluidContainerItem) item.getItem()).getFluid(item));
    }
    return false;
  }
  return false;
}
项目:NEI-Integration    文件:RecipeHandlerFluidRegistry.java   
@Override
public void loadCraftingRecipes(ItemStack result) {
    if (Utils.isFluidBlock(result)) {
        super.loadCraftingRecipes(result);
    }
    if (Config.handlerFluidRegistry) {
        for (Fluid fluid : this.getFluids()) {
            CachedFluidRegistryRecipe crecipe = new CachedFluidRegistryRecipe(fluid);
            if (crecipe.filledContainer != null && crecipe.filledContainer.contains(result)) {
                crecipe.setPermutation(crecipe.filledContainer, result);
                for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) {
                    if (Utils.areStacksSameTypeCraftingSafe(data.filledContainer, result)) {
                        crecipe.setPermutation(crecipe.emptyContainer, data.emptyContainer);
                    }
                }
                this.arecipes.add(crecipe);
            }
        }
    }
}
项目:NEI-Integration    文件:RecipeHandlerFluidRegistry.java   
@Override
public void loadUsageRecipes(ItemStack ingredient) {
    super.loadUsageRecipes(ingredient);
    if (Config.handlerFluidRegistry) {
        for (Fluid fluid : this.getFluids()) {
            CachedFluidRegistryRecipe crecipe = new CachedFluidRegistryRecipe(fluid);
            if (crecipe.emptyContainer != null && crecipe.emptyContainer.contains(ingredient)) {
                crecipe.setPermutation(crecipe.emptyContainer, ingredient);
                for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) {
                    if (Utils.areStacksSameTypeCraftingSafe(data.emptyContainer, ingredient)) {
                        crecipe.setPermutation(crecipe.filledContainer, data.filledContainer);
                    }
                }
                this.arecipes.add(crecipe);
            }
        }
    }
}
项目:ZeroQuest    文件:ModLiquids.java   
public static void load(){
 fluidAcid = new AcidFluid("acid").setBlock(acidBlock);
 registerFluid(fluidAcid);
 fluidNili = new NiliFluid("nili").setBlock(niliBlock);
 registerFluid(fluidNili);

 acidBlock = new BlockFluidAcid(fluidAcid, Material.lava).setBlockName("acid");
 registerBlock(acidBlock, "acid");
 niliBlock = new BlockFluidNili(fluidNili, Material.water).setBlockName("nili");
 registerBlock(niliBlock, "nili");

    acidBucket = new ItemAcidBucket(acidBlock).setUnlocalizedName("acidBucket").setContainerItem(Items.bucket).setTextureName(ZeroQuest.modid + ":" + "acidBucket");
    registerItem(acidBucket, "acid_Bucket"); 
    niliBucket = new ItemNiliBucket(niliBlock).setUnlocalizedName("niliBucket").setContainerItem(Items.bucket).setTextureName(ZeroQuest.modid + ":" + "niliBucket");
    registerItem(niliBucket, "nili_Bucket");

    registerFluidContainer(FluidRegistry.getFluidStack(fluidAcid.getName(), FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(acidBucket), new ItemStack(Items.bucket));
    registerFluidContainer(FluidRegistry.getFluidStack(fluidNili.getName(), FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(niliBucket), new ItemStack(Items.bucket));

    putLiquidsInBuckets(acidBlock, acidBucket);
    putLiquidsInBuckets(niliBlock, niliBucket);
 MinecraftForge.EVENT_BUS.register(BucketHandler.INSTANCE);
}
项目:ZeroQuest    文件:ModLiquids.java   
public static void load() {
    fluidAcid = new AcidFluid("acid").setBlock(acidBlock);
    Registers.addFluid(fluidAcid);
    fluidNili = new NiliFluid("nili").setBlock(niliBlock);
    Registers.addFluid(fluidNili);

    acidBlock = new BlockFluidAcid(fluidAcid, Material.lava).setUnlocalizedName("acid");
    Registers.addBlockWithClass(acidBlock, null, "acid");
    niliBlock = new BlockFluidNili(fluidNili, Material.water).setUnlocalizedName("nili");
    Registers.addBlockWithClass(niliBlock, null, "nili");

    acidBucket = new ItemAcidBucket(acidBlock).setUnlocalizedName("acidBucket").setContainerItem(Items.bucket);
    Registers.addItem(acidBucket, "acid_bucket");
    niliBucket = new ItemNiliBucket(niliBlock).setUnlocalizedName("niliBucket").setContainerItem(Items.bucket);
    Registers.addItem(niliBucket, "nili_bucket");

    Registers.addFluidContainer(FluidRegistry.getFluidStack(fluidAcid.getName(), FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(acidBucket), new ItemStack(Items.bucket));
    Registers.addFluidContainer(FluidRegistry.getFluidStack(fluidNili.getName(), FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(niliBucket), new ItemStack(Items.bucket));

    Registers.putLiquidsInBuckets(acidBlock, acidBucket);
    Registers.putLiquidsInBuckets(niliBlock, niliBucket);
    Registers.addForgeEventBus(BucketHandler.INSTANCE);
}
项目:AdventureBackpack2    文件:ModFluids.java   
public static void init()
{
    milk = new FluidMilk();
    melonJuice = new FluidMelonJuice();
    mushroomStew = new FluidMushroomStew();

    FluidRegistry.registerFluid(milk);
    FluidContainerRegistry.registerFluidContainer(milk, new ItemStack(Items.milk_bucket), FluidContainerRegistry.EMPTY_BUCKET);

    FluidRegistry.registerFluid(melonJuice);
    FluidContainerRegistry.registerFluidContainer(melonJuice, new ItemStack(ModItems.melonJuiceBottle), FluidContainerRegistry.EMPTY_BOTTLE);

    FluidRegistry.registerFluid(mushroomStew);
    FluidContainerRegistry.registerFluidContainer(mushroomStew, new ItemStack(Items.mushroom_stew), new ItemStack(Items.bowl));

    GeneralReference.init();
}
项目:AdventureBackpack2    文件:InventoryCopterPack.java   
@Override
public void setInventorySlotContents(int slot, ItemStack stack)
{
    inventory[slot] = stack;
    if (stack != null && stack.stackSize > getInventoryStackLimit())
    {
        stack.stackSize = getInventoryStackLimit();
    }
    if(FluidContainerRegistry.isFilledContainer(stack) && GeneralReference.isValidFuel(FluidContainerRegistry.getFluidForFilledItem(stack).getFluid()))
    {
        InventoryActions.transferContainerTank(this, fuelTank, 0);
    }else
    if(FluidContainerRegistry.isEmptyContainer(stack) && fuelTank.getFluid()!=null && FluidUtils.isContainerForFluid(stack, fuelTank.getFluid().getFluid()))
    {
        InventoryActions.transferContainerTank(this, fuelTank, 0);
    }
    dirtyTanks();
    dirtyInventory();
}
项目:AdventureBackpack2    文件:InventorySteamJetpack.java   
public void onInventoryChanged()
{
    for (int i = 0; i < inventory.length; i++)
    {
        if (i == 0)
        {
            ItemStack container = getStackInSlot(i);
            if(FluidContainerRegistry.isFilledContainer(container) && FluidUtils.isContainerForFluid(container, FluidRegistry.WATER))
            {
                InventoryActions.transferContainerTank(this, waterTank, i);
            }else
            if(FluidContainerRegistry.isEmptyContainer(container) && waterTank.getFluid()!=null && FluidUtils.isContainerForFluid(container, FluidRegistry.WATER))
            {
                InventoryActions.transferContainerTank(this, waterTank, i);
            }
        }
    }
    markDirty();
}
项目:AdventureBackpack2    文件:FluidUtils.java   
public static boolean isContainerForFluid(ItemStack container, Fluid fluid)
{
    if(container != null && fluid != null)
    {
        for (FluidContainerRegistry.FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData())
        {
            if (
                    (data.fluid.getFluid().getID() == fluid.getID()) &&
                            (data.emptyContainer.getItem().equals(container.getItem()) || data.filledContainer.getItem().equals(container.getItem()))
                    )
            {
                return true;
            }
        }
    }
    return false;
}
项目:AdventureBackpack2    文件:FluidUtils.java   
public static boolean isEmptyContainerForFluid(ItemStack container, Fluid fluid)
{
    if (container != null && fluid != null)
    {
        for (FluidContainerRegistry.FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData())
        {
            if (
                    (data.fluid.getFluid().getID() == fluid.getID()) &&
                            (data.emptyContainer.getItem().equals(container.getItem()))
                    )
            {
                return true;
            }
        }
    }
    return false;
}
项目:LanternsTFC    文件:Recipes.java   
private static void registerFluidContainers()
{
    for(int i = 0; i < Constants.Lanterns.length; i++)
    {
        Item shell = ItemList.LanternShells[i]; 
        ItemStack shellEmpty = new ItemStack(shell, 1, 0);

        for(int k = 0; k < FluidList.AlcoholFluids.length; k++)
        {
            FluidStack fluid = new FluidStack(FluidList.AlcoholFluids[k], 2000);
            ItemStack shellFilled = new ItemStack(shell, 1, k + 1);

            FluidContainerRegistry.registerFluidContainer(fluid, shellFilled, shellEmpty);
        }
    }
}
项目:AdvancedUtilities    文件:TileEntitySteamCrusher.java   
public boolean canCrush()
{
    if(this.tank.getFluidAmount() >= (FluidContainerRegistry.BUCKET_VOLUME/2)+this.costMod && inventory.length > 0)
    {
        if(inventory[0]!=null && CrushRecipes.getCrushResult(inventory[0])!=null)
        {
            if(inventory[1]== null)
                return true;
            ItemStack temp = CrushRecipes.getCrushResult(inventory[0]);

            if(inventory[1].isItemEqual(temp) && inventory[1].stackSize + temp.stackSize <= 64)
            {
                return true;
            }

        }
    }
    return false;
}
项目:A-Cup-of-Java    文件:ModItems.java   
public static void init()
{
    GameRegistry.registerItem(ItemCoffeeSeeds, Names.COFFEE_SEEDS);
    GameRegistry.registerItem(ItemCoffeeBeansDried, Names.DRIED_COFFEE);
    GameRegistry.registerItem(ItemCoffeePowder, Names.COFFEE_POWDER);
    GameRegistry.registerItem(ItemCoffeeCrusher, Names.COFFEE_CRUSHER);
    GameRegistry.registerItem(ItemCoffeeBucket, Names.COFFEE_BUCKET);
    GameRegistry.registerItem(ItemStoneBowl, Names.STONE_BOWL);
    GameRegistry.registerItem(ItemCoffeeMug, Names.COFFEE_MUG);
    GameRegistry.registerItem(ItemCoffeeFilter, Names.COFFEE_FILTER);

    GameRegistry.registerItem(BeverageBlackCoffee, Names.BLACK_COFFEE);
    GameRegistry.registerItem(BeverageSugarCoffee, Names.SUGAR_COFFEE);

    FluidContainerRegistry.registerFluidContainer(ModFluids.LiquidCoffee, new ItemStack(ItemCoffeeBucket), new ItemStack(Items.bucket));
}