Fix hand tracking

This commit is contained in:
fullwall 2024-01-26 18:55:11 +08:00
parent af728ec4b1
commit dbd9cdf1f1
1 changed files with 11 additions and 10 deletions

View File

@ -286,24 +286,25 @@ public class CommandTrait extends Trait {
executionErrors.put(player.getUniqueId().toString(), EnumSet.noneOf(CommandTraitError.class)); executionErrors.put(player.getUniqueId().toString(), EnumSet.noneOf(CommandTraitError.class));
} }
for (NPCCommand command : commandList) { for (NPCCommand command : commandList) {
if (executionMode == ExecutionMode.SEQUENTIAL) { PlayerNPCCommand info = null;
PlayerNPCCommand info = playerTracking.get(player.getUniqueId()); if (executionMode == ExecutionMode.SEQUENTIAL
if (info != null && info.lastUsedHand != hand) { && (info = playerTracking.get(player.getUniqueId())) != null) {
if (info.lastUsedHand != hand) {
info.lastUsedHand = hand; info.lastUsedHand = hand;
info.lastUsedId = -1; info.lastUsedId = -1;
} }
if (info != null && command.id <= info.lastUsedId) { if (command.id <= info.lastUsedId) {
if (info.lastUsedId == max) { if (info.lastUsedId != max)
info.lastUsedId = -1;
} else {
continue; continue;
} info.lastUsedId = -1;
} }
} }
runCommand(player, command); runCommand(player, command);
if (executionMode == ExecutionMode.SEQUENTIAL || charged != null && !charged) { if (executionMode == ExecutionMode.SEQUENTIAL) {
break; playerTracking.get(player.getUniqueId()).lastUsedHand = hand;
} }
if (executionMode == ExecutionMode.SEQUENTIAL || (charged != null && !charged))
break;
} }
} }