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


Java FluidUtil.tryFillContainer方法代码示例

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


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

示例1: onBlockActivated

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	ItemStack original = player.getHeldItem(hand);
	if (!original.isEmpty()) {
		ItemStack stack = original.copy();
		stack.setCount(1);
		TileEntity tank = getTileEntity(world, pos);
		if (tank instanceof TileEntityBTank) {
			IFluidHandler handler = ((TileEntityBTank) tank).getFluidHandler();
			FluidActionResult result = FluidUtil.tryEmptyContainer(stack, handler, Fluid.BUCKET_VOLUME, player, true);
			if (!result.success) {
				result = FluidUtil.tryFillContainer(stack, handler, Fluid.BUCKET_VOLUME, player, true);
			}
			if (result.success) {
				original.setCount(original.getCount() - 1);
				stack = InvUtil.putStackInInventory(result.result, player.inventory, true, false, false, null);
				if (!stack.isEmpty()) {
					WorldUtil.dropItemsRandom(world, stack, player.getPosition());
				}
				return true;
			}
		}
	}
	return super.onBlockActivated(world, pos, state, player, hand, facing, hitX, hitY, hitZ);
}
 
开发者ID:Aroma1997,项目名称:BetterChests,代码行数:26,代码来源:BlockBTank.java

示例2: tryFluidExtraction

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
/**
 * Attempt to extract fluid from the given fluid handler into the given fluid-containing item.
 *
 * @param srcHandler fluid handler into which to place the fluid
 * @param destStack the fluid container item to extract from
 * @param returnedItems the modified fluid container after extraction
 * @return true if any fluid was moved, false otherwise
 */
public static boolean tryFluidExtraction(IFluidHandler srcHandler, ItemStack destStack, NonNullList<ItemStack> returnedItems) {
    FluidActionResult result = FluidUtil.tryFillContainer(destStack, srcHandler, 1000, null, true);
    if (result.isSuccess()) {
        returnedItems.add(result.getResult());
        destStack.shrink(1);
        return true;
    } else {
        return false;
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:19,代码来源:FluidUtils.java

示例3: tryEmptyOrFillContainer

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
public static FluidActionResult tryEmptyOrFillContainer(ItemStack stack, IFluidHandler handler, int maxTransfer, EntityPlayer player) {
	FluidActionResult result = FluidUtil.tryEmptyContainer(stack, handler, maxTransfer, player, true);
	if (result.success) {
		return result;
	} else {
		FluidActionResult resultFill = FluidUtil.tryFillContainer(stack, handler, maxTransfer, player, true);
		return resultFill;
	}
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:10,代码来源:FluidTransport.java


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