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