From 0ac627db9654d4efaa556d6732a6744511655264 Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Mon, 7 Oct 2024 17:40:22 +0800 Subject: [PATCH] =?UTF-8?q?misc:=20=E4=B8=80=E4=BA=9B=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../watchers/types/WardenWatcher.java | 17 +++++++++-------- .../java/xiamomc/morph/misc/AnimationNames.java | 7 +++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/xiamomc/morph/backends/server/renderer/network/datawatcher/watchers/types/WardenWatcher.java b/src/main/java/xiamomc/morph/backends/server/renderer/network/datawatcher/watchers/types/WardenWatcher.java index 7ec1284e..52e78ad6 100755 --- a/src/main/java/xiamomc/morph/backends/server/renderer/network/datawatcher/watchers/types/WardenWatcher.java +++ b/src/main/java/xiamomc/morph/backends/server/renderer/network/datawatcher/watchers/types/WardenWatcher.java @@ -17,6 +17,8 @@ import xiamomc.morph.misc.NmsRecord; import xiamomc.morph.misc.AnimationNames; +import java.util.concurrent.atomic.AtomicBoolean; + public class WardenWatcher extends EHasAttackAnimationWatcher { public WardenWatcher(Player bindingPlayer) @@ -24,8 +26,6 @@ public WardenWatcher(Player bindingPlayer) super(bindingPlayer, EntityType.WARDEN); } - private final Pose DIG_PLACEHOLDER_POSE = Pose.SLEEPING; - @Override protected void onEntryWrite(RegistryKey key, X oldVal, X newVal) { @@ -48,20 +48,20 @@ protected void onEntryWrite(RegistryKey key, X oldVal, X newVal) { case AnimationNames.ROAR -> { - if (this.read(ValueIndex.BASE_LIVING.POSE) == DIG_PLACEHOLDER_POSE) return; + if (this.readEntryOrDefault(CustomEntries.VANISHED, false)) return; this.block(ValueIndex.BASE_LIVING.POSE); this.writePersistent(ValueIndex.BASE_LIVING.POSE, Pose.ROARING); } case AnimationNames.ROAR_SOUND -> { - if (this.read(ValueIndex.BASE_LIVING.POSE) == DIG_PLACEHOLDER_POSE) return; + if (this.readEntryOrDefault(CustomEntries.VANISHED, false)) return; world.playSound(bindingPlayer.getLocation(), Sound.ENTITY_WARDEN_ROAR, SoundCategory.HOSTILE, 3, 1); } case AnimationNames.SNIFF -> { - if (this.read(ValueIndex.BASE_LIVING.POSE) == DIG_PLACEHOLDER_POSE) return; + if (this.readEntryOrDefault(CustomEntries.VANISHED, false)) return; this.block(ValueIndex.BASE_LIVING.POSE); this.writePersistent(ValueIndex.BASE_LIVING.POSE, Pose.SNIFFING); @@ -70,7 +70,7 @@ protected void onEntryWrite(RegistryKey key, X oldVal, X newVal) } case AnimationNames.DIGDOWN -> { - if (this.read(ValueIndex.BASE_LIVING.POSE) == DIG_PLACEHOLDER_POSE) return; + if (this.readEntryOrDefault(CustomEntries.VANISHED, false)) return; this.block(ValueIndex.BASE_LIVING.POSE); this.writePersistent(ValueIndex.BASE_LIVING.POSE, Pose.DIGGING); @@ -78,7 +78,6 @@ protected void onEntryWrite(RegistryKey key, X oldVal, X newVal) } case AnimationNames.VANISH -> { - this.writePersistent(ValueIndex.BASE_LIVING.POSE, DIG_PLACEHOLDER_POSE); this.writePersistent(ValueIndex.BASE_ENTITY.GENERAL, (byte)0x20); this.writePersistent(ValueIndex.BASE_LIVING.SILENT, true); this.writeEntry(CustomEntries.VANISHED, true); @@ -104,7 +103,9 @@ protected void onEntryWrite(RegistryKey key, X oldVal, X newVal) } case AnimationNames.TRY_RESET -> { - if (this.read(ValueIndex.BASE_LIVING.POSE) == DIG_PLACEHOLDER_POSE) return; + // 如果当前已消失,则不要调用重置 + // 因为重置会将一些动作数据重新同步为玩家的数据 + if (this.readEntryOrDefault(CustomEntries.VANISHED, false)) return; reset(); } diff --git a/src/main/java/xiamomc/morph/misc/AnimationNames.java b/src/main/java/xiamomc/morph/misc/AnimationNames.java index 0d032571..1dc5a13f 100644 --- a/src/main/java/xiamomc/morph/misc/AnimationNames.java +++ b/src/main/java/xiamomc/morph/misc/AnimationNames.java @@ -46,7 +46,14 @@ public class AnimationNames public static final String CRAWL = "crawl"; + /** + * 无论如何都重置动作数据 + */ public static final String RESET = "reset"; + + /** + * 尝试重置动作数据,如果当前情况允许的话。 + */ public static final String TRY_RESET = "try_reset"; public static final String NONE = "none";