[LIB] [1.7] Remote entities - Next generation NPC library [No support]

Discussion in 'Resources' started by kumpelblase2, Nov 10, 2012.

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

    kumpelblase2

    I've used that when I tested it and worked fine...

    As far as I can see, some spawn errors even appear randomly to me (e.g. null check throws npe which doesn't make sense). I have no idea why that happens and when it happens, I can only say that the server or the javavm might mess up some things.
    I've tried making the errors appear less often in some cases which seems to work.
    (Lastest snapshot already contains these changes and should fix most of the issues.)
     
  2. Offline

    TeeePeee

    1.4.4 status, my good sir and excellent developer?
     
  3. Offline

    kumpelblase2

    haven't even considered looking into it. Fixing the current issues is more important for me. I might be able to finish it on friday, depending on how much actually changed.
     
  4. Offline

    Lolmewn Retired Staff

    Is there any way to get the name of a RemoteEntity while looping over all of them? I did give it a name while creating it, but cannot find a method to get it back.
     
  5. Offline

    kumpelblase2

    When spawning a named entity, it should always be an instance of Nameable. Casting the entity to Nameable will provide you with methods of getting and setting the name.
     
  6. Offline

    Lolmewn Retired Staff

    Ah, thanks.
     
  7. Offline

    kumpelblase2

    Taken a look into the changes of 1.4.4. ... Should be done by late friday/saturday.
    When someone is looking for the changes I made a list for myself containing the new names that I need (see spoiler). It's not complete, but should be correct.
    Show Spoiler

    Code:
    world.o() -> world.p()
    entity.b_() -> entity.c_()
    world.s() -> world.t()
    world.t() -> world.v()
    world.t() -> world.u()
    world.L() -> world.M()
    world.F() -> world.getDayTime()
    entity.c() -> entity.a()
    entity.bS() -> entity.bW()
    entity.j() -> entity.k()
    entity.bb() -> entity.be()
    entity.aV() -> entity.aX()
    entity.m() -> entity.n()
    entity.bh() -> entity.bk()
    entity.bk() -> entity.bn()
    entity.bG -> entity.bE
    entity.bE -> entity.bC
    entity.bZ -> entity.bW
    entity.bY -> entity.bV
    entity.ca -> entity.bX
    entity.bW -> entity.bU
    entity.bI -> entity.bG
    entity.aF() -> entity.aG()
    entity.l() -> entity.m()
    entity.o() -> entity.p()
    entity.bs() -> entity.bv()
    entity.n() -> entity.o()
    entity.aA() -> entity.aB()
    entity.az() -> entity.aA()
    entity.aB() -> entity.aC()
    entity.k() -> entity.l()
    entity.aI() -> entity.aJ()
    entity.bi() -> entity.bl()
    entity.bg() -> entity.bj()


    New version (1.1) is out!

    Changelog can be found in the first post.

    Note on 1.4.4:
    I already have like 80% done. What's left is basically testing and looking over all the changes again. I've made a separate branch on the repo for those who'd like to check it out.

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

    kumpelblase2

    New version (1.1.1) is out!

    Fixed a major issue with 1.1 .

    Also: changes I made for 1.4.4 seem to be stable, but I won't make a new version until a beta build is out.
     
  9. Offline

    Shiny Quagsire

    It seems that with the 1.4.4 branch the attacking desire classes cause entities to fly up into the air, ie when you make a modified wolf and you attack something, it will go up to attack, then fly into the air. Also, sometimes when I spawn something with a spawn egg and right click or touch it, it crashes with this:
    Code:
    10:48:55 [WARNING] Failed to handle packet for maxietom/127.0.0.1: java.lang.NullPointerException
    java.lang.NullPointerException
        at de.kumpelblase2.remoteentities.entities.RemoteWolfEntity.a(RemoteWolfEntity.java:168)
        at net.minecraft.server.EntityHuman.p(EntityHuman.java:717)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:1038)
        at net.minecraft.server.Packet7UseEntity.handle(SourceFile:36)
        at net.minecraft.server.NetworkManager.b(NetworkManager.java:290)
        at net.minecraft.server.NetServerHandler.d(NetServerHandler.java:112)
        at net.minecraft.server.ServerConnection.b(SourceFile:39)
        at net.minecraft.server.DedicatedServerConnection.b(SourceFile:30)
        at net.minecraft.server.MinecraftServer.r(MinecraftServer.java:595)
        at net.minecraft.server.DedicatedServer.r(DedicatedServer.java:222)
        at net.minecraft.server.MinecraftServer.q(MinecraftServer.java:493)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:426)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:856)
     
  10. Offline

    kumpelblase2

    hm.... It looked fine to me, but I'll look into it later again.

    Tried fixing it, but I couldn't, no idea why.
     
  11. Offline

    ferrybig

    can you give an example how to controll the mind of the npc?
     
  12. Offline

    TeeePeee

    Code:
    aM *= by() * this.bw;
    
    Any idea what by() has changed to or how I can figure it out myself?
    Thanks! :)
     
  13. Offline

    kumpelblase2

  14. Offline

    Lolmewn Retired Staff

  15. Offline

    kumpelblase2

    I assume you're using the 1.1(.1) version on a 1.4.4/1.4.5 server. Won't work as .az() changed to aB() and these changes are only included in the latest 1.2-SNAPSHOT.
     
  16. Offline

    Lolmewn Retired Staff

    Alright, downloading 1.2 :)
     
  17. Offline

    kumpelblase2

    I might got a bit confused because of all the different methods and which one is or was which so, I might be wrong. But testing 1.2 out would be a good idea anyway.
     
  18. Offline

    Lolmewn Retired Staff

    Seems to work now. Thanks.
     
  19. Offline

    kumpelblase2

    Alright guys, made the browsing for the last versions a bit easier for you and for the users.
    When you take a look at my website you can see all the versions and latest snapshots.
    Have fun!
     
  20. Offline

    confuserr

    Managed to get it working with the 1.2 snapshots :D

    Only problem is, zombies don't seem to be attacking anyone, they target the player and run after them, but don't do any damage.
     
  21. Offline

    kumpelblase2

    Checked with the native code, seems like I messed up method there. I'll quickly fix it.
     
  22. Offline

    confuserr

    Thanks.

    Also, any ideas about this? Can't actually join the server. Internal Error on join.

    Code:
    16:31:08 [WARNING] Failed to handle packet for confuserr/127.0.0.1: java.lang.
    llPointerException
    java.lang.NullPointerException
            at de.kumpelblase2.remoteentities.entities.RemoteZombieEntity.c_(Remot
    ombieEntity.java:137)
            at net.minecraft.server.EntityHuman.r(EntityHuman.java:346)
            at net.minecraft.server.EntityHuman.c(EntityHuman.java:338)
            at net.minecraft.server.EntityLiving.j_(EntityLiving.java:508)
            at net.minecraft.server.EntityHuman.j_(EntityHuman.java:154)
            at net.minecraft.server.EntityPlayer.g(EntityPlayer.java:192)
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:348)
            at net.minecraft.server.Packet10Flying.handle(SourceFile:136)
            at net.minecraft.server.NetworkManager.b(NetworkManager.java:290)
            at net.minecraft.server.NetServerHandler.d(NetServerHandler.java:112)
            at net.minecraft.server.ServerConnection.b(SourceFile:39)
            at net.minecraft.server.DedicatedServerConnection.b(SourceFile:30)
            at net.minecraft.server.MinecraftServer.r(MinecraftServer.java:595)
            at net.minecraft.server.DedicatedServer.r(DedicatedServer.java:222)
            at net.minecraft.server.MinecraftServer.q(MinecraftServer.java:493)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:426)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:856)
    >
    Edit: Ah, apears it doesn't like the following, I assumed the entitymanager doesn't save the entities so you have to re-add them when the chunk is loaded?

    Code:
    @EventHandler
        public void onChunkLoad(ChunkLoadEvent event) {
            World world = event.getWorld();
            for (Entity z : event.getChunk().getEntities()) {
                if (z.getType().getTypeId() != zombie) {
                    Location loc = z.getLocation();
                    z.remove();
                    world.spawnEntity(loc, EntityType.ZOMBIE);
                } else {
                    Zombie ze = (Zombie) z;
                    if(!craft.EntityManager.isRemoteEntity(ze)) {
                        RemoteEntity zomb = craft.EntityManager.createRemoteEntityFromExisting(ze);
                        zomb.setSpeed(zombieSpeed);
                        zomb.setMaxHealth(zombieHealth);
                    }
                }
            }
        }
     
  23. Offline

    kumpelblase2

    hm... interesting. No idea how that could actually happen. Same goes for the npes in the tick method for entities...
    However, when working with the nms code everything seems to be strange some times...
    Fixed in latest snapshot anyway.
     
  24. Offline

    confuserr

    Code:
    17:37:05 [SEVERE] Encountered an unexpected exception ReportedException
    net.minecraft.server.ReportedException: Ticking entity
            at net.minecraft.server.MinecraftServer.r(MinecraftServer.java:581)
            at net.minecraft.server.DedicatedServer.r(DedicatedServer.java:222)
            at net.minecraft.server.MinecraftServer.q(MinecraftServer.java:493)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:426)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:856)
    Caused by: java.lang.NullPointerException
            at de.kumpelblase2.remoteentities.entities.RemoteZombieEntity.die(Remote
    ZombieEntity.java:177)
            at net.minecraft.server.EntityLiving.damageEntity(EntityLiving.java:730)
     
            at net.minecraft.server.EntityMonster.damageEntity(EntityMonster.java:39
    )
            at net.minecraft.server.EntityLiving.y(EntityLiving.java:349)
            at net.minecraft.server.Entity.j_(Entity.java:230)
            at net.minecraft.server.EntityLiving.j_(EntityLiving.java:482)
            at net.minecraft.server.EntityMonster.j_(EntityMonster.java:24)
            at net.minecraft.server.EntityZombie.j_(EntityZombie.java:121)
            at de.kumpelblase2.remoteentities.entities.RemoteZombieEntity.j_(RemoteZ
    ombieEntity.java:129)
            at net.minecraft.server.World.entityJoinedWorld(World.java:1333)
            at net.minecraft.server.WorldServer.entityJoinedWorld(WorldServer.java:5
    46)
            at net.minecraft.server.World.playerJoinedWorld(World.java:1315)
            at net.minecraft.server.World.tickEntities(World.java:1193)
            at net.minecraft.server.WorldServer.tickEntities(WorldServer.java:444)
            at net.minecraft.server.MinecraftServer.r(MinecraftServer.java:577)
            ... 4 more
    Looks like its clearing desires when there aren't any?
     
  25. Offline

    kumpelblase2

    The problem is that, for some reason, the remote entity instance is null. I have no idea why that happens. Moreover, I can't force the constructor with the remote entity parameter because otherwise the nms code will fuck up in many cases, I can just say that every time I spawn one that I use that constructor. Also, these errors don't happen consistently, they appear totally random. This makes it even harder to find the actual source why the instance is null. I can more or less 'fix' them but that will just push the problem away instead of solving it directly.
     
  26. Offline

    fullwall

    kumpelblase2 - looking at your code here
    It seems that the code comes at least in part from Citizens. Could you please add some attribution per the terms of our license?
     
  27. Offline

    bergerkiller

    kumpelblase2 fullwall

    Good I see this in time...

    Does this plugin replace every single entity spawned on the server? Like, every single one of them? Or do you, as the plugin author, replace the entities manually/spawn them?

    Reason I ask is that if you do this by default (like I do only for minecarts in TrainCarts), it is going to render quite some custom entity based plugins useless...which includes TrainCarts and a plugin to ride ender dragons I believe.
     
  28. Offline

    kumpelblase2

    Well, I actually had this in mind instead of your code, which you also got from there, don't you? So I don't really see the point in giving credits here... However, I can't deny that I probably looked over your code at some point in time to see how you've managed certain things.

    No entity will be replaced until you manually do so. BUT since I need to register the entity class in the entity type enum, the server will spawn them later by itself. I'd like to prevent that but I haven't found a good way of doing it so far. I hope that I can come up with a decent solution at some point in the future.
     
  29. Offline

    Lolmewn Retired Staff

    What's the difference between pushable and stationary? When stationary = true, and pushable = true, the NPC cannot be pushed (I guess because it's stationary?)

    I have another slight issue. It seems I am unable of using the getRemoteEntityFromID function correctly.
    I create the entity like this:
    RemoteEntity ent = plugin.getEntityManager().createNamedEntity(type, ((Player) sender).getLocation(), args[1]);
    type being Human and args[1] being the name (in case of testing, Derp).
    I save the ent.getID() to a manager of my own, adding some more features. However, when getting all ID's back, it seems I cannot get the RemoteEntity attached to it. Code:
    Code:java
    1.  
    2. for(NPCWrapper n : this.getNPCManager().getAllNPCs()){
    3. RemoteEntity ent = this.getEntityManager().getRemoteEntityByID(n.getEntityID());
    4. if(ent == null){
    5. System.out.println("NPCWrapper returned an null RemoteEntity: " + n.getEntityID() + ", skipping");
    6. continue;
    7. }

    It seems ent is always null. Am I missing something, am I doing something stupid?

    I've narrowed down the issue some more, it seems the method getEntityManager().getAllEntities() from the EntityManager class returns 0 entities. This happens when the plugin is disabling, though.
    I've set up a listener, checking if remoteEntities is disabling, but it doesn't seem to pick it up (I'm guessing my plugin gets disabled first, since it's dependent of Remote-Entities).
    This would mean that, instead of saving it when the plugin is disabling, I have to save all changes done to it in real-time. Is there anything I can do to fix this?

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

    kumpelblase2

    Stationary means that the entity will always be at the same spot, no matter what happens. Pushable means that it can be pushed by other entities or, when it's false, not.

    Listen on the RemoteEntityDespawnEvent which gets fired when an entity gets despawned. You can check the despawn reason which should be in your case be 'PLUGIN_DISABLE'. I sadly don't have the time to take a look into it now, but I try to do that tomorrow after school.
     
Thread Status:
Not open for further replies.

Share This Page