[Lib] [1.7.10] NPCFactory v1.4 - Create walking npcs with custom names and skins!

Discussion in 'Resources' started by lenis0012, May 26, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    darkhelmet

    This is excellent.

    Is there any way to persist these NPCs through a reboot? I can work around it but I'd like to make a few NPCs that stay put.

    Also, I too am noticing that the custom interact event never fires, but the normal interact solution here works for me.
     
  2. Offline

    97WaterPolo

    lenis0012
    Hello! I am attempting to check when the NPC is hit, yet it doesn't seem to fire the event, I do have EventHandler, and it is registered in my OnEnable(). Doesn't even seem to fire, if it was an actual Bukkit even I would be extremely confused but since it is a custom event, I want to be sure I am not doing something wrong. First debug message isn't showing.

    Show Spoiler

    Code:java
    1. @EventHandler
    2. public void onDamage(NPCDamageEvent event){
    3. Bukkit.broadcastMessage("NPCDamageEvent");
    4. if (event.getDamager() instanceof Player){
    5. NPC n = event.getNpc();
    6. Player damager = (Player) event.getDamager();
    7. Bukkit.broadcastMessage("Check 7: Check if Teams are not the same.");
    8. if (npcteam.get(n.getBukkitEntity().getName()) != PlayerMeta.getMeta(damager).getTeam()){
    9. Bukkit.broadcastMessage("Check 8: Teams are the sanme. Checking to see if there are contents");
    10. if (contents.containsKey(n.getBukkitEntity().getName())){
    11. Bukkit.broadcastMessage("Check 9: Dropping inventory contents");
    12. for (ItemStack is : contents.get(n.getBukkitEntity().getName()))
    13. if (is != null)
    14. damager.getWorld().dropItemNaturally(n.getBukkitEntity().getLocation(), is);
    15. }
    16. Bukkit.broadcastMessage("Check 10: Checking to see if there are armor contents");
    17. if (armor.containsKey(n.getBukkitEntity().getName())){
    18. Bukkit.broadcastMessage("Check 9: Dropping armor contents");
    19. for (ItemStack is : armor.get(n.getBukkitEntity().getName()))
    20. if (is != null)
    21. damager.getWorld().dropItemNaturally(n.getBukkitEntity().getLocation(), is);
    22. }
    23. Bukkit.broadcastMessage("Check 11: heck if NPClist contains NPC.");
    24. if (npclist.containsKey(n.getBukkitEntity().getName())){
    25. Bukkit.broadcastMessage("Check 12: NRemoving the NPC");
    26. npclist.get(n.getBukkitEntity().getName()).getBukkitEntity().remove();
    27. npclist.remove(n.getBukkitEntity().getName());
    28. contents.remove(n.getBukkitEntity().getName());
    29. armor.remove(n.getBukkitEntity().getName());
    30. npcteam.remove(n.getBukkitEntity().getName());
    31. logout.put(n.getBukkitEntity().getName(), false);
    32. }
    33. }
    34. }
    35. }



    I am not to sure as I haven't used custom events, but do I need to call it within another event? I tried to call NPCDamageEvent from this, but it didn't work. Another question that arose was the fact you can't get DamageCause within EntityDamageByEntityEvent and you get get the Damager with EntityDamageEvent.
    Show Spoiler

    Code:java
    1. @EventHandler
    2. public void damageEvent(EntityDamageByEntityEvent event){
    3. if (f.isNPC(event.getEntity())){
    4. NPC npc = f.getNPC(event.getEntity());
    5. Bukkit.getServer()
    6. .getPluginManager()
    7. .callEvent(
    8. new NPCDamageEvent(npc, event.getDamager(), DamageCause.ENTITY_ATTACK, event.getDamage()));
    9. }
    10. }

     
  3. Offline

    lenis0012

    you have to code that yourself i am afraid.
    The events are completely broken :/

    use factory.isNPC(entity);
    then factory.getNPC(entity);

    Or get the entity class instance and check if it is an instance of NPC.
    But the method above is prefered.

    npc.getBukkitEntity().remove() works in 1.4 snapshot+
    It crashes the client in older versions if the player has the same uuid as an online player.
    I fixed this recently

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

    jimbo8

    lenis0012

    Thanks, but i already got it working by checking if it is a player, then check the name of it. Works like a charm :)

    If your methods is better, i might use that one instead.
     
  5. Offline

    lenis0012

    checking isNPC is better, in case a player with same name as npc logs on
     
    jimbo8 likes this.
  6. Offline

    skyrimfan1

    Ah, that makes sense as I was spawning an NPC with my name.
    Thanks!
     
  7. Offline

    Jimfutsu

    I have disabled godmode on my NPC But when I attempt to hit it, it seems that it gives me internal server error.

    NVM I fixed it there is a small bug in the code, which means that you cannot cast EntityPlayer to Entity. All you need to do to fix this is to remove change the casting to (net.minecraft.server.v1_7_R3.Entity).

    There 2 lines that you need to change are 197 and 200.

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

    CodeOne

    How do you add the maven repository into Eclipse? I can't figure that out
     
  9. Offline

    RingOfStorms

    You have to have the maven plugins installed and have the project converted to a maven project in eclipse. Then add the dependency to the pom as usual.
     
  10. Offline

    dsnid3r

    Any ideas on how to get this to work on Spigot 1.8?
     
  11. Offline

    RingOfStorms

    There is no difference. Spigot is built on CraftBukkit, and this is a library that you put into your plugins. Those plugins will work on both CraftBukkit and Spigot.
     
  12. Offline

    dsnid3r

    Yes that is true but something in the update to 1.8 it breaks, was wondering if anyone had any sort of fix for this.
     
  13. Online

    timtower Administrator Administrator Moderator

    dsnid3r Don't use protocol hacks. Problem solved.
    There is no official update for 1.8, when there will be one then there are enough developers able to update this code.
     
  14. Offline

    lenis0012

    umg it must be zo hard to replace 1_7_R3 with 1_8_R1
     
    Goblom and timtower like this.
  15. Offline

    quentin27230

    Can you make a 1.7.2 version? Because I dont have the cb 1.7.10 (download not available)

    #Sorry for my bad english im french
     
  16. Offline

    RingOfStorms

    Just download the source and downgrade the imports. Or look at github history and find the versions of the files that you need.
     
  17. Offline

    lenis0012

    Or get it from the build server.
    Oh wait, you cant.
    I had to take it down
     
  18. Offline

    Marten Mooij

    Can anyone help me?
    I am having a NoClassDefFound Error in the NPCNetworkManager class, I am using CraftBukkit 1.7.10 R1.
     
  19. Offline

    lenis0012

    No such version of craftbukkit as 1.7.10 R1 exists
    Did you mean 1.7.10-R0.1-SNAPSHOT?
     
  20. Offline

    Marten Mooij

  21. Offline

    lenis0012

    You must be running a wrong version of minecraft
    1_7_R3 is 1.7.10 i think
     
  22. Offline

    Marten Mooij

    <snip>
     
    Last edited: Jul 23, 2015
  23. Offline

    lenis0012

    I must have forgotten to respond.
    I dont know why the server would lock up.
     
  24. Offline

    jjssman

    The crouching animation doesn't seem to work. It isn't giving me any exception, It just doesn't show.
     
  25. Offline

    lenis0012

    1.8 update coming soon :)
     
    Feindbild, Goblom and crolemol like this.
  26. Offline

    Monkey_Swag

    lenis0012 please correct me if I am wrong, but this only works with a 1.7.10 CraftBukkit build right?
     
  27. Offline

    crolemol

    when will the update come because I really need it for my plugin!
     
  28. Offline

    lenis0012

    ran across a problem with how MC now writes packets
     
  29. Offline

    quentin27230

    How to set the NPC attacking someone ? Changing speed walking ? :)

    #Sorry if my english is bad, i'm french <3
     
    Last edited: Dec 26, 2014
  30. Offline

    elraro

    Hi @lenis0012 ! thanks for your library to create npcs!!!

    I have a problem :S im using ur NPCFactory version for spigot 1.7.9 and works great, but i have a problem. I need add invisibility potion effect to a npc, but it doesnt work...

    PotionEffect potion = new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1);

    npc.getBukkitEntity().addPotionEffect(potion);

    what can i do? :s:
    Thanks
     
Thread Status:
Not open for further replies.

Share This Page