Discussion in 'Spigot Plugin Development' started by 1461748123, Jun 27, 2015.

  1. Hi guys!
    I got a problem on detecting if water is stationary or not.

    because this problem, I make this code to explain the problem:
    Code (Text):

        public void onPlayerInteract(PlayerInteractEvent event) {

            if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getPlayer().isSneaking()) {
                event.getPlayer().sendMessage(event.getClickedBlock().getWorld().getBlockAt(new Location(event.getClickedBlock().getWorld(),
                        event.getClickedBlock().getLocation().getX(), event.getClickedBlock().getLocation().getY() + 1D,
            } else if (event.getAction()==Action.RIGHT_CLICK_BLOCK) {
    So as you can see, when I rightclick any block, it will set that block to WATER.
    And when I sneak and right the block underneath the block we just set, it should return WATER.

    But the problem is: Bukkit return it as STATIONARY_WATER instead of WATER.

    you can try the code by yourself.

    I'm not sure if this is a bug or something else, but now I got no way to detect if water is stationary or not.
    I think lava got the same problem too.

    Please help!
  2. WATER and STATIONARY_WATER aren't what you might think they are.

    Material.WATER (minecraft:flowing_water) is used for water that is currently spreading (the active edge of the water that is spreading outwards).

    Material.STATIONARY_WATER (minecraft:water) is used for water that is not currently spreading. Once a water source has completely finished spreading, all of it will be this material (even the blocks that have a flowing animated texture).

    The other thing to consider is the data value of the water. This is what determines if the water block is a source block (data value 0), and how high the water level is. Look here for more information on water's data values: http://minecraft.gamepedia.com/Water#Block_state
    #2 St3venAU, Jun 27, 2015
    Last edited: Jun 27, 2015
    • Useful Useful x 1