Solved WynnCraft NPCs?

Discussion in 'Plugin Development' started by spurkle, Aug 17, 2016.

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



    Recently I have played an amazing RPG server called WynnCraft, and they have both enemy and friendly NPCs, which have their own data on them.

    The curious thing I have noticed is that they have typical minecraft (non living) entities acting as NPCs. (XP orbs as a fairy, Blocks as a 'crab in a sand block', Stone as a falling stone NPC, etc.)

    I am really curious on how could this work?

    My guess would be a bunch of custom entities with custom path finding goals (for living entities), and some mumbo jumbo magic to make the entities move towards the player.

    Does anyone have more exact information? I'd like to recreate something like that.
  2. Offline


    Packets my friend. I myself do not know how to use them, but this can get you started:
  3. Offline


    @spurkle @flash110
    Actually, Wynncraft does something that is easier to manage. What they do is take entities in game (like FallingSand or XP orbs), and use another entities AI (like a zombie). What this means is that you see a FallingSand block, but it acts like a zombie. There are plenty of "new custom entity" tutorials out there, so just google search it to find out how to make it. (Remember, there are some tutorials that ask to replace existing entities. You do not want those. Look for ones that tell you how to make new custom entities instead.)
  4. Offline


    Ohh, I really haven't thought about making invisible zombies and making it look like something else.

    I always think about very complex stuff when it could be done so easily.

    Haha, thanks.
  5. Offline


    Wait, Did you mean using pathfinders and stuff for the Falling Sand for example?

    Because what I have currently did, is i made a 'transporter' mob (silver fish), and just made a loop which would teleport the mob (pig) onto it every three ticks.

    I'm not sure how memory intensive it is, but I successfully managed to spawn 500 mobs on a 1 GB Ram server.

    And it looks somewhat realistic as well, This probably won't work with the falling blocks and other entities, but it works for villagers and pigs.

    (They look into different directions sometimes, but they work overall)
  6. Offline


    No, that is not what I meant, and no, you should not have two mobs for this. What you need to do is spawn one entity, where they have the AI of one type of mob (lets say silver fish), but the mob will appear as though it it a zombie. There are two way to achieve this:
    1. Using this tutorial, create a custom entity with custom AI. This is most likely what Wynncraft does.
    2. Using ProtocolLib, check all outgoing packets. If the packet is for creating an entity, check if the ID for the entity is the same as the one for your custom entity. If so, change the MobTypeID to that of the entity you want to see (50 is a creeper, 51 is a skeleton).
  7. Offline


    The mob part is simple, but what about XP Orb mobs, let's say?

    It doesn't have pathfinding stuff, so you can't really make it move unless you go hardcore.

    Like, the class extends zombie class, you can change the way that zombie thinks, but how can i make it appear to be something else without using ProtocolLib?
  8. Offline


    For XP orbs, you will have to either use protocol lib or create your own method to 'disguise' your entity. Considering this can be done with 5 lines with P.L., I would recommend you use it for this issue. Please don't be the type of developer who will not use other libraries or APIs. Libraries and APIs are there to help with these kinds of issues.
    Last edited by a moderator: Aug 21, 2016
  9. Offline


    Would you be able to shoot me a little example on how it would be done with Protocol Lib so I could look into it?

    And thank you for your answers, I'll see whats the Protocol Lib thing about :)
  10. Offline


         private ProtocolManager protocolManager;
    //Inside on enable
    protocolManager = ProtocolLibrary.getProtocolManager();     
              new PacketAdapter(this, ListenerPriority.NORMAL,
              PacketType.Play.Server.ENTITY) {
              public void onPacketSending(PacketEvent event) {
              if (event.getPacketType() ==
              PacketType.Play.Server.ENTITY) {
                 for(Entity e : /*Arraylist of all the disguised entities*/){
                  event.getPacket().getIntegers().write(1, (int) EntityType.ZOMBIE.getTypeId());
    This will turn all entities that are stored inside the array into zombies.
  11. Offline


    The method getId() is undefined for the type Entity,

    And if i attempt to use e.getEntityId(), then it says that you can't compare Field and integer.


    And Even if i comment that line out, it doesn't seem to replace living mobs / other entities at all.

    EDIT 2:

    Could me using outdated ViaVersion plugin cause this?

    EDIT 3:

    Noop, updated and it's still the same.
    Last edited: Aug 21, 2016
  12. Offline


    Sorry, I imported the wrong entity (net.minecraft). Use "getEntityID()" and replace "getField" with "read(0)"
  13. Offline


    The pig is still a pig, unfortunately.

    This is the code:

  14. Offline


    [Edit] I realized the entity would have to be created before it can be put into the array. Here is what I would recommend instead:
    1. Before the pig is created, have a int field that stores the TypeID. Naturally it will be set to -1.
    2. When you want to spawn your custom entity, change that field to be equal to the TypeID of the zombie, spawn the pig, and then set the field equal to -1 again.
    3. Inside the packetAdapter, check if the field is not equal to -1. If it is equal to -1, do nothing. If it is not, set the type ID of the entity equal to the field.
    Doing this will allow you to have an entity that can be disguised as any mob type.
  15. Offline



    For some reason it appears that the event is not firing at all.


    I added some debug messages, and whenever I spawn a NPC, I don't get them.
  16. Offline


    Seems the naming has changed since I last worked with PL. Replace "ENTITY" with ".SPAWN_ENTITY".
    spurkle likes this.
  17. Offline


    It works if i do .SPAWN_ENTITY_LIVING.

    Thank you, that's exactly what I have wanted!

    Now I will have to play with it to make sure that mobs don't turn back into the first mob when player disconnects/teleports, etc.

    Thanks again, really appreciate it :)
Thread Status:
Not open for further replies.

Share This Page