Skip to content

Commit

Permalink
i dont believe in god but damn he better make this work
Browse files Browse the repository at this point in the history
  • Loading branch information
DavieDoo committed Feb 6, 2024
1 parent 3b934c6 commit b8a7337
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
Expand All @@ -53,20 +60,29 @@ 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++;
}
};
}

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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit b8a7337

Please sign in to comment.