当前位置: 首页>>代码示例>>Java>>正文


Java LivingHurtEvent.getEntity方法代码示例

本文整理汇总了Java中net.minecraftforge.event.entity.living.LivingHurtEvent.getEntity方法的典型用法代码示例。如果您正苦于以下问题:Java LivingHurtEvent.getEntity方法的具体用法?Java LivingHurtEvent.getEntity怎么用?Java LivingHurtEvent.getEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.event.entity.living.LivingHurtEvent的用法示例。


在下文中一共展示了LivingHurtEvent.getEntity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
		}
}
 
开发者ID:The-Fireplace-Minecraft-Mods,项目名称:Overlord,代码行数:23,代码来源:CommonEvents.java

示例2: onPlayerFall

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
@SuppressWarnings("unused")
public void onPlayerFall(LivingHurtEvent event) {
    if(!(event.getEntity() instanceof EntityPlayer)) {
        return;
    }
    if(!event.getSource().damageType.equals(DamageSource.FALL.getDamageType())) {
        return;
    }
    EntityPlayer player = (EntityPlayer) event.getEntity();
    ItemStack boots = player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
    if(boots != null && boots.getItem() == ItemRegistry.getInstance().itemFallBoots) {
        event.setAmount((1.0F-ConfigurationHandler.getInstance().bootFallDamageReduction)*event.getAmount());
    }

}
 
开发者ID:InfinityRaider,项目名称:3DManeuverGear,代码行数:17,代码来源:EntityLivingHandler.java

示例3: fallOutOfTeletory

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void fallOutOfTeletory(LivingHurtEvent ev) {
	if (ev.getEntity().getEntityWorld().isRemote || !(ev.getEntity() instanceof EntityPlayerMP)) {
		return;
	}

	if (ev.getSource() != DamageSource.OUT_OF_WORLD) {
		return;
	}

	EntityPlayerMP thePlayer = (EntityPlayerMP) ev.getEntity();

	if (thePlayer.dimension != Teletory.DIMID) {
		return;
	}
	ev.setCanceled(true);
	changeEntityDimension(thePlayer, TeleportorType.FALL);
}
 
开发者ID:ToroCraft,项目名称:TeleToro,代码行数:19,代码来源:Teletory.java

示例4: hurtEvents

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void hurtEvents(LivingHurtEvent e) {
    if (!e.getEntity().getEntityWorld().isRemote) {
        DamageSource source = e.getSource();
        Entity entity = e.getEntity();

        if (entity == null || entity.isDead) {
            return;
        }

        if (source == DamageSource.drown && entity.isWet() && entity instanceof EntityPlayer && ConfigurationFile.hardcoreAir) {
            ((EntityPlayer) entity).setHealth(0.0f);
        } else if (source == DamageSource.starve && entity instanceof EntityPlayer && ConfigurationFile.hardcoreHunger) {
            ((EntityPlayer) entity).setHealth(0.0f);
        } else if (source.getEntity() instanceof EntityPlayer && ConfigurationFile.mobsRevengeMode) {
            if (!(entity instanceof EntityPlayer) && entity instanceof EntityLiving) {
                ((EntityLiving) entity).addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 100, 1));
            }
        }
    }
}
 
开发者ID:baileyholl,项目名称:Event-Tweaks,代码行数:22,代码来源:MobEventHandler.java

示例5: onLivingHurtEvent

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingHurtEvent(LivingHurtEvent event) {
	if (event.getEntity() != null && event.getEntity() instanceof EntityPlayer)
	{
		EntityPlayer player = (EntityPlayer)event.getEntity();
		
		for (ItemStack armor : player.getArmorInventoryList()) {
		    if (armor != null && armor.getItem() instanceof LongFallBoots)
		    {
		    	if (event.getSource() == DamageSource.FLY_INTO_WALL) {
		    		System.out.println("Flew into wall");
					// this cancels the fall event so you take no damage
					event.setCanceled(true);
		    	}
		    }
		}
	}
}
 
开发者ID:yyon,项目名称:grapplemod,代码行数:19,代码来源:LongFallBoots.java

