Java Code Examples for net.minecraft.entity.passive.EntityAnimal#isBreedingItem()

The following examples show how to use net.minecraft.entity.passive.EntityAnimal#isBreedingItem() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BreedModule.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Listener
public void onUpdate(EventPlayerUpdate event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {
        final Minecraft mc = Minecraft.getMinecraft();
        for(Entity e : mc.world.loadedEntityList) {
            if(e != null && e instanceof EntityAnimal) {
                final EntityAnimal animal = (EntityAnimal) e;
                if(animal.getHealth() > 0) {
                    if (!animal.isChild() && !animal.isInLove() && mc.player.getDistance(animal) <= 4.5f && animal.isBreedingItem(mc.player.inventory.getCurrentItem())) {
                        mc.playerController.interactWithEntity(mc.player, animal, EnumHand.MAIN_HAND);
                    }
                }
            }
        }
    }
}
 
Example 2
Source File: ServerEventHandler.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
private boolean isFoodItem(EntityAnimal animal, ItemStack food) {
	if (animal.isBreedingItem(food))
		return true;
	else if (animal instanceof EntityPig && food.getItem() == ModItems.beetroot && EtFuturum.enableBeetroot)
		return true;
	else if (animal instanceof EntityChicken && food.getItem() == ModItems.beetroot_seeds && EtFuturum.enableBeetroot)
		return true;
	else
		return false;
}