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

项目:NewHorizonsCoreMod    文件:ItemInHandInfoCommand.java   
private String getFluidContainerContents(ItemStack pItemInQuestion)
{
    String tResult = "No fluid container";

    if (pItemInQuestion.getItem() instanceof IFluidContainerItem)
    {
        IFluidContainerItem tFluidContainer = IFluidContainerItem.class.cast(pItemInQuestion.getItem());
        FluidStack tContents = tFluidContainer.getFluid(pItemInQuestion);
        if (tContents != null)
        {
            tResult = String.format("FluidID: [%d], UnlocName: [%s], Name: [%s]", tContents.getFluid().getID(), tContents.getFluid().getUnlocalizedName(), tContents.getFluid().getName()); 
        }
    }

    return tResult;
}
项目: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;
}
项目: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;
}
项目:vsminecraft    文件:FluidContainerUtils.java   
public static FluidStack extractFluid(int needed, ItemStack container, Fluid fluid)
{
    IFluidContainerItem item = (IFluidContainerItem)container.getItem();

    if(item.getFluid(container) == null)
    {
        return null;
    }

    if(fluid != null && item.getFluid(container).getFluid() != fluid)
    {
        return null;
    }

    return item.drain(container, needed, true);
}
项目: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;
}
项目:Yamcl    文件:FluidHelper.java   
/**
 * Get the fluidStack of given itemStack, if there is any.
 * returns null if itemstack is null or not a fluid container
 * 
 * @param pItemStack
 * @return
 */
public static FluidStack getFluidStackFromContainer( ItemStack pItemStack )
{
  FluidStack tReturnVal = null;

  if( (Object) pItemStack.getItem() instanceof IFluidContainerItem )
  {
    IFluidContainerItem tFluidContainer = IFluidContainerItem.class.cast( pItemStack.getItem() );
    FluidStack tContents = tFluidContainer.getFluid( pItemStack );
    if( tContents != null )
    {
      tReturnVal = tContents;
    }
  }

  return tReturnVal;
}
项目: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;
}
项目:Extra-Food    文件:FluidContainerRegistryHelper.java   
public static int getContainerCapacity(FluidStack fluidStack, ItemStack stackInSlot) {
    if (specialCases.containsKey(stackInSlot.getItem())) {
        ArrayList<IFluidContainerItem> iFluidContainerItems = specialCases.get(stackInSlot.getItem());
        int result = 0;
        for (IFluidContainerItem iFluidContainerItem : iFluidContainerItems) {
            result = Math.max(iFluidContainerItem.fill(stackInSlot, fluidStack, false), result);
        }
        if (result > 0) {
            return result;
        }
    }
    if (stackInSlot.getItem() instanceof IFluidContainerItem) {
        return ((IFluidContainerItem) stackInSlot.getItem()).getCapacity(stackInSlot);
    }
    else {
        return FluidContainerRegistry.getContainerCapacity(fluidStack, stackInSlot);
    }
}
项目:ExtraCells1    文件:ECPrivatePatternInventory.java   
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
{
    if (gridTE != null)
    {
        ICraftingPattern currentPattern = Util.getAssemblerPattern(itemstack);
        if (currentPattern == null || currentPattern.getRequirements() == null)
            return false;
        if (FluidContainerRegistry.isEmptyContainer(currentPattern.getOutput()))
            return false;

        for (ItemStack entry : currentPattern.getRequirements())
        {
            if (entry != null && entry.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isFilledContainer(entry))
            {
                return doesRecipeExist((ICraftingPatternMAC) currentPattern);
            }
        }
    }
    return false;
}
项目:HeroUtils    文件:RecipeInputFluidContainer.java   
@Override
public boolean matches(ItemStack subject) {
    FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(subject);

    if (fs == null && subject.getItem() instanceof IFluidContainerItem) {
        IFluidContainerItem item = (IFluidContainerItem)subject.getItem();
        fs = item.getFluid(subject);
    }

    // match amount precisely to avoid having to deal with leftover
    return fs == null && fluid == null ||
            fs != null && fs.getFluid() == fluid && fs.amount >= amount;
}
项目:4Space-5    文件:FluidUtil.java   
/**
   * 
   * @param tank
   * @param inventory
   * @param slot
   */
  public static void tryFillContainerFuel(FluidTank tank, ItemStack[] inventory, int slot)
  {
    if (FluidUtil.isValidContainer(inventory[slot]))
{
    FluidStack liquid = tank.getFluid();

    if (liquid != null && liquid.amount > 0)
    {
        String liquidname = liquid.getFluid().getName();

        //Test for the GC fuels (though anything similarly named would also pass here)
        if (liquidname.startsWith("fuel"))
        {
            //Make sure it is the current GC fuel
            if (!liquidname.equals(GalacticraftCore.fluidFuel.getName()))
                liquid = new FluidStack(GalacticraftCore.fluidFuel, liquid.amount);

            //But match any existing fuel fluid in the container
            ItemStack stack = inventory[slot];
            //(No null check necessary here: it cannot be a null ItemStack thanks to the .isValidContainer() check above
            if (stack.getItem() instanceof IFluidContainerItem)
            {
                FluidStack existingFluid = ((IFluidContainerItem)stack.getItem()).getFluid(stack); 
                if (existingFluid != null && !existingFluid.getFluid().getName().equals(GalacticraftCore.fluidFuel.getName()))
                    liquid = new FluidStack(existingFluid, liquid.amount);
            }

            FluidUtil.tryFillContainer(tank, liquid, inventory, slot, GCItems.fuelCanister);
        }
    }
}
  }
