use of net.minecraftforge.event.entity.living.LivingHurtEvent in project Bewitchment by Um-Mitternacht.
the class ArrowDeflectionBrew method onHurt.
@Override
public void onHurt(LivingHurtEvent event, DamageSource source, EntityLivingBase affected, int amplifier) {
amplifier++;
affected.world.getEntitiesWithinAABB(EntityArrow.class, affected.getEntityBoundingBox().expand(amplifier / 3, 1, amplifier / 3).expand(-amplifier / 3, -1, -amplifier / 3)).parallelStream().filter(a -> a.shootingEntity != affected).filter(a -> !isInGround(a)).forEach(a -> {
if (!affected.world.isRemote && a.pickupStatus == EntityArrow.PickupStatus.ALLOWED) {
ItemStack arrow;
try {
arrow = (ItemStack) arrowstack.invoke(a);
EntityItem ei = new EntityItem(affected.world, a.posX, a.posY, a.posZ, arrow);
affected.world.spawnEntity(ei);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
}
}
a.setDead();
});
}
use of net.minecraftforge.event.entity.living.LivingHurtEvent in project ArsMagica2 by Mithion.
the class Recoil method applyEffect.
@Override
public boolean applyEffect(EntityPlayer player, World world, ItemStack stack, ImbuementApplicationTypes matchedType, Object... params) {
LivingHurtEvent event = (LivingHurtEvent) params[0];
Entity e = event.source.getSourceOfDamage();
if (e != null && e instanceof EntityLivingBase) {
((EntityLivingBase) e).knockBack(player, 10, player.posX - e.posX, player.posZ - e.posZ);
}
return true;
}
Aggregations