[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. If you want to you can view them online: HERE

    There are two different repos: one for the snapshots and one for the released ones so keep that in mind.
    Normal repo:
    Code:
    <repository>
        <id>remoteentities-repo</id>
        <url>http://repo.infinityblade.de/remoteentities/releases</url>
    </repository>
    Snapshot repo:
    Code:
    <repository>
        <id>remoteentities-repo</id>
        <url>http://repo.infinityblade.de/remoteentities/snapshots</url>
    </repository>
     
  2. Offline

    Fell

    And the version is 1.5-SNAPSHOT in the snapshot repo, right? I can't fetch it :/
     
  3. Yes. There are already 8 1.5 snapshots on there.
     
  4. Offline

    Fell

    OK, well there's an error (http://pastie.org/6585554) that makes entities with <remoteentity>.getBukkitEntity().setRemoveWhenFarAway(false); not work. They still despawn when the chunk unloads. Thanks!
     
  5. I pushed a workaround which should at least prevent the error.
     
  6. Offline

    Fell

    Awesome, no more error. They don't stay loaded though, unfortunately. I'm sure you'll get to it soon :) Thanks again for the awesome API! Huge part of my server now
     
  7. Offline

    bobacadodl

    Is there any way to get/find the default desires for a mob? say I wanted to create a Skeleton RemoteEntity that behaves exactly(or very similar) like a normal skeleton.

    I also have a question about priorities.. Does the higher # take over or does the lower # take over?
     
  8. Currently there's no way of getting them, but if you cast the handle to RemoteEntityHandle you can access a method to apply the default ones.

    And yes, if a desire has a higher priority than another one with the same type and is able to execute, it will cancel the one with the lower priority and then start.
     
  9. Offline

    bobacadodl

    Thank you!
     
  10. I have no idea how to fix this error. Its the same code I used for 1.4.7. I changed it slightly also.

    Code:
    22:24:05 [SEVERE] Could not pass event PlayerInteractEvent to WDMKits v1.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:427)
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:477)
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:462)
        at org.bukkit.craftbukkit.v1_5_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:178)
        at net.minecraft.server.v1_5_R1.PlayerInteractManager.interact(PlayerInteractManager.java:376)
        at net.minecraft.server.v1_5_R1.PlayerConnection.a(PlayerConnection.java:635)
        at net.minecraft.server.v1_5_R1.Packet15Place.handle(SourceFile:58)
        at net.minecraft.server.v1_5_R1.NetworkManager.b(NetworkManager.java:292)
        at net.minecraft.server.v1_5_R1.PlayerConnection.d(PlayerConnection.java:113)
        at net.minecraft.server.v1_5_R1.ServerConnection.b(SourceFile:35)
        at net.minecraft.server.v1_5_R1.DedicatedServerConnection.b(SourceFile:30)
        at net.minecraft.server.v1_5_R1.MinecraftServer.r(MinecraftServer.java:580)
        at net.minecraft.server.v1_5_R1.DedicatedServer.r(DedicatedServer.java:225)
        at net.minecraft.server.v1_5_R1.MinecraftServer.q(MinecraftServer.java:476)
        at net.minecraft.server.v1_5_R1.MinecraftServer.run(MinecraftServer.java:409)
        at net.minecraft.server.v1_5_R1.ThreadServerApplication.run(SourceFile:573)
    Caused by: java.lang.NoClassDefFoundError: net/minecraft/server/v1_4_R1/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.BurnBlader.WDMKits.WDMKits.onRightClickNetherStar(WDMKits.java:1462)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:425)
        ... 16 more
    Caused by: java.lang.ClassNotFoundException: net.minecraft.server.v1_4_R1.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)
        ... 38 more
    
    And this is my event:

    Code:
        @EventHandler
        public void onRightClickNetherStar(final PlayerInteractEvent event) {
            if (naruto.contains(event.getPlayer().getName())
                    && event.getPlayer().getItemInHand().getType() == Material.NETHER_STAR
                    && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
                if (!narutoing.contains(event.getPlayer().getName())) {
                    final RemoteEntity entity = manager.createNamedEntity(
                            RemoteEntityType.Human,
                            event.getPlayer().getLocation(), event.getPlayer()
                                    .getName());
                    Mind mind = entity.getMind();
                    mind.addMovementDesire(new DesireSwim(entity), 0);
                    mind.addMovementDesire(new DesireAttackOnCollide(entity,
                            EntityHuman.class, false), 2);
                    mind.addMovementDesire(
                            new DesireMoveTowardsRestriction(entity), 4);
                    mind.addMovementDesire(new DesireWanderAround(entity), 6);
                    mind.addMovementDesire(new DesireLookAtNearest(entity,
                            EntityHuman.class, 8), 7);
                    mind.addMovementDesire(new DesireLookRandomly(entity), 7);
                    mind.addTargetingDesire(new DesireFindNearestTarget(entity,
                            EntityHuman.class, 16, false, false, 0), 1);
                    TamingFeature feature = new RemoteTamingFeature(entity);
                    feature.tame(event.getPlayer());
                    entity.getFeatures().addFeature(feature);
                    ItemStack sword = new ItemStack(Material.IRON_SWORD, 1);
                    sword.addEnchantment(Enchantment.DAMAGE_ALL, 2);
                    entity.getBukkitEntity().getEquipment().setItemInHand(sword);
                    ItemStack chest = new ItemStack(Material.LEATHER_CHESTPLATE, 1);
                    LeatherArmorMeta iam = (LeatherArmorMeta) chest.getItemMeta();
                    iam.setColor(Color.BLACK);
                    chest.setItemMeta(iam);
                    ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS, 1);
                    LeatherArmorMeta iam2 = (LeatherArmorMeta) legs.getItemMeta();
                    iam2.setColor(Color.BLACK);
                    legs.setItemMeta(iam2);
                    ItemStack boots = new ItemStack(Material.LEATHER_BOOTS, 1);
                    LeatherArmorMeta iam3 = (LeatherArmorMeta) boots.getItemMeta();
                    iam3.setColor(Color.BLACK);
                    boots.setItemMeta(iam3);
                    ItemStack helmet = new ItemStack(Material.LEATHER_HELMET, 1);
                    LeatherArmorMeta iam4 = (LeatherArmorMeta) helmet.getItemMeta();
                    iam4.setColor(Color.RED);
                    helmet.setItemMeta(iam4);
                    entity.getBukkitEntity().getEquipment().setHelmet(helmet);
                    entity.getBukkitEntity().getEquipment().setChestplate(chest);
                    entity.getBukkitEntity().getEquipment().setLeggings(legs);
                    entity.getBukkitEntity().getEquipment().setBoots(boots);
                    final RemoteEntity entity2 = manager.createNamedEntity(
                            RemoteEntityType.Human,
                            event.getPlayer().getLocation(), event.getPlayer()
                                    .getName());
                    Mind mind2 = entity2.getMind();
                    mind2.addMovementDesire(new DesireSwim(entity2), 0);
                    mind2.addMovementDesire(new DesireAttackOnCollide(entity2,
                            EntityHuman.class, false), 2);
                    mind2.addMovementDesire(new DesireMoveTowardsRestriction(
                            entity2), 4);
                    mind2.addMovementDesire(new DesireWanderAround(entity2), 6);
                    mind2.addMovementDesire(new DesireLookAtNearest(entity2,
                            EntityHuman.class, 8), 7);
                    mind2.addMovementDesire(new DesireLookRandomly(entity2), 7);
                    for(Entity p : event.getPlayer().getNearbyEntities(25, 5, 25)) {
                        mind2.addTargetingDesire(new DesireFollowSpecific(entity2, (LivingEntity) p, 25, 25), 1);
                    }
                    TamingFeature feature2 = new RemoteTamingFeature(entity2);
                    feature2.tame(event.getPlayer());
                    entity2.getFeatures().addFeature(feature2);
                    entity2.getBukkitEntity().getEquipment().setItemInHand(sword);
                    entity2.getBukkitEntity().getEquipment().setHelmet(helmet);
                    entity2.getBukkitEntity().getEquipment().setChestplate(chest);
                    entity2.getBukkitEntity().getEquipment().setLeggings(legs);
                    entity2.getBukkitEntity().getEquipment().setBoots(boots);
                    narutoing.add(event.getPlayer().getName());
                    this.getServer().getScheduler()
                            .scheduleSyncDelayedTask(this, new Runnable() {
                                public void run() {
                                    entity.getBukkitEntity().getWorld().playEffect(entity.getBukkitEntity().getLocation(), Effect.SMOKE, 1, 1);
                                    entity2.getBukkitEntity().getWorld().playEffect(entity.getBukkitEntity().getLocation(), Effect.SMOKE, 1, 1);
                                    for(Entity p : entity.getBukkitEntity().getNearbyEntities(25, 5, 25)) {
                                        if(p instanceof Player) {
                                            Player player = (Player) p;
                                            player.playSound(entity.getBukkitEntity().getLocation(), Sound.FIZZ, 2, 2);
                                        }
                                    }
                                    for(Entity p : entity2.getBukkitEntity().getNearbyEntities(25, 5, 25)) {
                                        if(p instanceof Player) {
                                            Player player = (Player) p;
                                            player.playSound(entity2.getBukkitEntity().getLocation(), Sound.FIZZ, 2, 2);
                                        }
                                    }
                                    entity.despawn(DespawnReason.CUSTOM);
                                    entity2.despawn(DespawnReason.CUSTOM);
                                    event.getPlayer().sendMessage(
                                            ChatColor.BLUE + "WDMKits> "
                                                    + ChatColor.GOLD
                                                    + "Your clones have gone!");
                                    narutoing.remove(event.getPlayer().getName());
                                }
                            }, 240L);
                    this.getServer().getScheduler()
                            .scheduleSyncDelayedTask(this, new Runnable() {
                                public void run() {
                                    narutoing.remove(event.getPlayer().getName());
                                }
                            }, 360L);
                } else {
                    event.getPlayer().sendMessage(
                            ChatColor.BLUE + "WDMKits>" + ChatColor.GOLD
                                    + " You still have a cooldown!");
                }
            }
        }
    
     
  11. Offline

    Lolmewn Retired Staff

    BurnBlader Wrong plugin version for that Craftbukkit version.
    Regarding that, is there a 1.5.1 build coming soon kumpelblase2 ?
     
  12. I was busy the last week so I wasn't able to update it. However, I managed to get my hands on it yesterday and pushed out a snapshot build. I'm gonna try and test this as much as possible and hopefully bring out a release on it really soon.
     
  13. Offline

    Lolmewn Retired Staff

    Wooh, awesome to hear!
     
  14. Offline

    Vislo

    ┬┐Is a way to make a NPC (Player) use the Block Sword Right click?
     
  15. Vislo Could you rephrase that? I don't really get what you want to say. Do you want a player npc to swing it's arm?
     
  16. Offline

    Vislo

  17. Vislo Oh you mean blocking?
     
  18. Offline

    Vislo

  19. Offline

    Bart

    Hey kumpelblase2,

    I'm looking to create custom zombies which will follow a certain group of people without attacking that group, but when it comes within a radius of someone outside of that group, I want them to move to actually attack that person. I have got as far as getting the zombies to follow and not attack the first group of people, but how would I achieve the 'when it becomes within a radius of player, attack' issue?

    Thanks for your help,
    Bart
     
  20. Bart Make another desire with a higher priority than the first one. In the 'shouldExecute' you'll then check if a random person is in range, if so, let the desire execute. If that's not the case, just do nothing and the first desire will continue executing.

    Vislo I'll be taking a look at it.
     
  21. Offline

    Bart

    kumpelblase2 How would I add code to 'shouldExecute'? I have this:

    Code:
    RemoteEntity entity = manager.createEntity(RemoteEntityType.Zombie, event.getPlayer().getLocation());
    TamingFeature feature = new RemoteTamingFeature(entity);
    feature.tame(event.getPlayer());
    entity.getFeatures().addFeature(feature);
    entity.getMind().addMovementDesire(new DesireFollowTamer(entity, 5, 15), 1);
     
  22. Oh I see, you're using the taming feature, I thought you were already using your own desire. So what you want to do is create your own desire which will be similar to the DesireAttackOnCollide, but you modify it in the way that it only selects players outside of the party as a target.
     
  23. Offline

    Bart

    Thanks.
     
  24. Offline

    TeeePeee

    Great, fantastic and wonderful. Happy to see that you're maintaining this plugin :)

    About your equipment feature though, it's much easier to just cast the remote entity's bukkit entity and access it's inventory... Or does EquipmentFeature have a special side-effect I don't know of?

    Note that I haven't tested anything; everything I just said is completely theoretical.

    Code:
    /*
    * Create a remote entity copy of a person and clone it's inventory?
    */
    RemoteEntity re = EntityManager.createNamedEntity(RemoteEntityType.Human, owner.getLocation(), owner.getName());
     
    ((Player)re.getBukkitEntity()).getInventory().setContents(owner.getInventory().getContents())
     
  25. TeeePeee I guess I have to change the example, but the equipment feature does not exist anymore, because, like you mentioned, it now exists in bukkit.
    What you're referring to in your code is the inventory feature. To copy an inventory, there's a method inside every remote entity which is copyInventory(Player) or copyInventory(Player, boolean) to copy the inventory from the given player to the current entity. Because of that you could do this:
    Code:
    RemoteEntity re = EntityManager.createNamedEntity(RemoteEntityType.Human, owner.getLocation(), owner.getName());
    ((RemotePlayer)re).copyInventory(owner);
    Vislo : haven't figured it out yet, sorry.
     
  26. Offline

    TomShar

  27. Offline

    Vislo

  28. TomShar see my post above yours (#253).
    1.5 is out!

    Code:
    Version 1.5:
    - Entity will now have a metadatavalue representing the remote entity
    - Renamed and moved some internal classes such as DesireSelector and PathfinderGoalSelectorHelper
    - Changed action desires to target desires
    - Fixed serialization in some classes
    - Added  ability to override attacking mechanics in some desires
    - Added base for OneTimeDesires
    - Updated to 1.5.1
    - Added events for starting and stopping desires
    - Small other additions
    Download see first post!

    EDIT: Javadocs are up! Also updated the example in the first post to reflect recent changes.

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

    TeeePeee

    Ah, should have noticed that. I'm assuming the boolean denotes whether or not to copy the armor contents but you don't need to answer that, I can just check the javadocs :)

    Sorry if you've answered this before but is it possible to increase the aggro distance of a hostile mob?
     
  30. The desires mostly have a distance parameter in they constructor so remove the respected desire and create the same one with a bigger range in the constructor.
     
Thread Status:
Not open for further replies.

Share This Page