Packets Help

Discussion in 'Plugin Development' started by DevRosemberg, Oct 21, 2013.

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

    xTrollxDudex

    DevRosemberg
    Sorry. I have school and a bunch of other stuff on my schedule so I don't have a lot (not a lot but some time) to code
     
  2. Offline

    DevRosemberg

    xTrollxDudex Do you think you will be able this weekend?
     
  3. Offline

    xTrollxDudex

    DevRosemberg
    Sorry.... Completely forgot about this thread. Try
    PHP:
    public void disguiseToAll(Player p) {
        for (
    Player player Bukkit.getServer().getOnlinePlayers()) {
            if (
    player == p
                continue;

            
    Packet24MobSpawn packet = new Packet24MobSpawn(((CraftPig)((Pig)world.spawn(p.getLocation(), Pig.class)).getHandle());
            
    packet.= ((CraftPlayer)player).getEntityId();
            
    packet.this.plugin.playerMobId.get(p1.getName()).byteValue();

            ((
    CraftPlayer)player).getHandle().playerConnection.sendPacket(packet);
        }
    }
    h is an int I believe in Packet24MobSpawn. When you manually set the data for a and b is very iffy because the entity type and id don't match. I try to keep that, see what happens.

    By the way, I found this:
    Code:java
    1. this.datawatcher.a(0, Byte.valueOf((byte) 0));
    2. this.datawatcher.a(1, Short.valueOf((short) 300));

    In the Entity class.
     
  4. Offline

    DevRosemberg

    xTrollxDudex So this would disguise him as a pig right?

    Code:java
    1. Packet24MobSpawn packet = new Packet24MobSpawn(((CraftPig)((Pig)world.spawn(p.getLocation(), Pig.class)).getHandle());
     
  5. Offline

    xTrollxDudex

  6. Offline

    DevRosemberg

    xTrollxDudex then why this for?
    (CraftPig)((Pig

    kevinspl2000 Thats mean man... poor CaptainBern ;(

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  7. DevRosemberg @xTrollxDudex's code will not work. Why? It will work a few ticks and then the player will change back into a player. You need to use protocolLib.
    I will start of by letting you take a look at Lib's Disguises, in my opinion the best disguise plugin out there.
    https://github.com/libraryaddict/Li.../me/libraryaddict/disguise/LibsDisguises.java

    As you may see there's notting really interesting in that class, the really interesting stuff is in this class: https://github.com/libraryaddict/Li...me/libraryaddict/disguise/PacketsManager.java

    I think it will just be easier to fork the project or clone it and add it to your plugin. I really don't have the time at the moment to work on this, exams and school, I'm also doing some other projects and I'm working for a server.

    (And my internet is as good as dead so I'm using every second I have to chat with friends or play some games :p )

    kevinspl2000 ? I wrote an answer on your question here: http://forums.bukkit.org/threads/in...pplied-to-an-npc-created-with-packets.188454/ The only thing you need to do is add protocolLib as a dependency and add a new packet listener, then listen for the incoming Packet7UseEntity and check if the b field is the id of your npc, if so then continue and check if the c field is 1 or 0 to determine if it was a left or right click...
     
  8. Offline

    kevinspl2000

    CaptainBern
    Yea but I don't understand where I have to put everything and how to set it out.. I have NEVER wrote a packet or anything ever in my life so I have no idea what I would do.
     
  9. Offline

    libraryaddict

    Hi there! Lib's Disguises author here.

    Disguising players and mobs is not as simple as one two three.
    Disguising some entities to other entities require you to use ProtocolLib for full effect.
    Else you will definitely reach a whole range of troubles, including the disguises 'wearing off' and crashing.
    Disguising a player to another player is pretty simple. Just catch the named entity spawn packet and change the name there.

    Disguising a player to a horse is not simple. You need to catch the player spawn packet, cancel it, make a new mob spawn packet. Then proced to catch all entity metadata packets and check them for values that may crash the client.

    Don't even get me started on tricky disguises such as a living entity to a non-living. You also need to cancel the attribute packets and send velocity packets if you don't want the disguises to glitch around if they are the kind that disappear when they hit the ground.

    My disguise plugin does all the work for you, it would honestly be best just to switch to that as you wouldn't see a advantage over rewriting the same code.

    You can look into the disguise plugin, fork it, include it into your code if you like. But all the packet editing stuff in there is used.

    Some things in it such as the commands, update checker, self disguises and the api is not required. But you would see a minimal performance gain from that.

    Not everything is improved because you write it yourself. The original Lib's Disguises was simply using ProtocolLib to prevent the disguises wearing off. It was fairly simple.

    Went on from there when people really really liked it.
     
Thread Status:
Not open for further replies.

Share This Page