List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(entity.posX, entity.posY, entity.posZ, entity.posX + entity.width, entity.posY + entity.height, entity.posZ + entity.width));
for(EntityItem item : items) {
ItemStack itemstack = item.getEntityItem();
if(itemstack != null && itemstack.getItem() == Items.bucket && !world.isRemote) {
while(itemstack.stackSize > 0) {
EntityItem ent = entity.entityDropItem(new ItemStack(Items.milk_bucket), 1.0F);
ent.motionY += world.rand.nextFloat() * 0.05F;
ent.motionX += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F;
ent.motionZ += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F;
itemstack.stackSize--;
}
item.setDead();
}
}
}
}
Collections.shuffle(shearables);
int sheared = 0;
for(EntityLiving entity : shearables) {
if(sheared > 4)
break;
List<ItemStack> stacks = ((IShearable) entity).onSheared(stack, world, (int) entity.posX, (int) entity.posY, (int) entity.posZ, 0);
if(stacks != null && !world.isRemote)
for(ItemStack wool : stacks) {
EntityItem ent = entity.entityDropItem(wool, 1.0F);
ent.motionY += world.rand.nextFloat() * 0.05F;
ent.motionX += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F;
ent.motionZ += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F;
}
++sheared;