当前位置: 首页>>代码示例>>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;未经允许,请勿转载。