Solved On move Event with dirt

Discussion in 'Plugin Development' started by xelatercero, Jun 16, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    xelatercero

    I have done a event that checks if the block is liquid and if is true, change the block to dirt, but i have a problem when the player walks in the water the block change but the player fall to the water:

    Code:
    @EventHandler
        public void congelacion(PlayerMoveEvent e) {
            Player p = e.getPlayer();
            World world = p.getWorld();
            Block b = world.getBlockAt(p.getLocation().getBlockX() , p.getLocation().getBlockY(), p.getLocation().getBlockZ());
           
            if(!(b.isLiquid())) return;
            if(b.isLiquid()) {
                b.setType(Material.DIRT);
            }
        }
     
  2. Offline

    Zombie_Striker

    Instead of doing a double check, just remove the first if statement.

    What is your problem? Is the water not changing if the player is walking through the water?
     
  3. Offline

    xelatercero

    @Zombie_Striker yes the water changes but the problem is when the block changes the player fall in the water i mean he dont stand up in the dirt block, try it and you will understand me. Sorry for my english
     
  4. Offline

    Lordloss

    Code:
    Block b = world.getBlockAt(p.getLocation().getBlockX() , p.getLocation().getBlockY(), p.getLocation().getBlockZ());
    You can replace this with p.getLocation().getBlock();
    Your problem is that you are checking the block at the moment the player is allready inside of it. You need to check the blocks below, note that there can be multiple blocks at the same time, google for "get all blocks below player" if you need help with this.
     
  5. Offline

    iSexyChocobo

    I think he's saying that the player ends up stuck inside of the dirt block after the water turning into dirt, and since sinking into water is client-sided, this is hard to avoid.

    You could try to circumvent the problem by predicting the player's path and sending block updates of ex. lily pads to the player in advance.
     
  6. Offline

    Lordloss

    @iSexyChocobo My approach would work for air blocks too, i allready did this in the past. No need to send packages or anything.
     
  7. Offline

    xelatercero

    @Lordloss Ok thanks i solved the problem!! :p:D
     
Thread Status:
Not open for further replies.

Share This Page