Skip to content

Commit

Permalink
WM1.37.2 MM23.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
rfresh2 committed Dec 6, 2023
1 parent 70c8229 commit 19a08ac
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 58 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ configurations {
}

ext {
worldmap_version = "1.37.1"
minimap_version = "23.9.1"
worldmap_version = "1.37.2"
minimap_version = "23.9.2"
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import xaero.common.minimap.waypoints.WaypointWorld;
import xaeroplus.XaeroPlus;
import xaeroplus.feature.extensions.IWaypointDimension;
import xaeroplus.util.WaypointsHelper;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -46,7 +45,7 @@ public void addWaypointInject(
WaypointSet destinationSet) {
try {
waypointsEdited.forEach(waypoint -> {
((IWaypointDimension) waypoint).setDimension(WaypointsHelper.getDimensionKeyForWaypointWorldKey(destinationWorld.getContainer().getKey()));
((IWaypointDimension) waypoint).setDimension(destinationWorld.getDimId());
});
} catch (Throwable e) {
XaeroPlus.LOGGER.error("Failed setting waypoint dimension: {}", Arrays.toString(waypointsEdited.toArray()), e);
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/xaeroplus/mixin/client/MixinGuiMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -732,12 +732,10 @@ public void render(DrawContext guiGraphics, int scaledMouseX, int scaledMouseY,
.getMapWorld()
.getCurrentDimension()
.getDimensionType(this.mapProcessor.getWorldDimensionTypeRegistry());
Identifier dimTypeId = this.mapProcessor.getMapWorld().getCurrentDimension().getDimensionTypeId();
guiGraphics.drawTextWithShadow(
mc.textRenderer,
"MultiWorld ID: "
+ this.mapProcessor.getMapWorld().getCurrentMultiworld()
+ " Dim Type: "
+ (dimType == null ? "null" : dimType.effects()),
"MultiWorld ID: " + this.mapProcessor.getMapWorld().getCurrentMultiworld() + " Dim Type: " + (dimType == null ? "unknown" : dimTypeId),
5,
265,
-1
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/xaeroplus/mixin/client/MixinMapWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public void init(String mainId, String oldUnfixedMainId, MapProcessor mapProcess
*/
@Overwrite
public MapDimension getDimension(RegistryKey<World> dimId) {
return this.dimensions.get(dimId);
if (dimId == null) return null;
else return this.dimensions.get(dimId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import xaeroplus.settings.XaeroPlusModSettingsHooks;
import xaeroplus.settings.XaeroPlusSettingRegistry;
import xaeroplus.settings.XaeroPlusSettingsReflectionHax;
import xaeroplus.util.WaypointsHelper;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -65,7 +64,7 @@ public void getLockNorth(int mapSize, int shape, CallbackInfoReturnable<Boolean>
locals = LocalCapture.CAPTURE_FAILHARD)
public void createWaypointInject(final String[] args, final WaypointWorld wpw, final CallbackInfoReturnable<Boolean> cir, final String setName, final WaypointSet set, boolean yIncluded, int yCoord, Waypoint waypoint) {
try {
((IWaypointDimension) waypoint).setDimension(WaypointsHelper.getDimensionKeyForWaypointWorldKey(wpw.getContainer().getKey()));
((IWaypointDimension) waypoint).setDimension(wpw.getDimId());
} catch (final Throwable e) {
XaeroPlus.LOGGER.error("Failed setting waypoint dimension: {}", waypoint, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import xaeroplus.feature.extensions.IWaypointDimension;
import xaeroplus.settings.XaeroPlusSettingRegistry;
import xaeroplus.util.DataFolderResolveUtil;
import xaeroplus.util.WaypointsHelper;

import static net.minecraft.world.World.NETHER;
import static net.minecraft.world.World.OVERWORLD;
Expand All @@ -40,8 +39,6 @@ public abstract class MixinWaypointsManager {

@Shadow
public abstract String getDimensionDirectoryName(RegistryKey<World> dimKey);
@Shadow
public abstract RegistryKey<World> getDimensionKeyForDirectoryName(String dirName);

@Inject(method = "getMainContainer", at = @At("HEAD"), cancellable = true)
private void getMainContainer(boolean preIp6Fix, ClientPlayNetworkHandler connection, CallbackInfoReturnable<String> cir) {
Expand Down Expand Up @@ -107,6 +104,6 @@ public void createTempWaypointInject(final WaypointWorld wpw,
double waypointDestDimScale,
final double dimDiv,
final Waypoint waypoint) {
((IWaypointDimension) waypoint).setDimension(WaypointsHelper.getDimensionKeyForWaypointWorldKey(wpw.getContainer().getKey()));
((IWaypointDimension) waypoint).setDimension(wpw.getDimId());
}
}
18 changes: 5 additions & 13 deletions src/main/java/xaeroplus/module/impl/WaystoneSync.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.blay09.mods.balm.api.Balm;
import net.blay09.mods.waystones.api.IWaystone;
import net.blay09.mods.waystones.api.KnownWaystonesEvent;
import net.minecraft.client.MinecraftClient;
import net.minecraft.registry.RegistryKey;
import net.minecraft.world.World;
import xaero.common.XaeroMinimapSession;
Expand Down Expand Up @@ -162,18 +161,11 @@ private WaypointWorld getWaypointWorldForWaystone(final Waystone waystone,
final RegistryKey<World> waystoneDimension = waystone.dimension();
final String waystoneDimensionDirectoryName = waypointsManager.getDimensionDirectoryName(waystoneDimension);
final int waystoneDim = WaypointsHelper.getDimensionForWaypointWorldKey(waystoneDimensionDirectoryName);
// waypoint worlds can sometimes have irregular names
// if we have a world already open, trying syncing to that world
if (waystoneDim == getCurrentDimensionInt()) {
WaypointWorld currentWpWorld = waypointsManager.getCurrentWorld();
if (currentWpWorld == null) {
WaypointWorld newWaypointWorld = new WaypointWorld(waypointsManager.getWorldContainer(currentContainerId), "waypoints",
MinecraftClient.getInstance().world.getRegistryKey());
waypointsManager.getWorldContainer(currentContainerId).worlds.put(
"waypoints",
newWaypointWorld);
currentWpWorld = newWaypointWorld;
}
final WaypointWorld currentWpWorld = waypointsManager.getCurrentWorld();
if (currentWpWorld == null) {
throw new RuntimeException("WaystoneSync: current waypoint world is null");
}
if (currentWpWorld.getDimId() == waystoneDimension) {
return currentWpWorld;
}
final String worldContainerSuffix;
Expand Down
30 changes: 0 additions & 30 deletions src/main/java/xaeroplus/util/WaypointsHelper.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,6 @@
package xaeroplus.util;

import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

public class WaypointsHelper {
// nullable
public static @Nullable RegistryKey<World> getDimensionKeyForWaypointWorldKey(String waypointWorldKey) {
String dimIdPart = waypointWorldKey.substring(waypointWorldKey.lastIndexOf(47) + 1).substring(4);
if (dimIdPart.equals("0")) {
return World.OVERWORLD;
} else if (dimIdPart.equals("1")) {
return World.END;
} else if (dimIdPart.equals("-1")) {
return World.NETHER;
} else {
String[] idArgs = dimIdPart.split("\\$");
if (idArgs.length == 1) {
return null;
} else {
try {
Integer.parseInt(idArgs[1]);
return null;
} catch (NumberFormatException var5) {
return RegistryKey.of(RegistryKeys.WORLD, new Identifier(idArgs[0], idArgs[1].replace('%', '/')));
}
}
}
}

public static int getDimensionForWaypointWorldKey(final String waypointWorldKey) {
String dimIdPart = waypointWorldKey.substring(waypointWorldKey.lastIndexOf(47) + 1).substring(4);
if (!dimIdPart.matches("-{0,1}[0-9]+")) {
Expand Down

0 comments on commit 19a08ac

Please sign in to comment.