本文整理匯總了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)))));
}