Detecting bottles filled

Discussion in 'Plugin Development' started by Tytelcimi, Apr 28, 2021.

  1. Offline

    Tytelcimi

    Hi all. I am having some troubles detecting glass bottles being filled. I first tried the PlayerInteractEvent but, when the player is right clicking in water, getClickedBlock() returns null or the block they are clicking through the water so there is no way to know if they are clicking on land (no effect) or clicking in water (the bottle is filled). I also tried PlayerBucketFillEvent but, as the class name suggests, that it only called when buckets are filled not water bottles. How do I detect water bottles being filled? Thank you.
     
  2. Offline

    davidclue

    You want to use
    Code:
    Location loc = player.getTargetBlockExact(5, FluidCollisionMode.ALWAYS).getLocation();
     
    Kars likes this.
  3. Offline

    Kars

    But you don't need location, just the block to see if it is water.
    This might not work if the bottle is filled from a cauldron.
     
    davidclue likes this.
  4. Offline

    davidclue

    I was only pasting some code from one of my projects, I didn't feel like changing it. Just check if the block targeted was a water source or cauldron (I'm sure there are ways to check if the cauldron was filled or not) and if it was then do what you want to do, you could also add some checks to see if they are holding a filled bottle just to be sure.
     

Share This Page