当前位置: 首页>>代码示例>>Java>>正文


Java IFluidContainerItem类代码示例

本文整理汇总了Java中net.minecraftforge.fluids.IFluidContainerItem的典型用法代码示例。如果您正苦于以下问题:Java IFluidContainerItem类的具体用法?Java IFluidContainerItem怎么用?Java IFluidContainerItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IFluidContainerItem类属于net.minecraftforge.fluids包,在下文中一共展示了IFluidContainerItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFluidContainerContents

import net.minecraftforge.fluids.IFluidContainerItem; //导入依赖的package包/类
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;
}
 
开发者ID:GTNewHorizons,项目名称:NewHorizonsCoreMod,代码行数:17,代码来源:ItemInHandInfoCommand.java

示例2: getFluidFromItem

import net.minecraftforge.fluids.IFluidContainerItem; //导入依赖的package包/类
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;
}
 
开发者ID:SleepyTrousers,项目名称:EnderCore,代码行数:20,代码来源:FluidUtil.java

示例3: isItemFuel

import net.minecraftforge.fluids.IFluidContainerItem; //导入依赖的package包/类
@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;
}
 
开发者ID:katzenpapst,项目名称:amunra,代码行数:20,代码来源:TileEntityMothershipEngineJet.java

示例4: extractFluid

import net.minecraftforge.fluids.IFluidContainerItem; //导入依赖的package包/类
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);
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:17,代码来源:FluidContainerUtils.java

示例5: addLiquid

import net.minecraftforge.fluids.IFluidContainerItem; //导入依赖的package包/类
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;
}
 
开发者ID:StrayWolfe,项目名称:Cooking-with-TFC,代码行数:26,代码来源:TileCookingPot.java

示例6: getFluidStackFromContainer

import net.minecraftforge.fluids.IFluidContainerItem; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:GTNewHorizons,项目名称:Yamcl,代码行数:24,代码来源:FluidHelper.java

示例7: isMachineItemValidForSlot

import net.minecraftforge.fluids.IFluidContainerItem; //导入依赖的package包/类
@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;
}
 
开发者ID:HenryLoenwind,项目名称:EnderIOAddons,代码行数:21,代码来源:TileVoidTank.java

示例8: getContainerCapacity

import net.minecraftforge.fluids.IFluidContainerItem; //导入依赖的package包/类
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);
    }
}
 
开发者ID:TeamDmfMM,项目名称:Extra-Food,代码行数:19,代码来源:FluidContainerRegistryHelper.java

示例9: isItemValidForSlot

import net.minecraftforge.fluids.IFluidContainerItem; //导入依赖的package包/类
@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;
}
 
开发者ID:ExtraCells,项目名称:ExtraCells1,代码行数:22,代码来源:ECPrivatePatternInventory.java

示例10: matches

import net.minecraftforge.fluids.IFluidContainerItem; //导入依赖的package包/类
@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;
}
 
开发者ID:Herobone,项目名称:HeroUtils,代码行数:14,代码来源:RecipeInputFluidContainer.java

示例11: tryFillContainerFuel

import net.minecraftforge.fluids.IFluidContainerItem; //导入依赖的package包/类
/**
   * 
   * @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);
		}
	}
}
  }
 
开发者ID:4Space,项目名称:4Space-5,代码行数:39,代码来源:FluidUtil.java

示例12: insertFluid

import net.minecraftforge.fluids.IFluidContainerItem; //导入依赖的package包/类
public static int insertFluid(FluidStack fluid, ItemStack container)
{
	IFluidContainerItem item = (IFluidContainerItem)container.getItem();
	
	if(fluid == null)
	{
		return 0;
	}
	
	return item.fill(container, fluid, true);
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:12,代码来源:FluidContainerUtils.java

示例13: removeLiquid

import net.minecraftforge.fluids.IFluidContainerItem; //导入依赖的package包/类
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;
}
 
开发者ID:StrayWolfe,项目名称:Cooking-with-TFC,代码行数:36,代码来源:TileCookingPot.java

示例14: loadUsageRecipes

import net.minecraftforge.fluids.IFluidContainerItem; //导入依赖的package包/类
@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;
				}
			}
		}
	}
}
 
开发者ID:zmaster587,项目名称:AdvancedRocketry,代码行数:37,代码来源:TemplateNEI.java

示例15: getMeta

import net.minecraftforge.fluids.IFluidContainerItem; //导入依赖的package包/类
@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;
}
 
开发者ID:OpenMods,项目名称:OpenPeripheral-Integration,代码行数:16,代码来源:BoilerFuelMetaProvider.java


注:本文中的net.minecraftforge.fluids.IFluidContainerItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。