项目:vsminecraft    文件:FluidContainerUtils.java   
public static int insertFluid(FluidStack fluid, ItemStack container)
{
    IFluidContainerItem item = (IFluidContainerItem)container.getItem();

    if(fluid == null)
    {
        return 0;
    }

    return item.fill(container, fluid, true);
}
项目:Cooking-with-TFC    文件:TileCookingPot.java   
public ItemStack removeLiquid(ItemStack is)
{
    if(is == null || is.stackSize > 1)
        return is;
    if(FluidContainerRegistry.isEmptyContainer(is))
    {
        ItemStack out = FluidContainerRegistry.fillFluidContainer(cookingPotFluid, is);
        if(out != null)
        {
            FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(out);
            cookingPotFluid.amount -= fs.amount;
            is = null;
            if(cookingPotFluid.amount <= 0)
            {
                cookingPotFluid = null;
            }
            worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
            recipeHandling();
            return out;
        }
    }
    else if(cookingPotFluid != null && is.getItem() instanceof IFluidContainerItem)
    {
        FluidStack isfs = ((IFluidContainerItem) is.getItem()).getFluid(is);
        if(isfs == null || cookingPotFluid.isFluidEqual(isfs))
        {
            cookingPotFluid.amount -= ((IFluidContainerItem) is.getItem()).fill(is, cookingPotFluid, true);
            if(cookingPotFluid.amount <= 0)
                cookingPotFluid = null;
            worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
            recipeHandling();
        }
    }
    return is;
}
项目:AdvancedRocketry    文件:TemplateNEI.java   
@Override
public void loadUsageRecipes(ItemStack ingredient) {
    for(IRecipe irecipe : RecipesMachine.getInstance().getRecipes(getMachine())) {
        CachedMachineRecipe recipe = new CachedMachineRecipe((((Recipe)irecipe).getRecipeAsAllItemsOnly()));
        boolean match = false;

        for(PositionedStack posStack : recipe.getIngredients()) {
            if(posStack.item.isItemEqual(ingredient) || ZUtils.areOresSameTypeOreDict(posStack.item, ingredient)) {
                recipe.setIngredientPermutation(recipe.ingredients, ingredient);
                arecipes.add(recipe);
                match = true;
                break;
            }
        }

        if(!match && (FluidContainerRegistry.isFilledContainer(ingredient) || ingredient.getItem() instanceof IFluidContainerItem || 
                (Block.getBlockFromItem(ingredient.getItem()) != Blocks.air && FluidRegistry.lookupFluidForBlock(Block.getBlockFromItem(ingredient.getItem())) != null  ))) {

            FluidStack fluidStack = null;

            if(ingredient.getItem() instanceof IFluidContainerItem)
                fluidStack  = ((IFluidContainerItem)ingredient.getItem()).getFluid(ingredient);
            else if(FluidContainerRegistry.isFilledContainer(ingredient) && FluidContainerRegistry.isFilledContainer(ingredient))
                fluidStack = FluidContainerRegistry.getFluidForFilledItem(ingredient);

            for(FluidStack stack : ((Recipe)irecipe).getFluidIngredients() ) {
                if((fluidStack != null && fluidStack.getFluid() == stack.getFluid()) ||
                        (Block.getBlockFromItem(ingredient.getItem()) != Blocks.air && FluidRegistry.lookupFluidForBlock(Block.getBlockFromItem(ingredient.getItem())) == stack.getFluid() )) {
                    recipe.setIngredientPermutation(recipe.ingredients, ingredient);
                    arecipes.add(recipe);
                    break;
                }
            }
        }
    }
}
项目:OpenPeripheral-Integration    文件:BoilerFuelMetaProvider.java   
@Override
public Object getMeta(IFluidContainerItem target, ItemStack stack) {
    FluidStack fluidStack = target.getFluid(stack);
    if (fluidStack != null && fluidStack.amount > 0) {
        int heatPerBucket = FuelManager.getBoilerFuelValue(fluidStack.getFluid());
        if (heatPerBucket > 0) {
            Map<String, Number> result = Maps.newHashMap();
            result.put("total", heatPerBucket / 1000.0f * fluidStack.amount);
            result.put("per_bucket", heatPerBucket);
            return result;
        }
    }

    return null;
}
项目:OpenPeripheral-Integration    文件:FluidContainerMetaProvider.java   
@Override
public Object getMeta(IFluidContainerItem target, ItemStack stack) {
    Map<String, Object> map = Maps.newHashMap();
    map.put("contents", target.getFluid(stack));
    map.put("capacity", target.getCapacity(stack));
    return map;
}
项目:NEI-Integration    文件:Utils.java   
public static FluidStack getFluidStack(ItemStack stack) {
    if (stack != null) {
        FluidStack fluidStack = null;
        Block block = Block.getBlockFromItem(stack.getItem());

        if (stack.getItem() instanceof IFluidContainerItem) {
            fluidStack = ((IFluidContainerItem) stack.getItem()).getFluid(stack);
        }
        if (fluidStack == null) {
            fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack);
        }
        if (fluidStack == null && block instanceof IFluidBlock) {
            Fluid fluid = ((IFluidBlock) block).getFluid();
            if (fluid != null) {
                fluidStack = new FluidStack(fluid, 1000);
            }
        }
        if (fluidStack == null && (block == Blocks.water || block == Blocks.flowing_water)) {
            fluidStack = new FluidStack(FluidRegistry.WATER, 1000);
        }
        if (fluidStack == null && (block == Blocks.lava || block == Blocks.flowing_lava)) {
            fluidStack = new FluidStack(FluidRegistry.LAVA, 1000);
        }

        return fluidStack;
    }
    return null;
}
项目:FlowstoneEnergy    文件:TileEntityFluidPipe.java   
@Override
public boolean isValidInventory(BlockPos pos) {
    if (worldObj.getTileEntity(pos) != null) {
        return worldObj.getTileEntity(pos) instanceof IFluidHandler || worldObj.getTileEntity(pos) instanceof IFluidTank
                || worldObj.getTileEntity(pos) instanceof IFluidBlock || worldObj.getTileEntity(pos) instanceof IFluidContainerItem;
    } else {
        return false;
    }
}
项目:Extra-Food    文件:BucketEdible.java   
public BucketEdible(int foodBar, float saturation, Block fluidBlock, String localName){
    super(fluidBlock);
    this.setCreativeTab(EFTabs.INSTANCE);
       this.setUnlocalizedName(localName);

    this.FoodStat = foodBar;
    this.SaturationLvl = saturation;
    this.containedBlock = fluidBlock;
    try {
        FluidContainerRegistryHelper.specialCases.get(Items.BUCKET).add(this);
    } catch (NullPointerException e) {
        FluidContainerRegistryHelper.specialCases.put(Items.BUCKET, new ArrayList<IFluidContainerItem>());
        FluidContainerRegistryHelper.specialCases.get(Items.BUCKET).add(this);
    }
}
项目:Extra-Food    文件:FluidContainerRegistryHelper.java   
public static boolean isFilledContainer(ItemStack stackInSlot) {
    if (stackInSlot.getItem() instanceof IFluidContainerItem) {
        FluidStack fluidStack = ((IFluidContainerItem) stackInSlot.getItem()).getFluid(stackInSlot);
        if (fluidStack != null) {
            return true;
        }
        else {
            return false;
        }
    }
    else {
        return FluidContainerRegistry.isFilledContainer(stackInSlot);
    }

}
项目:Extra-Food    文件:FluidContainerRegistryHelper.java   
public static FluidStack getFluidForFilledItem(ItemStack stackInSlot) {
    if (stackInSlot.getItem() instanceof IFluidContainerItem) {
        return ((IFluidContainerItem) stackInSlot.getItem()).getFluid(stackInSlot);
    }
    else {
        return FluidContainerRegistry.getFluidForFilledItem(stackInSlot);
    }
}
项目:Extra-Food    文件:FluidContainerRegistryHelper.java   
public static ItemStack drainFluidContainer(ItemStack stackInSlot) {
    if (stackInSlot.getItem() instanceof IFluidContainerItem) {
        ItemStack working = stackInSlot.copy();
        ((IFluidContainerItem) stackInSlot.getItem()).drain(working, ((IFluidContainerItem) stackInSlot.getItem()).getCapacity(stackInSlot), true);
        return working;
    }
    else {
        return FluidContainerRegistry.drainFluidContainer(stackInSlot);
    }
}
项目:Extra-Food    文件:FluidContainerRegistryHelper.java   
public static boolean isEmptyContainer(ItemStack stackInSlot) {
    if (stackInSlot.getItem() instanceof IFluidContainerItem) {
        FluidStack fluidStack = ((IFluidContainerItem) stackInSlot.getItem()).getFluid(stackInSlot);
        if (fluidStack != null) {
            return false;
        }
        else {
            return true;
        }
    }
    else {
        return FluidContainerRegistry.isEmptyContainer(stackInSlot);
    }

}
项目:R0b0ts    文件:FluidHelper.java   
public static FluidStack getFluidForFilledItem(ItemStack container) {

        if (container != null && container.getItem() instanceof IFluidContainerItem) {
            return ((IFluidContainerItem) container.getItem()).getFluid(container);
        }
        return FluidContainerRegistry.getFluidForFilledItem(container);
    }
