Any such thing as skeleton.update()?

Discussion in 'Plugin Development' started by Agentleader1, Apr 25, 2015.

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

    Agentleader1

    I figured the title is rhetorical. But is there something that can update a skeleton's equipment.

    I used:
    Code:
    Skeleton skell = (Skeleton) player.getWorld().spawnEntity(player.getLocation(), EntityType.SKELETON);
    ((CraftEntity) skell).getHandle().setEquipment(0, CraftItemStack.asNMSCopy(new ItemStack(0)));
    to set a skeleton's hand to be empty. It doesn't however spawn it as empty as it appears. But if I relog, it ".update()"'s it, and the skeleton appears without a bow. How do I have it to where when it spawns from my code, just doesn't need a relog to update it.
     
  2. Offline

    Zombie_Striker

    Make a scheduler for that entity.
     
  3. Offline

    teej107

    @Agentleader1 Perhaps you should use the Bukkit API for this.
     
  4. Offline

    pie_flavor

    @Agentleader1 It's not a skeleton.update method. All information is sent to you upon joining, however no entity update packet was sent while you were online. You should probably use the Bukkit API instead of NMS.
     
  5. Offline

    Agentleader1

    Last edited: Apr 25, 2015
  6. Offline

    teej107

    Post code attempt
     
  7. Offline

    Agentleader1

    @teej107
    Code:
    EntityEquipment ee = skell.getEquipment();
    ee.setItemInHand(new ItemStack(0));
    ee.setArmorContents(player.getInventory().getArmorContents());
     
  8. Offline

    Gater12

  9. Offline

    Agentleader1

    @Gater12 Are you sure that would make a difference?
     
  10. Offline

    teej107

  11. Offline

    pie_flavor

    @Gater12 @Agentleader1 That will actually do nothing and generate a large error - you can't have an ItemStack with Material.AIR. Setting the item to null is correct.
    Maybe use reflection to set the CraftEntityEquipment of the CraftLivingEntity.
     
  12. Offline

    Agentleader1

    @teej107 Never thought of that. @pie_flavor Thanks for the feedback on that. I'll try it out.

    But to clarify, it does set the empty hand when the skeleton is spawned right? WITHOUT relog.
     
Thread Status:
Not open for further replies.

Share This Page