[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

    lenis0012

    Download link requires me to login on jenkins =$
    And i has no account on your build server
     
  2. Offline

    valon750

    kumpelblase2

    Sorry if I missed this, I'm currently on my iPhone so long posts are hard to keep up with, especially code snippets :S

    Will this allow me to create player NPC's? That's the main feature I've been looking for without having to rely on plugins such as "Citizens", of course the other features stated sound very promising, such as tameable mobs.

    Thanks in advance,
    - Valon -
     
  3. Offline

    Jamboozlez

    When I start the server I get this error:
    Show Spoiler
    2013-04-09 13:41:20 [INFO] [RemoteEntities] Enabling RemoteEntities v1.5.1
    2013-04-09 13:41:21 [INFO] [AdvancedVillagers] Enabling AdvancedVillagers v1.0
    2013-04-09 13:41:21 [INFO] [AdvancedVillagers] AdvancedVillagers was enabled!
    2013-04-09 13:41:21 [INFO] [AdvancedVillagers] We spawned a friendly Zombie at spawn!
    2013-04-09 13:41:21 [SEVERE] Error occurred while enabling AdvancedVillagers v1.0 (Is it up to date?)
    java.lang.NoClassDefFoundError: net/minecraft/server/v1_5_R2/Entity
    at de.kumpelblase2.remoteentities.EntityManager.<init>(EntityManager.java:34)
    at de.kumpelblase2.remoteentities.RemoteEntities.createManager(RemoteEntities.java:61)
    at de.kumpelblase2.remoteentities.RemoteEntities.createManager(RemoteEntities.java:45)
    at com.github.jamboozlez.advancedvillagers.AdvancedVillagers.onEnable(AdvancedVillagers.java:21)
    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_5_R1.CraftServer.loadPlugin(CraftServer.java:282)
    at org.bukkit.craftbukkit.v1_5_R1.CraftServer.enablePlugins(CraftServer.java:264)
    at net.minecraft.server.v1_5_R1.MinecraftServer.j(MinecraftServer.java:303)
    at net.minecraft.server.v1_5_R1.MinecraftServer.e(MinecraftServer.java:282)
    at net.minecraft.server.v1_5_R1.MinecraftServer.a(MinecraftServer.java:242)
    at net.minecraft.server.v1_5_R1.DedicatedServer.init(DedicatedServer.java:150)
    at net.minecraft.server.v1_5_R1.MinecraftServer.run(MinecraftServer.java:381)
    at net.minecraft.server.v1_5_R1.ThreadServerApplication.run(SourceFile:573)
    Caused by: java.lang.ClassNotFoundException: net.minecraft.server.v1_5_R2.Entity
    at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader.java:70)
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:53)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 15 more

    Here's the code that I run in my plugin:
    Code:
     package com.github.jamboozlez.advancedvillagers;
     
    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
     
    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.thinking.InteractBehavior;
    import de.kumpelblase2.remoteentities.api.thinking.goals.DesireLookAtNearest;
     
    public class AdvancedVillagers extends JavaPlugin{
     
    @Override
    public void onEnable() {
    getLogger().info("AdvancedVillagers was enabled!");
    getLogger().info("We spawned a friendly Zombie at spawn!");
    //First we need an instance of the manager, which keeps track of your entities
    EntityManager manager = RemoteEntities.createManager(this);
    //Using the manager we create a new Zombie npc at the spawn location, but we won't setup the standard desires/goals
    RemoteEntity entity = manager.createEntity(RemoteEntityType.Zombie, Bukkit.getWorld("world").getSpawnLocation(), false);
    //We don't want him to move so we make him stationary
    entity.setStationary(true);
    //Now we want him to look at the nearest player. This desire has a priority of 1 (the higher the better).
    //Since we don't have any other desires 1 is totally fine.
    //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)
    //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.
    entity.getMind().addMovementDesire(new DesireLookAtNearest(entity, Player.class, 8F), 1);
    //When a player interacts with him, we want him to tell something to the player.
    //I make an anonymous class here, but you can create a whole new class if you want to
    //but it needs to extend InteractBehaviour
    entity.getMind().addBehaviour(new InteractBehavior(entity)
    {
    @Override
    public void onInteract(Player inPlayer)
    {
    inPlayer.sendMessage("Hello " + inPlayer.getName() + "!");
    }
    });
    }
     
    @Override
    public void onDisable() {
    getLogger().info("AdvancedVillagers was disabled!");
    }
     
    }
    
    As you can see I have only used your code besides adding messages telling the console that the plugin was enabled/disabled and that 'we spawned a friendly zombie at spawn' which run fine in the console.
    If you need any more information then please tell me :)

    EDIT NOTE: I keep editing this post trying to work out how to make it show the code in Java syntax! I would appreaciate it if somebody told me the [*something here*] thing. :)
     
  4. Offline

    lenis0012

    java.lang.NoClassDefFoundError: net/minecraft/server/v1_5_R2/Entity
    You are either nor using 1.5.1-R0.1+ or you are using a modified jar a.k.a BukkitForge

    Having 2 issues

    1) All entities spanw twice after rejoin (it's back)
    2) callign createEntity does not apply default desires using thise code:
    Code:java
    1.  
    2. @EventHandler(priority = EventPriority.MONITOR)
    3. public void onPlayerJoin(PlayerJoinEvent event) {
    4. Player player = event.getPlayer();
    5. Location loc = player.getLocation();
    6.  
    7. Location spawnLoc = MathUtil.getRandomLocation(loc, 10.0D);
    8. float defaultSpeed = DefaultEntitySpeed.ZOMBIE_SPEED;
    9. float speed = MathUtil.getRandomFloat(defaultSpeed, defaultSpeed + (defaultSpeed / 2));
    10.  
    11. RemoteZombie zombie = (RemoteZombie) plugin.getEntityManager().createEntity(RemoteEntityType.Zombie, spawnLoc, true);
    12.  
    13. Mind mind = zombie.getMind();
    14. mind.addMovementDesire(new DesireAvoidSun(zombie), 0);
    15.  
    16. zombie.setSpeed(speed);
    17. zombie.spawn(player.getLocation());
    18. }
    19.  


    Btw MathUtil.getRandomLocation returns a random location with a radius from anorhter location.
    and MathUtil.getRandomFloat gives a random float between min and max:
    Code:
    private static final Random random = new Random();
     
    public static float getRandomFloat(float min, float max) {
        float i = max - min;
        float extra = random.nextFloat() * i;
        return min + extra;
    }
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
    Jamboozlez likes this.
  5. 2) is fixed in the latest commit. I'll take a look into 1) later.

    valon750 Yep, that's the exact idea of this. However, you'll still need to rely on a separate plugin as you can't ship it with your project only. It's a plugin on its own.
     
  6. Offline

    valon750

    kumpelblase2

    I'm rather new to working in conjunction with other plugins, the only work I've done is simply my own plugin creation.

    Could you explain that for me again? So if I were to add this in as I would normally with craftbukkit/bukkit, I'd still need another plugin for it to work?

    On top of that, when trying to download the necessary files, I keep being asked to supply a username and password for Jenkins, but with no option to register, so I'm not sure what I can do about that :/
     
  7. valon750 I updated first post and added a temp download link.
    Since RemoteEntities is a plugin in itself, users will need your plugin AND RemoteEntities. So what you want to do is, add it as a dependency like you do with (craft)bukkit and when you want to test, put your plugin and RemoteEntities into your server plugin folder. It's the same process as using ProtocolLib or Vault.
     
  8. Offline

    valon750

    kumpelblase2

    Oooooh, I think I understand you now.

    Well then, thank you for that information, I'll use that download link now :)
     
  9. Offline

    JeroenV

    Is there a way to make sure remote entities will only target players inside a List (or the opposite).
     
  10. Offline

    valon750

    kumpelblase2

    I am experiencing a problem! (no surprise considering I just started)

    I have the code:

    Code:
                RemoteEntity entity = manager.createEntity(RemoteEntityType.Human, player.getLocation());
    Executed when I do the "banker" command, my issue is that I get...

    Code:
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:187)
        at org.bukkit.craftbukkit.v1_5_R2.CraftServer.dispatchCommand(CraftServer.java:523)
        at net.minecraft.server.v1_5_R2.PlayerConnection.handleCommand(PlayerConnection.java:966)
        at net.minecraft.server.v1_5_R2.PlayerConnection.chat(PlayerConnection.java:884)
        at net.minecraft.server.v1_5_R2.PlayerConnection.a(PlayerConnection.java:841)
        at net.minecraft.server.v1_5_R2.Packet3Chat.handle(Packet3Chat.java:44)
        at net.minecraft.server.v1_5_R2.NetworkManager.b(NetworkManager.java:292)
        at net.minecraft.server.v1_5_R2.PlayerConnection.d(PlayerConnection.java:110)
        at net.minecraft.server.v1_5_R2.ServerConnection.b(SourceFile:35)
        at net.minecraft.server.v1_5_R2.DedicatedServerConnection.b(SourceFile:30)
        at net.minecraft.server.v1_5_R2.MinecraftServer.r(MinecraftServer.java:578)
        at net.minecraft.server.v1_5_R2.DedicatedServer.r(DedicatedServer.java:225)
        at net.minecraft.server.v1_5_R2.MinecraftServer.q(MinecraftServer.java:474)
        at net.minecraft.server.v1_5_R2.MinecraftServer.run(MinecraftServer.java:407)
        at net.minecraft.server.v1_5_R2.ThreadServerApplication.run(SourceFile:573)
    Caused by: java.lang.NoClassDefFoundError: net/minecraft/server/EntityPlayer
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader.java:80)
        at org.bukkit.plugin.java.JavaPluginLoader.getClassByName0(JavaPluginLoader.java:300)
        at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader.java:76)
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:53)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at de.kumpelblase2.remoteentities.api.RemoteEntityType.<clinit>(RemoteEntityType.java:9)
        at me.valon.ServerEcon.ServerEcon.onCommand(ServerEcon.java:100)
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
        ... 15 more
    Caused by: java.lang.ClassNotFoundException: net.minecraft.server.EntityPlayer
        at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader.java:70)
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:53)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        ... 33 more
    The two main things to take in to account are..

    Code:
    Caused by: java.lang.NoClassDefFoundError: net/minecraft/server/EntityPlayer
    Code:
    Caused by: java.lang.ClassNotFoundException: net.minecraft.server.EntityPlayer
    I tried with other entities, but I can't seem to get rid of this outcome... :S
     
  11. JeroenV create your own targeting desire as easy as that. You could build upon already existing desires like DesireFindNearestTarget or similar to make it easier.


    Also, the jenkins server should be available again.
     
  12. Offline

    valon750

    JeroenV

    I've not had enough time to test that, but would you be able to check if the player targeted is on an arraylist? Then if so, do / do not follow?
     
  13. valon750 Are you sure you're using a recent version or RemoteEntities ( 1.5 / 1.5.1 )? Because it doesn't look like that's the case. Keep in mind that specific version only work for specific craftbukkit/minecraft versions, this is due to bukkits protection.
     
  14. Offline

    valon750

    kumpelblase2

    Hmm odd, I downloaded the latest version (besides snapshots).

    I'll have a go at the snapshots and report back

    kumpelblase2

    Update time!

    When using "Cow" instead of "Human" it works like a charm, but when it's set as "Human" nothing happens :S

    On top of that, when I reload the server the npc disappears.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
  15. valon750 because a Human is a named entity, thus it should get spawned using createNamedEntity(...). The despawning is normal and can only be prevented by serializing them manually (i.e. adding a serializer) and load them on startup.
     
  16. Offline

    valon750

    kumpelblase2

    Ah, the man of many talents you are!

    I noticed I have to leave the general area before it actually appears, should that just be a matter of reloading the chunk the player is standing in? (assuming you can do that)

    I'll need to have a look in to saving the NPC, I've never done it so it's another thing to hurt my brain with :S

    Thank you so much for the help :)

    Edit: Here's something interesting, only the most RECENT npc is removed on reload :S So I guess you can just add an additional npc for the time being
     
  17. valon750 Oh I though you wrote restart and not reload. Don't reload the server, just don't do that, restart instead.
    I also prevented that issue from happening in the last commit.
    Saving the entity is actually as easy as it can be. See #202 for an example.
     
  18. Offline

    valon750

    kumpelblase2

    Yeah I meant just the chunk that the player was stood in, thinking that may make the NPC show.

    Do you happen to know off the top of your head how to stop NPC's from looking around? I've tried "entity.setStationary(true)" and "entity.stopMoving();" but neither seem to stop the NPC from looking around the area.

    And on top of that! (sorry, may as well get all the questions out of the way now) I was wondering how I'd get the NPC to follow the player around, hopefully going to incorporate it as some form of follower gift for players who complete a quest or something.
     
  19. valon750 You can either fix their yaw and pitch to a certain value or remove possible looking desires (those depend on which entity you're working with).
    For the second one: 1. Add the taming feature to the npc. 2. Tame it to the player to follow. 3. add the desire DesireFollowTamer to the npc. Done.
     
  20. Offline

    valon750

    kumpelblase2

    Alright then, I'm going to need to read up on that taming feature as I can't seem to figure it out at the moment, probably because it's getting to 10pm and I've only had 1 day off work lately.
     
  21. Offline

    FlySkyPie

    Hi ,
    I'm Tiwanese,
    so my Grammar and Words many has problem,
    please forgive me :D.

    I useed remoteentities NPC lib,
    and I create a NPC,like this:
    Code:
            //產生NPC
            EntityManager manager = RemoteEntities.createManager(this);
            RemoteEntity entity = manager.createNamedEntity(RemoteEntityType.Human , npcspawn,"herobrine" );
            entity.getMind().addMovementDesire(new DesireLookAtNearest(entity, Player.class, 8F), 1);
            player1.teleport(npcspawn);
            return true;
    but problem is when I create npc in a location,
    I need to wait 40 sec to spawn npc on location,
    in this 40sec I can fined this NPC in another place,
    and I can hut it、move it.
    [​IMG]
    How can I to fix this? :)
     
  22. Vislo : Have been trying this for so long but still no avail.

    FlySkyPie : Hm... you're not the only one who reported this issue. However, I'm still not able to reproduce it on my server within the last couple of days.
     
  23. Offline

    confuserr

    I can't seem to get maven to download the 1.6 snapshot, nor the 1.5. Any ideas?

    Code:
    <repository>
                <id>remoteentities-repo</id>
                <url>http://repo.infinityblade.de/remoteentities/snapshots</url>
            </repository>
     
    <dependency>
                    <groupId>de.kumpelblase2</groupId>
                    <artifactId>remoteentities</artifactId>
                    <version>1.6-SNAPSHOT</version>
                </dependency>
    4/10/13 4:26:47 PM GMT+01:00: [WARN] The POM for de.kumpelblase2:remoteentities:jar:1.6-SNAPSHOT is missing, no dependency information available

    Did you change the repo urls at all? 1.4-SNAPSHOT is working fine.
     
  24. confuserr Nope I didn't change anything on the maven repository and in the deploying information. I also took a look at the repo server and the files are all fine.
     
  25. Offline

    confuserr

    Ah, I deleted the maven folders in the repo and now it's downloaded them fine. Weird. Thanks for the quick response.
     
  26. Offline

    Jamboozlez

    lenis0012 I'll get the latest version of CraftBukkit now, thanks for your help :)

    kumpelblase2 I have made some code to spawn a Human NPC at the spawn of the world, is it possible yet to change the player's skin? I thought that maybe using .createNamedEntity() and setting the name to a player's name would give it a skin, but I don't want it to say above them 'RandomPlayer' to have that skin.

    I hope this makes sense,
    - Jamboozlez.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
  27. Jamboozlez Skins are client sided so there's nothing we can do about that.
     
  28. Offline

    lenis0012

    Add spout support :)

    But im not to sure if spout has been updated to 1.5.1 yet

    setSpeed is not working

    even tried entity.setSpeed(entity.getSpeed() * 2);
    But the entity does not move faster (tested with zombie)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
  29. Probably later, there are some other things which should be done first, e.g. pathfinding.

    If you tested it with default desires, some of them have their own set speed, then maybe those are the issue. Otherwise, it should at least be fixed by the custom pathfinding/movement system. However, that might take a bit longer because I still have idea on how to make it properly customizable.
     
Thread Status:
Not open for further replies.

Share This Page