當前位置: 首頁>>代碼示例>>Java>>正文


Java LivingHurtEvent.getEntityLiving方法代碼示例

本文整理匯總了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);
}
 
開發者ID:DaedalusGame,項目名稱:Soot,代碼行數:20,代碼來源:Attributes.java

示例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);
        }
    }
}
 
開發者ID:Randores,項目名稱:Randores2,代碼行數:19,代碼來源:LivingHurtListener.java

示例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();
}
 
開發者ID:bafomdad,項目名稱:uniquecrops,代碼行數:24,代碼來源:EmblemTransformation.java

示例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;
}
 
開發者ID:sblectric,項目名稱:AdvancedCombat,代碼行數:18,代碼來源:ArmorHandler.java

示例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);
		}
}
 
開發者ID:The-Fireplace-Minecraft-Mods,項目名稱:Overlord,代碼行數:23,代碼來源:CommonEvents.java

示例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);
	}
}
 
開發者ID:murapix,項目名稱:Inhuman-Resources,代碼行數:19,代碼來源:EventHandler.java

示例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);
			}
		}
	}
}
 
開發者ID:TheXFactor117,項目名稱:Lost-Eclipse-Outdated,代碼行數:20,代碼來源:EventFlameCloak.java

示例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;
      }
    }
  }
}
 
開發者ID:PrinceOfAmber,項目名稱:Cyclic,代碼行數:27,代碼來源:ItemSoulstone.java

示例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;
}
 
開發者ID:kenijey,項目名稱:harshencastle,代碼行數:9,代碼來源:PlayerPunchedEvent.java

示例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);
        }
    }
}
 
開發者ID:Randores,項目名稱:Randores2,代碼行數:13,代碼來源:EmpoweredArmorListener.java

示例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;
			}
		}
	}
}
 
開發者ID:Lemonszz,項目名稱:Anima-Mundi,代碼行數:41,代碼來源:ShieldEvents.java

示例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);
}
 
開發者ID:ToroCraft,項目名稱:NemesisSystem,代碼行數:30,代碼來源:AttackHandler.java

示例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);
	}
}
 
開發者ID:sblectric,項目名稱:AdvancedCombat,代碼行數:10,代碼來源:ArmorHandler.java

示例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;
}
 
開發者ID:sblectric,項目名稱:AdvancedCombat,代碼行數:29,代碼來源:ArmorHandler.java

示例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);
		}
	}
}
 
開發者ID:V0idWa1k3r,項目名稱:ExPetrum,代碼行數:13,代碼來源:ExPHandlerServer.java


注:本文中的net.minecraftforge.event.entity.living.LivingHurtEvent.getEntityLiving方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。