[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

    BlueMustache

    skyrimfan1
    Your right!
    Gosh, I have never overlooked anything like that before.
    Won't happen again!
    Thanks, :)
    -Blue

    BlueMustache
    I tested it, it works!
    Finally, I can make an army of combine!

    skyrimfan1
    Lol, above. :D
    Thanks, that was meant for you.

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

    jimbo8

    lenis0012

    Okay, so i'm developing a plugin and i'm trying to open a inventory menu when a player right clicks the NPC, but i don't know which type of entity the NPC is. How can i get the entity type of the NPC to compare?

    I'm using PlayerInteractEntityEvent to compare and open the inventory.

    Edit:

    Tried to print the name of the entity, but it returned null.
     
  3. 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.
     
  4. 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. }

     
  5. 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
  6. 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.
     
  7. Offline

    lenis0012

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

    skyrimfan1

    Ah, that makes sense as I was spawning an NPC with my name.
    Thanks!
     
  9. 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
  10. Offline

    CodeOne

    How do you add the maven repository into Eclipse? I can't figure that out
     
  11. 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.
     
  12. Offline

    dsnid3r

    Any ideas on how to get this to work on Spigot 1.8?
     
  13. 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.
     
  14. 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.
     
  15. Offline

    timtower Moderator 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.
     
  16. Offline

    lenis0012

    umg it must be zo hard to replace 1_7_R3 with 1_8_R1
     
    Goblom and timtower like this.
  17. 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
     
  18. 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.
     
  19. Offline

    lenis0012

    Or get it from the build server.
    Oh wait, you cant.
    I had to take it down
     
  20. 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.
     
  21. Offline

    lenis0012

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

    Marten Mooij

  23. Offline

    lenis0012

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

    Marten Mooij

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

    lenis0012

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

    jjssman

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

    lenis0012

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

    Monkey_Swag

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

    crolemol

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

    lenis0012

    ran across a problem with how MC now writes packets
     
Thread Status:
Not open for further replies.

Share This Page