Wall Climbing Plugin Help

Discussion in 'Plugin Development' started by crookedmaze98, Aug 1, 2012.

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

    crookedmaze98

    Hello I'm trying to create a plugin to make it so you can climb walls when you hold shift and move/walk forward I have the climbing part down but I can't seem to make it so you can only do it while your right next to a wall could someone help me to do this.

    Code:
    @EventHandler
        public void wallClimb(PlayerMoveEvent event){
        Location loc1, loc2, loc3, loc4;
        Location location;
    
        loc1 = loc2 = loc3 = loc4 = event.getPlayer().getLocation();
        Player player = event.getPlayer();
    
        location = player.getLocation();
        loc1.setY(loc1.getY());
        loc2.setY(loc2.getY());
        loc3.setY(loc3.getY());
        loc4.setY(loc4.getY());
        
        
        loc1.setX(loc1.getX() +.5);
        loc2.setZ(loc2.getZ() +.5);
        loc3.setZ(loc3.getZ() +.5);
        loc4.setX(loc4.getX() +.5);
        
        location.setY(loc1.getY() + 2);
        World w = loc1.getWorld();
        Block left, right, back, front;
        
        left = w.getBlockAt(loc1);
        right = w.getBlockAt(loc2);
        front = w.getBlockAt(loc3);
        back = w.getBlockAt(loc4);
    
    
            if(player.isSneaking() && left.getType() != Material.AIR || player.isSneaking()  &&   right.getType() != Material.AIR   || player.isSneaking() &&  back.getType() != Material.AIR    || player.isSneaking() &&  front.getType() != Material.AIR )
            {
                player.teleport(location);
    
            }
    
        
        
        }
        
       
    
    Rights now I have this which makes it so it only works on some of the walls but not all of them and
    Code:
        loc1.setX(loc1.getX() +.5);
        loc2.setZ(loc2.getZ() +.5);
        loc3.setZ(loc3.getZ() +.5);
        loc4.setX(loc4.getX() +.5);
    
    when I try to do
    Code:
        loc1.setX(loc1.getX() +.5);
        loc2.setZ(loc2.getZ() +.5);
        loc3.setZ(loc3.getZ() -.5);
        loc4.setX(loc4.getX() -.5);
    
    It makes it so it won't work anywhere... Is there anyway I can fix this so the climbing can work anywhere?

    Thanks for reading my post! - Crookedmaze
     
  2. Offline

    Malikk

    I'm not sure I really understand what you're trying to do here, but if you need to subtract values from a location you can do it like this;

    Code:
    loc.subtract(0,0,0);
    
    I would think this would be a lot better, and less confusing, than setting the X, Y, and Z coords for each block separately. Also, depending on what you need, you should consider using getBlockX(), rather than getX() if all you need is block locations.

    EDIT: Also, these lines do absolutely nothing.
    Code:
        loc1.setY(loc1.getY());
        loc2.setY(loc2.getY());
        loc3.setY(loc3.getY());
        loc4.setY(loc4.getY());
    
     
    crookedmaze98 likes this.
  3. Offline

    crookedmaze98

    Thanks for the reply malikk! I'm sorry I should of been clearer about what I am trying to do, what I am trying to do is check if there is a block by the player like this

    B=Block P=Playier
    B
    BPB
    B

    If there is a block in front behind of or to the left or to the right of the player I want them to be able to climb the block/wall/building if they sneak and move forward they climb by climb I mean they are teleported 2 blocks up and then if they're still sneaking and moving they get teleported up again until they get to the top of the wal
     
  4. Offline

    NSArray

    I think you want to do

    Code:
    loc1.setX(loc1.getX() +.5);
    loc2.setZ(loc2.getZ() +.5);
    loc3.setZ(loc3.getZ() -1.0);
    loc4.setX(loc4.getX() -1.0);
     
    crookedmaze98 likes this.
  5. Offline

    crookedmaze98

    Thanks NSArray!!!! I was able to get it to work!

    Using
    Code:
        loc1.setX(loc1.getX() +.5);
        loc2.setZ(loc2.getZ() +.5);
        loc3.setZ(loc3.getZ() -1.0);
        loc4.setX(loc4.getX() -1.0);
        loc5.setX(loc5.getX() -.5);
        loc6.setZ(loc6.getZ() -.5);
        loc7.setZ(loc7.getZ() +1.0);
        loc8.setX(loc8.getX() +1.0);
    
     
  6. Offline

    azyhd

    Will this be a private plugin
     
Thread Status:
Not open for further replies.

Share This Page