Creeper head changing to Skeleton on repair

Discussion in 'Plugin Development' started by RizzelDazz, Feb 6, 2014.

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


    Hey guys, I am using code to repair armor when they are hit to prevent loosing any durability. I have noticed that when I hit a player, their head changes from a creeper head to skeleton head. (Obviously I have them spawn with a creeper head) Here is the code I am using:

    1. @EventHandler
    2. public void noWeaponBreakDamage( EntityDamageByEntityEvent event){
    3. if( event.getDamager() instanceof Player )
    4. ((Player) event.getDamager()).getItemInHand().setDurability((short) 1);
    5. else
    6. if ( event.getEntity() instanceof Player ){
    7. ItemStack[] armor = ((Player) event.getEntity()).getInventory().getArmorContents();
    8. for(ItemStack i:armor) {
    9. i.setDurability((short) 0);
    10. }
    11. ((Player) event.getEntity()).getInventory().setArmorContents(armor);
    12. }
    13. }
  2. Offline


    well. My guess is that a creeper hat has a different durability value than a skeleton skull. Yet you set all to durability 0 which equals the skeleton skull obviously
  3. Offline


    I can confirm this. If the ItemStack is a Skull then you shouldn't set the durability.
  4. Offline


    Simple fix, thanks.
Thread Status:
Not open for further replies.

Share This Page