[Help] Block walkspeed

Discussion in 'Plugin Development' started by F4BSE, Jan 19, 2013.

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

    F4BSE

    How can I change the block walkspeed for a specific block like dirt and not for all blocks?
    Probably a double walkspeed for dirt?

    Thanks for help :)
     
  2. Offline

    DarkBladee12

    F4BSE You could use the PlayerMoveEvent and check if (player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.DIRT) and then multiply the player's velocity. That's how you would do that!
     
  3. Offline

    F4BSE

    Thanks. Like this?

    Code:
    @EventHandler
        public void onPlayerMove(PlayerMoveEvent player) {
        boolean doMultiply = false;
       
        Block below = player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.DIRT;
        MaterialBlock mb = (MaterialBlock) below;
       
                if (doMultiply) {
                mb.setAirSpeedMultiplier(4);
                mb.setWalkingMultiplier(4);
                mb.setJumpingMultiplier(1.50);
            } else {
                mb.setAirSpeedMultiplier(1);
                mb.setWalkingMultiplier(1);
                mb.setJumpingMultiplier(1);
            }
        }
     
  4. Offline

    DarkBladee12

    F4BSE No I meant event.getPlayer().setVelocity(event.getPlayer().getVelocity().multiply(2.0D));
     
  5. Offline

    fireblast709

    you don't want to multiply the velocity vector ;3. Imagine a long strip of dirt :D.
    Code:
    player.setWalkSpeed(0.2);
    //0.2 is the normal speed
    // Like, 0.4 is the double. 0.8 is still doable
     
  6. Offline

    F4BSE

    Plz give me an example :p. I'm not good in java. I'm learning it.

    Is this right?

    Code:
            @EventHandler
            public void onPlayerMove(PlayerMoveEvent event) {
            boolean doMultiply = false;
     
            Block below = event.getPlayer().setVelocity(event.getPlayer().getVelocity().multiply(2.0D));
            BlockDirt bd = (BlockDirt) below;
       
                    if (doMultiply) {
                    bd.setAirSpeedMultiplier(0.2);
                    bd.setWalkSpeedMultiplier(0.2);
                    bd.setJumpingMultiplier(0.2);
                } else {
                    bd.setAirSpeedMultiplier(0.1);
                    bd.setWalkingMultiplier(0.1);
                    bd.setJumpingMultiplier(0.1);
                }
            }
    I get a lot of Issues. Whats my fault? :/

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
Thread Status:
Not open for further replies.

Share This Page