项目:Project-Zed    文件:AbstractBlockTankBase.java   
protected boolean isEmptyComplexContainer(ItemStack item) {
    if (item == null) return false;

    if (item.getItem() instanceof IFluidContainerItem) {
        IFluidContainerItem container = (IFluidContainerItem) item.getItem();
        FluidStack containerFluid = container.getFluid(item);

        return (containerFluid == null || containerFluid.amount == 0);
    }

    return false;
}
项目:Project-Zed    文件:BlockIndustrialCentrifuge.java   
protected boolean isEmptyComplexContainer(ItemStack item) {
    if (item == null) return false;

    if (item.getItem() instanceof IFluidContainerItem) {
        IFluidContainerItem container = (IFluidContainerItem) item.getItem();
        FluidStack containerFluid = container.getFluid(item);

        return (containerFluid == null || containerFluid.amount == 0);
    }

    return false;
}
项目:SciAPI    文件:IEFluidMover.java   
@Override
public void updateEntity()
{
    if(!worldObj.isRemote && worldObj.getItemStack(pos) != null)
    {
        EVecInt dvec = McInvDirection.LEFT.toDifference();
        McInvPos cur = pos.getDiffPos(dvec);
        dvec = McInvDirection.RIGHT.toDifference();
        McInvPos next = pos.getDiffPos(dvec);

        ItemStack from = worldObj.getItemStack(cur);
        ItemStack to = worldObj.getItemStack(next);

        if(from == null || !(from.getItem() instanceof IFluidContainerItem))
            return;

        if(to == null || !(to.getItem() instanceof IFluidContainerItem))
            return;

        IFluidContainerItem fri = (IFluidContainerItem) from.getItem();
        IFluidContainerItem toi = (IFluidContainerItem) to.getItem();

        FluidStack drain = fri.drain(from, 10, false);
        if(drain == null || drain.amount == 0)
            return;
        if(toi.fill(to, drain, false) != 0)
        {
            int dr = toi.fill(to, drain, true);
            fri.drain(from, dr, true);
        }
    }
}
项目:SciAPI    文件:MultiFluidHeater.java   
/**
 * Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc.
 */