示例6: PlayerInteraction

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
  public void PlayerInteraction(LivingHurtEvent evt) {
	if(Main.debug==1)System.out.println(evt.getEntity().getName() + " called PlayerHurt  " + evt.getEntity().toString());
	
	if(evt.getEntity() instanceof EntityPlayer && !Main.logged.contains(evt.getEntity().getName())){
		evt.setCanceled(true);
	}
}
 
开发者ID:Fungie2134,项目名称:AuthMod,代码行数:9,代码来源:PlayerHurt.java

示例7: onAttacked

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAttacked(LivingHurtEvent event) {
	World world = event.getEntity().getEntityWorld();

	if (world.isRemote || !(event.getEntity() instanceof EntityCreature)) {
		return;
	}

	if (event.getEntity().getTags().contains(NemesisSystem.TAG_NEMESIS)) {
		orderGuardsToAttackAggressor((EntityCreature) event.getEntity(), event.getSource().getTrueSource());
	}
}
 
开发者ID:ToroCraft,项目名称:NemesisSystem,代码行数:13,代码来源:AttackHandler.java

示例8: underworldTeleport

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void underworldTeleport(LivingHurtEvent event) {
	if (!(event.getEntity() instanceof EntityPlayer)) return;
	if (event.getSource() == DamageSource.FALL && fallResetter.contains(event.getEntity().getUniqueID())) {
		fallResetter.remove(event.getEntity().getUniqueID());
		event.setCanceled(true);
		return;
	}
	if (event.getEntity().getEntityWorld().provider.getDimension() == Wizardry.underWorld.getId()) {
		if (event.getSource() == EntityDamageSource.OUT_OF_WORLD) {
			EntityPlayer player = ((EntityPlayer) event.getEntityLiving());
			BlockPos spawn = player.isSpawnForced(0) ? player.getBedLocation(0) : player.world.getSpawnPoint().add(player.world.rand.nextGaussian() * 16, 0, player.world.rand.nextGaussian() * 16);
			BlockPos teleportTo = spawn.add(0, 300 - spawn.getY(), 0);
			TeleportUtil.teleportToDimension((EntityPlayer) event.getEntity(), 0, teleportTo.getX(), teleportTo.getY(), teleportTo.getZ());
			fallResetter.add(event.getEntity().getUniqueID());
			event.setCanceled(true);
		}
	} else if (event.getEntity().getEntityWorld().provider.getDimension() == 0) {
		if (event.getSource() == EntityDamageSource.FALL && event.getEntity().fallDistance >= ConfigValues.underworldFallDistance) {
			BlockPos location = event.getEntity().getPosition();
			BlockPos bedrock = PosUtils.checkNeighborBlocksThoroughly(event.getEntity().getEntityWorld(), location, Blocks.BEDROCK);
			if (bedrock != null) {
				TeleportUtil.teleportToDimension((EntityPlayer) event.getEntity(), Wizardry.underWorld.getId(), 0, 300, 0);
				((EntityPlayer) event.getEntity()).addPotionEffect(new PotionEffect(ModPotions.NULLIFY_GRAVITY, 100, 0, true, false));
				fallResetter.add(event.getEntity().getUniqueID());
				event.setCanceled(true);
			}
		}
	}
}
 
开发者ID:TeamWizardry,项目名称:Wizardry,代码行数:31,代码来源:EventHandler.java

示例9: onLivingHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingHurt(LivingHurtEvent event) {
    if (!event.getEntity().worldObj.isRemote) {
        if (event.getEntity() instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) event.getEntity();
            // Exclude Creative Players
            if (player.isCreative()) {
                return;
            }

            // Check Armor in Inventory
            for (ItemStack stack : player.getArmorInventoryList()) {
                if (stack != null && stack.getItem() == this) {
                    if (player.experienceTotal > event.getAmount()) {
                        float amount = event.getAmount();
                        // Reduce the attack amount
                        event.setAmount(amount * (1 - reduction));
                        // Take the experience
                        int exp = (int) (amount * reduction);
                        player.experience -= exp / (float) player.xpBarCap();
                        for (player.experienceTotal -= exp; player.experience <= 0.0F;
                             player.experience /= player.xpBarCap()) {
                            player.experience = (player.experience + 1.0F) * player.xpBarCap();
                            player.removeExperienceLevel(1);
                        }
                    } else {
                        // Reduce the attack amount
                        event.setAmount(event.getAmount() - player.experienceTotal);
                        // Take the experience
                        player.experienceLevel = 0;
                        player.experience = 0.0F;
                        player.experienceTotal = 0;
                    }
                    return;
                }
            }
        }
    }
}
 
