Solved Make player sit on a stair

Discussion in 'Plugin Help/Development/Requests' started by cnc4, Apr 1, 2015.

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

    cnc4

    Hello, i am trying to make that player could sit on a stair.
    i am using this sorce code: https://github.com/spoothie/Chairs/tree/master/src/net

    Code:
    @EventHandler
        public void OnPlayerSit ( PlayerInteractEvent e) {
          
          
            if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
                Player p =e.getPlayer();
                if(e.getClickedBlock().getType().equals(Material.DARK_OAK_STAIRS)){
                    Block block = e.getClickedBlock();
                    Stairs stairs = (Stairs)block.getState().getData();
                  
                    Item drop = dropSeat(block);
                  
                    Location plocation = p.getLocation();
              
                        if(p.getVehicle() != null)
                            p.getVehicle().remove();
    
                      
                      
                        switch(stairs.getDescendingDirection()) {
                            case NORTH:
                                plocation.setYaw(180);
                                System.out.println("NORTH");
                                break;
                            case EAST:
                                plocation.setYaw(180);
                                break;
                            case SOUTH:
                                plocation.setYaw(270);
                                break;
                            case WEST:
                                plocation.setYaw(0);
                        }
                  
                    p.teleport(plocation);
                      
                        drop.setPassenger(p);  
              
                      
                  
                      
                  
                }
            }
        }
      
        private Item dropSeat(Block chair) {
            Location location = chair.getLocation().add(0.5,0.2, 0.5);
            Item drop = location.getWorld().dropItem(location, new ItemStack(Material.LEVER));
            drop.setPickupDelay(Integer.MAX_VALUE);
            drop.teleport(location);
            drop.setVelocity(new Vector(0, 0, 0));
      
            return drop;
        }
    The problem is that the item just jumping of the stairs and he doesn't stay in his position, I tried to change the location without success.

    plz help and thanks in advance!

    up plz help!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
  2. Offline

    Konato_K

    @cnc4 What I've seen done before it's spawn an arrow stucked in the stair, then sit the player on the arrow.
     
  3. @cnc4 Wait 24 hours to bump.
    And see that post ^
    Also, there is a way to get an entity to be invisible if I recall correctly, so you could probably make the arrow invisible, but I don't remember how.
     
  4. Offline

    cnc4

    i am using a lever and i dont know how to make him stay stuck in the stair :/

    ok sorry didnt know that.
    amm I dont think I need to make the item invisible i just want him to stay stuck in the stair...
     
  5. Offline

    Derpiee

  6. Offline

    cnc4

  7. Offline

    mine-care

    @cnc4 hehehehe you might need to use nms to make it invisible by sending PacketPlayOutEntityDestroy to all players that should not see the arrow, or by a data watcher value I don't really remember, other than that you can drop some seeds, make them un picable and then set the player as passenger.
     
  8. Offline

    ResultStatic

    @mine-care dont send a destroy packet. that will glitch out the entity riding animation. the entity has to actually exist for you to be a passenger of it.
     
    mine-care likes this.
  9. Offline

    cnc4

    PacketPlayOutEntityDestroy is not an option, what is data watcher value? How do i use it? And about the seeds i will try it later
    Maybe you have another idea?
     
    Last edited: Apr 3, 2015
  10. Offline

    Ruptur

    @cnc4
    What you can do is move the arrow into the chair.
    So you don't spawn in on the stair's location.
    Code:
    p.getWorld().spawnEntity(chair.getLocation().add(0, 0.5D, 0);
    
     
  11. Offline

    cnc4

    @Ruptur

    Well i got it to work thx!, do you have any idea hhow to disable the arrow sound?
     
  12. Offline

    mine-care

    @ResultStatic thats true, i forgot to mention, the packet has to go to all the clients EXCEPT the one siting on it. The rest will still see it as if the player is sitting on the stair but the one on the chair will see himself sitting.

    @cnc4
    \
    ^
    Droping seeds produces no sound.
     
  13. Offline

    cnc4

    [
    no, you are wong i checked it agian the player is sitting but the other players see him standing..

    the seeds will probably work like the the lever i used in the beginning^.

    thx you for your help!
     
  14. Offline

    mine-care

    @cnc4 Hm this should not be hapening (at least from my experience), if i may what server version youre using? i have done it in the past (faar past) and it worked wonders!

    Np i am here to help ya =)
     
  15. Offline

    cnc4

    @mine-care

    I am using craftbukkit from get spigot, 1.8
     
  16. Moved to Bukkit Alternates.
     
  17. Offline

    cnc4

  18. Offline

    nverdier

    @cnc4 Because you're using Spigot. Spigot is an alternative of Bukkit. This thread belongs in the Bukkit Alternatives section.
     
  19. Offline

    cnc4

    But I took craftbukkit from get spigot. does it mean that i am using spigot? from where else i can get bukkit?
     
  20. Offline

    nverdier

    @cnc4 There is no CraftBukkit for 1.8, which I am assuming you're using because you got it from Spigot.
     
  21. Offline

    cnc4

    Well yes... but what is that Craftbukkit: http://getspigot.org/
     
  22. Offline

    ResultStatic

    no still wont work, the client rendering it must also see the entity its riding
     
    cnc4 likes this.
  23. Offline

    mine-care

    @ResultStatic Lol thats odd? in my plugin it worked as a treat!
    EDIT oh wait! it was the datawatcher value on an arrow :3 (just decompliled my plugin and it involves datawatcher, the value seems to be 10 but i just tryed it (on a 1.7.10 server) and it does not work :3)
     
  24. Offline

    cnc4

    So what does it mean? Using EntityDesttoy wont help? What is dataWatcher?
     
  25. Offline

    cnc4

    seems good but from where can i download this library?

    EDIT: nvm I found it, but how can I check which sound was made? with out cancel all the sound side server...
     
    Last edited: Apr 5, 2015
  26. Offline

    cnc4

  27. Offline

    Mrgts

    ChairsReloaded plugin does that
     
Thread Status:
Not open for further replies.

Share This Page