當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。