当前位置: 首页>>代码示例>>Java>>正文


Java DamageModifier类代码示例

本文整理汇总了Java中org.bukkit.event.entity.EntityDamageEvent.DamageModifier的典型用法代码示例。如果您正苦于以下问题:Java DamageModifier类的具体用法?Java DamageModifier怎么用?Java DamageModifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DamageModifier类属于org.bukkit.event.entity.EntityDamageEvent包,在下文中一共展示了DamageModifier类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: callEntityDamageEvent

import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; //导入依赖的package包/类
private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions) {
    EntityDamageEvent event;
    if (damager != null) {
        event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    } else {
        event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    }

    callEvent(event);

    if (!event.isCancelled()) {
        event.getEntity().setLastDamageCause(event);
    }

    return event;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:17,代码来源:CraftEventFactory.java

示例2: handleLivingEntityDamageEvent

import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; //导入依赖的package包/类
public static EntityDamageEvent handleLivingEntityDamageEvent(Entity damagee, DamageSource source, double rawDamage, double hardHatModifier, double blockingModifier, double armorModifier, double resistanceModifier, double magicModifier, double absorptionModifier, Function<Double, Double> hardHat, Function<Double, Double> blocking, Function<Double, Double> armor, Function<Double, Double> resistance, Function<Double, Double> magic, Function<Double, Double> absorption) {
    Map<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    Map<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<DamageModifier, Function<? super Double, Double>>(DamageModifier.class);
    modifiers.put(DamageModifier.BASE, rawDamage);
    modifierFunctions.put(DamageModifier.BASE, ZERO);
    if (source == DamageSource.fallingBlock || source == DamageSource.anvil) {
        modifiers.put(DamageModifier.HARD_HAT, hardHatModifier);
        modifierFunctions.put(DamageModifier.HARD_HAT, hardHat);
    }
    if (damagee instanceof EntityPlayer) {
        modifiers.put(DamageModifier.BLOCKING, blockingModifier);
        modifierFunctions.put(DamageModifier.BLOCKING, blocking);
    }
    modifiers.put(DamageModifier.ARMOR, armorModifier);
    modifierFunctions.put(DamageModifier.ARMOR, armor);
    modifiers.put(DamageModifier.RESISTANCE, resistanceModifier);
    modifierFunctions.put(DamageModifier.RESISTANCE, resistance);
    modifiers.put(DamageModifier.MAGIC, magicModifier);
    modifierFunctions.put(DamageModifier.MAGIC, magic);
    modifiers.put(DamageModifier.ABSORPTION, absorptionModifier);
    modifierFunctions.put(DamageModifier.ABSORPTION, absorption);
    return handleEntityDamageEvent(damagee, source, modifiers, modifierFunctions);
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:24,代码来源:CraftEventFactory.java

示例3: handleNonLivingEntityDamageEvent

import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; //导入依赖的package包/类
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage) {
    if (entity instanceof EntityEnderCrystal && !(source instanceof EntityDamageSource)) {
        return false;
    }

    final EnumMap<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    final EnumMap<DamageModifier, Function<? super Double, Double>> functions = new EnumMap(DamageModifier.class);

    modifiers.put(DamageModifier.BASE, damage);
    functions.put(DamageModifier.BASE, ZERO);

    final EntityDamageEvent event = handleEntityDamageEvent(entity, source, modifiers, functions);
    if (event == null) {
        return false;
    }
    return event.isCancelled() || (event.getDamage() == 0 && !(entity instanceof EntityItemFrame)); // Cauldron - fix frame removal
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:18,代码来源:CraftEventFactory.java

示例4: damage

import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; //导入依赖的package包/类
@Override
public void damage(double amount)
{
	Map<DamageModifier, Double> modifiers = new EnumMap<>(DamageModifier.class);
	modifiers.put(DamageModifier.BASE, 1.0);
	Map<DamageModifier, Function<Double, Double>> modifierFunctions = new EnumMap<>(DamageModifier.class);
	modifierFunctions.put(DamageModifier.BASE, damage -> damage);
	
	EntityDamageEvent event = new EntityDamageEvent(this, DamageCause.CUSTOM, modifiers, modifierFunctions);
	event.setDamage(amount);
	Bukkit.getPluginManager().callEvent(event);
	if (!event.isCancelled())
	{
		setHealth(health - amount);
	}
}
 
开发者ID:seeseemelk,项目名称:MockBukkit,代码行数:17,代码来源:PlayerMock.java

示例5: handleLivingEntityDamageEvent

import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; //导入依赖的package包/类
public static EntityDamageEvent handleLivingEntityDamageEvent(Entity damagee, DamageSource source, double rawDamage, double hardHatModifier, double blockingModifier, double armorModifier, double resistanceModifier, double magicModifier, double absorptionModifier, Function<Double, Double> hardHat, Function<Double, Double> blocking, Function<Double, Double> armor, Function<Double, Double> resistance, Function<Double, Double> magic, Function<Double, Double> absorption) {
    Map<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    Map<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<DamageModifier, Function<? super Double, Double>>(DamageModifier.class);
    modifiers.put(DamageModifier.BASE, rawDamage);
    modifierFunctions.put(DamageModifier.BASE, ZERO);
    if (source == DamageSource.FALLING_BLOCK || source == DamageSource.ANVIL) {
        modifiers.put(DamageModifier.HARD_HAT, hardHatModifier);
        modifierFunctions.put(DamageModifier.HARD_HAT, hardHat);
    }
    if (damagee instanceof EntityHuman) {
        modifiers.put(DamageModifier.BLOCKING, blockingModifier);
        modifierFunctions.put(DamageModifier.BLOCKING, blocking);
    }
    modifiers.put(DamageModifier.ARMOR, armorModifier);
    modifierFunctions.put(DamageModifier.ARMOR, armor);
    modifiers.put(DamageModifier.RESISTANCE, resistanceModifier);
    modifierFunctions.put(DamageModifier.RESISTANCE, resistance);
    modifiers.put(DamageModifier.MAGIC, magicModifier);
    modifierFunctions.put(DamageModifier.MAGIC, magic);
    modifiers.put(DamageModifier.ABSORPTION, absorptionModifier);
    modifierFunctions.put(DamageModifier.ABSORPTION, absorption);
    return handleEntityDamageEvent(damagee, source, modifiers, modifierFunctions);
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:24,代码来源:CraftEventFactory.java

示例6: handleNonLivingEntityDamageEvent

import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; //导入依赖的package包/类
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage, boolean cancelOnZeroDamage) {
    if (entity instanceof EntityEnderCrystal && !(source instanceof EntityDamageSource)) {
        return false;
    }

    final EnumMap<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    final EnumMap<DamageModifier, Function<? super Double, Double>> functions = new EnumMap(DamageModifier.class);

    modifiers.put(DamageModifier.BASE, damage);
    functions.put(DamageModifier.BASE, ZERO);

    final EntityDamageEvent event = handleEntityDamageEvent(entity, source, modifiers, functions);
    if (event == null) {
        return false;
    }
    return event.isCancelled() || (cancelOnZeroDamage && event.getDamage() == 0);
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:18,代码来源:CraftEventFactory.java

示例7: processSwordCombat

import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; //导入依赖的package包/类
private static void processSwordCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) {
    McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
    SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
    double initialDamage = event.getDamage();
    Map<DamageModifier, Double> modifiers = getModifiers(event);

    if (swordsManager.canActivateAbility()) {
        mcMMOPlayer.checkAbilityActivation(SkillType.SWORDS);
    }

    if (swordsManager.canUseBleed()) {
        swordsManager.bleedCheck(target);
    }

    if (swordsManager.canUseSerratedStrike()) {
        swordsManager.serratedStrikes(target, initialDamage, modifiers);
    }

    startGainXp(mcMMOPlayer, target, SkillType.SWORDS);
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:21,代码来源:CombatUtils.java

示例8: applyScaledModifiers

import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; //导入依赖的package包/类
public static EntityDamageByEntityEvent applyScaledModifiers(double initialDamage, double finalDamage, EntityDamageByEntityEvent event) {
    // No additional damage
    if (initialDamage == finalDamage) {
        return event;
    }

    for (DamageModifier modifier : DamageModifier.values()) {
        if (!event.isApplicable(modifier)) {
            continue;
        }

        if (modifier == DamageModifier.BASE) {
            event.setDamage(modifier, finalDamage);
            continue;
        }

        event.setDamage(modifier, finalDamage / initialDamage * event.getDamage(modifier));
    }

    return event;
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:22,代码来源:CombatUtils.java


注:本文中的org.bukkit.event.entity.EntityDamageEvent.DamageModifier类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。