private boolean canSmelt()
{
    if (this.getFurnaceItemStack(0) == null)
    {
        return false;
    }
    else
    {
        ItemStack cur0 = this.getFurnaceItemStack(0);
        ItemStack cur = this.getFurnaceItemStack(2);
        FluidStack fluidstack = FluidHeatRecipes.heating().getHeatingResultF(cur0);
        if (fluidstack == null) return false;
        if (cur == null) return false;
        if (FluidContainerRegistry.isContainer(cur) && (FluidContainerRegistry.isEmptyContainer(cur) || FluidContainerRegistry.containsFluid(cur, fluidstack))) return true;
        if (cur0.getItem() instanceof IFluidContainerItem && cur.getItem() instanceof IFluidContainerItem)
        {
            FluidStack stack = ((IFluidContainerItem)cur0.getItem()).drain(cur0, 100, false);
            if(stack != null && stack.amount == 100)
                return true;
            return false;
        }
        else if(cur.getItem() instanceof IFluidContainerItem)
        {
            return ((IFluidContainerItem)cur.getItem()).fill(cur0, fluidstack, false) != 0;
        }
        return false;
    }
}
项目:Open-Exchange    文件:FluidUtil.java   
public static boolean storesFluid(ItemStack itemstack) {
  if (itemstack.getItem() instanceof IFluidContainerItem) {
    return true;
  }
  for (FluidContainerData f : getFluidData()) {
    if (Item.getIdFromItem(f.filledContainer.getItem()) == Item.getIdFromItem(itemstack.getItem()) && f.filledContainer.getItemDamage() == itemstack.getItemDamage()) {
      return true;
    }
  }
  return false;
}
项目:AgeCraft-Old    文件:ACUtil.java   
public static ItemStack fillFluidContainer(ItemStack stack, FluidStack fluidStack) {
    if(stack != null && stack.getItem() instanceof IFluidContainerItem) {
        ((IFluidContainerItem) stack.getItem()).fill(stack, fluidStack, true);
        return stack;
    }
    return FluidContainerRegistry.fillFluidContainer(fluidStack, stack);
}
项目:AgeCraft-Old    文件:ACUtil.java   
public static ItemStack drainFluidContainer(ItemStack stack, int amount) {
    if(stack != null && stack.getItem() instanceof IFluidContainerItem) {
        ((IFluidContainerItem) stack.getItem()).drain(stack, amount, true);
        return stack;
    }
    return ACUtil.consumeItem(stack);
}
项目:CustomWorldGen    文件:FluidContainerItemWrapper.java   
public FluidContainerItemWrapper(IFluidContainerItem handler, ItemStack container)
{
    this.handler = handler;
    this.container = container;
}
项目:NewHorizonsCoreMod    文件:OvenGlove.java   
/**
 * Check if given ItemStack is a valid lava-containing container.
 * Either the "unlocalized name" contains the word "lava"
 * - OR -
 * The item is a Tinkers-LavaTank block which contains lava
 * - OR -
 * The item is an item which implements the IFluidContainer Interface, and it actually
 * does contain lava
 * 
 * @param pHeldItem
 * @return
 */
