[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

    Hatchcatch020

    kumpelblase2 Ahh well thats a bum.. But okay another question. I am using .perpareEntity() to create an entity then spawn it on command however I want to add movement desires, when I tried using .withMovementDesires() I could not understand what I was supposed to put in the parentheses, I searched the docs but just couldnt get my head around it.

    Here is my code anyway :
    Code:java
    1. public CreateEntityContext Pguard = manager.prepareEntity(RemoteEntityType.Human).withName("Personal Guard").withID(10);
     
  2. Offline

    confuserr

    kumpelblase2 Has setting speed changed at all for mc 1.6.2? I set the speed like I have done since mc 1.4 with the same values and they appear to be moving extremely slow now. I increased it a lot, zombies that aren't targeting a player were then moving very very fast lol due to the change, but as soon as they targeted a player, they slowed right down, almost as though it was vanilla speed. I have the latest 1.7 snapshot from the repo. Not sure if it is a bug or something I need to change hence why I haven't posted this on github.
     
  3. Offline

    kumpelblase2

    Hatchcatch020 This is in fact sort of my fault. Earlier you couldn't create a desire without a remote entity instance, thus adding desires in the context was technically possible but practically not really. This has changed in the latest snapshot (you can easily provide 'null' and it will get set afterwards). So much about that. What is requested is an array of DesireItems which is essentially just a holder class for the two values: the desire and it's priority. So you'd just pass over as many desire items as you want.

    confuserr It's because of the attribute system which got added in 1.6.1 . Everything needs to be polished and that's one thing which isn't yet.
     
  4. Offline

    confuserr

    kumpelblase2 Is there anyway around that for the time being until craftbukkit implements an attributes api?
     
  5. Offline

    bluegru

    is it able to change the speed of a player?
     
  6. Offline

    Hatchcatch020

    Is there an example of how I could do this ?
     
  7. Offline

    kumpelblase2

    Hatchcatch020 I don't think one is needed. Just create a new menu item, the only constructor there is takes two arguments, the priority and the desire itself. Either create an array out of these menu items or just pass them in all after another.

    confuserr Besides me fixing it, I don't know.

    bluegru yes.
     
  8. Offline

    Hatchcatch020

    kumpelblase2 So this is what I should do ?

    Code:java
    1. public CreateEntityContext Pguard = manager.prepareEntity(RemoteEntityType.Human).withName("Personal Guard").withID(10).withMovementDesires(new DesireItem(new DesireLookRandomly(null), 1));


    Then how and what do I replace the null with ?
     
  9. Offline

    bluegru


    And how do i do something like that?
    Code?
     
  10. Offline

    kumpelblase2

    confuserr I updated the desires a bit, so it might be fixed now.

    Hatchcatch020 Like I said in #458, it is technically possible to do so but currently (v1.6) it's not possible do create a desire without an entity. Thus you have to apply and create the desire after you created the entity (entity.getMind().addMovementDesire(...)). However, in 1.7 you can just remove the parameter because there are now constructors provided which don't need an entity as parameter and thus can be used in the createentitycontext.

    bluegru Come on. Is it so hard to think about a method that sets speed? 'setSpeed' maybe? No that would be too easy.

    From my side, the version seems stable and will probably be done tonight. If you find something, please report it so I can fix it before release.

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

    bluegru


    :|
    setSpeed is not the problem, but how do i get the player as remote entity?

    Code:java
    1. de.kumpelblase2.remoteentities.EntityManager manager = RemoteEntities.createManager(this);
    2. RemoteEntity entity = manager.getRemoteEntityFromEntity(player);
    3. entity.setSpeed(5);


    but i get a NPE

    and what is the default speed of a player/entity?
     
  12. Offline

    kumpelblase2

    bluegru It results in an npe because 'player' is probably a normal player, not a remote entity. You'd have to create it first with the manager (see createRemoteEntityFromExisting in EntityManager to use an already existing entity or just use createNamedEntity for a new one.).
     
  13. Offline

    bluegru

    Code:java
    1. de.kumpelblase2.remoteentities.EntityManager manager = RemoteEntities.createManager(this);
    2. RemoteEntity entity = manager.createRemoteEntityFromExisting(player);
    3. entity.setSpeed(2);


    it spawns a Human with my name and skin
     
  14. Offline

    kumpelblase2

    bluegru and that is what is expected isn't it?


    Alright, 1.7 is now pushed out and available via the maven repo (-> web interface)! BukkitDev will follow shortly.
    Changelog:
    Code:
    - Updated to minecraft 1.6.2
        - Updated desire logic
        - Added horse
        - Use attributes for speed
    - Added event for touching and pushing an entity
    - Added event for creating (not spawning) and entity
    - Added ability to change pathfinding range
    - Added serialization for features and behaviors
    - Added trading feature (see examples)
    - Added ability to add a speed modifier to an entity
    - Added error prevention with incompatible minecraft versions by disabling
    - Javadoc updates
    - Fix DesireMoveToLocation not finishing sometimes
    - Changed desires so they can be created without an entity and could be reapplied to a different entity
    - Vectors will now get released when they aren't used anymore.
    - createNamedEntity will now create an entity with a custom name when it's not a human entity
    - Fixed some spawning issues, including players
    - When using DesireWanderAroundArea, the entity will now also try to move back into the area when it went outside
    - Pigmen will now use the default desires of zombies
    - Internal changes and updates
     
  15. Offline

    jb_aero

    If all you want to do is make actual player faster, you can use pure Bukkit for that.
    Code:java
    1. Bukkit.getPlayer("bluegru").setWalkspeed(0.2f);
     
    bluegru likes this.
  16. Offline

    TomFromCollege

    Ok, I got a bug after creating a Chicken and giving it the now deprecated DesireFollow (Why the deprecation?) This is with the 1.7 full release :)
    Code:
    2013-07-14 20:38:46 [SEVERE] java.lang.NullPointerException
    2013-07-14 20:38:46 [SEVERE]    at de.kumpelblase2.remoteentities.api.thinking.goals.DesireSwim.<init>(DesireSwim.java:25)
    2013-07-14 20:38:46 [SEVERE]    at de.kumpelblase2.remoteentities.entities.RemoteChickenEntity.getDefaultMovementDesires(RemoteChickenEntity.java:121)
    2013-07-14 20:38:46 [SEVERE]    at de.kumpelblase2.remoteentities.entities.RemoteChickenEntity.setupStandardGoals(RemoteChickenEntity.java:51)
    2013-07-14 20:38:46 [SEVERE]    at de.kumpelblase2.remoteentities.ChunkEntityLoader.spawn(ChunkEntityLoader.java:134)
    2013-07-14 20:38:46 [SEVERE]    at de.kumpelblase2.remoteentities.ChunkEntityLoader.queueSpawn(ChunkEntityLoader.java:122)
    2013-07-14 20:38:46 [SEVERE]    at de.kumpelblase2.remoteentities.EntityManager.createEntity(EntityManager.java:138)
    2013-07-14 20:38:46 [SEVERE]    at de.kumpelblase2.remoteentities.EntityManager.createEntity(EntityManager.java:114)
    2013-07-14 20:38:46 [SEVERE]    at co.mcparty.manager.PetManager.spawnPet(PetManager.java:117)
    2013-07-14 20:38:46 [SEVERE]    at co.mcparty.manager.PlayerManager.login(PlayerManager.java:218)
    2013-07-14 20:38:46 [SEVERE]    at co.mcparty.manager.WebManager.handleRecieve(WebManager.java:138)
    2013-07-14 20:38:46 [SEVERE]    at co.mcparty.manager.WebManager$4.run(WebManager.java:287)
    
    (I'm not adding a desire swim and I'm also calling
    entity.getMind().clearBehaviours();
    entity.getMind().clearMovementDesires();
    entity.getMind().clearTargetingDesires();
     
  17. Offline

    kumpelblase2

    TomFromCollege Thanks, fixed.

    Please redownload if you already downloaded. Thanks.
     
  18. Offline

    ICodeMaster

    kumpelblase2
    Just curious because i saw this was updated (gotta play with it later) but are flying mobs pathing fixed? In the last version i tried the ride-able ender dragons and i tried some things with ghasts but it causes a very long loop of sorts. Ill have to retest it tonight just wanted to check if you fixed it :p
     
  19. Offline

    kumpelblase2

    ICodeMaster It wasn't fixed, because I haven't had the time to do so. Sorry.



    On another note, development will be paused for about a month from tomorrow, because I'm on vacation. I might take a look at the thread here and there, but not that regularly. You may still create tickets/PRs on github and I will take care of them once I get back.
    Have some nice days!
     
  20. Offline

    Woodenplanks320

    Code:java
    1. EntityManager manager = RemoteEntities.createManager(this);
    2. RemoteEntity entity = manager.createEntity(RemoteEntity.Zombie, Bukkit.getWorld("world").getSpawnLocation(), false);
    3. entity.setStationary(true);
    Zombie cannot resolved or is not a field
     
  21. Offline

    Hatchcatch020

    Okay so kumpelblase2 my line should be like this :
    Code:java
    1. public CreateEntityContext Pguard = manager.prepareEntity(RemoteEntityType.Human).withName("Personal Guard").withID(10).withMovementDesires(new DesireItem(new DesireLookRandomly(), 1));


    With the latest build on Jenkins that is.
     
  22. Offline

    Snipey

    ive looked though the java docs of this and cannot find where i can make a mob not take damage.
     
  23. Offline

    confuserr

    Just listen to the entity damage event and cancel it.
     
  24. Offline

    bluegru

    Snipey
    Code:java
    1. @EventHandler
    2. public void onEntityDamagedByEntity(EntityDamageByEntityEvent event){
    3.  
    4. if(event.getEntity().getType().getName().equalsIgnoreCase("villager")){
    5.  
    6. event.setCancelled(true);
    7.  
    8. }
    9.  
    10. }


    villager can't get damage
     
  25. Offline

    Snipey

    *facepalm* -_- sorry was incredibly tired when i asked this D: thanks that worked
     
  26. Offline

    gyroninja

    Ok, this is a pretty nice library. Though I am having a problem. I can not set the yaw of the Human Entity. They pitch seems to work just fine put my "NPC's" head's yaw is always 0.

    Code:
    entity.teleport(new Location((World) pa.arguments.get(0), (Double) pa.arguments.get(1), (Double) pa.arguments.get(2), (Double) pa.arguments.get(3)));
     
                            entity.setHeadYaw((Float) pa.arguments.get(4));
                            entity.setYaw((Float) pa.arguments.get(4));
                            entity.setPitch((Float) pa.arguments.get(5));
     
                            entity.getMind().fixHeadYawAt((Float) pa.arguments.get(4));
                            entity.getMind().fixYawAt((Float) pa.arguments.get(4));
                            entity.getMind().fixPitchAt((Float) pa.arguments.get(5));
     
                            entity.lookAt(new Location((World) pa.arguments.get(0), (Double) pa.arguments.get(1), (Double) pa.arguments.get(2), (Double) pa.arguments.get(3)));
    I took some of this code form someone having the same problem as me earlier in the thread. but this code still dose not work. pa.arguments is an List which contains valid location and yaw data.
     
  27. Offline

    TomFromCollege

    Don't mean to be the bearer of bad news! :/

    Code:
    2013-07-17 21:22:15 [SEVERE] net.minecraft.server.v1_6_R2.ReportedException: Ticking entity
    2013-07-17 21:22:15 [SEVERE]    at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:576)
    2013-07-17 21:22:15 [SEVERE]    at net.minecraft.server.v1_6_R2.DedicatedServer.t(DedicatedServer.java:226)
    2013-07-17 21:22:15 [SEVERE]    at net.minecraft.server.v1_6_R2.MinecraftServer.s(MinecraftServer.java:486)
    2013-07-17 21:22:15 [SEVERE]    at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java:419)
    2013-07-17 21:22:15 [SEVERE]    at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:582)
    2013-07-17 21:22:15 [SEVERE] Caused by: java.util.ConcurrentModificationException
    2013-07-17 21:22:15 [SEVERE]    at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:819)
    2013-07-17 21:22:15 [SEVERE]    at java.util.ArrayList$Itr.next(ArrayList.java:791)
    2013-07-17 21:22:15 [SEVERE]    at de.kumpelblase2.remoteentities.api.thinking.DesireSelector.onUpdate(DesireSelector.java:31)
    2013-07-17 21:22:15 [SEVERE]    at de.kumpelblase2.remoteentities.api.thinking.Mind.tick(Mind.java:389)
    2013-07-17 21:22:15 [SEVERE]    at de.kumpelblase2.remoteentities.entities.RemoteZombieEntity.l_(RemoteZombieEntity.java:68)
    2013-07-17 21:22:15 [SEVERE]    at net.minecraft.server.v1_6_R2.World.entityJoinedWorld(World.java:1354)
    2013-07-17 21:22:15 [SEVERE]    at net.minecraft.server.v1_6_R2.World.playerJoinedWorld(World.java:1335)
    2013-07-17 21:22:15 [SEVERE]    at net.minecraft.server.v1_6_R2.World.tickEntities(World.java:1223)
    2013-07-17 21:22:15 [SEVERE]    at net.minecraft.server.v1_6_R2.WorldServer.tickEntities(WorldServer.java:480)
    2013-07-17 21:22:15 [SEVERE]    at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:572)
    2013-07-17 21:22:15 [SEVERE]    ... 4 more
    2013-07-17 21:22:15 [SEVERE] Encountered an unexpected exception ReportedException
    net.minecraft.server.v1_6_R2.ReportedException: Ticking entity
            at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:576)
            at net.minecraft.server.v1_6_R2.DedicatedServer.t(DedicatedServer.java:226)
            at net.minecraft.server.v1_6_R2.MinecraftServer.s(MinecraftServer.java:486)
            at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java:419)
            at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:582)
    Caused by: java.util.ConcurrentModificationException
            at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:819)
            at java.util.ArrayList$Itr.next(ArrayList.java:791)
            at de.kumpelblase2.remoteentities.api.thinking.DesireSelector.onUpdate(DesireSelector.java:31)
            at de.kumpelblase2.remoteentities.api.thinking.Mind.tick(Mind.java:389)
            at de.kumpelblase2.remoteentities.entities.RemoteZombieEntity.l_(RemoteZombieEntity.java:68)
            at net.minecraft.server.v1_6_R2.World.entityJoinedWorld(World.java:1354)
            at net.minecraft.server.v1_6_R2.World.playerJoinedWorld(World.java:1335)
            at net.minecraft.server.v1_6_R2.World.tickEntities(World.java:1223)
            at net.minecraft.server.v1_6_R2.WorldServer.tickEntities(WorldServer.java:480)
            at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:572)
            ... 4 more
    
     
  28. Offline

    kumpelblase2

  29. Offline

    gyroninja

    To my previous issue, a zombie or villager. Works. But using a human remote entity dose not work with changing the yaw..
     
  30. Offline

    ICodeMaster

    On what scale or range does setHeadYaw work? Is it in degrees and what number would make a mobs head look up?

    Edit:

    Also should my creeper try to murder things?

    Code:java
    1. entity = managerE.createEntity(RemoteEntityType.Creeper, Bukkit.getPlayer("1CodeMaster").getLocation(), false);
    2. float yaw = Bukkit.getPlayer("1CodeMaster").getLocation().getYaw();
    3. Bukkit.getPlayer("1CodeMaster").sendMessage("" + yaw);
    4. entity.setName("Bobo the Bomber");
    5. entity.getMind().clearMovementDesires();
    6. RemoteTamingFeature tame = new RemoteTamingFeature();
    7. tame.tame(Bukkit.getPlayer("1CodeMaster"));
    8. entity.getFeatures().addFeature(tame);
    9. DesireFollowSpecific desire = new DesireFollowSpecific(Bukkit.getPlayer("1CodeMaster"), 5, 10);
    10. entity.addSpeedModifier(100, true);
    11. entity.getBukkitEntity().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 100000, 7), true);
    12. entity.getMind().addMovementDesire(desire, 1);
    13. entity.getMind().addMovementDesire(new DesireLookAtNearest(Player.class, 8F), 2);
    14. entity.getMind().addTargetingDesire(new DesireFindNearestTarget(Zombie.class, 10, true, 100), 9);
    15. entity.getMind().addTargetingDesire(new DesireMoveToTarget(3), 10);
    16. entity.getMind().addBehaviour(new InteractBehavior(entity)
    17. {
    18. @Override
    19. public void onInteract(Player inPlayer)
    20. {
    21. ParticleEffect.HEART.play(entity.getBukkitEntity().getLocation(), 1, 1, 1, 5, 60);
    22. }
    23. });


    No errors, only the desires aren't working
     
Thread Status:
Not open for further replies.

Share This Page