本文整理汇总了Java中org.spongepowered.api.event.entity.DamageEntityEvent.setBaseDamage方法的典型用法代码示例。如果您正苦于以下问题:Java DamageEntityEvent.setBaseDamage方法的具体用法?Java DamageEntityEvent.setBaseDamage怎么用?Java DamageEntityEvent.setBaseDamage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.event.entity.DamageEntityEvent
的用法示例。
在下文中一共展示了DamageEntityEvent.setBaseDamage方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerDamaged
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerDamaged(DamageEntityEvent event)
{
if (event.getTargetEntity() instanceof Player)
{
Player player = (Player) event.getTargetEntity();
if (Utils.isTeleportCooldownEnabled() && EssentialCmds.teleportingPlayers.contains(player.getUniqueId()))
{
EssentialCmds.teleportingPlayers.remove(player.getUniqueId());
player.sendMessage(Text.of(TextColors.RED, "Teleportation canceled due to damage."));
}
if (EssentialCmds.godPlayers.contains(player.getUniqueId()))
{
event.setBaseDamage(0);
event.setCancelled(true);
}
}
}
示例2: onEntityDamage
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
@Listener(order = Order.LAST)
public void onEntityDamage(DamageEntityEvent event) {
if (event.isCancelled() || event.getFinalDamage() == 0) {
return;
}
if (event.getTargetEntity().getType() == EntityTypes.PLAYER) {
UUID id = event.getTargetEntity().getUniqueId();
IActiveCharacter character = characterService.getCharacter(id);
IEffectContainer container = character.getEffect(name);
if (container == null)
return;
if (!event.getCause().first(SoulBindEffect.class).isPresent()) {
event.setBaseDamage(event.getBaseDamage() * .5);
SoulBindEffect effect = (SoulBindEffect) container;
SkillDamageSourceBuilder builder = new SkillDamageSourceBuilder();
if (effect.getConsumer() == character) {
effect.getTarget().getEntity().damage(event.getBaseDamage(), builder.build());
} else {
effect.getConsumer().getEntity().damage(event.getBaseDamage(), builder.build());
}
}
}
}
示例3: onEntityDamage
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
@Listener(order = Order.LATE)
public void onEntityDamage(DamageEntityEvent event, @Getter(value = "getTargetEntity") Player player, @First DamageSource dmgSrc) {
if (!isBlockable(dmgSrc)) {
return;
}
Optional<Clause<Integer, Clause<ItemStack, Clause<Integer, Long>>>> optFeatherDetail = getHighestPoweredFeather(player);
if (!optFeatherDetail.isPresent()) {
return;
}
Clause<Integer, Clause<ItemStack, Clause<Integer, Long>>> featherDetail = optFeatherDetail.get();
int redQ = featherDetail.getValue().getValue().getKey();
final double dmg = event.getBaseDamage();
final int k = (dmg > 80 ? 16 : dmg > 40 ? 8 : dmg > 20 ? 4 : 2);
final double blockable = redQ * k;
final double blocked = blockable - (blockable - dmg);
event.setBaseDamage(Math.max(0, dmg - blocked));
redQ = (int) ((blockable - blocked) / k);
updateFeatherPower(featherDetail.getValue().getKey(), redQ, (long) blocked * 75);
tf(player).inventory.mainInventory.set(featherDetail.getKey(), tf(featherDetail.getValue().getKey()));
}
示例4: onEntityDamageEvent
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
@Listener(order = Order.LAST)
public void onEntityDamageEvent(DamageEntityEvent event) {
Entity defender = event.getTargetEntity();
Optional<PatientXInstance> optInst = manager.getApplicableZone(defender);
if (!optInst.isPresent()) {
return;
}
PatientXInstance inst = optInst.get();
DamageSource dmgSource = event.getCause().first(DamageSource.class).get();
if (defender instanceof Player && manager.getBlockedDamage().contains(dmgSource.getType())) {
// Explosive damage formula: (1 × 1 + 1) × 8 × power + 1
// Use 49, snowball power is 3
double ratio = event.getBaseDamage() / 49;
// Nullify all modifiers
for (DamageFunction modifier : event.getModifiers()) {
event.setDamage(modifier.getModifier(), (a) -> 0D);
}
event.setBaseDamage(ratio * inst.getDifficulty());
}
}
示例5: onPlayerDamage
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerDamage(DamageEntityEvent event) {
// C'est un joueur
if (event.getTargetEntity() instanceof Player) {
EPlayer player = this.plugin.getEServer().getEPlayer((Player) event.getTargetEntity());
if (player.isGod()) {
Optional<DamageSource> damagesource = event.getCause().first(DamageSource.class);
// Le joueur tombe dans le vide
if (damagesource.isPresent() && damagesource.get().equals(DamageSources.VOID)) {
// L'option de téléportation au spwan est activé
if (this.plugin.getConfigs().isGodTeleportToSpawn()) {
EEMessages.GOD_TELEPORT.sendTo(player);
player.teleportSpawn();
player.heal();
event.setCancelled(true);
}
// Domage normal
} else {
player.heal();
event.setCancelled(true);
}
}
} else if (event.getTargetEntity() instanceof Creature) {
if (this.plugin.getConfigs().isGameModeKill()) {
Optional<EntityDamageSource> optDamageSource = event.getCause().first(EntityDamageSource.class);
if (optDamageSource.isPresent() && optDamageSource.get().getSource() instanceof Player) {
Player killer = (Player) optDamageSource.get().getSource();
if (killer.get(Keys.IS_SNEAKING).orElse(false) &&
killer.get(Keys.GAME_MODE).orElse(GameModes.SURVIVAL).equals(GameModes.CREATIVE)) {
Entity entity = event.getTargetEntity();
event.setBaseDamage(entity.get(Keys.MAX_HEALTH).orElse(Double.MAX_VALUE));
}
}
}
}
}
示例6: onIndirectEntityDamage
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
@Listener
public void onIndirectEntityDamage(DamageEntityEvent event,
@First(typeFilter = IndirectEntityDamageSource.class)
IndirectEntityDamageSource indirectEntityDamageSource) {
Projectile projectile = (Projectile) indirectEntityDamageSource.getSource();
IEntity shooter = entityService.get((Entity) projectile.getShooter());
IEntity target = entityService.get(event.getTargetEntity());
ProjectileProperties projectileProperties = ProjectileProperties.cache.get(projectile);
if (projectileProperties != null) {
ProjectileProperties.cache.remove(projectile);
projectileProperties.consumer.accept(shooter, target);
return;
}
double projectileDamage = 0;
if (shooter.getType() == IEntityType.CHARACTER) {
IActiveCharacter c = (IActiveCharacter) shooter;
projectileDamage = damageService.getCharacterProjectileDamage(c, projectile.getType());
} else if (shooter.getType() == IEntityType.MOB) {
if (!PluginConfig.OVERRIDE_MOBS) {
projectileDamage = entityService.getMobDamage(shooter.getEntity().getType());
}
}
ProjectileHitEvent event1 = new ProjectileHitEvent(shooter, target, projectileDamage, projectile);
Sponge.getGame().getEventManager().post(event1);
if (event1.isCancelled() || event1.getProjectileDamage() <= 0) {
event.setCancelled(true);
return;
}
event.setBaseDamage(event1.getProjectileDamage());
}
示例7: processAttackOnEntity
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
public void processAttackOnEntity(Living attacker, DamageEntityEvent event) {
int diff = (int) (getMaxHealth(attacker) - getHealth(attacker));
double randomRelative = Probability.getRandom(Probability.getRandom(Math.pow(diff, 2)));
event.setBaseDamage(Math.max(5, randomRelative));
// Damage the user by 1 damage
attacker.offer(Keys.HEALTH, getHealth(attacker) - 1);
}
示例8: processAttackOnPlayer
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
public void processAttackOnPlayer(Living attacker, Player defender, DamageEntityEvent event) {
event.setBaseDamage(0);
Living target = defender;
if (Probability.getChance(2)) {
target = attacker;
}
double targetHealth = getHealth(target);
target.offer(Keys.HEALTH, Math.max(0, targetHealth - 16));
}
示例9: apply
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
@Override
public Optional<Instruction<DamageCondition, Boss<Zombie, CatacombsBossDetail>>> apply(
DamageCondition damageCondition, Boss<Zombie, CatacombsBossDetail> zombieCatacombsBossDetailBoss
) {
int wave = zombieCatacombsBossDetailBoss.getDetail().getWave();
DamageEntityEvent event = damageCondition.getEvent();
event.setBaseDamage(Probability.getRandom(Probability.getRandom(wave * .2)) + event.getBaseDamage());
return Optional.empty();
}
示例10: onEntityDamage
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
@Listener
public void onEntityDamage(DamageEntityEvent event)
{
if(event.getCause().root() instanceof DamageSource)
{
DamageSource source = (DamageSource) event.getCause().root();
if(event.getTargetEntity().getType() == EntityTypes.PLAYER)
{
Player attackedPlayer = (Player) event.getTargetEntity();
World world = attackedPlayer.getWorld();
if(FactionLogic.getFactionNameByChunk(world.getUniqueId(), attackedPlayer.getLocation().getChunkPosition()).equals("SafeZone"))
{
event.setBaseDamage(0);
event.setCancelled(true);
return;
}
if(source instanceof Player)
{
Player player = (Player) source;
if(FactionLogic.getFactionNameByChunk(world.getUniqueId(), player.getLocation().getChunkPosition()).equals("SafeZone"))
{
event.setBaseDamage(0);
event.setCancelled(true);
return;
}
else
{
if(FactionLogic.getFactionName(player.getUniqueId()) != null)
{
//Check if players are in the same faction
if(FactionLogic.getFactionName(player.getUniqueId()) == FactionLogic.getFactionName(attackedPlayer.getUniqueId()))
{
if(!FactionLogic.getFactionFriendlyFire(FactionLogic.getFactionName(player.getUniqueId())))
{
event.setBaseDamage(0);
event.setCancelled(true);
return;
}
else
{
if(event.willCauseDeath())
{
PowerService.punish(player.getUniqueId());
return;
}
}
}//Check if players are in the alliance.
else if(FactionLogic.getAlliances(FactionLogic.getFactionName(player.getUniqueId())).contains(FactionLogic.getFactionName(attackedPlayer.getUniqueId())) && !MainLogic.getAllianceFriendlyFire())
{
event.setBaseDamage(0);
event.setCancelled(true);
return;
}
else if(FactionLogic.getAlliances(FactionLogic.getFactionName(player.getUniqueId())).contains(FactionLogic.getFactionName(attackedPlayer.getUniqueId())) && MainLogic.getAllianceFriendlyFire())
{
if(event.willCauseDeath())
{
PowerService.punish(player.getUniqueId());
return;
}
}
}
else
{
if(event.willCauseDeath())
{
PowerService.addPower(player.getUniqueId(), true);
return;
}
}
}
}
}
}
return;
}
示例11: run
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
@Override
public void run(Living owner, Living attacker, DamageEntityEvent event) {
double reflectionAmount = event.getBaseDamage() * modifier;
event.setBaseDamage(event.getBaseDamage() - reflectionAmount);
attacker.damage(Math.max(minimum, reflectionAmount), damageSource(owner));
}
示例12: run
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
event.setBaseDamage(event.getBaseDamage() * modifier);
}