private boolean isValidLavaContainerItem( ItemStack pHeldItem )
{
  boolean tResult = false;

  if( pHeldItem.getUnlocalizedName().toLowerCase().contains( "lava" ) ) {
    tResult = true;
  }

  if( pHeldItem.getItem() instanceof IFluidContainerItem )
  {
    FluidStack tStackFluid = FluidHelper.getFluidStackFromContainer( pHeldItem );
    if( tStackFluid != null )
    {
      if( tStackFluid.amount > 0 && "lava".equalsIgnoreCase(tStackFluid.getFluid().getName())) {
        tResult = true;
      }
    }
  }
  else if("tconstruct.smeltery.itemblocks.LavaTankItemBlock".equals(pHeldItem.getItem().getClass().getName()))
  {
    NBTTagCompound tNBT = pHeldItem.getTagCompound();
    if( tNBT != null && tNBT.hasKey( "Fluid" ) )
    {
      // _mLogger.info("...Has NBT 'Fluid'...");
      NBTTagCompound tFluidCompound = tNBT.getCompoundTag( "Fluid" );
      if( tFluidCompound != null && tFluidCompound.hasKey( "FluidName" ) )
      {
        String tFluidName = tFluidCompound.getString( "FluidName" );
        if( tFluidName != null && !tFluidName.isEmpty())
        {
          if("lava".equalsIgnoreCase(tFluidName)) {
            tResult = true;
          }
        }
      }
    }
  }

  return tResult;
}
项目:vsminecraft    文件:TileEntityChemicalWasher.java   
private void manageBuckets()
{
    if(inventory[0] != null)
    {
        if(inventory[0].getItem() instanceof IFluidContainerItem)
        {
            fluidTank.fill(FluidContainerUtils.extractFluid(fluidTank, inventory[0], FluidRegistry.WATER), true);

            if(((IFluidContainerItem)inventory[0].getItem()).getFluid(inventory[0]) == null || fluidTank.getFluidAmount() == fluidTank.getCapacity())
            {
                if(inventory[1] == null)
                {
                    inventory[1] = inventory[0].copy();
                    inventory[0] = null;

                    markDirty();
                }
            }
        }
        else if(FluidContainerRegistry.isFilledContainer(inventory[0]))
        {
            FluidStack itemFluid = FluidContainerRegistry.getFluidForFilledItem(inventory[0]);

            if((fluidTank.getFluid() == null && itemFluid.amount <= MAX_FLUID) || fluidTank.getFluid().amount+itemFluid.amount <= MAX_FLUID)
            {
                if(itemFluid.getFluid() != FluidRegistry.WATER || (fluidTank.getFluid() != null && !fluidTank.getFluid().isFluidEqual(itemFluid)))
                {
                    return;
                }

                ItemStack containerItem = inventory[0].getItem().getContainerItem(inventory[0]);

                boolean filled = false;

                if(containerItem != null)
                {
                    if(inventory[1] == null || (inventory[1].isItemEqual(containerItem) && inventory[1].stackSize+1 <= containerItem.getMaxStackSize()))
                    {
                        inventory[0] = null;

                        if(inventory[1] == null)
                        {
                            inventory[1] = containerItem;
                        }
                        else {
                            inventory[1].stackSize++;
                        }

                        filled = true;
                    }
                }
                else {
                    inventory[0].stackSize--;

                    if(inventory[0].stackSize == 0)
                    {
                        inventory[0] = null;
                    }

                    filled = true;
                }

                if(filled)
                {
                    fluidTank.fill(itemFluid, true);
                    markDirty();
                }
            }
        }
    }
}
项目:AdvancedRocketry    文件:ItemJetpack.java   
@Override
public void onAccelerate(ItemStack stack, IInventory inv, EntityPlayer player) {
    boolean hasFuel = false;

    MODES mode = getMode(stack);

    for(int i = 0; i < inv.getSizeInventory(); i++) {
        ItemStack fuelTank = inv.getStackInSlot(i);

        if(fuelTank != null && fuelTank.getItem() instanceof IFluidContainerItem) {
            FluidStack fluid = ((IFluidContainerItem)fuelTank.getItem()).drain(fuelTank, 1, false);
            if(fluid != null && fluid.getFluidID() == FluidRegistry.getFluidID(AdvancedRocketryFluids.fluidHydrogen)) {
                ((IFluidContainerItem)fuelTank.getItem()).drain(fuelTank, 1, true);
                hasFuel = true;
                break;
            }
        }

    }

    if(hasFuel) {

        if(mode == MODES.HOVER) {
            if(Configuration.jetPackThrust > DimensionManager.getInstance().getDimensionProperties(player.worldObj.provider.dimensionId).getGravitationalMultiplier())
                player.capabilities.isFlying = true;
        } else 
            player.addVelocity(0, (double)Configuration.jetPackThrust*0.1, 0);

        if(player.worldObj.isRemote) {
            double xPos = player.posX;
            double zPos = player.posZ;
            float playerRot = (float) ((Math.PI/180f)*(player.rotationYaw - 55));
            xPos = player.posX + MathHelper.cos(playerRot)*.4f;
            zPos = player.posZ + MathHelper.sin(playerRot)*.4f;

            float ejectSpeed = mode == MODES.HOVER ? 0.1f : 0.3f;
            //AdvancedRocketry.proxy.spawnParticle("smallRocketFlame", player.worldObj, xPos, player.posY - 0.75, zPos, (player.worldObj.rand.nextFloat() - 0.5f)/18f,-.1 ,(player.worldObj.rand.nextFloat() - 0.5f)/18f);

            AdvancedRocketry.proxy.spawnParticle("smallRocketFlame", player.worldObj, xPos, player.posY - 0.75, zPos, 0, player.motionY -ejectSpeed ,0);

            playerRot = (float) ((Math.PI/180f)*(player.rotationYaw - 125));
            xPos = player.posX + MathHelper.cos(playerRot)*.4f;
            zPos = player.posZ + MathHelper.sin(playerRot)*.4f;

            AdvancedRocketry.proxy.spawnParticle("smallRocketFlame", player.worldObj, xPos, player.posY - 0.75, zPos, 0, player.motionY -ejectSpeed ,0);
        }

        if(player.motionY > -1) {
            player.fallDistance = 0;
        }
    }

}
项目:FlowCraft    文件:BlockTank.java   
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
    if (!world.isRemote) {
        ItemStack equippedItemStack = player.getCurrentEquippedItem();

        if (equippedItemStack != null)
            if (equippedItemStack.getItem() instanceof IToolWrench) { // react to Buildcraft Api ToolWrench
                this.handleToolWrenchClick(world, x, y, z, player, equippedItemStack);
                return true;
            } else {
                TileEntityTank tileTank = (TileEntityTank) world.getBlockTileEntity(x, y, z);
                if (tileTank != null)
                    if (equippedItemStack.getItem().itemID == Item.bucketLava.itemID) { // Lava Bucket
                        FluidStack fluidstack = new FluidStack(FluidRegistry.LAVA, 1000);
                        if (tileTank.fill(null, fluidstack, false) == 1000) {
                            tileTank.fill(null, fluidstack, true);

                            if (!player.capabilities.isCreativeMode)
                                player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Item.bucketEmpty, 1));
                            // FlowCraft.log("onBlcokActivated", "tankFilledEvent", world);
                        }
                    } else if (equippedItemStack.getItem().itemID == Item.bucketEmpty.itemID) { // Empty Bucket

                        FluidStack drained = tileTank.drain(ForgeDirection.DOWN, 1000, false);

                        if (drained != null && drained.amount >= 1000) {

                            tileTank.drain(ForgeDirection.DOWN, 1000, true);
                            player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Item.bucketLava, 1));
                        }
                    } else if (equippedItemStack.getItem() instanceof IFluidContainerItem) { // IFluidContainer

                        NBTTagCompound tag = equippedItemStack.getTagCompound();

                        if (tag != null && tag.hasKey("Fluid")) {
                            tag = tag.getCompoundTag("Fluid");
                            // Just drain the container as much as the tank can fit;
                            ((IFluidContainerItem) equippedItemStack.getItem()).drain(  equippedItemStack,
                                                                                        tileTank.fill(  ForgeDirection.UP,
                                                                                                        FluidStack.loadFluidStackFromNBT(tag),
                                                                                                        true),
                                                                                        true);
                        } else {
                            NBTTagCompound fluidTag = new NBTTagCompound();
                            IFluidContainerItem item = ((IFluidContainerItem) equippedItemStack.getItem());
                            if (item.getCapacity(equippedItemStack) <= tileTank.getFluidAmount())
                                item.fill(equippedItemStack, tileTank.drain(ForgeDirection.DOWN, item.getCapacity(equippedItemStack), true), true);

                        }
                    }

                return false;
            }
        return false;
    }
    return true;
}
项目:SciAPI    文件:IEFluidFiller.java   
@Override
public void updateEntity()
{
    if(!worldObj.isRemote && worldObj.getItemStack(pos) != null)
    {
        EVecInt dvec = McInvDirection.LEFT.toDifference();
        McInvPos cur = pos.getDiffPos(dvec);
        dvec = McInvDirection.RIGHT.toDifference();
        McInvPos next = pos.getDiffPos(dvec);
        dvec = McInvDirection.UP.toDifference();
        McInvPos fr = pos.getDiffPos(dvec);

        ItemStack frup = worldObj.getItemStack(fr);
        ItemStack from = worldObj.getItemStack(cur);
        ItemStack post = worldObj.getItemStack(next);

        if(frup == null || !(frup.getItem() instanceof IFluidContainerItem))
            return;

        if(from == null || !FluidContainerRegistry.isEmptyContainer(from))
            return;

        IFluidContainerItem con = (IFluidContainerItem) frup.getItem();
        ItemStack copy = from.copy();
        ItemStack res = FluidContainerRegistry.fillFluidContainer(con.drain(frup, Integer.MAX_VALUE, false), copy);

        if(res == null)
            return;

        if(post != null)
        {
            if(!post.isItemEqual(res))
                return;
            int max = post.getMaxStackSize();
            if((res.stackSize + post.stackSize) > max)
                return;
        }

        delay++;
        worldObj.getItemStack(pos).setItemDamage(100-delay);

        if(delay >= 100)
        {
            delay = 0;

            FluidStack filled = FluidContainerRegistry.getFluidForFilledItem(res);

            if(from.stackSize <= 1)
                worldObj.setItemStack(cur, null);
            else from.stackSize--;

            if(post == null)
                worldObj.setItemStack(next, res);
            else post.stackSize += res.stackSize;

            con.drain(frup, filled.amount, true);
        }
    }
}
项目:SciAPI    文件:IEFluidDrain.java   
@Override
public void updateEntity()
{
    if(!worldObj.isRemote && worldObj.getItemStack(pos) != null)
    {
        EVecInt dvec = McInvDirection.LEFT.toDifference();
        McInvPos cur = pos.getDiffPos(dvec);
        dvec = McInvDirection.RIGHT.toDifference();
        McInvPos next = pos.getDiffPos(dvec);
        dvec = McInvDirection.DOWN.toDifference();
        McInvPos fr = pos.getDiffPos(dvec);

        ItemStack frup = worldObj.getItemStack(fr);
        ItemStack from = worldObj.getItemStack(cur);
        ItemStack post = worldObj.getItemStack(next);

        if(frup == null || !(frup.getItem() instanceof IFluidContainerItem))
            return;

        if(from == null || !FluidContainerRegistry.isFilledContainer(from))
            return;

        IFluidContainerItem con = (IFluidContainerItem) frup.getItem();

        FluidStack in = FluidContainerRegistry.getFluidForFilledItem(from);
        int res = con.fill(frup, in, false);

        if(res != in.amount)
            return;

        ItemStack result = from.getItem().getContainerItem(from);

        if(post != null)
        {
            if(!post.isItemEqual(result))
                return;
            int max = post.getMaxStackSize();
            if((result.stackSize + post.stackSize) > max)
                return;
        }

        delay++;
        worldObj.getItemStack(pos).setItemDamage(100-delay);

        if(delay >= 100)
        {
            delay = 0;

            if(from.stackSize <= 1)
                worldObj.setItemStack(cur, null);
            else from.stackSize--;

            if(result == null)
                return;
            if(post == null)
                worldObj.setItemStack(next, result);
            else post.stackSize += result.stackSize;

            con.fill(frup, in, true);
        }
    }
}
项目:SciAPI    文件:MultiFluidHeater.java   
/**
 * Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack
 */