开发者ID:InfinityStudio,项目名称:InspiringWorld,代码行数:40,代码来源:ItemAbyssArmor.java

示例10: onDamageArmor

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onDamageArmor(LivingHurtEvent event) {
    if (event.getEntity() instanceof EntityWolf) {
        @Nullable IWolfArmorCapability wolfArmorCapability = event.getEntity().getCapability(CapabilityWolfArmor.WOLF_ARMOR_CAPABILITY, null);
        if (wolfArmorCapability != null) {
            wolfArmorCapability.damageArmor(event.getAmount());
        }
    }
}
 
开发者ID:CenturionFox,项目名称:wolfarmor,代码行数:10,代码来源:CapabilityWolfArmor.java

示例11: onLivingHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingHurt(LivingHurtEvent ev)
{
    if (ev.getEntity().world.isRemote)
        return;

    if (ev.getEntity() instanceof EntityPlayer)
    {
        EntityPlayer player = (EntityPlayer) ev.getEntityLiving();

        ItemBreakingTracker.get(player).before();
    }
}
 
开发者ID:gigaherz,项目名称:Survivalist,代码行数:14,代码来源:ItemBreakingTracker.java

示例12: onLivingHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
/** Handle living hurt events */
@SubscribeEvent
public void onLivingHurt(LivingHurtEvent event) {
	if(event.getEntity() instanceof EntityLivingBase && !event.getEntity().worldObj.isRemote) {
		handleLightningSwordStrike(event);
		handleSpecialStrike(event);
		handleElecAuraHurt(event);
	}
}
 
开发者ID:sblectric,项目名称:LightningCraft,代码行数:10,代码来源:CombatEvents.java

示例13: handleLightningSwordStrike

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
/** Check for Hand of Thor strikes */
public void handleLightningSwordStrike(LivingHurtEvent event) {
	// make sure this hit is a valid weapon strike
	EntityLivingBase target = (EntityLivingBase)event.getEntity();
	if(target == null || target.isEntityInvulnerable(event.getSource())) return;
	EntityLivingBase user = null;
	if(event.getSource().getEntity() instanceof EntityLivingBase) user = (EntityLivingBase)event.getSource().getEntity();
	if(user == null) return;
	ItemStack weapon = user.getHeldItem(EnumHand.MAIN_HAND); if(weapon == null) return;

	// Hand of Thor enchantment
	int j = EnchantmentHelper.getEnchantmentLevel(LCEnchantments.handOfThor, weapon);
	int m = LCEnchantments.handOfThor.getMaxLevel();
	Item w = weapon.getItem();
	
	// divine overkill achievement
	int s = EnchantmentHelper.getEnchantmentLevel(Enchantments.SHARPNESS, weapon);
	if(!user.worldObj.isRemote && user instanceof EntityPlayer && j == 3 && s == 5) {
		((EntityPlayer)user).addStat(LCAchievements.mysticHammer, 1);
	}

	// different chances based on item type
	// hammers: 50% chance, up to 100% with top Hand of Thor
	// charged swords: 15% chance, up to 45%
	// regular weaponry: 0% chance, up to 10%
	double init = w instanceof ItemChargedSword ? (w instanceof ItemHammer ? 0.5 : 0.15) : 0;
	double var = w instanceof ItemChargedSword ? (w instanceof ItemHammer ? 0.5 : 0.3) : 0.1;
	if(!user.isSneaking() && random.nextDouble() < (init + var * j / m)) {
		Effect.lightning(target, false);
		weapon.damageItem(2, user);
	}
}
 
开发者ID:sblectric,项目名称:LightningCraft,代码行数:33,代码来源:CombatEvents.java

