How do you make a baby zombie drop its armor?

Discussion in 'Plugin Development' started by phondeux, Jul 25, 2013.

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

    phondeux

    I'm using the following to grab a mob on death to adjust their drops;
    Code:
        public void onEntityDeath(EntityDeathEvent event) {
     
            LivingEntity theMob = event.getEntity();
            if (theMob instanceof Player) {
                return;
            } else if ((theMob instanceof Skeleton) || (theMob instanceof Zombie)) {
    .. but I just noticed now that baby zombies drop nothing. Of course, I'm not checking for an instanceof BabyZombie! Wait, that doesn't exist ... so how do I do it?
     
  2. Offline

    chasechocolate

    I believe in the EntityEquipment class there's methods to set the drop chance of armor (e.g. helmet.setDropChance(1.0F)). Use livingEntity.getEquipment().
     
  3. Offline

    phondeux

    I'm using that, but I check to see if it's a zombie or skeleton to make sure i'm not trying to make entities whom aren't wearing anything drop things so there's no exception.

    Here's the entire method;
    Code:
        @EventHandler(priority = EventPriority.MONITOR)
        public void onEntityDeath(EntityDeathEvent event) {
     
            LivingEntity theMob = event.getEntity();
            if (theMob instanceof Player) {
                return;
            } else if ((theMob instanceof Skeleton) || (theMob instanceof Zombie)) {
                // Check if killed by Player
                Entity killer = event.getEntity().getKiller();
                if (killer instanceof Player) {
                    theMob.getEquipment().setBootsDropChance(1F);
                    theMob.getEquipment().setChestplateDropChance(1F);
                    theMob.getEquipment().setHelmetDropChance(1F);
                    theMob.getEquipment().setLeggingsDropChance(1F);
                    theMob.getEquipment().setItemInHandDropChance(1F);
                } else {
                    theMob.getEquipment().setBootsDropChance(0F);
                    theMob.getEquipment().setChestplateDropChance(0F);
                    theMob.getEquipment().setHelmetDropChance(0F);
                    theMob.getEquipment().setLeggingsDropChance(0F);
                    theMob.getEquipment().setItemInHandDropChance(0F);
                    theMob.getEquipment().clear();
                    event.getDrops().clear();
                }
            }
        }
    Am I doing this the hard way?
     
Thread Status:
Not open for further replies.

Share This Page