public void smeltItem()
{
    if (this.canSmelt())
    {           
        FluidStack res = FluidHeatRecipes.heating().getHeatingResultF(this.getFurnaceItemStack(0));
        FluidStack copy = res.copy();

        ItemStack istack;
        Item item;

        ItemStack filled = FluidContainerRegistry.fillFluidContainer(copy, this.getFurnaceItemStack(2));
        if(filled != null)
        {
            this.setFurnaceItemStack(2, filled);
            istack = this.getFurnaceItemStack(0);
            item = istack.getItem();
            this.setFurnaceItemStack(0, item.getContainerItem(istack));
            return;
        }

        if(this.getFurnaceItemStack(2).getItem() instanceof IFluidContainerItem)
        {
            int filledam = ((IFluidContainerItem) this.getFurnaceItemStack(2).getItem())
                    .fill(this.getFurnaceItemStack(2), copy, true);
            if(filledam > 0)
            {
                istack = this.getFurnaceItemStack(0);
                item = istack.getItem();
                if(item instanceof IFluidContainerItem)
                    ((IFluidContainerItem) item).drain(istack, 100, true);
                else
                {
                    if(istack.stackSize == 1)
                        this.setFurnaceItemStack(0, item.getContainerItem(istack));
                    else istack.stackSize--;
                }
            }
        }
    }
}