Search in sources :

Example 1 with EntityChicken

use of net.minecraft.entity.passive.EntityChicken in project BetterStorage by copygirl.

the class CommonProxy method onEntityInteract.

@SubscribeEvent
public void onEntityInteract(EntityInteractEvent event) {
    if (event.entity.worldObj.isRemote || event.isCanceled())
        return;
    EntityPlayer player = event.entityPlayer;
    Entity target = event.target;
    ItemStack holding = player.getCurrentEquippedItem();
    if ((target.getClass() == EntityChicken.class) && (holding != null) && (holding.getItem() == Items.name_tag)) {
        EntityChicken chicken = (EntityChicken) target;
        if (!chicken.isDead && !chicken.isChild() && "Cluckington".equals(holding.getDisplayName()))
            EntityCluckington.spawn(chicken);
    }
    if ((BetterStorageItems.slimeBucket != null) && (target instanceof EntityLiving) && (holding != null) && (holding.getItem() == Items.bucket)) {
        ItemBucketSlime.pickUpSlime(player, (EntityLiving) target);
        if (player.getCurrentEquippedItem().getItem() instanceof ItemBucketSlime)
            preventSlimeBucketUse = true;
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityChicken(net.minecraft.entity.passive.EntityChicken) EntityLiving(net.minecraft.entity.EntityLiving) ItemBucketSlime(net.mcft.copy.betterstorage.item.ItemBucketSlime) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 2 with EntityChicken

use of net.minecraft.entity.passive.EntityChicken in project MineFactoryReloaded by powercrystals.

the class RanchableChicken method ranch.

@Override
public List<ItemStack> ranch(World world, EntityLiving entity, IInventory rancher) {
    List<ItemStack> drops = new LinkedList<ItemStack>();
    EntityChicken chicken = ((EntityChicken) entity);
    if (chicken.timeUntilNextEgg < 300) {
        chicken.playSound("mob.chicken.plop", 1.0F, (chicken.rand.nextFloat() - chicken.rand.nextFloat()) * 0.2F + 1.0F);
        chicken.attackEntityFrom(DamageSource.generic, 0);
        // panic
        chicken.setRevengeTarget(chicken);
        chicken.timeUntilNextEgg = chicken.rand.nextInt(6000) + 6200;
        if (rand.nextInt(4) != 0) {
            drops.add(new ItemStack(Item.egg));
        } else {
            int k = chicken.rand.nextInt(4) + 1;
            drops.add(new ItemStack(Item.feather, k));
        }
    }
    return drops;
}
Also used : EntityChicken(net.minecraft.entity.passive.EntityChicken) ItemStack(net.minecraft.item.ItemStack) LinkedList(java.util.LinkedList)

Example 3 with EntityChicken

use of net.minecraft.entity.passive.EntityChicken in project BetterWithAddons by DaedalusGame.

the class EggIncubationHandler method handleEggs.

private void handleEggs() {
    if (TrackedItemsIterator == null || !TrackedItemsIterator.hasNext()) {
        TrackedItems.addAll(TrackedItemsAdd);
        TrackedItemsAdd.clear();
        TrackedItemsIterator = TrackedItems.iterator();
    } else {
        EntityItem entity = TrackedItemsIterator.next();
        World world = entity.world;
        ItemStack stack = entity.getEntityItem();
        BlockPos pos = entity.getPosition();
        boolean remove = false;
        if (entity.isDead || stack.isEmpty() || stack.getItem() != Items.EGG || stack.getCount() > 1)
            remove = true;
        else if ((int) ReflectionHelper.getPrivateValue(EntityItem.class, entity, "d", "field_70292_b", "age") > 5400 && hasPadding(world, pos.down()) && hasLitLight(world, pos.up())) {
            world.playSound(null, entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_CHICKEN_EGG, SoundCategory.NEUTRAL, 0.25F, world.rand.nextFloat() * 1.5F + 1.0F);
            EntityChicken chick = new EntityChicken(world);
            chick.setGrowingAge(-24000);
            chick.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, 0F, 0F);
            world.spawnEntity(chick);
            stack.shrink(1);
            if (stack.isEmpty())
                entity.setDead();
        }
        if (remove)
            TrackedItemsIterator.remove();
    }
}
Also used : EntityChicken(net.minecraft.entity.passive.EntityChicken) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Aggregations

EntityChicken (net.minecraft.entity.passive.EntityChicken)3 ItemStack (net.minecraft.item.ItemStack)3 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 LinkedList (java.util.LinkedList)1 ItemBucketSlime (net.mcft.copy.betterstorage.item.ItemBucketSlime)1 Entity (net.minecraft.entity.Entity)1 EntityLiving (net.minecraft.entity.EntityLiving)1 EntityItem (net.minecraft.entity.item.EntityItem)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1