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


Java LivingHurtEvent.setAmount方法代码示例

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


在下文中一共展示了LivingHurtEvent.setAmount方法的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: 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

示例3: postInit

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void postInit(LivingHurtEvent e) {

	DamageSource source = e.getSource();

	Iterable<ItemStack> armorStacks = e.getEntityLiving().getArmorInventoryList();

	// boolean hasHeavyArmor = false;
	float reduction = 0;

	for (ItemStack armorStack : armorStacks) {
		if (isHeavyArmor(armorStack)) {
			if (source.isProjectile() || source.isExplosion()) {
				reduction += 0.2;
			}
		}
	}

	if (reduction > 0) {
		float newDamage = (1 - reduction) * e.getAmount();
		System.out.println("Heavy armor reduction: [" + reduction + "] IN[" + e.getAmount() + "] OUT[" + newDamage + "]");
		e.setAmount(newDamage);
	}
}
 
开发者ID:ToroCraft,项目名称:ToroQuest,代码行数:25,代码来源:ItemReinforcedDiamondArmor.java

示例4: 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

示例5: onEntityDamage

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityDamage(LivingHurtEvent event) {
	DamageSource source = event.getSource();

	Entity attacker = source.getTrueSource();
	if ((attacker instanceof EntityLivingBase) && ((EntityLivingBase) attacker).getCreatureAttribute() == EnumCreatureAttribute.UNDEAD) {
		event.setAmount(event.getAmount() * 0.95F);
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:10,代码来源:ItemSilverArmor.java

示例6: onLivingHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@HarshenEvent
public void onLivingHurt(LivingHurtEvent event)
{
	if(event.getSource() instanceof EntityDamageSource && ((EntityDamageSource)event.getSource()).getTrueSource() instanceof EntityZombie &&
			!(((EntityDamageSource)event.getSource()).getTrueSource() instanceof EntityPigZombie))
		event.setAmount(1);
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:8,代码来源:ZombiPendant.java

示例7: 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

示例8: onHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHurt(LivingHurtEvent event) {
	DamageSource source = event.getSource();
	if (source != null && source.getImmediateSource() != null) {
		Entity entity = source.getImmediateSource();
		if (entity != null && entity instanceof EntityLivingBase) {
			EntityLivingBase attacker = (EntityLivingBase) entity;
			if (attacker.getHeldItemMainhand().getItem() == ModItems.mace) {
				float amount = Math.max(event.getAmount() - (20F / ((event.getEntityLiving().getTotalArmorValue() + 1F)) - 1F), (event.getAmount() / 3F));
				event.setAmount(amount);
			}
		}
	}
}
 
开发者ID:the-realest-stu,项目名称:Adventurers-Toolbox,代码行数:15,代码来源:WeaponHandler.java

示例9: livingAttack

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority=EventPriority.HIGH)
public void livingAttack(LivingHurtEvent event) {
	if(event.isCanceled() || event.getSource().isUnblockable())
		return;
	if(event.getEntityLiving().hasCapability(RIG.RIG_ITEM, null)) {
		ItemStack rig=event.getEntityLiving().getCapability(RIG.RIG_ITEM, null).getStackInSlot(0);
		if(rig.hasTagCompound()) {
			int reslevel=1+rig.getTagCompound().getInteger("ResU");
			if(event.getAmount() > 1f)
				event.setAmount(Math.max(1f,event.getAmount() - reslevel * 0.5f));
			
		}
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:15,代码来源:RIGEvents.java

示例10: 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

示例11: livingHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void livingHurt(LivingHurtEvent event) {
    if (event.getSource().getTrueSource() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
        if (player.getHeldItemMainhand() != ItemStack.EMPTY) {
            if (player.getHeldItemMainhand().getItem() == Items.APPLE) {
                event.setAmount(10);
                event.getEntity().setFire(10);
            }
    }
}
}
 
开发者ID:Wehavecookies56,项目名称:Tutorial-Mod,代码行数:13,代码来源:TutorialModEventHandler.java

示例12: onLivingHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingHurt(LivingHurtEvent event)
{
	if (event.getEntityLiving() instanceof EntityPlayer)
	{
		PlayerAether playerAether = PlayerAether.get((EntityPlayer) event.getEntityLiving());

		if (playerAether != null && playerAether.isWearingObsidianSet())
		{
			float original = event.getAmount();
			event.setAmount(original / 2);
		}
	}
}
 
开发者ID:Modding-Legacy,项目名称:Aether-Legacy,代码行数:15,代码来源:PlayerAetherEvents.java

示例13: 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

示例14: onLivingHurtStart

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingHurtStart(LivingHurtEvent event)
{
	Entity sourceEntity = event.getSource().getTrueSource();
	if (sourceEntity instanceof EntityLivingBase)
	{
		EntityLivingBase attacker = (EntityLivingBase) sourceEntity;
		PotionEffect effect = attacker.getActivePotionEffect(PotionRegistry.MAX_CRIT);
		if (effect != null && !Util.isCritting(attacker))
			event.setAmount(event.getAmount() * 1.5F);
	}
}
 
开发者ID:murapix,项目名称:Inhuman-Resources,代码行数:13,代码来源:PotionMaxCrit.java

示例15: onLivingHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingHurt(LivingHurtEvent event)
{
	Entity sourceEntity = event.getSource().getTrueSource();
	if (sourceEntity instanceof EntityLivingBase)
	{
		EntityLivingBase attacker = (EntityLivingBase) sourceEntity;
		PotionEffect effect = attacker.getActivePotionEffect(PotionRegistry.CRIT_BONUS);
		if (effect != null && Util.isCritting(attacker))
			event.setAmount(event.getAmount() / 1.5F);
	}
}
 
开发者ID:murapix,项目名称:Inhuman-Resources,代码行数:13,代码来源:PotionCritBonus.java


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