use of com.cjm721.overloaded.block.tile.infinity.TileInfiniteTank in project Overloaded by CJ-MC-Mods.
the class BlockInfiniteTank method onBlockActivated.
@Override
public boolean onBlockActivated(@Nonnull World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (!worldIn.isRemote) {
ItemStack heldItem = playerIn.getHeldItem(hand);
if (heldItem.isEmpty() && hand == EnumHand.MAIN_HAND) {
LongFluidStack storedFluid = ((TileInfiniteTank) worldIn.getTileEntity(pos)).getStorage().getFluidStack();
if (storedFluid == null || storedFluid.fluidStack == null) {
playerIn.sendStatusMessage(new TextComponentString("Fluid: EMPTY"), false);
} else {
playerIn.sendStatusMessage(new TextComponentString(String.format("Fluid: %s Amount %,d", storedFluid.fluidStack.getLocalizedName(), storedFluid.amount)), false);
}
} else {
TileEntity te = worldIn.getTileEntity(pos);
if (te != null && te instanceof TileInfiniteTank) {
IFluidHandler handler = te.getCapability(FLUID_HANDLER_CAPABILITY, side);
// FluidUtil.interactWithFluidHandler(playerIn.getHeldItem(hand), te.getCapability(FLUID_HANDLER_CAPABILITY, facing), playerIn);
FluidActionResult result = FluidUtil.interactWithFluidHandler(heldItem, handler, playerIn);
if (result.isSuccess())
playerIn.setHeldItem(hand, result.getResult());
}
}
}
return true;
}
Aggregations