Skip to content

Commit

Permalink
Merge branch '1.20.1' into 1.19.4
Browse files Browse the repository at this point in the history
# Conflicts:
#	common/src/main/java/xaeroplus/mixin/client/MixinMinimapFBORenderer.java
#	common/src/main/java/xaeroplus/mixin/client/MixinMinimapRenderer.java
#	fabric/build.gradle.kts
#	settings.gradle.kts
  • Loading branch information
rfresh2 committed Sep 2, 2024
2 parents 0445c89 + d6f9f94 commit d3f39ca
Show file tree
Hide file tree
Showing 23 changed files with 318 additions and 506 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package xaeroplus.mixin.client;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import xaero.common.minimap.waypoints.Waypoint;
import xaero.hud.minimap.waypoint.set.WaypointSet;

import java.util.List;

@Mixin(value = WaypointSet.class, remap = false)
public interface AccessorWaypointSet {
// we could alternatively just cast the iterable getter back to list
// but doing an accessor should cause compile errors if the type ever changes from under us in future updates
@Accessor
List<Waypoint> getList();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package xaeroplus.mixin.client;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import xaero.common.minimap.info.BuiltInInfoDisplays;
import xaero.common.minimap.info.render.compile.InfoDisplayCompiler;
import xaero.hud.minimap.world.MinimapWorld;
import xaeroplus.settings.XaeroPlusSettingRegistry;
import xaeroplus.util.ChunkUtils;

@Mixin(value = BuiltInInfoDisplays.class, remap = false)
public class MixinBuiltInInfoDisplays {

@WrapOperation(method = "lambda$static$13", at = @At(
value = "INVOKE",
target = "Lxaero/common/minimap/info/render/compile/InfoDisplayCompiler;addWords(ILjava/lang/String;)V"))
private static void hideAutoSubworldInfoWhenOwAutoWaypointsEnabled(final InfoDisplayCompiler instance, final int lineWidth, final String text, final Operation<Void> original,
@Local(name = "currentWorld") MinimapWorld currentWorld) {
if (XaeroPlusSettingRegistry.owAutoWaypointDimension.getValue()) {
ResourceKey<Level> actualDimension = ChunkUtils.getActualDimension();
if (actualDimension == Level.NETHER && currentWorld.getDimId() == Level.OVERWORLD) return;
}
original.call(instance, lineWidth, text);
}
}

This file was deleted.

4 changes: 2 additions & 2 deletions common/src/main/java/xaeroplus/mixin/client/MixinGuiMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,8 @@ public void renderTileSelectionSize(
) {
MapTileSelection selection = this.mapTileSelection;
if (selection == null) return;
var sideLen = Math.abs(Math.abs(selection.getRight()) - Math.abs(selection.getLeft()))+1;
var heightLen = Math.abs(Math.abs(selection.getBottom()) - Math.abs(selection.getTop()))+1;
var sideLen = Math.abs(selection.getRight() - selection.getLeft())+1;
var heightLen = Math.abs(selection.getBottom() - selection.getTop())+1;
if (sideLen <= 1 && heightLen <= 1) return;
// todo: it'd be better if we could render this directly on the highlight
// but we need a function for map -> screen coordinates translation
Expand Down
29 changes: 0 additions & 29 deletions common/src/main/java/xaeroplus/mixin/client/MixinGuiWaypoint.java

This file was deleted.

33 changes: 16 additions & 17 deletions common/src/main/java/xaeroplus/mixin/client/MixinGuiWaypoints.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,30 @@
import xaero.common.gui.MySmallButton;
import xaero.common.gui.ScreenBase;
import xaero.common.minimap.waypoints.Waypoint;
import xaero.common.minimap.waypoints.WaypointWorld;
import xaero.common.minimap.waypoints.WaypointsManager;
import xaero.common.minimap.waypoints.WaypointsSort;
import xaero.common.misc.KeySortableByOther;
import xaero.hud.minimap.module.MinimapSession;
import xaero.hud.minimap.world.MinimapWorld;
import xaeroplus.settings.XaeroPlusSettingRegistry;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ConcurrentSkipListSet;

@Mixin(value = GuiWaypoints.class, remap = false)
public abstract class MixinGuiWaypoints extends ScreenBase {

@Shadow
private WaypointWorld displayedWorld;
@Shadow
private ArrayList<Waypoint> waypointsSorted;
@Shadow
private WaypointsManager waypointsManager;
@Unique private EditBox searchField;
@Unique private final int TOGGLE_ALL_ID = 69;
@Unique private MySmallButton toggleAllButton;
@Unique private String waypointsSearchFilter = "";

@Shadow private MinimapWorld displayedWorld;
@Shadow private ArrayList<Waypoint> waypointsSorted;
@Shadow protected abstract boolean isOneSelected();
@Shadow private MinimapSession session;
@Shadow private ConcurrentSkipListSet<Integer> selectedListSet;

protected MixinGuiWaypoints(final IXaeroMinimap modMain, final Screen parent, final Screen escape, final Component titleIn) {
super(modMain, parent, escape, titleIn);
}
Expand Down Expand Up @@ -123,9 +123,6 @@ public void drawScreenInject(final PoseStack guiGraphics, final int mouseX, fina
}
}

@Shadow
protected abstract boolean isOneSelected();

@Redirect(method = "updateButtons", at = @At(value = "INVOKE", target = "Lxaero/common/gui/GuiWaypoints;isOneSelected()Z"))
public boolean shareButtonRedirect(final GuiWaypoints instance) {
if (XaeroPlusSettingRegistry.disableWaypointSharing.getValue()) {
Expand All @@ -134,11 +131,13 @@ public boolean shareButtonRedirect(final GuiWaypoints instance) {
return isOneSelected();
}

@Unique
private void updateSearch() {
if (this.searchField.isFocused()) {
String newValue = this.searchField.getValue();
if (!Objects.equal(this.waypointsSearchFilter, newValue)) {
this.waypointsSearchFilter = this.searchField.getValue();
selectedListSet.clear();
updateSortedList();
}
}
Expand All @@ -150,9 +149,9 @@ private void updateSearch() {
*/
@Overwrite
private void updateSortedList() {
WaypointsSort sortType = this.displayedWorld.getContainer().getRootContainer().getSortType();
ArrayList<Waypoint> waypointsList = this.displayedWorld.getCurrentSet().getList();
GuiWaypoints.distanceDivided = this.waypointsManager.getDimensionDivision(this.displayedWorld);
WaypointsSort sortType = this.displayedWorld.getContainer().getRoot().getSortType();
Iterable<Waypoint> waypointsList = this.displayedWorld.getCurrentWaypointSet().getWaypoints();
GuiWaypoints.distanceDivided = this.session.getDimensionHelper().getDimensionDivision(this.displayedWorld);
Camera camera = this.minecraft.gameRenderer.getMainCamera();

final List<Waypoint> disabledWaypoints = new ArrayList<>();
Expand All @@ -168,11 +167,11 @@ private void updateSortedList() {
disabledWaypoints.removeIf(waypoint -> !waypoint.getName().toLowerCase().contains(this.waypointsSearchFilter.toLowerCase()));
}
this.waypointsSorted = new ArrayList<>();

this.waypointsSorted.addAll(sortWaypoints(enabledWaypoints, sortType, camera));
this.waypointsSorted.addAll(sortWaypoints(disabledWaypoints, sortType, camera));
}

@Unique
private List<Waypoint> sortWaypoints(final List<Waypoint> waypointsList, WaypointsSort sortType, final Camera camera) {
final ArrayList<Waypoint> waypointsSorted = new ArrayList<>();
final ArrayList<KeySortableByOther<Waypoint>> sortableKeys = new ArrayList<>();
Expand All @@ -192,7 +191,7 @@ private List<Waypoint> sortWaypoints(final List<Waypoint> waypointsList, Waypoin
for (KeySortableByOther<Waypoint> k : sortableKeys) {
waypointsSorted.add(k.getKey());
}
if (this.displayedWorld.getContainer().getRootContainer().isSortReversed()) {
if (this.displayedWorld.getContainer().getRoot().isSortReversed()) {
Collections.reverse(waypointsSorted);
}
return waypointsSorted;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import xaero.common.gui.GuiWaypoints;
import xaero.common.minimap.waypoints.Waypoint;
import xaero.hud.minimap.waypoint.set.WaypointSet;
import xaero.hud.minimap.world.MinimapWorld;
import xaeroplus.settings.XaeroPlusSettingRegistry;

import java.text.NumberFormat;
import java.util.ArrayList;

@Mixin(targets = "xaero.common.gui.GuiWaypoints$List", remap = false)
public abstract class MixinGuiWaypointsList {
Expand All @@ -45,10 +46,14 @@ public void getWaypointCount(final CallbackInfoReturnable<Integer> cir) {

@Redirect(method = "getWaypoint", at = @At(
value = "INVOKE",
target = "Lxaero/common/minimap/waypoints/WaypointSet;getList()Ljava/util/ArrayList;"
target = "Lxaero/hud/minimap/world/MinimapWorld;getCurrentWaypointSet()Lxaero/hud/minimap/waypoint/set/WaypointSet;"
))
public ArrayList<Waypoint> getWaypointList(final xaero.common.minimap.waypoints.WaypointSet waypointSet) {
return ((AccessorGuiWaypoints) thisGuiWaypoints).getWaypointsSorted();
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;
}

@Inject(method = "drawWaypointSlot", at = @At(
Expand Down
Loading

0 comments on commit d3f39ca

Please sign in to comment.