本文整理匯總了Java中net.minecraftforge.fluids.FluidTank.setCanDrain方法的典型用法代碼示例。如果您正苦於以下問題:Java FluidTank.setCanDrain方法的具體用法?Java FluidTank.setCanDrain怎麽用?Java FluidTank.setCanDrain使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.fluids.FluidTank
的用法示例。
在下文中一共展示了FluidTank.setCanDrain方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onBlockActivated
import net.minecraftforge.fluids.FluidTank; //導入方法依賴的package包/類
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if(!worldIn.isRemote) {
TileEntity te = worldIn.getTileEntity(pos);
if(te != null && te instanceof TileFluidTank) {
ItemStack activeHand = playerIn.getHeldItem(hand);
if(!activeHand.isEmpty() && FluidUtil.getFluidHandler(activeHand) != null) {
FluidTank ft = ((TileFluidTank) te).getTank();
boolean canFillPrev = ft.canFill();
boolean canDrainPrev = ft.canDrain();
ft.setCanFill(true);
ft.setCanDrain(true);
try {
FluidUtil.interactWithFluidHandler(playerIn, hand, ft);
} finally {
ft.setCanFill(canFillPrev);
ft.setCanDrain(canDrainPrev);
}
return true;
}
playerIn.openGui(ModularMachinery.MODID, CommonProxy.GuiType.TANK_INVENTORY.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ());
}
}
return true;
}
示例2: getFluidHandlerFromTank
import net.minecraftforge.fluids.FluidTank; //導入方法依賴的package包/類
public static IFluidHandler getFluidHandlerFromTank(FluidTank tank, Fluid fluid, boolean canFill, boolean canDrain) {
tank.setCanFill(canFill);
tank.setCanDrain(canDrain);
FluidHandlerFluidMap m = new FluidHandlerFluidMap();
m.addHandler(fluid, tank);
return m;
}