[WIP/LIB] Remote entities - Next generation NPC library

Discussion in 'WIP and Development Status' started by kumpelblase2, Oct 2, 2012.

Thread Status:
Not open for further replies.
  1. Hey everyone!

    Since the library made by Top_Cat just supports Human NPCs and I failed adding the functionality that I'd like to have for NPCs, I decided to start working on my own library which I want to share with everyone once finished.

    The idea I have is that you can have ANY entity as a NPC and do anything that the entities are capable of. Want to let dragons fly a specific path? Here you go! Or you want a Zombie as a pet? Sure, why not! I'm aiming to make it as easy to use as I can but still keeping it flexible and powerful.

    Current status: Finished planing everything or at least everything I wanted to plan for. Also you can already spawn Human NPCs. No movement has been done so far. But will be my next thing I'll do.

    If someone wants to help me, send me a message here and I'll get more into detail of what I've planned.
    You can also checkout the repository and submit a pull request at any time.
    Repository url:
    https://github.com/kumpelblase2/Remote-Entities


    Alright, have fun!

    ~kumpelblase2
     
  2. I might be able to help you. My experience with MobFighter left me with a pretty good understanding of Mob AI and how to redesign and take advantage of it.
    I'm not very good at API design, though, but I'd like to contribute what I can.
    A fully-fledged API would be awesome and a good abstraction layer towards the native mostly obfuscated code.

    See you on teamspeak some time?
     
  3. Alright, I hope I'll be there on the weekend so we could have a talk. I'll finish up my class diagram so you and any others might take a look at it and give suggestions (Biggest part is done but I'll always find some new things that I like to add). I'm currently working on wrapping the native Pathfinders so It might be a bit easier for the people to use them, but also giving the ability to create their own ones.

    There current class diagram will always be found here: https://dl.dropbox.com/u/15011952/RemoteEntities.jpeg but I'll upload the raw file to the repo later as well.

    EDIT: image should be updated to the latest version.
     
  4. Offline

    Wundark

    Looking good, I really need this Library.
     
  5. Offline

    Top_Cat

    You know, you could do this thing called "Forking", maybe even PRs or push access...
     
  6. If I would've been able to build it on top of your basement then sure, I would've probably made (a) pr(s), but since I wasn't able to, there was no other way then starting from zero again. And instead of making a pr which would throw over all of the work you've done, I decided to make a separate repo/project. It's not like I haven't thought about these things. I might not have though about every just so small detail/possibility, but that's just human, you'll never be able to think about everything concerning a specific topic.
     
  7. Alright, pathfinders seem to work pretty well, so all that's left is making it even more customizable!
    Updating to 1.4.2 needs to be done as well though.
     
  8. Offline

    IDragonfire

    Nice URL Class Diagram and project ;)
    A problem with NPCLib from topcat is, that some plugins like AuthMe, Modifyworld stay in conflict with some Entities ...
    Keep that in your mind ...
     
  9. Offline

    ChrisixStudios

    This is an awesome idea! I hope to see the library soon but I don't know how far you are. But over all good work :)
     
  10. I'll see what I can do.

    Actually I'm really far by now, when you don't care about 1.4.2 compatibility, since I'm still missing some entities there. So I'm already planing on making a guide/wiki/video or whatever as an introduction into that library, how to use it and how to customize it to your liking.

    However, I'm still not finished testing everything and I might miss some methods for the individual entities which I'd like to implement before the release.

    Since I have a bit of free time I might post a quick start guide on how to use the lib as it currently is.

    EDIT: Also totally forgot to update the digram on the way. I've added all the changes now though.

    This is just a really really quick example on how you could use it:
    Code:java
    1. public void onEnable()
    2. {
    3. //First we need an instance of the manager
    4. EntityManager manager = new EntityManager(this);
    5. //Using the manager we create a new Zombie npc at the spawn location, but we won't setup the standard desires/goals
    6. RemoteEntity entity = manager.createEntity(RemoteEntity.Zombie, Bukkit.getWorld("world").getSpawnLocation(), false);
    7. //We don't want him to move so we make him stationary
    8. entity.setStationary(true);
    9. //Now we want him to look at the nearest player. this desire has a priority of 1 (the higher the better).
    10. //Since we don't have any other desires 1 is totally fine.
    11. //Note that when you have more than one desire with the same priority, both could get executed, but they'd need a different type (e.g. looking and moving)
    12. //This does not get executed all the time. It might just get executed but he might take a break for 2 seconds after that. It's random.
    13. entity.getMind().addDesire(new DesireLookAtNearest(entity, EntityHuman.class, 8F), 1);
    14. //When a player interacts with him, we want him to tell something to the player.
    15. //I make an anonymous class here, but you can create a whole new class if you want to
    16. //but it needs to extend InteractBehaviour
    17. entity.getMind().addBehaviour(new InteractBehaviour(entity)
    18. {
    19. @Override
    20. public void onInteract(Player inPlayer)
    21. {
    22. inPlayer.sendMessage("Hello " + inPlayer.getName() + "!");
    23. }
    24. });
    25.  
    26. //Lastly we want him to wear a different weapon (which you can do since 1.4.2 or only for players in 1.3.2)
    27. //In order of that to work, we add an EquipmentFeature.
    28. //Again, you can create your own class for that which just needs to implement EquipmentFeature
    29. EqipmentFeature feature = new RemoteEquipmentFeature(entity);
    30. //We now apply it to the entity
    31. entity.getFeatures().addFeature(feature);
    32. //Set the item in the hand
    33. feature.setItemInHand(new ItemStack(Material.DIAMOND_SWORD));
    34. //Update the equipment on the entity.
    35. feature.updateEquipment();
    36. }


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

    IDragonfire

    Any ETA for 1.4.2?
    Maybe I switch from top-cat to your library ;)
    I love your design and first testing with my Plugin cause no problems ;)
    But TagAPI also not work with your library (if I spawn a Human) :(
     
  12. I won't give any eta for anything. I'm programming when I have time to, so there's no way I can predict when it's done. Sometimes I spontaneously finish everything on one day whereas I can barely do anything on another. Sorry, no eta. never.

    But what's the issues with the tag api?
     
  13. Offline

    IDragonfire

    TagAPI & Co listen to "Packet20NamedEntitySpawn" and fire his own events (PlayerReceiveNameTagEvent) , but if I spawn a Human RemoteEntity it doesn't fire the PlayerReceiveNameTagEvent (and they have no filter for the "Packet20NamedEntitySpawn" event). The problem is, that I am not so familiar with bukkit, but I investigate some time to analyse the calls:

    http://forums.bukkit.org/threads/ta...-over-peoples-heads.99485/page-4#post-1404850
     
  14. So what are you trying to do? I mean as far as I can see, the tagAPI is used to color names. When creating the NPC you could just directly insert the colored name, can't you? I'll look into it never the less, but I don't really see the point...
     
  15. Offline

    IDragonfire

    Damm, you are right xD
    Thank you very much !
     
  16. IDragonfire : I tried finding a proper solution to resolve compatibility issues with for example authme or some other plugins but couldn't find a good solution for doing so. The problem is a global api would be needed to be able to determine whether it's a normal entity or npc. There's no such API, nothing even close to that. That's the problem. It was more or less a problem with the economy earlier as well. There was no global API which you could use and you'd have to add support for every economy plugin. Sure we have Vault now, which is great, but we don't have something like that for other needed APIs.
     
  17. Offline

    IDragonfire

    You are right,
    Same problem for building access ...
    WorldGuard, Factions, Towny, BanaRegion and more plugins are managing build rights ...
    Maybe it would be a good idea to implement Remote Entities as a plugin, like ProtocolLib or TagAPI ...
     
  18. Yeah, after I've taken a look at TagAPI I'm pretty sure that it would be a good idea to do so. Won't take too long, should be done in an hour or so...
     
  19. Offline

    IDragonfire

    Nice :)
    If I had time I finish my Timer and start my Access Library ...
     
  20. Alright, changes are made!
    You can no longer create an instance of the EntityManager by your own, the plugin will take care of that. You can now also get the managers of other plugins to be able to hook into their entities as well!
    Code:java
    1. public void onEnable()
    2. {
    3. //This is how we create the manager now:
    4. EntityManager manager = RemoteEntities.createManager(this);
    5.  
    6. //When you lost track of it, you can simply do this to get the instance back:
    7. //you could replace 'this.getName()' with your plugin name to use it anywhere in your plugin with out a reference to your main class
    8. //Using this you can also get manager of other plugins.
    9. EntityManager manager = RemoteEntities.getManagerOfPlugin(this.getName());
    10.  
    11. //Not sure if another plugin already registered a manager? Use this:
    12. boolean registered = RemoteEntities.hasManagerForPlugin("Plugin");
    13. }


    don't forget to add a (soft)dependency to RemoteEntities!
    EDIT: Also, RemoteEntities will automatically despawn all of your entities when your plugin gets disabled. You wouldn't be able to access them after a server restart anyway.
     
  21. Offline

    IDragonfire

  22. I know what a singleton is but it's, as far as I'm concerned, not the best way for the EntityManager. You still want to have an instance per plugin, don't you? When I would make it a singleton, every plugin would share one EntityManager with every other plugin, that's not what I want and not what you want probably as well.
     
  23. Offline

    IDragonfire

    That is the right question and your design decision ...
    I prefer one EntityManager, because as AuthMe author I only want so check one EntityManager ...
    as DragonAntiPvpLeaver author, I wish I had my own EntityManager, or I must live with a shared one ...
    I though you implement new events ...
    Like RemoteEntitySpawns ... RemoteEntityDespawns ... and all plugins can hook into these events ...
    e.g. authMe to proof, if the new player is a real one ...
    As a hooker plugin it is not importang which EntityManager fire these events ...
    ...
    But it is k ... you can fire all events from the EntitiyManagers to a new RemoteEntityManager, or or or ...
    There are many ways to rome ...
     
  24. Good point! I'll probably wrap my head around that and see what I can do.

    Yeah, event need to be done. I had a greater focus on the actual entities, so I'll work on those things now.
     
  25. Offline

    IDragonfire

    Maybe Events are not so important ...
    NPCManager.isRemoteEntity(Entity e)
    Is also an usefull method ...
     
  26. Done that along with one or two other methods.

    They are at least not as important as the general functionality and performance. But they contribute to the usability a lot.
     
  27. Offline

    IDragonfire

    Damm, next time I look first into your code xd
    Great work!!!
     
  28. Alright. Now that the wither is implemented, all the javadocs are written, no idea what's missing from my point of view, I'll just give myself a small break - at least until the weekend. If there's something missing that you think should be inside the lib, feel free to make a ticket or PR on github. You can also post it here, but it would be more organized when it's directly at the repo.

    I'll put up the javadocs on my webserver when I get the time to, which will probably be around the weekend. When that is done, an example is written and I'm sure that nothing major is missing, I'll put up a bukkitdev page, maven repo and other stuff.

    Until then, have a great time trying out the library and have fun!
    ~kumpelblase2.
     
  29. Offline

    drampelt

    You are amazing. I've been trying to get custom entities working for a while but without much luck. Thank you!
    EDIT: I noticed it still uses 1.3.2 craftbukkit. What is the 1.4 status? I don't need any of the new mobs, just wondering if there are any problems with 1.4.
     
  30. see the 1.4.2 branch. it's most likely done.
     
Thread Status:
Not open for further replies.

Share This Page