Making a player sit down

Discussion in 'Plugin Development' started by Jnorr44, Sep 29, 2012.

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

    Jnorr44

    I had this working twice, once before using NMS code, then using the vehicle attachment methods in bukkit. Now neither work, and I need a new solution. Is there any way to make it so a player cannot move, and so they are sitting down? Thanks.
     
  2. Offline

    Vandrake

    yes there is a way.
     
    JazzaG likes this.
  3. Offline

    brord

  4. Offline

    Jnorr44

    I know there is a way, I fixed this, just used the old nms method I used before...
     
  5. Offline

    Loogeh

    How I do it. player.setPassenger() and set their passenger as themself.​
     
  6. Offline

    Vandrake

    Loogeh god no. hell no. hecks no xD I tried this before and it didn't look pretty. xD so I just send a fake packet with byte 4
     
    chasechocolate likes this.
  7. Offline

    Loogeh

    Okay, haha :>
     
  8. Offline

    Jnorr44

    Same, its a good way to do it.
     
  9. Offline

    Me4502

    That'll give you a StackOverflowException, I wouldn't ever recommend doing that... ever.
     
  10. Offline

    travja

    Couldn't you set the passenger as the block that they are standing in?
     
  11. Offline

    brettleaver

    How would you do that? What effect do sent packets have on the client?
     
  12. Offline

    zeeveener

    They change what the client sees from the server. It is how the client knows where other players/entities are on the server in regards to their positions at all times.
    Although I haven't yet touched packets, i have a feeling that if one knows them fairly well, they can do some pretty intense things that no method in Bukkit can reproduce.
     
  13. Offline

    MrFigg

    If you're going to look into using packets I'd recommend using ProtocolLib. Best packet lib I can find as of this post, and Comphenix has been updating it regularly.
     
  14. Offline

    md_5

    Pretty sure the client won't like it if you try to make them sit in a non existant entity.
     
  15. Offline

    Vandrake

    Tell that to the DBrain plugin, Craftbook plugin, Chairs plugin and many many others
     
  16. Offline

    md_5

    Why don't we asl Me4502 then? You could always take a look at his code.
     
  17. Offline

    Necrodoom

    arent these using arrows to sit on?
     
  18. Offline

    Me4502

    The CraftBook code tell all nearby players the entity action packet with sitting enabled... so other clients see the player as sitting, but they aren't actually... its a hacky client side way.
     
  19. Offline

    Vandrake

    I don't know about others but what I did was:
    -> Send a fake packet of a player sitting down.
    -> Block the movement while sitting. (ofcourse in the new version I removed this but as soon as they move out of the block they are no longer seen as sitting).
     
  20. Offline

    cnaude

    Would it be possible to see the code where you did this? I took over the Chairs plugin and the game no longer allows items to occupy the same space as a block. I have been reading about sending packets and that seems like a different way to accomplish the chair sitting.
     
  21. Offline

    Vandrake

    Code:
    public byte metadata;
        public static class ChairWatcher extends DataWatcher
        {
            private byte metadata;
            public ChairWatcher(byte i)
            {
                this.metadata = i;
            }
            public ArrayList<WatchableObject> b()
            {
                ArrayList<WatchableObject> list = new ArrayList<WatchableObject>();
                WatchableObject wo = new WatchableObject(0, 0, Byte.valueOf(this.metadata));
                list.add(wo);
                return list;
            }
        }
    then
    Code:
    Packet40EntityMetadata packet = new Packet40EntityMetadata(e.getPlayer().getEntityId(), new ChairWatche[B]r((byte) 4), fa[/B]lse);
                                for (Player play : Bukkit.getOnlinePlayers())
                                {
                                  ((CraftPlayer)play).getHandle().netServerHandler.sendPacket(packet);
                                }
                                e.getPlayer().teleport(e.getClickedBlock().getLocation().add(0.5D, 0.0D, 0.5D));
                                if(!main.sit.containsKey(e.getPlayer().getName()))
                                {
                                    e.getPlayer().sendMessage(ChatColor.GRAY + "You are now sitting.");
                                    main.sit.put(e.getPlayer().getName(), null);
                                }
    This will send a packet of the player sitting. Byte 4 is a player sitting. Byte 0 is a player standing. Play around with those :p I found a player on fire in those byte xD Its fun eheh
     
  22. Offline

    cnaude

    Thanks! I'll take a crack at this tonight.
     
  23. Offline

    Vandrake

    youre welcome. Have fun xD
     
  24. Offline

    cnaude

    It worked like a charm. The ChairsReloaded plugin works once again!
     
Thread Status:
Not open for further replies.

Share This Page