net.minecraftforge.event.entity.player.EntityInteractEvent Java Examples
The following examples show how to use
net.minecraftforge.event.entity.player.EntityInteractEvent.
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: ServerEventHandler.java From Et-Futurum with The Unlicense | 6 votes |
@SubscribeEvent public void interactEntityEvent(EntityInteractEvent event) { ItemStack stack = event.entityPlayer.getCurrentEquippedItem(); if (stack == null) return; if (!(event.target instanceof EntityAnimal)) return; EntityAnimal animal = (EntityAnimal) event.target; if (!animal.isChild()) { if (animal instanceof EntityPig) { if (stack.getItem() == ModItems.beetroot && EtFuturum.enableBeetroot) setAnimalInLove(animal, event.entityPlayer, stack); } else if (animal instanceof EntityChicken) if (stack.getItem() == ModItems.beetroot_seeds && EtFuturum.enableBeetroot) setAnimalInLove(animal, event.entityPlayer, stack); } else if (EtFuturum.enableBabyGrowthBoost && isFoodItem(animal, stack)) feedBaby(animal, event.entityPlayer, stack); }
Example #2
Source File: CommonHookContainer.java From archimedes-ships with MIT License | 6 votes |
@SubscribeEvent public void onInteractWithEntity(EntityInteractEvent event) { if (event.entityPlayer != null) { int x = MathHelper.floor_double(event.target.posX); int y = MathHelper.floor_double(event.target.posY); int z = MathHelper.floor_double(event.target.posZ); TileEntity te = event.entity.worldObj.getTileEntity(x, y, z); if (te instanceof TileEntityCrate && ((TileEntityCrate) te).getContainedEntity() == event.target) { ((TileEntityCrate) te).releaseEntity(); event.setCanceled(true); } } }