Skip to content

Commit

Permalink
优化一轮圣符传说第二章
Browse files Browse the repository at this point in the history
  • Loading branch information
boybook committed Jul 4, 2023
1 parent 5b239a0 commit 5f7be06
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/main/java/cn/nukkit/entity/EntityLiving.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,19 @@ public void collidingWith(Entity ent) { // can override (IronGolem|Bats)
public boolean attack(EntityDamageEvent source) {
if (System.currentTimeMillis() < this.nextAllowAttack/*this.attackTime > 0*/) {
EntityDamageEvent lastCause = this.getLastDamageCause();
if (lastCause != null && (lastCause.getFinalDamage() == 0 || lastCause.getCause() == DamageCause.FIRE_TICK)) {
//上次伤害是0,这次允许输出
if (this instanceof Player) {
if (lastCause != null && (lastCause.getFinalDamage() == 0 || lastCause.getCause() == DamageCause.FIRE_TICK)) {
//上次伤害是0,这次允许输出
} else {
//叠刀时的自我安慰
if (source instanceof EntityDamageByEntityEvent && source.getCause() == DamageCause.ENTITY_ATTACK && ((EntityDamageByEntityEvent) source).getDamager() instanceof Player)
this.getLevel().addSound(this.add(0, 15, 0), SoundEnum.GAME_PLAYER_HURT, 1, 1, (Player) ((EntityDamageByEntityEvent) source).getDamager());
return false;
}
} else {
//叠刀时的自我安慰
if (source instanceof EntityDamageByEntityEvent && source.getCause() == DamageCause.ENTITY_ATTACK && ((EntityDamageByEntityEvent) source).getDamager() instanceof Player)
this.getLevel().addSound(this.add(0, 15, 0), SoundEnum.GAME_PLAYER_HURT, 1, 1, (Player) ((EntityDamageByEntityEvent) source).getDamager());
return false;
if (lastCause != null && lastCause.getDamage() >= source.getDamage()) {
return false;
}
}
}
if (this.noDamageTicks > 0) {
Expand Down

0 comments on commit 5f7be06

Please sign in to comment.