示例14: getDamage

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void getDamage(LivingHurtEvent attackEvent) {
    if (attackEvent.getSource() != null && attackEvent.getSource().getEntity() instanceof EntityPlayer) {
        ItemStack tool = ((EntityPlayer) attackEvent.getSource().getEntity()).inventory.getCurrentItem();
        int sharpness = getEffectStrength(tool, EnumRainbowColor.VIOLET, EnumRainbowColor.VIOLET);
        if (sharpness > 0) {
            attackEvent.setAmount((float) (attackEvent.getAmount() + .5 * sharpness));
        }

        int dullness = getEffectStrength(tool, EnumRainbowColor.VIOLET, EnumRainbowColor.GREEN);
        if (dullness > 0) {
            attackEvent.setAmount(attackEvent.getAmount() - dullness);
            if (attackEvent.getAmount() < 0) {
                attackEvent.setAmount(0);

            }
        }
    }
    if (attackEvent.getEntity() instanceof EntityPlayer) {
        ItemStack heldStack = ((EntityPlayer) attackEvent.getEntity()).inventory.getCurrentItem();
        if (heldStack != null) {
            int protection = getEffectStrength(heldStack, EnumRainbowColor.RED, EnumRainbowColor.VIOLET);
            if (protection > 0) {
                attackEvent.setAmount((float) (attackEvent.getAmount() * Math.pow(.9, protection)));
            }
        }
    }
}
 
开发者ID:AdlyTempleton,项目名称:Aura-Cascade,代码行数:29,代码来源:EnchantEventHandler.java

示例15: handleElecAuraHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
/** Strike back with Electrostatic Aura */
public void handleElecAuraHurt(LivingHurtEvent event) {
	if (event.getEntity() instanceof EntityPlayer) {
		EntityPlayer player = (EntityPlayer) event.getEntity();
		if(event.getSource().getEntity() instanceof EntityLivingBase) {
			EntityLivingBase attacker = (EntityLivingBase) event.getSource().getEntity();

			// Electrostatic Aura handling
			if(!attacker.isEntityInvulnerable(event.getSource())) { 
				IntList ench = new IntList();
				ItemStack helm = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
				ItemStack chest = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
				ItemStack legs = player.getItemStackFromSlot(EntityEquipmentSlot.LEGS);
				ItemStack boots = player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
				int lv = 0, a = 0;
				int damageHelm = 0, damageChest = 0, damageLegs = 0, damageBoots = 0;
				if(helm != null) {
					damageHelm = EnchantmentHelper.getEnchantmentLevel(LCEnchantments.elecAura, helm);
					ench.add(damageHelm);
					if(helm.getItem() instanceof ItemMysticArmor) ++a;
				}
				if(chest != null) {
					damageChest = EnchantmentHelper.getEnchantmentLevel(LCEnchantments.elecAura, chest);
					ench.add(damageChest);
					if(chest.getItem() instanceof ItemMysticArmor) ++a;
				}
				if(legs != null) {
					damageLegs = EnchantmentHelper.getEnchantmentLevel(LCEnchantments.elecAura, legs);
					ench.add(damageLegs);
					if(legs.getItem() instanceof ItemMysticArmor) ++a;
				}
				if(boots != null) {
					damageBoots = EnchantmentHelper.getEnchantmentLevel(LCEnchantments.elecAura, boots);
					ench.add(damageBoots);
					if(boots.getItem() instanceof ItemMysticArmor) ++a;
				}

				// get the max enchantment
				for(int i : ench) {
					lv += i; // the effect stacks
				}

				// now apply a thorns-like lightning defense
				// the effect stacks (maximum of 24% chance with all armor enchanted)
				if(lv > 0) {
					// EA I = 2% chance per item
					// EA II = 4% chance per item
					// EA III = 6% chance per item
					if(random.nextDouble() <= lv * 2/100D) {
						Effect.lightning(attacker, false);
						if(damageHelm > 0) helm.damageItem(4 * damageHelm, player);
						if(damageChest > 0) chest.damageItem(4 * damageChest, player);
						if(damageLegs > 0) legs.damageItem(4 * damageLegs, player);
						if(damageBoots > 0) boots.damageItem(4 * damageBoots, player);
						
						// achievement get (full Mystic armor, full elecAura)
						if(a >= 4 && lv >= 12) {
							player.addStat(LCAchievements.mysticArmor, 1);
						}
					}
				}
			}				
		}
	}
}
 
开发者ID:sblectric,项目名称:LightningCraft,代码行数:66,代码来源:CombatEvents.java


注:本文中的net.minecraftforge.event.entity.living.LivingHurtEvent.getEntity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。