Skip to content

Commit

Permalink
minor opts
Browse files Browse the repository at this point in the history
  • Loading branch information
rfresh2 committed Sep 11, 2024
1 parent 62cf2a4 commit 86c4c39
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package xaeroplus.event;

public record ClientPlaySessionFinalizedEvent() {
public static ClientPlaySessionFinalizedEvent INSTANCE = new ClientPlaySessionFinalizedEvent();
public static final ClientPlaySessionFinalizedEvent INSTANCE = new ClientPlaySessionFinalizedEvent();
}
4 changes: 2 additions & 2 deletions common/src/main/java/xaeroplus/event/ClientTickEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

public class ClientTickEvent {
public static class Pre extends ClientTickEvent {
public static Pre INSTANCE = new Pre();
public static final Pre INSTANCE = new Pre();
}

public static class Post extends ClientTickEvent {
public static Post INSTANCE = new Post();
public static final Post INSTANCE = new Post();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.world.entity.Entity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
Expand All @@ -22,7 +23,8 @@

@Mixin(targets = "xaero.common.gui.GuiWaypoints$List", remap = false)
public abstract class MixinGuiWaypointsList {
private GuiWaypoints thisGuiWaypoints;
@Unique private final WaypointSet waypointsSortedSet = WaypointSet.Builder.begin().setName("xp-wp-sorted").build();
@Unique private GuiWaypoints thisGuiWaypoints;

@Inject(method = "<init>", at = @At("RETURN"))
public void init(final GuiWaypoints this$0, final CallbackInfo ci) throws NoSuchFieldException, IllegalAccessException {
Expand All @@ -48,11 +50,10 @@ public void getWaypointCount(final CallbackInfoReturnable<Integer> cir) {
target = "Lxaero/hud/minimap/world/MinimapWorld;getCurrentWaypointSet()Lxaero/hud/minimap/waypoint/set/WaypointSet;"
))
public WaypointSet getWaypointList(final MinimapWorld instance) {
// todo: could be optimized to reduce unnecessary list allocs
WaypointSet currentWaypointSet = instance.getCurrentWaypointSet();
var wpSet = WaypointSet.Builder.begin().setName(currentWaypointSet.getName()).build();
wpSet.addAll(((AccessorGuiWaypoints) thisGuiWaypoints).getWaypointsSorted());
return wpSet;
// reusing waypoint set to avoid allocating an arraylist every call to this method
waypointsSortedSet.clear();
waypointsSortedSet.addAll(((AccessorGuiWaypoints) thisGuiWaypoints).getWaypointsSorted());
return waypointsSortedSet;
}

@Inject(method = "drawWaypointSlot", at = @At(
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/xaeroplus.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"required": true,
"package": "xaeroplus.mixin.client",
"compatibilityLevel": "JAVA_17",
"minVersion": "0.8",
"injectors": {
"defaultRequire": 1
},
Expand Down
1 change: 1 addition & 0 deletions fabric/src/main/resources/xaeroplus-fabric.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"required": true,
"package": "xaeroplus.fabric.mixin.client",
"compatibilityLevel": "JAVA_17",
"minVersion": "0.8",
"injectors": {
"defaultRequire": 1
},
Expand Down
1 change: 1 addition & 0 deletions forge/src/main/resources/xaeroplus-forge.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"required": true,
"package": "xaeroplus.forge.mixin.client",
"compatibilityLevel": "JAVA_17",
"minVersion": "0.8",
"injectors": {
"defaultRequire": 1
},
Expand Down

0 comments on commit 86c4c39

Please sign in to comment.