Modify Mob Behaviour

Discussion in 'Plugin Development' started by weaversam8, Jul 15, 2013.

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

    weaversam8

    Tell me if I am posting in the wrong thread, but here's the deal. I am trying to basically override all mob behavior. I don't want skeletons shooting at me, I don't want zombies to burn up. I am trying to create mobs where I can control all of their actions. I have been following the tutorial here:

    http://forums.bukkit.org/threads/tutorial-how-to-customize-the-behaviour-of-a-mob-or-entity.54547/

    But I am lost and it seems to be outdated. Can someone lead me in the right direction? I am kinda new to java.

    Bump

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

    chasechocolate

    If you are "kind of new to Java" then I don't recommend starting to use NMS right off the bat. Also, please bump every 12 hours. Regarding your question, Jacek can probably help.
     
  3. Offline

    weaversam8

    Sorry about that, I'll remember.
     
  4. Offline

    Jacek

    Both things you mentioned can be done with the Bukkit API using ProjectileLaunchEvent and EntityCombustEvent

    Example:
    Code:
        public void onProjectileLaunch(ProjectileLaunchEvent event){
            if (event.getEntity() instanceof Arrow && event.getEntity().getShooter() instanceof Skeleton){
                event.setCancelled(true);
            }
        }
       
        public void onEntityCombust(EntityCombustEvent event){
            if (event.getEntity() instanceof Zombie){
                event.setCancelled(true);
            }
        }
     
  5. Offline

    weaversam8

    I apologize for not clarifying further, I want to override all mob behavior, those were just examples. I am planning to basically make groups of mobs that march around like soldiers. I need to have them move where I choose and not use default behavior to attack players. Is it possible?
     
  6. Offline

    Jacek

    weaversam8 You would need to add a new pathfinder for that, I showed how in the tutorial you linked above, it's not simple though :/ You might be better off sticking to API stuff for now.
     
  7. Offline

    weaversam8

    Ok, I guess I am not at that point yet. What I am asking of you right now is to teach me how to suppress all mob behavior. I will tackle the path finding later. If it clarifies, help me make a mob a statue that can look at a specific location.
     
  8. Offline

    Jacek

    Follow my tutorial, override the onTick() method (currently bj()).
     
  9. Offline

    weaversam8

    Ok, I believe I have done it right now, according to your tutorial Jacek, but how would you spawn a modified mob?
     
  10. Offline

    Jacek

    That should be covered in the topic, it's more of an all or nothing thing though so you'll have to add a flag to the entity if some of them need to behave specially.
     
  11. Offline

    xigsag

    Thank god this isn't a year-old post.

    Regarding your tutorial, Jacek.
    What's the ZombieMoveEvent? No such class for me.
    and yes, I am using both Craftbukkit and Bukkit for reference libs.

    Much simpler for me, I just want that mob to stay still. No movements. Just like a statue.
    Little help?
     
  12. Offline

    Jacek

    xigsag That's an event I added, probably not a good idea though since it really spams. I'd just not call the super method to prevent them moving.
     
  13. Offline

    xigsag

    It'd make my day if you could lay down an example of what you just said? I know you're a busy person and all, but if it's not too much trouble.. :D

    Jacek
    More specifically, how do I "just not call the super method to prevent them moving."?

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

    Jacek

    Instead of
    Code:
    @Override
    public void bj(){
        super.bj();
    }
    you'd have
    Code:
    @Override
    public void bj(){
       
    }
    or something might make more sense would be to add a frozen flag
    Code:
    @Override
    public void bj(){
        if (!this.frozen){
            super.bj();
        }
    }
     
  15. Offline

    xigsag

    Jacek
    Thanks a bunch!

    Jacek
    Just got to testing the code. Is there actually a frozen flag?

    super bj(); gives me an error too.

    Leaving it blank doesn't do anything either.

    I've also just realized, that you mentioned bj() is onTick. Didn't you mention that onMove was F_() or something on your tutorial thread? Has it changed? Because I can't seem to find it.

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

    Jacek

    xigsag There is no frozen flag, that's why I suggested you add it :p Those methods change with every game version, you'll have to work out the new names.
     
  17. Offline

    xigsag

    Jacek
    Bummer..
    Oh well, thanks anyways. I was actually trying to figure out how you could put nametags on blocks by spawning a EntityHuman/ EntityCreeper (their size and proportions allow them to hide in the block) inside a block, add a nametag on them, and freeze them so you cant push them around, and also so that the nametag stays still. Something like the chests from DungeonRealms.

    I've seen a bunch of threads about DungeonRealms's chest tags, but none seemed to tell me anything about how you would go about doing that in detail. So I thought, "Why not just ask that genius who made the mob behaviour tutorial directly?".

    Explaining what I meant to do, hoping you would actually have an idea or two on how to achieve this.
    But if you don't, then I guess it's all just a matter of time while we wait for someone to release a way to do that.
     
  18. Offline

    Jacek

    xigsag I've looked into that for another project actually. They seem to just send the entity spawn packet to the client instead of creating an actual entity, if you don't need to be able to interact with the entity then that will be the simplest way. There are some examples around the forum under different topics, like how to copy MobDisguise :p
     
  19. Offline

    xigsag

    Jacek
    Ooo, MobDisguise does that? Let's give it a try then.
     
  20. Offline

    Jacek

    xigsag It does a bit more than that but that is part of the process :)
     
  21. Offline

    xigsag

    Jacek
    Great timing.

    I have been looking around for solutions on how to spawn in an EntityPlayer with packets, and I've found little to few threads which have not really helped me as much as I was hoping them to.

    Some mentioned about spawning in an EntityPlayer with an empty socket? Wonder what that means.
    Many of the threads I found depended on ProtocolLib. I didn't want to rely on dependencies as much as possible.
    If spawning in an actual entity was too complicated, then settling for just a hologram of it would be just fine for me.

    I've also found a few threads of people asking how to move these 'hologram entities', stating that they already know how to spawn them in. Wasn't willing to ask the, so maybe I thought you would know.

    Again, sorry for the inconvenience, but I really can't bear to start another thread about this.
     
  22. Offline

    Jacek

  23. Offline

    xigsag

    Jacek
    Alright, I hope this isn't a huge blow to you, but here it goes.


    I don't know how to manipulate packets. :l
     
  24. Offline

    Jacek

    xigsag :p That's definitely something you can get on the forum.

    Code:
    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(Packet packet);
    you'll have to work out what the packet is from the mc-dev repo
     
  25. Offline

    xigsag

    Jacek
    I've gotten the packet. Packet20NamedEntitySpawn.

    One last thing, how do I utilize that snippet you just gave me to spawn this fake EntityPlayer?
     
  26. Offline

    Jacek

    Create a new Packet20NamedEntitySpawn() with the info you want then send it with the line I gave you.
     
  27. Offline

    xTrollxDudex

    xigsag
    Once you create the packet you would put the packet variable where it says Packet packet in Jacek 's snippet
     
  28. Offline

    xigsag

    xTrollxDudex
    Heh, sorry. Kind of trigger happy with my questions, alittle tired. I actually figured it out.

    Jacek
    End of Stream?

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

    Jacek

    No idea :/ Maybe you somehow sent an invalid packet, check all the fields.
     
  30. Offline

    xigsag

    Fields for packet20 (EntityHuman). Put that in, but it didn't spawn. At least it didn't boot me out for EoS.

    I also did
    this.c=l.getX();
    this.d=l.getY();
    this.e=l.getZ();

    And the others in the super method inside the custon entity class.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
Thread Status:
Not open for further replies.

Share This Page