List of usage examples for net.minecraftforge.fluids FluidUtil interactWithFluidHandler
public static boolean interactWithFluidHandler(@Nonnull PlayerEntity player, @Nonnull Hand hand, @Nonnull World world, @Nonnull BlockPos pos, @Nullable Direction side)
From source file:com.lothrazar.cyclicmagic.block.anvilmagma.BlockAnvilMagma.java
License:Open Source License
@Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { // check the TE TileEntityAnvilMagma te = (TileEntityAnvilMagma) world.getTileEntity(pos); boolean success = FluidUtil.interactWithFluidHandler(player, hand, world, pos, side); if (te != null) { if (!world.isRemote) { int currentFluid = te.getCurrentFluidStackAmount(); UtilChat.sendStatusMessage(player, UtilChat.lang("cyclic.fluid.amount") + currentFluid); }//from ww w. j a v a 2 s . co m } // otherwise return true if it is a fluid handler to prevent in world placement return success || FluidUtil.getFluidHandler(player.getHeldItem(hand)) != null || super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ); }
From source file:com.lothrazar.cyclicmagic.block.enchanter.BlockEnchanter.java
License:Open Source License
@Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { // check the TE TileEntityEnchanter te = (TileEntityEnchanter) world.getTileEntity(pos); boolean success = FluidUtil.interactWithFluidHandler(player, hand, world, pos, side); if (te != null) { if (!world.isRemote) { int currentFluid = te.getCurrentFluidStackAmount(); UtilChat.sendStatusMessage(player, UtilChat.lang("cyclic.fluid.amount") + currentFluid); }/*from w w w. j a v a2s.c o m*/ } // otherwise return true if it is a fluid handler to prevent in world placement return success || FluidUtil.getFluidHandler(player.getHeldItem(hand)) != null || super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ); }
From source file:com.lothrazar.cyclicmagic.block.exppylon.BlockXpPylon.java
License:Open Source License
@Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { // check the TE TileEntityXpPylon te = (TileEntityXpPylon) world.getTileEntity(pos); boolean success = FluidUtil.interactWithFluidHandler(player, hand, world, pos, side); if (te != null) { if (!world.isRemote) { int currentFluid = te.getCurrentFluidStackAmount(); UtilChat.sendStatusMessage(player, UtilChat.lang("cyclic.fluid.amount") + currentFluid); }//w w w . jav a 2 s .c o m } // otherwise return true if it is a fluid handler to prevent in world placement return success || FluidUtil.getFluidHandler(player.getHeldItem(hand)) != null || super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ); }
From source file:com.lothrazar.cyclicmagic.block.fluidplacer.BlockFluidPlacer.java
License:Open Source License
@Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { // check the TE TileEntityBaseMachineFluid te = (TileEntityBaseMachineFluid) world.getTileEntity(pos); boolean success = FluidUtil.interactWithFluidHandler(player, hand, world, pos, side); if (te != null) { if (world.isRemote == false) { //server side String message = null; FluidStack fs = te.getCurrentFluidStack(); if (fs != null) { String amtStr = fs.amount + " / " + te.getCapacity() + " "; message = UtilChat.lang("cyclic.fluid.amount") + amtStr + fs.getLocalizedName(); } else { message = UtilChat.lang("cyclic.fluid.empty"); }// www.j a v a 2 s. co m String powered = world.isBlockPowered(pos) ? "cyclic.redstone.on" : "cyclic.redstone.off"; UtilChat.sendStatusMessage(player, message + "; " + UtilChat.lang(powered)); } } // otherwise return true if it is a fluid handler to prevent in world placement return success || super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ); }
From source file:com.lothrazar.cyclicmagic.block.hydrator.BlockHydrator.java
License:Open Source License
/** * with thanks and gratitude @KnightMiner https://github.com/KnightMiner/Ceramics/blob/1.11/src/main/java/knightminer/ceramics/blocks/BlockBarrel.java * // ww w . j a v a 2s. c o m * */ @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { // check the TE TileEntityHydrator te = (TileEntityHydrator) world.getTileEntity(pos); // FluidStack bucket = FluidUtil.getFluidContained(player.getHeldItem(hand)); boolean success = false; success = FluidUtil.interactWithFluidHandler(player, hand, world, pos, side); if (te != null) { if (!world.isRemote) { int currentFluid = te.getCurrentFluidStackAmount(); UtilChat.sendStatusMessage(player, UtilChat.lang("cyclic.fluid.amount") + currentFluid); } } // otherwise return true if it is a fluid handler to prevent in world placement return success || FluidUtil.getFluidHandler(player.getHeldItem(hand)) != null || super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ); }
From source file:com.lothrazar.cyclicmagic.block.peat.farm.BlockPeatFarm.java
License:Open Source License
@Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { // check the TE TileEntityPeatFarm te = (TileEntityPeatFarm) world.getTileEntity(pos); boolean success = false; success = FluidUtil.interactWithFluidHandler(player, hand, world, pos, side); if (te != null) { if (!world.isRemote && te.getCurrentFluidStack() != null) { int currentFluid = te.getCurrentFluidStack().amount; UtilChat.sendStatusMessage(player, UtilChat.lang("cyclic.fluid.amount") + currentFluid); }/* ww w .jav a2 s .c om*/ } // otherwise return true if it is a fluid handler to prevent in world placement return success || FluidUtil.getFluidHandler(player.getHeldItem(hand)) != null || super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ); }
From source file:com.lothrazar.cyclicmagic.block.tank.BlockFluidTank.java
License:Open Source License
@Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (player.getHeldItem(hand).getItem() == Item.getItemFromBlock(this)) { return false; }//from w w w .j a va 2 s. com // check the TE boolean success = FluidUtil.interactWithFluidHandler(player, hand, world, pos, side); int heightCheck = 0; BlockPos posLoop = new BlockPos(pos); //connected tanks: try to move up again while (!success && heightCheck < heightCheckMax) { heightCheck++; posLoop = posLoop.up(); success = FluidUtil.interactWithFluidHandler(player, hand, world, posLoop, side); } if (world.isRemote == false) { //server side TileEntityFluidTank te = (TileEntityFluidTank) world.getTileEntity(pos); if (te != null) { FluidStack fs = te.getCurrentFluidStack(); if (fs != null) { String amtStr = fs.amount + " / " + te.getCapacity() + " "; UtilChat.sendStatusMessage(player, UtilChat.lang("cyclic.fluid.amount") + amtStr + fs.getLocalizedName()); } else { UtilChat.sendStatusMessage(player, UtilChat.lang("cyclic.fluid.empty")); } } } // otherwise return true if it is a fluid handler to prevent in world placement return success || FluidUtil.getFluidHandler(player.getHeldItem(hand)) != null || super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ); }
From source file:com.lothrazar.cyclicmagic.util.UtilFluid.java
License:Open Source License
public static boolean interactWithFluidHandler(@Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nullable EnumFacing side) { return FluidUtil.interactWithFluidHandler(player, EnumHand.MAIN_HAND, world, pos, side); }