mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 21:17:32 +00:00
Stop sorting keys list, create sorted copy instead.
Made it so the rendering for them would still work for visual grouping, but the ticking logic wouldn't suffer
This commit is contained in:
1 parent
2efdafe254
commit
780dc4ca76
1 file changed
+4
-2
@@ -11,6 +11,7 @@ import java.util.List;
|
||||
|
||||
public class KeyPresetManager {
|
||||
public List<KeyPreset> keys = new ArrayList<>();
|
||||
public List<KeyPreset> keysSorted = new ArrayList<>();
|
||||
public String fileName;
|
||||
|
||||
private boolean wasSorted = false;
|
||||
@@ -22,17 +23,18 @@ public class KeyPresetManager {
|
||||
public KeyPreset add(String name) {
|
||||
KeyPreset preset = new KeyPreset(name);
|
||||
keys.add(preset);
|
||||
keysSorted.add(preset);
|
||||
wasSorted = false;
|
||||
return preset;
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
if (!wasSorted) {
|
||||
keys.sort(KeyPreset::compareTo);
|
||||
keysSorted.sort(KeyPreset::compareTo);
|
||||
wasSorted = true;
|
||||
}
|
||||
|
||||
for (KeyPreset key : keys) {
|
||||
for (KeyPreset key : keysSorted) {
|
||||
key.tick();
|
||||
if (key.isDown && key.shouldConflict)
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user