[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

    Jumla


    From your error above, a plugin is referencing the 1.5.3 craftbukkit.
     
  2. Offline

    shohouku


    Idk must be some weird bug because I have 1.6.1 craftbukkit latest version lol.

    It even shows it on the console logs o_o
     
  3. Offline

    soulofw0lf

    yes your bukkit is the latest that's why something trying to referense an old version of bukkit isn't working. One of your plugins is trying to use the old bukkit. Are you sure you uploaded the new remoteentities onto your server when you got it?



    cause this is saying that you're using an old version to me.
     
  4. Offline

    shohouku


    So... I put 1.7 in my plugins folder and I get e'nd of stream null' it's fully spamming my console log lol. o.o
     
  5. Offline

    soulofw0lf

    full error report would help through paste bin or git preffered
     
  6. Offline

    shohouku


    Uhm...the only error was
    Code:
    Reached end of stream for Null
    That was the only error and it was spamming my console log,

    Heres my code:

    Code:
    package plugin;
     
    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    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 final class npc extends JavaPlugin implements Listener {
     
    //First we need an instance of the manager, which keeps track of your entities
     
     
     
        EntityManager manager = RemoteEntities.createManager(this);
     
    @Override
    public void onEnable() {
     
        getLogger().info("PlayRevolveNPC was enabled!");
    Bukkit.getPluginManager().registerEvents(this, this);
     
    this.manager = RemoteEntities.createManager(this);
     
    }
     
    public void createNPC(Location location) {
    //Using the manager we create a new human npc at the spawn location, but we won't setup the standard desires/goals
    RemoteEntity entity = manager.createNamedEntity(RemoteEntityType.Human, location, "Tour Guide", 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("Stop hitting me!");
    }
    });
    }
     
    public void onEnabled() {
    getLogger().info("PlayRevolveNPC was disabled!");
    }
     
     
    @EventHandler
    public void onJoin(PlayerJoinEvent inEvent) throws Exception
    {
    createNPC(inEvent.getPlayer().getLocation());
    inEvent.getPlayer().sendMessage("test");
    }
    }
    Is this code suppose to be in onEnabled?

    Code:
        EntityManager manager = RemoteEntities.createManager(this);
    Because I get resolve errors if I do .-.
     
  7. Offline

    soulofw0lf

    try this instead, just a couple very minor changes, i don't know if it matters or not to be honest but i personally do not like initializing objects outside of methods, just variables. and also your onDisable method was called onEnabled for some reason and not overwritten.
     
  8. Offline

    shohouku


    Hmmh I copied the code you pasted for me,

    I still got the error, Reached end of stream for Null.

    o.o
     
  9. Offline

    soulofw0lf

    well i don't see any errors in your code at all, and that same code works for me, so what else are you using?
     
  10. Offline

    shohouku


    Im using both of these in my plugin.

    remoteentities-1.7-SNAPSHOT
    remoteentities-1.7-20130703.200842-21

    Does that cause errors?

    Human entity doesn't work that's all lol.

    # :D

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

    soulofw0lf


    anyone have any ideas on this why the maven isn't working?
     
  12. Offline

    shohouku

    Why isn't the Human entity isn't working?
     
  13. Offline

    kumpelblase2

    ICodeMaster I'll take a look and try to at least fix them somehow for 1.7 so they're not completely broken.

    Jumla I was looking for that yesterday and I think I've found the issue why it does that. It is hopefully fixed by this commit. Could you prove that?

    soulofw0lf I had that once as well and I ended up clearing my local maven repo and tried again.

    shohouku Because of the update the entity wasn't working. You can try out the new version which should at least not spam your console anymore.



    And for anyone who hasn't looked at my commits, there is now a trading feature which you can add on any entity to allow villager-like trading! It is not documented yet, but already functional. So if you want to try it out, here's a small example code:
    Code:
    RemoteEntity entity = <your entity>
    RemoteTradingFeature feature = new RemoteTradingFeature(entity, "Custom store");
    feature.addOffer(new ItemStack(Material.PAPER), new ItemStack(Material.STONE));
    feature.addOffer(new TradeOffer(new ItemStack(Material.FEATHER), new ItemStack(Material.STONE), 2));
    ItemStack customItem = new ItemStack(Material.DIAMOND_SWORD);
    ItemMeta meta = customItem.getItemMeta();
    meta.setDisplayName("BACON MAKER");
    meta.setLore(new ArrayList<String>(Arrays.asList("GET THAT BACON!")));
    customItem.setItemMeta(meta);
    feature.addOffer(new TradeOffer(customItem, new ItemStack(Material.FEATHER), 1));
    (Yes, 'Custom store' will actually be displayed to the player)
    This will provide the player with three offers:
    - 1 paper for 1 stone
    - 1 feather for 1 stone, but it's limited to 2 (so it can only be bought twice, which is not per player)
    - 1 custom diamond sword for 1 feather and is also limited to 1.

    However, the client doesn't update and/or is unable to get updated while it's in the trade, which means that the player has to close and reopen the trade to be able to see changes (for example when an offer isn't available anymore or an new offer is there).
     
    jb_aero likes this.
  14. Offline

    soulofw0lf

    @kumpelblase2 yup that did it for me. maven can be so finicky!
     
  15. Offline

    kumpelblase2

  16. Offline

    shohouku

    When I spawn the Human he doesn't look at me or do anything lol,
    But the interaction works :D

    How would I get the 'human' to look at a player??
    Code:
     public void createNPC1(Location location) {
            //Using the manager we create a new human npc at the spawn location, but we won't setup the standard              //desires/goals
          RemoteEntity entity = manager.createNamedEntity(RemoteEntityType.Human, location, "Jack", 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(final Player inPlayer)
                {
                      final Player p = (Player) inPlayer.getPlayer();
    p.sendMessage("Hi");
                }
            });
        }
     
  17. Offline

    kumpelblase2

    First 1.6.2 snapshot is out! Have fun guys!

    shohouku it should work like that, maybe I forgot to update something when 1.6.1 came out. I'll check that.
     
    shohouku likes this.
  18. Offline

    soulofw0lf

    @kumpelblase2 and what is the new snapshot called? cause all i'm seeing on the repo is 1.7 still?
     
  19. Offline

    kumpelblase2

    soulofw0lf it's still the 1.7-SNAPSHOT, just a new version.
     
  20. Offline

    kezz101

    [​IMG]

    But seriously thank you this is so awesome.
     
  21. Offline

    bluegru

    pls can you show me a code with features (taming feature or so)
     
  22. Offline

    Jishaxe

    Hi, I wish to make a horde of zombies continuously follow a single player, no matter where they are.
    Before, I calculated a position 15 blocks away from the zombie's current location in the direction of the target, and then called this NMS code every tick:

    Code:java
    1. Navigation nav = (Navigation) ((CraftCreature) zombie).getHandle().getNavigation();
    2. nav.a(location.getX(),location.getY(),location.getZ(), 0.6F);


    This worked okay but I suspect that calling that every tick is not the most efficient, and not very dynamic, so I'd like to switch to RemoteEntities.

    However, what would be the best way to achieve what I want to do using RemoteEntities?
    Would I apply a DesireMoveToLocation the same way I used the NMS code, every tick?
    Or,
    Would I apply a DesireMoveToLocation, wait for the pathfinding to finish, then apply another one to chain them together so the zombie eventually reaches the target? But what happens if the player moves while the zombie is still pathfinding?

    Please give me some pointers on this.
     
  23. Offline

    Hatchcatch020

    Hey I was wondering is it possible to spawn a Human entity with a custom skin ? Even if it is a client side texture.
     
  24. Offline

    jb_aero

    You can give it a custom name, and the client will look up the skin that matches that name from the MC skin server. If the name is not a real player (or capitalized wrong), the client will not find a matching skin, so it will just use Steve.
     
  25. Offline

    bluegru

    i want to spawn a human:

    Code:java
    1.  
    2. de.kumpelblase2.remoteentities.EntityManager manager = RemoteEntities.createManager(plugin);
    3. RemoteEntity entity = manager.createNamedEntity(RemoteEntityType.Human, loc, ChatColor.BLUE + "TeleportMaster", true);
    4. entity.setStationary(true);
    5. entity.getMind().addMovementDesire(new DesireLookAtNearest(entity, Player.class, 8F), 255);
    6.  


    but he does not spawn where i want him to do, and after a few minutes he teleports to the location,
    but when i teleport away he despawns, how can i prevent him from despawning?
     
  26. Offline

    kumpelblase2

    Crunkle Haven't had time in the last days, but I will look at it now.

    Jishaxe Take a look at DesireFollowSpecific, that will exactly do what you want.

    bluegru Which version are you using, 1.6? If so, it's fixed in 1.7 .
     
  27. Offline

    bluegru

    no its 1.5.2
     
  28. Offline

    kumpelblase2

    bluegru ->
     
  29. Offline

    Hatchcatch020

    So no I cant use a custom skin ? Can I not just draw my skin add it to a texture pack and have my plugin search for it ?
     
  30. Offline

    kumpelblase2

    Hatchcatch020 No you can't. That's just how minecraft works, sadly.
     
Thread Status:
Not open for further replies.

Share This Page