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;
}
}
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;
}
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();
}
}
Aggregations