[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

    SuperOriginal

    So here's what I put:
    Code:java
    1. public void onEnable(){
    2. OurEntities();
    3. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    4.  
    5.  
    6.  
    7. }
    8.  
    9. public void OurEntities(){
    10.  
    11. EntityManager manager = RemoteEntities.createManager(this);
    12. RemoteEntity entity = manager.createEntity(RemoteEntityType.Pig, Bukkit.getWorld("world").getSpawnLocation(), false);
    13. entity.getMind().addTargetingDesire(new DesireFindAttackingTarget(50F, true, false), 0);
    14. entity.getMind().addMovementDesire(new DesireMoveAndMeleeAttack(Player.class, true), 0);
    15. }


    But whenever I hit a pig they don't seem to follow me they run around a couple seconds then stand still. Also how do I make every single pig spawned do this instead of manually spawned?
     
  2. Offline

    macguy8

    supercube101
    I'm by no means a RE expert, but if you post your code using his suggestions, we'd be able to better help you. Perhaps a missing or incorrect parameter value?
     
  3. Offline

    SuperOriginal

    macguy8 My apologies, I've updated my post to contain the suggested original code
     
  4. Offline

    EnderLance

    Hi, I need some help here..

    I'm making a plugin which basically creates a Herobrine entity and can imitate Player behavior. However, when I create my entity, and I spawn it in-game, non of the MovementDesires take effect (except DesireSwim). I tried making it move towards a location ( DesireMoveToLocation() ), DesireLookAtNearest(), DesireWanderAround()... Nothing makes it move. I can push it around, mobs can do so too, and I can get it to look in my direction, but it never walks towards me (or anywhere else). I'm using RemoteEntity as my entity's Type, (as oppose to RemotePlayer (should I use that instead?)). Also, I can't seem to damage the entity, I mean, I hit it but it doesn't move or turn red. This is strange, I posted my (very messy) code to pastebin, please have a look. I didn't erase anything (except some imports) , I just commented things out. Here: http://pastebin.com/9w3QSqmS

    Thanks for any help you can offer!

    - EnderLance
     
  5. Offline

    SuperOriginal

    How come whenever I spawn RemoteEntityType.Mushroom, it spawns a normal cow? Here's the code:

    Code:java
    1. EntityManager manager = RemoteEntities.createManager(this);
    2. RemoteEntity entity = manager.createEntity(RemoteEntityType., pig.getLocation(), false);
    3. //entity.getMind().addTargetingDesire(new DesireFindAttackingTarget(50F, true, false), 5);
    4. //entity.getMind().addMovementDesire(new DesireMoveAndMeleeAttack(Player.class, true), 4);
    5. entity.getMind().addMovementDesire(new DesireKillTarget(li), 4);
    6. entity.setName(ChatColor.RED + "§lASSASSIN MOOSH");
    7. pig.remove();
     
  6. Offline

    Dudemister1999

    I get an error when testing. I don't actually know what is causing it.
    Code:java
    1. 11:19:18 PM org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: de/kumpelblase2/remoteentities/api/thinking/Behavior
    2. 11:19:18 PM at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:184) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    3. 11:19:18 PM at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:308) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    4. 11:19:18 PM at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:231) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    5. 11:19:18 PM at org.bukkit.craftbukkit.v1_7_R1.CraftServer.loadPlugins(CraftServer.java:255) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    6. 11:19:18 PM at org.bukkit.craftbukkit.v1_7_R1.CraftServer.<init>(CraftServer.java:233) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    7. 11:19:18 PM at net.minecraft.server.v1_7_R1.PlayerList.<init>(PlayerList.java:63) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    8. 11:19:18 PM at net.minecraft.server.v1_7_R1.DedicatedPlayerList.<init>(SourceFile:14) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    9. 11:19:18 PM at net.minecraft.server.v1_7_R1.DedicatedServer.init(DedicatedServer.java:126) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    10. 11:19:18 PM at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:424) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    11. 11:19:18 PM at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    12. 11:19:18 PM Caused by: java.lang.NoClassDefFoundError: de/kumpelblase2/remoteentities/api/thinking/Behavior
    13. 11:19:18 PM at java.lang.Class.forName0(Native Method) ~[?:1.7.0_45]
    14. 11:19:18 PM at java.lang.Class.forName(Unknown Source) ~[?:1.7.0_45]
    15. 11:19:18 PM at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:173) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    16. 11:19:18 PM ... 9 more
    17. 11:19:18 PM Caused by: java.lang.ClassNotFoundException: de.kumpelblase2.remoteentities.api.thinking.Behavior
    18. 11:19:18 PM at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.7.0_45]
    19. 11:19:18 PM at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.7.0_45]
    20. 11:19:18 PM at java.security.AccessController.doPrivileged(Native Method) ~[?:1.7.0_45]
    21. 11:19:18 PM at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.7.0_45]
    22. 11:19:18 PM at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader.java:80) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    23. 11:19:18 PM at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:53) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    24. 11:19:18 PM at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_45]
    25. 11:19:18 PM at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_45]
    26. 11:19:18 PM at java.lang.Class.forName0(Native Method) ~[?:1.7.0_45]
    27. 11:19:18 PM at java.lang.Class.forName(Unknown Source) ~[?:1.7.0_45]
    28. 11:19:18 PM at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:173) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    29. 11:19:18 PM ... 9 more


    Oh, I had forgotten to add the code I was using. My bad, sorry!

    Code:java
    1. @EventHandler
    2. public void onMobSpawn(CreatureSpawnEvent e)
    3. {
    4. if(e.getEntity() instanceof Villager)
    5. {
    6. final Villager villager = (Villager)e.getEntity();
    7. if(villager.getCustomName() != null)
    8. {
    9. if(villager.getCustomName().equals(ChatColor.GOLD + "Back to Hub"))
    10. {
    11. villager.playEffect(EntityEffect.WOLF_HEARTS);
    12. RemoteEntity entity = manager.createEntity(RemoteEntityType.Human, villager.getLocation(), false);
    13. entity.setStationary(true);
    14. entity.setName(ChatColor.GOLD + "Back to Hub");
    15. entity.setPushable(false);
    16. Mind mind = entity.getMind();
    17.  
    18. mind.addBehaviour(new InteractBehavior(entity)
    19. {
    20. @Override
    21. public void onInteract(Player inPlayer)
    22. {
    23. inPlayer.sendMessage("Hello " + inPlayer.getName() + "!");
    24. }
    25. });
    26.  
    27. entity.save();
    28. e.setCancelled(true);
    29. }
    30. }
    31. }
    32. }
     
  7. Offline

    iFamasssxD

    Is there any way I can talk with you on Skype for a quicker chat? I work for Minecade and SkyDoesMinecraft and would like to talk to you about your plugin.
     
  8. Offline

    EnderLance

    Um... "RemoteEntityType." -- You didn't specify the entity type?
     
  9. Offline

    Dudemister1999

    I quite like this utility! I've been experimenting, trying to get my error resolved, but to no avail. If I can find a solution, I will post the fix I made!
     
  10. supercube101 I fixed part of your original issue with the latest snapshot. However, the other part has to be done by yourself. The pig normally doesn't have a "damage" method, so it just sets its last attacked target, without damaging it in any way. There are two ways to fix this "issue": First method, which is way more elegant, is to create your own MoveAndMeleeAttack desire and override the attack(entity) method to also damage the target entity if your current entity is a pig. The other one would be to create your own pig entity class, override the m(entity) method and register it in RemoteEntities, where m(entity) is the method that handles the damaging. You have the choice, both will work in the end.

    EnderLance I've pointed this out in several posts already and it's the reason "[Partly broken]" is in the title: player movement doesn't work since 1.6.4 anymore.

    Dudemister1999 Are you sure that your classes are loaded AFTER RemoteEntities?

    iFamasssxD You can always come on IRC (irc.esper.net #remoteentities) and ask me there. I'm always there when I'm at home.
     
  11. Offline

    Ultimate_n00b

    r u guys loking for new devs?
     
  12. Offline

    SuperOriginal

    Ok so I'm trying to classify a regular mob vs a modified RemoteEntity so that it plays a sound when only the remote entity is hit. Does anyone know how to do that?
     
  13. Offline

    HeavyMine13

    Why does this not work(Does not spawn a villager), without any error:
    Code:java
    1. package me.HeavyMine13.snw;
    2.  
    3. import java.util.ArrayList;
    4. import java.util.List;
    5.  
    6. import me.HeavyMine13.snw.IconMenu;
    7.  
    8. import org.bukkit.Bukkit;
    9. import org.bukkit.ChatColor;
    10. import org.bukkit.Location;
    11. import org.bukkit.Material;
    12. import org.bukkit.command.Command;
    13. import org.bukkit.command.CommandSender;
    14. import org.bukkit.entity.LivingEntity;
    15. import org.bukkit.entity.Player;
    16. import org.bukkit.entity.Snowball;
    17. import org.bukkit.event.EventHandler;
    18. import org.bukkit.event.Listener;
    19. import org.bukkit.event.entity.EntityDamageByEntityEvent;
    20. import org.bukkit.event.player.PlayerQuitEvent;
    21. import org.bukkit.inventory.ItemStack;
    22. import org.bukkit.plugin.java.JavaPlugin;
    23.  
    24. import de.kumpelblase2.remoteentities.CreateEntityContext;
    25. import de.kumpelblase2.remoteentities.EntityManager;
    26. import de.kumpelblase2.remoteentities.RemoteEntities;
    27. import de.kumpelblase2.remoteentities.api.RemoteEntity;
    28. import de.kumpelblase2.remoteentities.api.RemoteEntityType;
    29. import de.kumpelblase2.remoteentities.api.thinking.InteractBehavior;
    30.  
    31. public class Snowman extends JavaPlugin implements Listener {
    32. List<String> dod = new ArrayList<String>();
    33. private EntityManager manager;
    34.  
    35. public void onEnable(){
    36. Bukkit.getPluginManager().registerEvents(this, this);
    37. manager = RemoteEntities.createManager(this);
    38. }
    39.  
    40. public void spawnNPC(String name, Location loc) {
    41. CreateEntityContext c = manager
    42. .prepareEntity(RemoteEntityType.Villager)
    43. .asPushable(false)
    44. .asStationary(true)
    45. .atLocation(loc)
    46. .withName(name);
    47.  
    48.  
    49.  
    50. final RemoteEntity re = c.create();
    51.  
    52.  
    53. re.setSpeed(0D);
    54. re.stopMoving();
    55. re.getMind().addBehaviour(new InteractBehavior(re)
    56. {
    57. @Override
    58. public void onInteract(Player inPlayer)
    59. {
    60. if(re.getName().equalsIgnoreCase("Kit Selector")){
    61. final Player player = (Player) inPlayer.getPlayer();
    62. IconMenu menu = new IconMenu("Magical Music List", 9, new IconMenu.OptionClickEventHandler() {
    63.  
    64. @Override
    65. public void onOptionClick(IconMenu.OptionClickEvent event) {
    66. if(dod.contains(player.getName())){
    67. if(event.getPosition() == 3){
    68. ItemStack[] armor = new ItemStack[4];
    69. armor[0] = new ItemStack(Material.IRON_BOOTS, 1);
    70. armor[1] = new ItemStack(Material.IRON_LEGGINGS, 1);
    71. armor[2] = new ItemStack(Material.IRON_CHESTPLATE, 1);
    72. armor[3] = new ItemStack(Material.IRON_HELMET, 1);
    73.  
    74. player.getInventory().setArmorContents(armor);
    75. event.setWillClose(true);
    76. }
    77. }
    78. }
    79. }, Snowman.this);
    80. menu.setOption(3, new ItemStack(Material.IRON_CHESTPLATE, 1), "Juggernaut", "Nothing Stronger?!");
    81. menu.open(player);
    82. }
    83. }
    84. });
    85.  
    86. }
    87.  
    88.  
    89.  
    90. @Override
    91. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    92. Player player = (Player) sender;
    93. if(cmd.getLabel().equalsIgnoreCase("snowdodge")){
    94. if(args.length == 0){
    95. if(!dod.contains(player.getName())){
    96. dod.add(player.getName());
    97. player.sendMessage(ChatColor.LIGHT_PURPLE + "[Snow Dodge]" + ChatColor.GOLD + "You are now playing Snow Dodge!");
    98. return true;
    99. }else{
    100. player.sendMessage(ChatColor.LIGHT_PURPLE + "[Snow Dodge]" + ChatColor.AQUA + "You are ALREADY playing Snow Dodge.");
    101. }
    102. }
    103. }else if(cmd.getLabel().equalsIgnoreCase("stopdodge")){
    104. if(args.length == 0){
    105. if(dod.contains(player.getName())){
    106. dod.remove(player.getName());
    107. player.setHealth(20D);
    108. player.sendMessage(ChatColor.LIGHT_PURPLE + "[Snow Dodge]" + ChatColor.GREEN + "You are no longer playing Snow Dodge!");
    109. return true;
    110. }else{
    111. player.sendMessage(ChatColor.LIGHT_PURPLE + "[Snow Dodge]" + ChatColor.RED + "You are not playing Snow Dodge.");
    112. }
    113. }
    114. }else if(cmd.getLabel().equalsIgnoreCase("spawnkit")){
    115. if(player.hasPermission("Spawn.Kitter")){
    116. if(!dod.contains(player.getName())){
    117. if(args.length == 0){
    118. spawnNPC("Kit Selector", player.getLocation());
    119. }
    120. }
    121. }
    122. }
    123.  
    124. return true;
    125. }
    126.  
    127.  
    128.  
    129.  
    130.  
    131. @EventHandler
    132. public void SnowHit(EntityDamageByEntityEvent event){
    133. if(event.getDamager() instanceof Snowball && event.getEntity() instanceof Player) {
    134. @SuppressWarnings("deprecation")
    135. LivingEntity shooter = ((Snowball)event.getDamager()).getShooter();
    136. Player player = (Player) event.getEntity();
    137. if(shooter instanceof org.bukkit.entity.Snowman){
    138. if(dod.contains(player.getName())){
    139. player.sendMessage(ChatColor.LIGHT_PURPLE + "[Snow Dodge]" + ChatColor.DARK_RED + "You failed to dodge the snowballs.");
    140. player.damage(7D);
    141. }
    142. }
    143. }
    144. }
    145.  
    146.  
    147.  
    148.  
    149.  
    150.  
    151.  
    152. @EventHandler
    153. public void Leavf(PlayerQuitEvent e){
    154. Player p = e.getPlayer();
    155. dod.remove(p.getName());
    156. }
    157.  
    158. }
     
  14. Offline

    Dudemister1999

    Here's how I load it. (I excluded code that is not relevant.)
    Code:java
    1. public EntityManager manager;
    2.  
    3. @Override
    4. public void onEnable()
    5. {
    6. Bukkit.getPluginManager().registerEvents(this, this);
    7. manager = RemoteEntities.createManager(this);
    8. }
    9.  
    10. @EventHandler
    11. public void onMobSpawn(CreatureSpawnEvent e)
    12. {
    13. if(e.getEntity() instanceof Villager)
    14. {
    15. final Villager villager = (Villager)e.getEntity();
    16. if(villager.getCustomName() != null)
    17. {
    18. if(villager.getCustomName().equals(ChatColor.GOLD + "Back to Hub"))
    19. {
    20. villager.playEffect(EntityEffect.WOLF_HEARTS);
    21. RemoteEntity entity = manager.createEntity(RemoteEntityType.Human, villager.getLocation(), false);
    22. entity.setStationary(true);
    23. entity.setName(ChatColor.GOLD + "Back to Hub");
    24. entity.setPushable(false);
    25. Mind mind = entity.getMind();
    26.  
    27. mind.addBehaviour(new InteractBehavior(entity)
    28. {
    29. @Override
    30. public void onInteract(Player inPlayer)
    31. {
    32. inPlayer.sendMessage("Hello " + inPlayer.getName() + "!");
    33. }
    34. });
    35.  
    36. entity.save();
    37. e.setCancelled(true);
    38. }
    39. }
    40. }
    41. }
    42.  
    43.  
     
  15. Offline

    Dudemister1999

    EDIT: Fixed it! Works beautifully! Thanks for the awesome library!
     
  16. Offline

    ItsMilo

    How can I despawn only the player's tamed remote entity?
     
  17. Offline

    legoman519

    When my Villager spawns he is facing South, I want him facing west
     
  18. ItsMilo I don't keep track of it, so you have to do it yourself.. I only keep track of who an entity is tamed to which you can get from the feature.

    legoman519 Fixed.

    HeavyMine13 Are you sure your code gets executed properly?
     
  19. Offline

    legoman519

  20. legoman519 There was an issue that spawned entities will always be facing south. That's fixed now, they'll look into the correct direction now when spawning.
     
  21. Offline

    legoman519

  22. legoman519 Use the proper yaw values on the location you're spawning the entity at.
     
  23. Offline

    minimihm98

    I am getting an error on enabling the plugin

    and this is my Code:
    Code:java
    1. private EntityManager manager;
    2.  
    3. public void onEnable() {
    4. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    5. manager = RemoteEntities.createManager(this);
    6. }
     
  24. minimihm98 Are you sure, you're depending on RE so your plugin gets enabled afterwards?
     
  25. Offline

    minimihm98

    how do i do it?
     
  26. Offline

    frogawesome

    Every time i launch my server it shuts the plugin down because it's a 1.7 server, any way to stop this really want to mess around with some features but don't feel like downgrading to 1.6.2
     
  27. Offline

    frogawesome

    @kumpelblase2 ok, got it thanks. one more question tho, how to use the DesireGoToBed?
     
  28. frogawesome You just add it as a new movement desire and the player will automatically move to and enter a bed when it's near him (you can specify the range in the constructor). But since players currently won't move, it doesn't work.
     
  29. Offline

    minimihm98

    kumpelblase2 also durch deinen Namen gehe ich mal davon aus das du Deutsch bist....
    noch mal zu meiner Frage...
    Was ist eine RE und warum funktioniert mein code nicht?
    Hier der Code:
    Code:java
    1. public class Main extends JavaPlugin implements Listener{
    2.  
    3. private EntityManager npcManager;
    4.  
    5. public void onEnable()
    6. {
    7. Bukkit.getPluginManager().registerEvents(this, this);
    8. this.npcManager = RemoteEntities.createManager(this);
    9. }
    10.  
    11. @SuppressWarnings("unused")
    12. @EventHandler
    13. public void onJoin(PlayerJoinEvent inEvent) throws Exception
    14. {
    15. RemoteEntity entity = npcManager.createNamedEntity(RemoteEntityType.Human, inEvent.getPlayer().getLocation(), "test");
    16. }
    17. }


    LG minimihm98
     
Thread Status:
Not open for further replies.

Share This Page