本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
示例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);
}
示例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;
}
示例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;
}
}
}
}
}
示例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;
}