NMS Skeleton Not Appearing

Discussion in 'Plugin Development' started by guangong4, Aug 8, 2014.

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


    I'm using this tutorial to make a custom skeleton without replacing the original Skeleton. https://forums.bukkit.org/threads/e...obs-without-replacing-the-default-mob.264172/

    I'm spawning in my Skeleton with this code:
    1. SkeletonShade ss = new SkeletonShade(((CraftWorld) p.getWorld()).getHandle());
    2. ss.setLocation(p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(), 0F, 0F);
    3. ((CraftWorld) p.getWorld()).getHandle().addEntity(ss);

    My SkeletonShade class:
    1. public class SkeletonShade extends EntitySkeleton {
    3. public SkeletonShade(World world) {
    4. super(world);
    5. }
    6. }

    Some notes:
    - The skeleton doesn't appear when I execute the code to spawn it in (I know it's activating, debug messages).
    - I don't get any errors.
    - Using Craftbukkit and Bukkit 1.7.9 R3, because that's what the tutorial I got this from used.
    - See below posts.

    Bump, it's been a day with 0 replies...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 9, 2016
  2. guangong4
    try setPosition instaed of setLocation maybe it works
  3. Offline


    No dice. Got any other ideas?
    Thanks for posting, though.
  4. Any errors? p.getWorld() may be null or you're building against the wrong CraftBukkit version.
  5. Offline


    I'm getting no errors at all. I tried it with EntitySkeleton, and it's not working either.

    Here's more surrounding code:
    1. // Remove old shades
    2. if (shade.get(p.getName()) != null) {
    3. shade.get(p.getName()).damage(100);
    4. shade.remove(p.getName());
    5. }
    6. p.sendMessage("§8[§6DW§8] §r" + "You summon a Shade Archer to your side.");
    7. // Player invis
    8. p.removePotionEffect(PotionEffectType.INVISIBILITY);
    9. p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 600, 0));
    10. FireworkEffectPlayer.fire(p.getLocation(), Type.BURST, Color.GRAY, false);
    11. // Set Items
    12. ItemStack i = new ItemStack(Material.BOW, 1);
    13. ItemStack[] is = new ItemStack[4];
    14. is[0] = new ItemStack(Material.LEATHER_BOOTS);
    15. is[1] = new ItemStack(Material.LEATHER_LEGGINGS);
    16. is[2] = new ItemStack(Material.LEATHER_CHESTPLATE);
    17. is[3] = new ItemStack(Material.LEATHER_HELMET);
    18. // Spawn in skeleton
    19. EntitySkeleton ss = new EntitySkeleton(((CraftWorld) p.getWorld()).getHandle());
    20. ss.setLocation(p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(), 0F, 0F);
    21. ((CraftWorld) p.getWorld()).getHandle().addEntity(ss);
    22. final Skeleton s = (Skeleton) ss.getBukkitEntity();
    23. shade.put(p.getName(), s);
    24. s.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0));
    25. s.setCustomName("Shade Archer");
    26. s.getEquipment().setItemInHand(i);
    27. s.getEquipment().setArmorContents(is);
    28. // Set velocities
    29. Vector v = new Vector((new Random().nextDouble() - 0.5)*2, 0, (new Random().nextDouble() - 0.5)*2);
    30. // s.setVelocity(v);
    31. p.setVelocity(v.multiply(-1.5));

    I'm making it to the SetVelocity part, so the code is executing all the way through.
    One interesting note is that whenever I activate the skill again, I hear a skeleton death sound, which is coming from the first 4 lines of code. The skeleton IS there, but it's not showing up.
  6. Stick to setPosition, and I believe this is happening because you're setting the location before you're spawning it? Try setting its position after it has spawned.
  7. Offline


    I'm not sure about this, but what about the invisibility you gave it? guangong4

    EDIT: But wait... It has armor. I honestly don't know then :(
  8. Offline


    Yeah, I tried commenting out the invisibility and it still didn't appear.
    It holds a bow as well.

    I got this from your tutorial, could you please help me?
  9. guangong4
    try adding a spawnreason like this,
    1. ((CraftWorld) p.getWorld()).getHandle().addEntity(ss, SpawnReason.CUSTOM);

    this is the only difference i can see when i compare your and mine code.

Thread Status:
Not open for further replies.

Share This Page