From 5fcfc7aa8dfcfe69708e26ab34c2db5c589659d9 Mon Sep 17 00:00:00 2001 From: altrisi Date: Sun, 2 Apr 2023 21:54:44 +0200 Subject: [PATCH] Tiny drive-by cleanup of action pack's `onUpdate` --- src/main/java/carpet/helpers/EntityPlayerActionPack.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/carpet/helpers/EntityPlayerActionPack.java b/src/main/java/carpet/helpers/EntityPlayerActionPack.java index 53916b95..2df403fe 100644 --- a/src/main/java/carpet/helpers/EntityPlayerActionPack.java +++ b/src/main/java/carpet/helpers/EntityPlayerActionPack.java @@ -213,19 +213,20 @@ public class EntityPlayerActionPack public void onUpdate() { Map actionAttempts = new HashMap<>(); - actions.entrySet().removeIf((e) -> e.getValue().done); + actions.values().removeIf(e -> e.done); for (Map.Entry e : actions.entrySet()) { + ActionType type = e.getKey(); Action action = e.getValue(); // skipping attack if use was successful - if (!(actionAttempts.getOrDefault(ActionType.USE, false) && e.getKey() == ActionType.ATTACK)) + if (!(actionAttempts.getOrDefault(ActionType.USE, false) && type == ActionType.ATTACK)) { Boolean actionStatus = action.tick(this, e.getKey()); if (actionStatus != null) - actionAttempts.put(e.getKey(), actionStatus); + actionAttempts.put(type, actionStatus); } // optionally retrying use after successful attack and unsuccessful use - if ( e.getKey() == ActionType.ATTACK + if (type == ActionType.ATTACK && actionAttempts.getOrDefault(ActionType.ATTACK, false) && !actionAttempts.getOrDefault(ActionType.USE, true) ) {