[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

    gyroninja

    Well its in minecraft degrees. Pretty sure it goes from -127 to 127 .
     
  2. Offline

    bluegru

    ICodeMaster
    Its from -180 to 180, (0=South)(90=West)(-90=East)(180|-180=North)
    and look up and down is not Yaw, its pitch
     
  3. Offline

    Ultimate_n00b

    :confused: your library is now for 1.7?
     
  4. Offline

    shohouku

    Any ideas on how to cancel damage behavior?

    :confused:
     
  5. Offline

    bluegru

    entitydamageentity Event
    cancel event
     
  6. Offline

    lzravanger

    kumpelblase2 The maven dependencies section still says 1.6 when it should say 1.7.

    Great plugin, amazing API. Definitely using in the future.
     
  7. Offline

    TomFromCollege

    Unfortunately, the issue and concurrentModificationError mentioned above has caused me to completely abandon RemoteEntities until it's resolved, any ideas Kumpel?
    I realize Concurrency errors are usually quite deep when they are found and will no doubt take some reworking of your current code structure... Any news at all!? :p
     
  8. Offline

    krazytraynz

    How would I set the Parent of an NPC?
     
  9. Offline

    Comphenix

    You could also clone Remote Entities and debug it yourself.

    The problem is that this array is being modified from a different thread. The stack trace you posted depicts the main thread, so it won't help you track down the offending multi-threaded access.

    In order to debug this, I would create a custom ArrayList that throws whenever it is accessed by a different thread than the main thread (Bukkit.getServer().isPrimaryThread()). That way, you'll find the actual cause of this problem, which could very well be your own plugin.

    Are you using async tasks, by the way (runTaskAsynchronously)? If you are, you should look through it and make sure you never call the API through a different thread.
     
  10. Offline

    Milkywayz

    Download link is broken, I'll compile the code from github but just letting you know kumpelblase2

    Edit: I see the jenkins is still working, so it's all good.
     
  11. Offline

    tylersyme

    I am getting this error
    Code:
    19:19:32 [INFO] [RemoteEntities] Disabling RemoteEntities v1.7
    19:19:32 [INFO] [Mobs] Disabling Mobs v1.0
    19:19:32 [INFO] [Mobs] Loading Mobs v1.0
    19:19:32 [INFO] [RemoteEntities] Loading RemoteEntities v1.7
    19:19:32 [INFO] [Mobs] Enabling Mobs v1.0
    19:19:32 [SEVERE] Error occurred while enabling Mobs v1.0 (Is it up to date?)
    de.kumpelblase2.remoteentities.exceptions.PluginNotEnabledException: RemoteEntities needs to be enable in order to use this operation
        at de.kumpelblase2.remoteentities.RemoteEntities.createManager(RemoteEntities.java:66)
        at me.minecraft.username.tylersyme.Main.onEnable(Main.java:28)
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:457)
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381)
        at org.bukkit.craftbukkit.v1_6_R2.CraftServer.loadPlugin(CraftServer.java:282)
        at org.bukkit.craftbukkit.v1_6_R2.CraftServer.enablePlugins(CraftServer.java:264)
        at org.bukkit.craftbukkit.v1_6_R2.CraftServer.reload(CraftServer.java:605)
        at org.bukkit.Bukkit.reload(Bukkit.java:275)
        at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:23)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:189)
        at org.bukkit.craftbukkit.v1_6_R2.CraftServer.dispatchCommand(CraftServer.java:523)
        at org.bukkit.craftbukkit.v1_6_R2.CraftServer.dispatchServerCommand(CraftServer.java:512)
        at net.minecraft.server.v1_6_R2.DedicatedServer.ar(DedicatedServer.java:262)
        at net.minecraft.server.v1_6_R2.DedicatedServer.t(DedicatedServer.java:227)
        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)
    19:19:32 [INFO] [RemoteEntities] Enabling RemoteEntities v1.7
    19:19:32 [INFO] Server permissions file permissions.yml is empty, ignoring it
    19:19:33 [INFO] CONSOLE: Reload complete.
    
    The Remote_Entities.jar Library is in my plugins folder

    Code:
    package me.minecraft.username.tylersyme;
     
    import net.minecraft.server.v1_6_R2.Material;
     
    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.java.JavaPlugin;
     
    import de.kumpelblase2.remoteentities.CreateEntityContext;
    import de.kumpelblase2.remoteentities.EntityManager;
    import de.kumpelblase2.remoteentities.RemoteEntities;
    import de.kumpelblase2.remoteentities.api.RemoteEntity;
    import de.kumpelblase2.remoteentities.api.RemoteEntityType;
    import de.kumpelblase2.remoteentities.api.events.RemoteEntityTouchEvent;
    import de.kumpelblase2.remoteentities.api.thinking.Behavior;
    import de.kumpelblase2.remoteentities.persistence.BehaviorData;
     
    public class Main extends JavaPlugin implements Listener {
       
        private EntityManager manager;
       
        public void onEnable()
        {
            manager = RemoteEntities.createManager(this);
           
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
        }
       
        public void spawnNPC(String name, Location loc)
        {
            CreateEntityContext c = manager
                    .prepareEntity(RemoteEntityType.Human)
                    .asPushable(true)
                    .asStationary(false)
                    .atLocation(loc)
                    .withName(name);
           
            RemoteEntity re = c.create();
        }
       
        @EventHandler
        public void onPlayerJoin(PlayerJoinEvent e)
        {
            spawnNPC(e.getPlayer().getName(), e.getPlayer().getLocation());
        }
    }
    The error is in the "onEnable" method where I initialize "manager"

    The problem is that my plugin is loading and trying to enable before your library does, so how would I fix that?
     
  12. Offline

    thecrystalflame

    tylersyme
    I had this same problem, the reason you are getting the error is because the RemoteEntities plugin has not finished enabling when your plugin requires it to be. I got some help and had it fixed by adding a delayed task before initilizing the EntityManager

    delayed task:
    Code:java
    1.  
    2. Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    3. @Override
    4. public void run(){
    5.  
    6. }
    7. }, 60L);
    8.  

    kumpelblase2
    this is a very neat library and thanks for taking the time to bring it to us, although i'm having a problem
    I am currently using the 1.8-SNAPSHOT
    I cant seem to get the human entity looking at the nearest player, the method you showed as example in the description of this post no longer works, so I have tried changing it to this,

    Code:java
    1.  
    2. entity.getMind().addMovementDesire(new DesireLookAtNearest(Player.class, 8f, 1f), 1);
    3.  


    not sure if its just a simple mistake or not, thanks in advance.
     
  13. Offline

    Muffin89

    Kumpelblase2 is on vacation to around 13/08/12. But he might be back earlier and a bit later as well. Just wanted to let you to know so you do not think he is ignoring or has left the project :)
     
  14. Offline

    desht

    Trying to get to grips with this library now - looks pretty good, but I have a question. I want to get one RemoteEntity to go and kill another. I'm using this code:
    PHP:
    LivingEntity e otherEntity.getBukkitEntity();
    entity.getMind().addMovementDesire(new DesireKillTarget(e), 100);
    However, this seems to require importing CraftBukkit, since I'm getting this compilation error:
    Code:
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project chesscraft: Compilation failure
    [ERROR] /home/des/workspace/ChessCraft/src/main/java/me/desht/chesscraft/chess/pieces/EntityChessStone.java:[62,38] cannot access net.minecraft.server.v1_6_R2.EntityLiving
    [ERROR] class file for net.minecraft.server.v1_6_R2.EntityLiving not found
    [ERROR] entity.getMind().addMovementDesire(new DesireKillTarget(e), 100);
    
    I could add a dependency on CraftBukkit, but I really don't want to. I thought part of the reason for RemoteEntities was to insulate plugin developers from tracking CB versions.

    On a related note, what's the best way to get notification about when the first entity succeeds in killing the second one? I could:
    • Subclass DesireKillTarget and override the stopExecuting() method (and check isFinished()), or
    • Add a DamageBehaviour to the second entity, which fires when the entity's health is <= 0
    Thoughts?

    A few more observations, having spent a couple of hours playing with this:
    • If you spawn a pigman with no default desires, it wanders off; unlike all other mobs, which just stand still.
    • I spawn a bunch of mobs with names (many with the same name, e.g. "Black Pawn", "White Pawn", etc.) and no default desires, and they stand motionless, as expected. I keep a persistent handle on all the mobs I've spawned, but if I log out & in again (no server restart/reload), all the named mobs I spawned seem to have regained their default desire - e.g. any spawned zombies immediately attack. In addition, there are a bunch of new, unnamed, mobs standing motionless where the named mobs are supposed to be. What's going on here? Update: so it looks like it happens when the chunk containing the remote entity mobs unloads - on reload, we have the problem I saw above. How do I get around that?
    • Is there any way to override the mob sounds? I could use ProtocolLib here if needed, just wondering if RemoteEntities provided any built-in mechanism (I can't see one offhand)
    • getYaw() definitely isn't working, assuming the yaw value is the usual Minecraft value (as reported by F3). Seems I'm not the only one to notice this.

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

    Alex3543

    How can you set the armor of a human entity?!
     
  16. Offline

    Diederikmc

    So yeah, where can I find the javadocs or something like that? The page doesn't exist. :(
     
    TheGreenGamerHD likes this.
  17. Offline

    silthus

    Has anybody written a SQLSerializer yet? Or has an idea how to write one that also will serialize all the features and so on?
     
  18. Offline

    dram

    Do you know how to block spawn monsters by server (on night, or in dark places) on special location.

    But allow to spawn monsters with remote entities ?
    What is default value of speed (for zombie etc)
    When i respawn zombie by this - Zombie is not moving :|
    Code:
                        EntityManager manager = RemoteEntities.createManager(this);
                        RemoteEntity entity = manager.createEntity(RemoteEntityType.Zombie, ((Player) sender).getLocation(), true);
                        entity.getBukkitEntity().getEquipment().setChestplate(new ItemStack(300, 1));
                        ((Player) sender).sendMessage(entity.getName());
                        
     
  19. Offline

    noamro

    Why it dosnt work??

    entity.getMind().addMovementDesire(new DesireLookAtNearest(Player.class, 8f, 1f), 1);
     
  20. Offline

    confuserr

    Yes, within the entity spawn event, check to see if the entity that is spawned is a RemoteEntity.

    Code:
    EntityManager.isRemoteEntity(event.getEntity())
    Something along those lines.

    You also need to setup the zombies with their default desires if it's not doing anything.

    Code:
    ((RemoteEntityHandle) remoteEntityZombie.getHandle()).setupStandardGoals();
     
  21. Offline

    kumpelblase2

    Just got back last night, still didn't really caught up with everything so... The only thing I know so far is that my friend update the server which fucked up the file system and the automated backups from the hosting company contained everything except the website contents. What does that mean? Maven repo is completely wiped out and the docs are gone. Re-uploading the docs won't be an issue but it will take some time until the maven repo is back up and populated. Good thing that the jenkis is running on a different server. But like I said, it might take some time.

    desht How about checking for entity death event and check which entity it is? I will also take a look at the things you mentioned, especially the issue with the error and the issue with the yaw value, maybe I fucked up something when I updated the library.

    Alex3543 Get the bukkit entity and do it like you normally would.

    silthus I would have done it already, but there's an issue I would have with it. It would have to be really dynamic when it comes to how and what it should save. I'm fine with having a large file full of information but I hate having a table which has too many columns which would be required to save everything. Moreover, sometimes I don't need all the information of the entity and just some simple things and thus I would prefer writing my own serializer for one specific project.

    noamro I'll check that.

    Docs are back up!
    Maven repo should work again for the 1.7 release. I'll try to upload older versions as well, but that will follow tomorrow.

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

    ZeusAllMighty11 Retired Staff

    Code:
    11.08 09:44:09 [Server] INFO Caused by: java.lang.NullPointerException
    11.08 09:44:09 [Server] INFO at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:582)
    11.08 09:44:09 [Server] INFO at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java:419)
    11.08 09:44:09 [Server] INFO at net.minecraft.server.v1_6_R2.MinecraftServer.s(MinecraftServer.java:486)
    11.08 09:44:09 [Server] INFO at net.minecraft.server.v1_6_R2.DedicatedServer.t(DedicatedServer.java:226)
    11.08 09:44:09 [Server] INFO at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:576)
    11.08 09:44:09 [Server] INFO net.minecraft.server.v1_6_R2.ReportedException: Ticking entity
    11.08 09:44:09 [Server] SEVERE Encountered an unexpected exception ReportedException
    11.08 09:44:09 [Server] SEVERE ... 4 more
    11.08 09:44:09 [Server] SEVERE at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:572)
    11.08 09:44:09 [Server] SEVERE at net.minecraft.server.v1_6_R2.WorldServer.tickEntities(WorldServer.java:480)
    11.08 09:44:09 [Server] SEVERE at net.minecraft.server.v1_6_R2.World.tickEntities(World.java:1223)
    11.08 09:44:09 [Server] SEVERE at net.minecraft.server.v1_6_R2.World.playerJoinedWorld(World.java:1335)
    11.08 09:44:09 [Server] SEVERE at net.minecraft.server.v1_6_R2.World.entityJoinedWorld(World.java:1354)
    11.08 09:44:09 [Server] SEVERE at de.kumpelblase2.remoteentities.entities.RemotePlayerEntity.l_(RemotePlayerEntity.java:91)
    11.08 09:44:09 [Server] SEVERE at de.kumpelblase2.remoteentities.api.thinking.Mind.tick(Mind.java:390)
    11.08 09:44:09 [Server] SEVERE at de.kumpelblase2.remoteentities.api.thinking.DesireSelector.onUpdate(DesireSelector.java:56)
    11.08 09:44:09 [Server] SEVERE at de.kumpelblase2.remoteentities.api.thinking.goals.DesireWanderAround.startExecuting(DesireWanderAround.java:70)
    11.08 09:44:09 [Server] SEVERE at de.kumpelblase2.remoteentities.entities.RemoteBaseEntity.move(RemoteBaseEntity.java:125)
    11.08 09:44:09 [Server] SEVERE at de.kumpelblase2.remoteentities.entities.RemoteBaseEntity.move(RemoteBaseEntity.java:134)
    11.08 09:44:09 [Server] SEVERE at de.kumpelblase2.remoteentities.nms.PlayerNavigation.a(PlayerNavigation.java:83)
    11.08 09:44:09 [Server] SEVERE at de.kumpelblase2.remoteentities.nms.PlayerNavigation.a(PlayerNavigation.java:78)
    11.08 09:44:09 [Server] SEVERE at de.kumpelblase2.remoteentities.nms.PlayerNavigation.d(PlayerNavigation.java:73)
    11.08 09:44:09 [Server] SEVERE Caused by: java.lang.NullPointerException
    11.08 09:44:09 [Server] SEVERE at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:582)
    11.08 09:44:09 [Server] SEVERE at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java:419)
    11.08 09:44:09 [Server] SEVERE at net.minecraft.server.v1_6_R2.MinecraftServer.s(MinecraftServer.java:486)
    11.08 09:44:09 [Server] SEVERE at net.minecraft.server.v1_6_R2.DedicatedServer.t(DedicatedServer.java:226)
    11.08 09:44:09 [Server] SEVERE at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:576)
    11.08 09:44:09 [Server] SEVERE net.minecraft.server.v1_6_R2.ReportedException: Ticking entity
    
    Whenever I spawn a human npc with a wander around goal, I get this. :(
    Code:
        public void createNPC(String name, Location loc)
        {
            CreateEntityContext cec = manager.prepareEntity(RemoteEntityType.Human).asPushable(true).withName("Herobrine").asStationary(false).atLocation(loc.add(0, 2, 0));
            RemoteEntity re = cec.create();
            re.getMind().addTargetingDesire(new DesireWanderAround(), 100);
        }
    
     
  23. Offline

    desht

    Thanks. I worked around a few of the problems I mentioned, but your suggestion about the death event should solve that nicely. Also, the problem with the entities respawning as "wild" version on chunk unload has been at least worked around by cancelling chunk unloads where there's a game in progress.

    In case it wasn't clear, I'm adding the ability to use entities as chess pieces in my ChessCraft plugin, and it's to the point where a game is actually playable - there are just some rough edges to sort out now :)
     
    TheGreenGamerHD likes this.
  24. Offline

    soulofw0lf

    @kumpelblase2 Been looking through your source all day trying to figure out why A: I can't get player entities to look at nearest and b why i can't trigger a right click interact event, why it only triggers on left click? Just testing with something really really simple since i couldn't get it to work in my complex code.

    Code:java
    1. public static EntityManager manager;
    2. @Override
    3. public void onEnable()
    4. {
    5. plugin = this;
    6. manager = RemoteEntities.createManager(this);
    7. manager.setEntitySerializer(new YMLSerializer(this));
    8. RemoteEntity entity = manager.createNamedEntity(RemoteEntityType.Human, new Location(Bukkit.getWorld("minigames"), -12.5, 53.0, -344.5), "HuskyMUDKIPS", false);
    9. entity.setStationary(true);
    10. entity.setPushable(false);
    11. entity.getMind().addMovementDesire(new DesireLookAtNearest(Player.class, 8F), 10);
    12. entity.getMind().addBehaviour(new InteractBehavior(entity)
    13. {
    14. @Override
    15. public void onInteract(Player inPlayer)
    16. {
    17.  
    18. inPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', "&f[&4HuskyMudkips&f] &2Hello &e" + inPlayer.getName() + " &2you're my favorite fan!!!"));
    19. }
    20. }); entity.getMind().addBehaviour(new DamageBehavior(entity) {
    21. @Override
    22. public void onDamage(EntityDamageEvent event) {
    23. event.setCancelled(true);
    24. }
    25. });
    26. // entity.save();
    27. }
    28. @EventHandler
    29. public void playerLogIn(PlayerJoinEvent event){
    30. manager.loadEntities();
    31. }
    32. }


    and ignore the savers and loaders cause those don't work at all, just complete null pointers when trying to save, hoping that's on my end but i'll look into it more later.
     
  25. Offline

    IDragonfire


    Please use the "PlayerInteractEntityEvent" - Event from Bukkit.
    https://github.com/kumpelblase2/Remote-Entities/issues/51


    I hope I fixed it:
    https://github.com/kumpelblase2/Remote-Entities/pull/52
    compiled jar:
    https://www.dropbox.com/sh/h0io2z7kaz762lm/3W9yv7gNAj

    issue:
    https://github.com/kumpelblase2/Remote-Entities/issues/50

    Background:
    if you set any goal/desire set use the pathfinding, RemoteEntites try to set a GenericAttribute that does not exist for Humans.

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

    JJE990

    Hi there, so I can spawn in players with their name plates right? And just make them stand there looking in one direction and doing nothing? People can't interact with them? If so, then thanks :)

    Someone let me know please ;-)

    JJE990

    http://www.trinitycraft.co.nr/ <------ My server
     
  27. Offline

    IDragonfire


    These is a library for developers. Entites are able to move, or interact, if the developer wishs it ;)
    You can interact with the RemoteEntites for example over events:
    https://github.com/kumpelblase2/Rem...ava/de/kumpelblase2/remoteentities/api/events
    or you can use the other part of the api:
    https://github.com/kumpelblase2/Rem.../main/java/de/kumpelblase2/remoteentities/api

    Examples:
    https://github.com/kumpelblase2/Remote-Entities/tree/master/examples
     
  28. Offline

    ZeusAllMighty11 Retired Staff

  29. Offline

    soulofw0lf

    IDragonfire any clue about the named RE not being able to look around? even if i set their yaw to 180 they are still looking straight south no matter what and the look desire isn't working?
     
  30. Offline

    IDragonfire

    @TheGreenGamerHD: Strange, at my server it works, maybe I fixed something else.
    @soulofw0lf: Some RE change break a lot stuff :( I try to find it.
     
Thread Status:
Not open for further replies.

Share This Page