Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Fix ArrayList module overlap bug (#834)
Browse files Browse the repository at this point in the history
Co-authored-by: xia__mc <[email protected]>
Co-authored-by: smugvee <[email protected]>
  • Loading branch information
3 people authored Nov 2, 2024
1 parent 96e153f commit 9678fd0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ apply plugin: 'java'

group = "keystrokesmod"
archivesBaseName = "raven-XD"
//version = "Dev"
version = "Dev"

compileJava {
sourceCompatibility = '1.8'
Expand Down
37 changes: 17 additions & 20 deletions src/main/java/keystrokesmod/module/impl/render/ArrayList.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import keystrokesmod.module.Module;
import keystrokesmod.module.ModuleManager;
import keystrokesmod.module.impl.combat.KillAura;
import keystrokesmod.module.impl.render.arraylist.ArrayListModule;
import keystrokesmod.module.setting.impl.*;
import keystrokesmod.utility.Theme;
Expand All @@ -22,7 +21,6 @@

import java.awt.*;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

public class ArrayList extends Module implements Moveable {
Expand Down Expand Up @@ -88,7 +86,7 @@ public void render() {
final IFont font = FontManager.getFont(FontManager.Fonts.TENACITY, (int) (20 * size.getInput()));
final double height = font.height();

updateArrayList(font);
updateArrayList();

final ScaledResolution sr = new ScaledResolution(mc);
moveX(Utils.limit(minX, 0, sr.getScaledWidth()) - minX);
Expand All @@ -98,7 +96,7 @@ public void render() {
int nextMaxX = minX;
int nextMaxY = minY;

final double shadowExtra = 1 * size.getInput();
final double shadowExtra = size.getInput() * 0.5;
final double lineInterval = shadowExtra * 3;
final int enableX = right.isToggled() ? maxX : minX;
for (ArrayListModule module : mapping.values()) {
Expand Down Expand Up @@ -178,22 +176,23 @@ public void render() {
}
}

private void updateArrayList(IFont font) {
private void updateArrayList() {
final int[] renderingIndex = {0};
ModuleManager.organizedModules.parallelStream()
ModuleManager.organizedModules.stream()
.filter(this::canRender)
.map(module -> {
if (!mapping.containsKey(module)) {
return mapping.put(module, new ArrayListModule(module));
.forEach(module -> {
ArrayListModule arrayListModule = mapping.get(module);
if (module.isEnabled()) {
if (arrayListModule == null) {
mapping.put(module, new ArrayListModule(module));
}
if (arrayListModule != null) {
arrayListModule.onUpdate(renderingIndex[0]);
}
renderingIndex[0]++;
} else {
mapping.remove(module);
}
return mapping.get(module);
})
.filter(Objects::nonNull)
.sorted((c1, c2) -> Double.compare(font.width(getText(c2)), font.width(getText(c1))))
.forEachOrdered(module -> {
module.onUpdate(renderingIndex[0]);
if (module.getModule().isEnabled())
renderingIndex[0] += 1;
});
}

Expand All @@ -214,9 +213,7 @@ private boolean canRender(@NotNull Module module) {
if (module.moduleCategory() == category.client && !client.isToggled()) return false;
if (module.moduleCategory() == category.scripts && !scripts.isToggled()) return false;
if (module.moduleCategory() == category.exploit && !exploit.isToggled()) return false;
if (module.moduleCategory() == category.experimental && !experimental.isToggled()) return false;

return true;
return module.moduleCategory() != category.experimental || experimental.isToggled();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void onUpdate(int index) {
}

public boolean shouldRender() {
return animeX.getValue() != 0;
return module.isEnabled();
}

public String getName() {
Expand Down

0 comments on commit 9678fd0

Please sign in to comment.