本文整理汇总了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);
}
}
示例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))));
}
}
示例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();
}
示例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);
}
示例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)))));
}