本文整理汇总了Java中net.minecraftforge.event.entity.living.LivingHurtEvent.getEntityLiving方法的典型用法代码示例。如果您正苦于以下问题:Java LivingHurtEvent.getEntityLiving方法的具体用法?Java LivingHurtEvent.getEntityLiving怎么用?Java LivingHurtEvent.getEntityLiving使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.living.LivingHurtEvent
的用法示例。
在下文中一共展示了LivingHurtEvent.getEntityLiving方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onHurtEvent
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void onHurtEvent(LivingHurtEvent event)
{
EntityLivingBase entity = event.getEntityLiving();
DamageSource damageSource = event.getSource();
float damage = event.getAmount();
if(entity != null)
{
IAttributeInstance damageRate = null;
if(isPhysicalDamage(damageSource))
damageRate = entity.getEntityAttribute(PHYSICAL_DAMAGE_RATE);
if(damageSource.isFireDamage())
damageRate = entity.getEntityAttribute(FIRE_DAMAGE_RATE);
if(damageRate != null)
damage *= damageRate.getAttributeValue();
}
event.setAmount(damage);
}
示例2: onHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHurt(LivingHurtEvent ev) {
DamageSource source = ev.getSource();
Entity root = source.getImmediateSource();
if (root instanceof EntityLivingBase) {
EntityLivingBase cause = (EntityLivingBase) root;
EntityLivingBase hurt = ev.getEntityLiving();
EnumHand active = cause.getActiveHand();
ItemStack stack = cause.getHeldItem(active);
RandoresItemHelper.doEmpowered(stack, hurt, cause);
if(stack.getItem() instanceof RandoresSledgehammer) {
Vec3d vector = hurt.getPositionVector().subtract(cause.getPositionVector()).normalize().scale(2);
hurt.addVelocity(vector.x, 0.5, vector.z);
}
}
}
示例3: onHitEntity
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHitEntity(LivingHurtEvent event) {
if (event.getAmount() <= 0 || event.getEntityLiving() instanceof EntityPlayer) return;
if (!(event.getSource().getSourceOfDamage() instanceof EntityPlayer)) return;
ItemStack transformer = BaublesApi.getBaublesHandler((EntityPlayer)event.getSource().getSourceOfDamage()).getStackInSlot(6);
if (transformer == null || (transformer != null && transformer.getItem() != this)) return;
Random rand = new Random();
if (rand.nextInt(100) != 0) return;
EntityLivingBase elb = event.getEntityLiving();
List<String> entities = new ArrayList<String>(EntityList.ENTITY_EGGS.keySet());
String randomString = entities.get(rand.nextInt(entities.size()));
Entity entity = EntityList.createEntityByName(randomString, elb.worldObj);
if (!entity.isNonBoss()) return;
entity.setPositionAndRotation(elb.posX, elb.posY, elb.posZ, elb.rotationYaw, elb.rotationPitch);
elb.worldObj.spawnEntityInWorld(entity);
elb.setDead();
}
示例4: obsidianArmor
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
/** Handle wearing obsidian armor */
private boolean obsidianArmor(LivingHurtEvent e) {
EntityLivingBase hurt = e.getEntityLiving();
// do things based on the armor status
int armorCount = getWearingSetCount(hurt, ItemArmorObsidian.class);
if(armorCount > 0) {
// blast resistance II
if(e.getSource().isExplosion()) {
e.setAmount(e.getAmount() * (1 - armorCount / 4F));
}
return true;
}
return false;
}
示例5: livingHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void livingHurt(LivingHurtEvent event) {
if (!event.getEntity().world.isRemote)
if(event.getSource().getTrueSource() instanceof EntityArmyMember) {
if (event.getEntityLiving() instanceof EntityPlayerMP) {
if (event.getSource().isProjectile()) {
if (event.getSource().getTrueSource() instanceof EntitySkeletonWarrior && ((EntitySkeletonWarrior) event.getSource().getTrueSource()).getOwnerId().equals(event.getEntityLiving().getUniqueID()))
CriterionRegistry.instance.SKELETON_STATUS_UPDATE.trigger((EntityPlayerMP) event.getEntityLiving(), event.getSource().getTrueSource(), Items.ARROW, 0);
else if (event.getSource().getTrueSource() instanceof EntityConvertedSkeleton && ((EntityConvertedSkeleton) event.getSource().getTrueSource()).getOwnerId().equals(event.getEntityLiving().getUniqueID()))
CriterionRegistry.instance.SKELETON_STATUS_UPDATE.trigger((EntityPlayerMP) event.getEntityLiving(), event.getSource().getTrueSource(), Items.ARROW, 1);
}
if(ConfigValues.FF && Alliances.getInstance().isAlliedTo(((EntityArmyMember) event.getSource().getTrueSource()).getOwnerId(), event.getEntityLiving().getUniqueID()))
event.setCanceled(true);
} else if(ConfigValues.FF && event.getEntityLiving() instanceof EntityArmyMember && Alliances.getInstance().isAlliedTo(((EntityArmyMember) event.getSource().getTrueSource()).getOwnerId(), ((EntityArmyMember)event.getEntityLiving()).getOwnerId()))
event.setCanceled(true);
} else if (ConfigValues.FF && event.getSource().getTrueSource() instanceof EntityPlayer) {
if(event.getEntityLiving() instanceof EntityPlayer && Alliances.getInstance().isAlliedTo(event.getSource().getTrueSource().getUniqueID(), event.getEntityLiving().getUniqueID()))
event.setCanceled(true);
else if(event.getEntityLiving() instanceof EntityArmyMember && Alliances.getInstance().isAlliedTo(event.getSource().getTrueSource().getUniqueID(), ((EntityArmyMember)event.getEntityLiving()).getOwnerId()))
event.setCanceled(true);
}
}
示例6: onEntityAttacked
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityAttacked(LivingHurtEvent event)
{
Entity sourceEntity = event.getSource().getTrueSource();
if (sourceEntity instanceof EntityLivingBase)
{
EntityLivingBase target = event.getEntityLiving();
if (target == null)
return;
EntityLivingBase attacker = (EntityLivingBase) sourceEntity;
ItemStack weapon = attacker.getHeldItemMainhand();
ItemStack offhand = attacker.getHeldItemOffhand();
if (offhand != null && offhand.getItem() instanceof IUpgradable)
((IUpgradable) weapon.getItem()).onAttackEntity(event, attacker, target, weapon, offhand);
if (weapon != null && weapon.getItem() instanceof IUpgradable)
((IUpgradable) weapon.getItem()).onAttackEntity(event, attacker, target, weapon, offhand);
}
}
示例7: hasFlameCloak
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void hasFlameCloak(LivingHurtEvent event)
{
if (event.getEntityLiving() instanceof EntityPlayer && event.getSource().getSourceOfDamage() instanceof EntityLivingBase)
{
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
EntityLivingBase attacker = (EntityLivingBase) event.getSource().getSourceOfDamage();
if (player != null && attacker != null)
{
IFlameCloak flameCloak = player.getCapability(CapabilityFlameCloak.FLAME_CLOAK_CAP, null);
if (flameCloak != null && flameCloak.hasFlameCloak())
{
attacker.setFire(5);
}
}
}
}
示例8: onPlayerHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerHurt(LivingHurtEvent event) {
if (event.getEntityLiving().getHealth() - event.getAmount() <= 0 && event.getEntityLiving() instanceof EntityPlayer) {
EntityPlayer p = (EntityPlayer) event.getEntityLiving();
for (int i = 0; i < p.inventory.getSizeInventory(); ++i) {
ItemStack s = p.inventory.getStackInSlot(i);
if (s.getItem() instanceof ItemSoulstone) {
UtilChat.addChatMessage(p, event.getEntityLiving().getName() + UtilChat.lang("item.soulstone.used"));
p.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
UtilSound.playSound(p, SoundEvents.BLOCK_GLASS_BREAK);
p.setHealth(6);// 3 hearts
int time = Const.TICKS_PER_SEC * 30;
p.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, time));
time = Const.TICKS_PER_SEC * 60;//a full minute
p.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, time));
p.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, time, 4));
//and bad luck lasts much longer
time = Const.TICKS_PER_SEC * 60 * 10;
p.addPotionEffect(new PotionEffect(MobEffects.UNLUCK, time));
p.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, time, 1));
event.setCanceled(true);
break;
}
}
}
}
示例9: PlayerPunchedEvent
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
public PlayerPunchedEvent(LivingHurtEvent event, EntityPlayer attacker)
{
super(event.getEntityLiving());
this.source = event.getSource();
this.amount = event.getAmount();
this.attacker = attacker;
this.event = event;
}
示例10: onHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHurt(LivingHurtEvent ev) {
DamageSource source = ev.getSource();
Entity root = source.getTrueSource();
if (root instanceof EntityLivingBase) {
EntityLivingBase cause = (EntityLivingBase) root;
EntityLivingBase hurt = ev.getEntityLiving();
if (EmpoweredEnchantment.appliedTo(hurt)) {
EmpoweredEnchantment.doArmor(hurt, cause);
}
}
}
示例11: playerHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void playerHurt(LivingHurtEvent event)
{
if(!(event.getEntityLiving() instanceof EntityPlayer))
return;
List<ItemStack> stackList = EntityUtil.getFullPlayerInventory((EntityPlayer) event.getEntityLiving());
for(ItemStack stack : stackList)
{
if(!stack.isEmpty())
{
if(stack.getItem() instanceof ItemAnimaShield)
{
ItemAnimaShield item = (ItemAnimaShield) stack.getItem();
if(!item.isOn(stack))
continue;
if(item.getCurrentCharge(stack) > 0 && item.getShieldCharge(stack) > 0)
{
float amountTaken = event.getAmount();
float shieldScaled = item.getShieldCharge(stack) / 10;
float remain = Math.max(0, amountTaken - shieldScaled);
event.setAmount(remain);
item.depleteShield(stack, amountTaken * 10);
item.removeCharge(stack, (int) (amountTaken * 40));
if(item.getShieldCharge(stack) == 0)
{
item.getShield(stack).onDeplete(stack, event.getEntityLiving());
}
}
return;
}
}
}
}
示例12: onTeleportEntityHarm
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onTeleportEntityHarm(LivingHurtEvent event) {
if (!(event.getEntityLiving() instanceof EntityLiving) || !event.getEntityLiving().getTags().contains(NemesisSystem.TAG_NEMESIS)) {
return;
}
EntityLiving entity = (EntityLiving) event.getEntityLiving();
NemesisEntry nemesis = NemesisUtil.loadNemesisFromEntity(entity);
if (nemesis == null) {
return;
}
if (!nemesis.hasTrait(Type.TELEPORT)) {
return;
}
World world = entity.getEntityWorld();
if (world.rand.nextInt(2) != 0) {
return;
}
List<EntityCreature> guards = NemesisUtil.findNemesisBodyGuards(world, nemesis.getId(), entity.getPosition());
if (guards.size() < 1) {
return;
}
EntityCreature teleportTarget = guards.get(world.rand.nextInt(guards.size()));
NemesisActions.throwPearl(entity, teleportTarget);
}
示例13: onLivingHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
/** Stuff to handle on living hurt events */
@SubscribeEvent
public void onLivingHurt(LivingHurtEvent e) {
if(!e.getEntityLiving().world.isRemote && e.getSource() != null) {
// handle armor stuff
netherFortressArmor(e);
obsidianArmor(e);
}
}
示例14: netherFortressArmor
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
/** Handle wearing nether fortress armor */
private boolean netherFortressArmor(LivingHurtEvent e) {
EntityLivingBase hurt = e.getEntityLiving();
// do things based on the armor status
int armorCount = getWearingSetCount(hurt, ItemArmorNether.class);
if(armorCount > 0) {
// knockback resistance
IAttributeInstance inst = hurt.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE);
AttributeModifier mod = new AttributeModifier(knockbackID, "nfakb", armorCount / 4D, 0).setSaved(false);
if(inst.getModifier(knockbackID) == null) inst.applyModifier(mod);
// wither thorns
if(e.getSource().getTrueSource() != null && e.getSource().getTrueSource() instanceof EntityLivingBase) {
EntityLivingBase attacker = (EntityLivingBase)e.getSource().getTrueSource();
attacker.addPotionEffect(new PotionEffect(MobEffects.WITHER, armorCount * 20, armorCount > 2 ? 1 : 0));
}
// blast resistance I
if(e.getSource().isExplosion()) {
e.setAmount(e.getAmount() * (1 - armorCount / 8F));
}
return true;
}
return false;
}
示例15: onDamageTaken
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onDamageTaken(LivingHurtEvent event)
{
if (event.getEntityLiving() instanceof EntityPlayer && !event.getEntityLiving().world.isRemote)
{
if (event.getSource() != null && !event.getSource().canHarmInCreative())
{
PlayerManager.takeDamage((EntityPlayer) event.getEntityLiving(), event.getSource(), event.getAmount());
event.setCanceled(true);
}
}
}