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


Java IFluidTankProperties.canDrain方法代码示例

本文整理汇总了Java中net.minecraftforge.fluids.capability.IFluidTankProperties.canDrain方法的典型用法代码示例。如果您正苦于以下问题:Java IFluidTankProperties.canDrain方法的具体用法?Java IFluidTankProperties.canDrain怎么用?Java IFluidTankProperties.canDrain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.fluids.capability.IFluidTankProperties的用法示例。


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

示例1: isValidInContainer

import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入方法依赖的package包/类
private boolean isValidInContainer(ItemStack stack) {
    if (!ItemStackUtil.isEmpty(stack)) {
        if (stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
            IFluidHandlerItem handler = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
            if (handler != null) {
                IFluidTankProperties[] tanks = handler.getTankProperties();
                if ((tanks != null) && (tanks.length > 0)) {
                    for(IFluidTankProperties tank: tanks) {
                        if (tank.canDrain()) {
                            FluidStack content = tank.getContents();
                            if ((content != null) && (content.amount > 0) && (content.getFluid() == FluidsRegistry.liquidXP)) {
                                return true;
                            }
                        }
                    }
                }
            }
        }
    }
    return false;
}
 
开发者ID:faceofcat,项目名称:Mekfarm,代码行数:22,代码来源:LiquidXPStorageEntity.java

示例2: onItemRightClick

import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World worldIn, EntityPlayer playerIn, EnumHand hand) {
	init(stack);
	if (getFluidStored(stack) >= FLUID_CAPACITY) {
		return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
	}
	RayTraceResult ray = rayTrace(worldIn, playerIn, true);
	if (ray == null || ray.typeOfHit == null || hand == null) {
		return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
	}
	if (ray.typeOfHit == RayTraceResult.Type.BLOCK && hand == EnumHand.MAIN_HAND && !worldIn.isRemote) {
		BlockPos blockpos = ray.getBlockPos();
		IBlockState iblockstate = worldIn.getBlockState(blockpos);
		Material material = iblockstate.getMaterial();

		if (material == Material.WATER && iblockstate.getValue(BlockLiquid.LEVEL).intValue() == 0) {
			worldIn.setBlockState(blockpos, Blocks.AIR.getDefaultState(), 11);
			playerIn.addStat(StatList.getObjectUseStats(this));
			playerIn.playSound(SoundEvents.ITEM_BUCKET_FILL, 1.0F, 1.0F);
			addFluid(stack, 1000);
			return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
		}
		else if (iblockstate.getBlock().hasTileEntity(iblockstate) && worldIn.getTileEntity(blockpos).hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, ray.sideHit)) {
			IFluidHandler fluidHandler = worldIn.getTileEntity(blockpos).getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, ray.sideHit);
			for (IFluidTankProperties property : fluidHandler.getTankProperties()) {
				if (property.getContents().getFluid() == FluidRegistry.WATER && property.getContents().amount >= 1000 && property.canDrain()) {
					fluidHandler.drain(new FluidStack(FluidRegistry.WATER, 1000), true);
					addFluid(stack, 1000);
				}
			}
		}

	}
	return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
}
 
开发者ID:p455w0rd,项目名称:ToughExpansion,代码行数:36,代码来源:ItemThirstQuencher.java


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