Skip to content

Commit

Permalink
misc: 一些调整
Browse files Browse the repository at this point in the history
  • Loading branch information
MATRIX-feather committed Oct 7, 2024
1 parent ab5d276 commit 0ac627d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
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)
{
super(bindingPlayer, EntityType.WARDEN);
}

private final Pose DIG_PLACEHOLDER_POSE = Pose.SLEEPING;

@Override
protected <X> void onEntryWrite(RegistryKey<X> key, X oldVal, X newVal)
{
Expand All @@ -48,20 +48,20 @@ protected <X> void onEntryWrite(RegistryKey<X> 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);
Expand All @@ -70,15 +70,14 @@ protected <X> void onEntryWrite(RegistryKey<X> 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);
world.playSound(bindingPlayer.getLocation(), Sound.ENTITY_WARDEN_DIG, 5, 1);
}
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);
Expand All @@ -104,7 +103,9 @@ protected <X> void onEntryWrite(RegistryKey<X> 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();
}
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/xiamomc/morph/misc/AnimationNames.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 0ac627d

Please sign in to comment.