Skip to content

Commit

Permalink
Prevent JMapStages hiding minimap if already hidden
Browse files Browse the repository at this point in the history
Telling JourneyMap to hide the minimap causes JourneyMap to write its settings out to disk even if they haven't changed; this happens on the render thread and so can cause significant hangs opening the file, serializing and writing.

This patch adds a check to see if the minimap is already hidden; if it is then we return early without rewriting the settings
  • Loading branch information
sam-kirby committed Oct 8, 2024
1 parent 1618332 commit d217f24
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version_base = 1.14.1
version_base = 1.15.0

# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public byte[] transform(String name, String transformedName, byte[] basicClass)
return new PatchGalacticraftSlimeling(basicClass).apply();
case "net.darkhax.infoaccessories.info.InfoType":
return new PatchInfoAccCompass(basicClass).apply();
case "net.darkhax.jmapstages.JMapPermissionHandler":
return new PatchJMapStagesStutter(basicClass).apply();
default:
return basicClass;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package tv.darkosto.sevpatches.core.patches;

import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.*;
import tv.darkosto.sevpatches.core.utils.AsmUtils;

public class PatchJMapStagesStutter extends Patch {
public PatchJMapStagesStutter(byte[] inputClass) {
super(inputClass);
}

@Override
protected boolean patch() {
MethodNode toggleMinimap = AsmUtils.findMethod(this.classNode, "toggleMinimap");
if (toggleMinimap == null) return false;

InsnList insns = new InsnList();
LabelNode ln = new LabelNode();

/*
if (enable == this.uiManager.isMiniMapEnabled()) return;
*/
insns.add(new VarInsnNode(Opcodes.ALOAD, 0));
insns.add(new FieldInsnNode(Opcodes.GETFIELD, "net/darkhax/jmapstages/JMapPermissionHandler", "uiManager", "Ljourneymap/client/ui/UIManager;"));
insns.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "journeymap/client/ui/UIManager", "isMiniMapEnabled", "()Z", false));
insns.add(new VarInsnNode(Opcodes.ILOAD, 1));
insns.add(new JumpInsnNode(Opcodes.IF_ICMPNE, ln));
insns.add(new InsnNode(Opcodes.RETURN));
insns.add(ln);

toggleMinimap.instructions.insert(insns);

return true;
}
}

0 comments on commit d217f24

Please sign in to comment.