Search in sources :

Example 1 with EntityWitherSkeleton

use of net.minecraft.entity.monster.EntityWitherSkeleton in project EnderIO by SleepyTrousers.

the class CapturedMob method getEntity.

@SuppressWarnings("null")
@Nullable
public Entity getEntity(@Nullable World world, @Nullable BlockPos pos, @Nullable DifficultyInstance difficulty, boolean clone) {
    if (world == null) {
        return null;
    }
    if (entityNbt != null && (clone || isUnspawnable(entityId))) {
        final Entity entity = EntityList.createEntityFromNBT(entityNbt, world);
        if (!clone && entity != null) {
            // The caller doesn't expect a clone, but we return one. Give it a unique/new ID to avoid problems with duplicate entities.
            entity.setUniqueId(MathHelper.getRandomUUID(world.rand));
        }
        return entity;
    }
    Entity entity = EntityList.createEntityByIDFromName(entityId, world);
    if (entity == null) {
        return null;
    }
    if (pos != null) {
        entity.setPosition(pos.getX(), pos.getY(), pos.getZ());
    }
    if (entity instanceof EntityLiving) {
        if (pos != null && difficulty == null) {
            difficulty = world.getDifficultyForLocation(pos);
        }
        if (difficulty != null) {
            ((EntityLiving) entity).onInitialSpawn(difficulty, null);
        }
    }
    if (entity instanceof EntityWitherSkeleton) {
        if (Celeb.H31.isOn() && Math.random() < 0.25) {
            entity.setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(Math.random() < 0.1 ? Blocks.LIT_PUMPKIN : Blocks.PUMPKIN));
            ((EntityWitherSkeleton) entity).setDropChance(EntityEquipmentSlot.HEAD, 0.0F);
        } else if (Celeb.C06.isOn() && Math.random() < 0.25) {
            entity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Math.random() < 0.25 ? Items.LEATHER_BOOTS : Items.STICK));
        } else if (Math.random() < 0.1) {
            entity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(ModObject.itemDarkSteelSword.getItemNN()));
            ((EntityWitherSkeleton) entity).setDropChance(EntityEquipmentSlot.MAINHAND, 0.00001F);
        }
    }
    return entity;
}
Also used : Entity(net.minecraft.entity.Entity) EntityLiving(net.minecraft.entity.EntityLiving) EntityWitherSkeleton(net.minecraft.entity.monster.EntityWitherSkeleton) ItemStack(net.minecraft.item.ItemStack) Nullable(javax.annotation.Nullable)

Example 2 with EntityWitherSkeleton

use of net.minecraft.entity.monster.EntityWitherSkeleton in project NetherEx by LogicTechCorp.

the class EventHandler method onLivingDrops.

@SubscribeEvent
public static void onLivingDrops(LivingDropsEvent event) {
    Random rand = new Random();
    BlockPos deathPoint = event.getEntity().getPosition();
    if (event.getEntity() instanceof EntityGhast) {
        event.getDrops().add(new EntityItem(event.getEntity().getEntityWorld(), deathPoint.getX(), deathPoint.getY(), deathPoint.getZ(), new ItemStack(NetherExItems.FOOD_MEAT_GHAST_RAW, rand.nextInt(3) + 1, 0)));
    } else if (event.getEntity() instanceof EntityWitherSkeleton) {
        ListIterator<EntityItem> iter = event.getDrops().listIterator();
        while (iter.hasNext()) {
            EntityItem entityItem = iter.next();
            ItemStack stack = entityItem.getEntityItem();
            if (stack.getItem() == Items.BONE || stack.getItem() == Items.COAL) {
                iter.remove();
            }
        }
        event.getDrops().add(new EntityItem(event.getEntity().world, deathPoint.getX(), deathPoint.getY(), deathPoint.getZ(), new ItemStack(NetherExItems.ITEM_BONE_WITHER, rand.nextInt(3), 0)));
    }
}
Also used : Random(java.util.Random) EntityGhast(net.minecraft.entity.monster.EntityGhast) BlockPos(net.minecraft.util.math.BlockPos) EntityWitherSkeleton(net.minecraft.entity.monster.EntityWitherSkeleton) ItemStack(net.minecraft.item.ItemStack) ListIterator(java.util.ListIterator) EntityItem(net.minecraft.entity.item.EntityItem) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

EntityWitherSkeleton (net.minecraft.entity.monster.EntityWitherSkeleton)2 ItemStack (net.minecraft.item.ItemStack)2 ListIterator (java.util.ListIterator)1 Random (java.util.Random)1 Nullable (javax.annotation.Nullable)1 Entity (net.minecraft.entity.Entity)1 EntityLiving (net.minecraft.entity.EntityLiving)1 EntityItem (net.minecraft.entity.item.EntityItem)1 EntityGhast (net.minecraft.entity.monster.EntityGhast)1 BlockPos (net.minecraft.util.math.BlockPos)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1