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


Java DamageSource.isProjectile方法代碼示例

本文整理匯總了Java中net.minecraft.util.DamageSource.isProjectile方法的典型用法代碼示例。如果您正苦於以下問題:Java DamageSource.isProjectile方法的具體用法?Java DamageSource.isProjectile怎麽用?Java DamageSource.isProjectile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.util.DamageSource的用法示例。


在下文中一共展示了DamageSource.isProjectile方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onHurt

import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
@Override
public void onHurt(LivingHurtEvent event, DamageSource source, EntityLivingBase affected, int amplifier) {
	Entity attacker = source.getImmediateSource();
	if (attacker != null && source.isProjectile()) {
		event.setCanceled(true);
	}
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:8,代碼來源:BulletProofBrew.java

示例2: calcModifierDamage

import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
/**
 * Calculates the damage protection of the enchantment based on level and damage source passed.
 */
public int calcModifierDamage(int level, DamageSource source)
{
    if (source.canHarmInCreative())
    {
        return 0;
    }
    else
    {
        float f = (float)(6 + level * level) / 3.0F;
        return this.protectionType == 0 ? MathHelper.floor_float(f * 0.75F) : (this.protectionType == 1 && source.isFireDamage() ? MathHelper.floor_float(f * 1.25F) : (this.protectionType == 2 && source == DamageSource.fall ? MathHelper.floor_float(f * 2.5F) : (this.protectionType == 3 && source.isExplosion() ? MathHelper.floor_float(f * 1.5F) : (this.protectionType == 4 && source.isProjectile() ? MathHelper.floor_float(f * 1.5F) : 0))));
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:16,代碼來源:EnchantmentProtection.java

示例3: isPhysicalDamage

import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
private static boolean isPhysicalDamage(DamageSource damageSource)
{
    return damageSource.getImmediateSource() != null && !damageSource.isProjectile() && !damageSource.isExplosion() && !damageSource.isFireDamage() && !damageSource.isMagicDamage() && !damageSource.isDamageAbsolute();
}
 
開發者ID:DaedalusGame,項目名稱:Soot,代碼行數:5,代碼來源:Attributes.java

示例4: onLivingHurt

import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOWEST) //so all other can modify their damage first, and we apply after that
public static void onLivingHurt(LivingHurtEvent event) {
    EntityLivingBase entity = event.getEntityLiving();
    float amountToDamage = event.getAmount();
    if (entity.getEntityWorld().isRemote || !(entity instanceof EntityPlayer))
        return;
    EntityPlayer player = (EntityPlayer) entity;
    AbstractPlayerDamageModel damageModel = PlayerDataManager.getDamageModel(player);
    DamageSource source = event.getSource();

    if (amountToDamage == Float.MAX_VALUE) {
        damageModel.forEach(damageablePart -> damageablePart.currentHealth = 0F);
        if (player instanceof EntityPlayerMP)
            Arrays.stream(EnumPlayerPart.VALUES).forEach(part -> FirstAid.NETWORKING.sendTo(new MessageReceiveDamage(part, Float.MAX_VALUE, 0F), (EntityPlayerMP) player));
        event.setCanceled(true);
        CommonUtils.killPlayer(player, source);
        return;
    }

    amountToDamage = ArmorUtils.applyGlobalPotionModifiers(player, source, amountToDamage);

    //VANILLA COPY - combat tracker and exhaustion
    if (amountToDamage != 0.0F) {
        player.addExhaustion(source.getHungerDamage());
        //2nd param is actually never queried, no need to worry about wrong values
        player.getCombatTracker().trackDamage(source, -1, amountToDamage);
    }

    boolean addStat = amountToDamage < 3.4028235E37F;
    IDamageDistribution damageDistribution = FirstAidRegistryImpl.INSTANCE.getDamageDistribution(source);

    if (source.isProjectile()) {
        Pair<Entity, RayTraceResult> rayTraceResult = hitList.remove(player);
        if (rayTraceResult != null) {
            Entity entityProjectile = rayTraceResult.getLeft();
            EntityEquipmentSlot slot = ProjectileHelper.getPartByPosition(entityProjectile, player);
            if (slot != null)
                damageDistribution = new PreferredDamageDistribution(slot);
        }
    }

    float left = damageDistribution.distributeDamage(amountToDamage, player, source, addStat);
    if (left > 0) {
        damageDistribution = RandomDamageDistribution.NEAREST_KILL;
        damageDistribution.distributeDamage(left, player, source, addStat);
    }

    event.setCanceled(true);
    if (damageModel.isDead(player))
        CommonUtils.killPlayer(player, source);

    hitList.remove(player);
}
 
開發者ID:ichttt,項目名稱:FirstAid,代碼行數:54,代碼來源:EventHandler.java

示例5: calcModifierDamage

import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
/**
 * Calculates the damage protection of the enchantment based on level and damage source passed.
 */
public int calcModifierDamage(int level, DamageSource source)
{
    return source.canHarmInCreative() ? 0 : (this.protectionType == EnchantmentProtection.Type.ALL ? level : (this.protectionType == EnchantmentProtection.Type.FIRE && source.isFireDamage() ? level * 2 : (this.protectionType == EnchantmentProtection.Type.FALL && source == DamageSource.fall ? level * 3 : (this.protectionType == EnchantmentProtection.Type.EXPLOSION && source.isExplosion() ? level * 2 : (this.protectionType == EnchantmentProtection.Type.PROJECTILE && source.isProjectile() ? level * 2 : 0)))));
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:8,代碼來源:EnchantmentProtection.java


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