Posted February 27, 20214 yr I have added and registered a fluid, and I need to detect when the player right clicks the fluid with a bottle, but there is no way to detect that within the class extending FlowingFluid, and if I use onBlockActivated in the class extending FlowingFluidBlock, nothing happens. It seems vanilla Minecraft detects it within the bottle itself, so where would I detect a bottle clicking my fluid at?
February 27, 20214 yr Author 5 hours ago, diesieben07 said: This happens in GlassBottleItem#onItemRightClick, which you can intercept using PlayerInteractEvent.RightClickItem. Alright, so I have done that, but I cannot use the same rayTrace method that the bottle uses because it is protected, so how do I find the fluid that was clicked? @SubscribeEvent public static void playerRightClickItem(PlayerInteractEvent.RightClickItem event) { System.out.println("Player Right Clicked!"); World worldIn = event.getWorld(); PlayerEntity playerIn = event.getPlayer(); if (event.getPlayer().getHeldItem(event.getHand()).getItem() == Items.GLASS_BOTTLE) { RayTraceResult raytraceresult = rayTrace(worldIn, playerIn, RayTraceContext.FluidMode.SOURCE_ONLY); //Error: 'rayTrace(net.minecraft.world.World, net.minecraft.entity.player.PlayerEntity, net.minecraft.util.math.RayTraceContext.FluidMode)' has protected access in 'net.minecraft.item.Item' if (raytraceresult.getType() == RayTraceResult.Type.MISS) { } else { if (raytraceresult.getType() == RayTraceResult.Type.BLOCK) { BlockPos blockpos = ((BlockRayTraceResult)raytraceresult).getPos(); if (worldIn.getFluidState(blockpos).getFluid() instanceof RedWater) { worldIn.playSound(playerIn, playerIn.getPosX(), playerIn.getPosY(), playerIn.getPosZ(), SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.NEUTRAL, 1.0F, 1.0F); turnBottleIntoItem(event.getPlayer().getHeldItem(event.getHand()), event.getPlayer(), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.HEALING)); } } } } }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.