From b8a7337bfe9fffbd73fd50ab7ed14418095caec2 Mon Sep 17 00:00:00 2001 From: Aidan Date: Tue, 6 Feb 2024 00:00:39 +0000 Subject: [PATCH] i dont believe in god but damn he better make this work --- .../radix/condition/ChainedCondition.java | 2 +- .../magus/radix/condition/MultiCondition.java | 2 +- .../minecraft/forge/key/KeyHoldCondition.java | 20 +++++++++++++++++-- .../magus/server/ServerEvents.java | 2 +- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/amuzil/omegasource/magus/radix/condition/ChainedCondition.java b/src/main/java/com/amuzil/omegasource/magus/radix/condition/ChainedCondition.java index 19ac738a..8641da71 100644 --- a/src/main/java/com/amuzil/omegasource/magus/radix/condition/ChainedCondition.java +++ b/src/main/java/com/amuzil/omegasource/magus/radix/condition/ChainedCondition.java @@ -37,7 +37,7 @@ private void finishCurrentCondition() { } else { currentConditionIndex++; } -// LogManager.getLogger().info("UNREGISTERING CURRENT CONDITION: " + currentCondition.getClass()); + LogManager.getLogger().info("UNREGISTERING CURRENT CONDITION: " + currentCondition.getClass()); currentCondition.unregister(); currentCondition = conditionSequence.get(currentConditionIndex); diff --git a/src/main/java/com/amuzil/omegasource/magus/radix/condition/MultiCondition.java b/src/main/java/com/amuzil/omegasource/magus/radix/condition/MultiCondition.java index 96ca8720..b23a23d2 100644 --- a/src/main/java/com/amuzil/omegasource/magus/radix/condition/MultiCondition.java +++ b/src/main/java/com/amuzil/omegasource/magus/radix/condition/MultiCondition.java @@ -43,7 +43,7 @@ public void reset() { int id = counter.getAndIncrement(); condition.register(() -> { synchronized (conditionsMet){ -// LogManager.getLogger().info("MARKING CONDITION MET: " + concurrentConditions.get(id).getClass()); + LogManager.getLogger().info("MARKING CONDITION MET: " + concurrentConditions.get(id).getClass()); conditionsMet.put(id, true); condition.unregister(); } diff --git a/src/main/java/com/amuzil/omegasource/magus/radix/condition/minecraft/forge/key/KeyHoldCondition.java b/src/main/java/com/amuzil/omegasource/magus/radix/condition/minecraft/forge/key/KeyHoldCondition.java index 182d8fff..35c413f6 100644 --- a/src/main/java/com/amuzil/omegasource/magus/radix/condition/minecraft/forge/key/KeyHoldCondition.java +++ b/src/main/java/com/amuzil/omegasource/magus/radix/condition/minecraft/forge/key/KeyHoldCondition.java @@ -44,6 +44,13 @@ public KeyHoldCondition(int key, int duration, int timeout, boolean release) { if (release) { LogManager.getLogger().info("ONSUCCESS RUNNING 1"); this.onSuccess.run(); + reset(); + } + } else { + if(this.currentHolding > 0) { + LogManager.getLogger().info("ONFAILURE RUNNING 1"); + this.onFailure.run(); + reset(); } } } @@ -53,11 +60,14 @@ public KeyHoldCondition(int key, int duration, int timeout, boolean release) { if (!release) { LogManager.getLogger().info("ONSUCCESS RUNNING 2"); this.onSuccess.run(); + reset(); } } if (this.currentTotal >= timeout) { + LogManager.getLogger().info("ONFAILURE RUNNING 2"); this.onFailure.run(); + reset(); } this.currentTotal++; } @@ -65,8 +75,14 @@ public KeyHoldCondition(int key, int duration, int timeout, boolean release) { } public boolean pressed(int held, int duration) { - LogManager.getLogger().info("Checking pressed. held:" + held + ", duration: " + duration); - return held >= duration || held > 0 && duration <= KEY_PRESS_TIMEOUT; + boolean pressed = held >= duration || held > 0 && duration <= KEY_PRESS_TIMEOUT; + LogManager.getLogger().info("Checking pressed. held:" + held + ", duration: " + duration + ", result: " + pressed); + return pressed; + } + + public void reset() { + this.currentTotal = 0; + this.currentHolding = 0; } public int getKey() { diff --git a/src/main/java/com/amuzil/omegasource/magus/server/ServerEvents.java b/src/main/java/com/amuzil/omegasource/magus/server/ServerEvents.java index 28dbef54..2b2ba51c 100644 --- a/src/main/java/com/amuzil/omegasource/magus/server/ServerEvents.java +++ b/src/main/java/com/amuzil/omegasource/magus/server/ServerEvents.java @@ -63,7 +63,7 @@ public static void onEntityJoinLevel(EntityJoinLevelEvent event) { @SubscribeEvent public static void OnPlayerLeaveWorld(EntityLeaveLevelEvent event) { - if(event.getLevel().isClientSide()) + if(event.getLevel().isClientSide() && event.getEntity() instanceof Player) { Magus.keyboardInputModule.unregisterInputs(); }