本文整理汇总了Java中net.minecraft.server.DamageSource类的典型用法代码示例。如果您正苦于以下问题:Java DamageSource类的具体用法?Java DamageSource怎么用?Java DamageSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DamageSource类属于net.minecraft.server包,在下文中一共展示了DamageSource类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: handleLivingEntityDamageEvent
import net.minecraft.server.DamageSource; //导入依赖的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
示例2: handleNonLivingEntityDamageEvent
import net.minecraft.server.DamageSource; //导入依赖的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
示例3: copyOf
import net.minecraft.server.DamageSource; //导入依赖的package包/类
public static DamageSource copyOf(final DamageSource original) {
CraftDamageSource newSource = new CraftDamageSource(original.translationIndex);
// Check ignoresArmor
if (original.ignoresArmor()) {
newSource.setIgnoreArmor();
}
// Check magic
if (original.isMagic()) {
newSource.setMagic();
}
// Check fire
if (original.isExplosion()) {
newSource.setExplosion();
}
return newSource;
}
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:21,代码来源:CraftDamageSource.java
示例4: copyOf
import net.minecraft.server.DamageSource; //导入依赖的package包/类
public static DamageSource copyOf(final DamageSource original) {
CraftDamageSource newSource = new CraftDamageSource(original.translationIndex);
// Check ignoresArmor
if (original.ignoresArmor()) {
newSource.j();
}
// Check magic
if (original.q()) {
newSource.r();
}
// Check fire
if (original.c()) {
newSource.l();
}
return newSource;
}
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:21,代码来源:CraftDamageSource.java
示例5: setHealth
import net.minecraft.server.DamageSource; //导入依赖的package包/类
public void setHealth(double health) {
if ((health < 0) || (health > getMaxHealth())) {
throw new IllegalArgumentException("Health must be between 0 and " + getMaxHealth());
}
if (entity instanceof EntityPlayer && health == 0) {
((EntityPlayer) entity).die(DamageSource.GENERIC);
}
getHandle().setHealth((float) health);
}
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:12,代码来源:CraftLivingEntity.java
示例6: damage
import net.minecraft.server.DamageSource; //导入依赖的package包/类
public void damage(double amount, org.bukkit.entity.Entity source) {
DamageSource reason = DamageSource.GENERIC;
if (source instanceof HumanEntity) {
reason = DamageSource.playerAttack(((CraftHumanEntity) source).getHandle());
} else if (source instanceof LivingEntity) {
reason = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle());
}
if (entity instanceof EntityEnderDragon) {
((EntityEnderDragon) entity).dealDamage(reason, (float) amount);
} else {
entity.damageEntity(reason, (float) amount);
}
}
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:16,代码来源:CraftLivingEntity.java
示例7: damage
import net.minecraft.server.DamageSource; //导入依赖的package包/类
public void damage(double amount, org.bukkit.entity.Entity source) {
DamageSource reason = DamageSource.GENERIC;
if (source instanceof HumanEntity) {
reason = DamageSource.playerAttack(((CraftHumanEntity) source).getHandle());
} else if (source instanceof LivingEntity) {
reason = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle());
}
entity.damageEntity(reason, (float) amount);
}
开发者ID:tgnmc,项目名称:Craftbukkit,代码行数:12,代码来源:CraftLivingEntity.java
示例8: handleNonLivingEntityDamageEvent
import net.minecraft.server.DamageSource; //导入依赖的package包/类
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, float damage) {
if (!(source instanceof EntityDamageSource)) {
return false;
}
// We don't need to check for null, since EntityDamageSource will always return an event
EntityDamageEvent event = handleEntityDamageEvent(entity, source, damage);
return event.isCancelled() || event.getDamage() == 0;
}
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:9,代码来源:CraftEventFactory.java
示例9: setHealth
import net.minecraft.server.DamageSource; //导入依赖的package包/类
public void setHealth(int health) {
if ((health < 0) || (health > getMaxHealth())) {
throw new IllegalArgumentException("Health must be between 0 and " + getMaxHealth());
}
if (entity instanceof EntityPlayer && health == 0) {
((EntityPlayer) entity).die(DamageSource.GENERIC);
}
getHandle().setHealth(health);
}
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:12,代码来源:CraftLivingEntity.java
示例10: damage
import net.minecraft.server.DamageSource; //导入依赖的package包/类
public void damage(int amount, org.bukkit.entity.Entity source) {
DamageSource reason = DamageSource.GENERIC;
if (source instanceof HumanEntity) {
reason = DamageSource.playerAttack(((CraftHumanEntity) source).getHandle());
} else if (source instanceof LivingEntity) {
reason = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle());
}
if (entity instanceof EntityEnderDragon) {
((EntityEnderDragon) entity).dealDamage(reason, amount);
} else {
entity.damageEntity(reason, amount);
}
}
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:16,代码来源:CraftLivingEntity.java
示例11: handleNonLivingEntityDamageEvent
import net.minecraft.server.DamageSource; //导入依赖的package包/类
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, int damage) {
if (!(source instanceof EntityDamageSource)) {
return false;
}
// We don't need to check for null, since EntityDamageSource will always return an event
EntityDamageEvent event = handleEntityDamageEvent(entity, source, damage);
return event.isCancelled() || event.getDamage() == 0;
}
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:9,代码来源:CraftEventFactory.java
注:本文中的net.minecraft.server.DamageSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论