From 254d960fe202fa4cba4d6a69afc24280b436b509 Mon Sep 17 00:00:00 2001 From: boybook Date: Sun, 24 Dec 2023 20:46:55 +0800 Subject: [PATCH] =?UTF-8?q?12=E6=9C=8824=E6=97=A5=E4=B8=8A=E7=BA=BF?= =?UTF-8?q?=EF=BC=9A=E7=BB=A7=E7=BB=AD=E4=BC=98=E5=8C=96Entity=E5=BA=95?= =?UTF-8?q?=E5=B1=82=E7=9A=84=E6=80=A7=E8=83=BD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/cn/nukkit/entity/Entity.java | 45 ++++++++++++---------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/main/java/cn/nukkit/entity/Entity.java b/src/main/java/cn/nukkit/entity/Entity.java index a2a93ccd9d2..79726e7bdec 100644 --- a/src/main/java/cn/nukkit/entity/Entity.java +++ b/src/main/java/cn/nukkit/entity/Entity.java @@ -66,6 +66,9 @@ public abstract class Entity extends Location implements Metadatable, EntityData private static final Map BY_NAME = new Object2ObjectOpenHashMap<>(); private static final Map, EntityEntry> BY_CLASS = new IdentityHashMap<>(); + //EaseCation 优化 + protected boolean needEntityBaseTick = true; + protected Map hasSpawned = new ConcurrentHashMap<>(); protected final Map effects = new ConcurrentHashMap<>(); @@ -1272,30 +1275,32 @@ public boolean entityBaseTick(int tickDiff) { boolean hasUpdate = false; - this.checkBlockCollision(); + if (this.needEntityBaseTick) { + this.checkBlockCollision(); - if (this.y < level.getMinHeight() - 18 && this.isAlive()) { - this.attack(new EntityDamageEvent(this, DamageCause.VOID, 4)); - hasUpdate = true; - } + if (this.y < level.getMinHeight() - 18 && this.isAlive()) { + this.attack(new EntityDamageEvent(this, DamageCause.VOID, 4)); + hasUpdate = true; + } - if (this.fireTicks > 0) { - if (this.fireProof) { - this.fireTicks -= 4 * tickDiff; - if (this.fireTicks < 0) { - this.fireTicks = 0; + if (this.fireTicks > 0) { + if (this.fireProof) { + this.fireTicks -= 4 * tickDiff; + if (this.fireTicks < 0) { + this.fireTicks = 0; + } + } else { + if (!this.hasEffect(Effect.FIRE_RESISTANCE) && ((this.fireTicks % 20) == 0 || tickDiff > 20) && (!isPlayer || level.gameRules.getBoolean(GameRule.FIRE_DAMAGE))) { + this.attack(new EntityDamageEvent(this, DamageCause.FIRE_TICK, 1)); + } + this.fireTicks -= tickDiff; } - } else { - if (!this.hasEffect(Effect.FIRE_RESISTANCE) && ((this.fireTicks % 20) == 0 || tickDiff > 20) && (!isPlayer || level.gameRules.getBoolean(GameRule.FIRE_DAMAGE))) { - this.attack(new EntityDamageEvent(this, DamageCause.FIRE_TICK, 1)); + if (this.fireTicks <= 0) { + this.extinguish(); + } else { + this.setDataFlag(DATA_FLAG_ONFIRE, true); + hasUpdate = true; } - this.fireTicks -= tickDiff; - } - if (this.fireTicks <= 0) { - this.extinguish(); - } else { - this.setDataFlag(DATA_FLAG_ONFIRE, true); - hasUpdate = true; } }