From 5b2669a4ee39ff9907a47ec616747bfea2b34bd3 Mon Sep 17 00:00:00 2001 From: Scribble Date: Mon, 16 Mar 2026 19:33:51 +0100 Subject: [PATCH] Update legacy-fabric and switch mappings to ornithe-mcp --- build.gradle | 68 ++++++++++--------- gradle.properties | 5 +- settings.gradle | 3 +- .../mixin/MixinNetHandlerPlayClient.java | 4 +- .../com/minecrafttas/tasmod/TASmodClient.java | 6 +- .../commands/CommandRestartAndPlay.java | 2 +- .../com/minecrafttas/tasmod/gui/InfoHud.java | 13 ++-- .../tasmod/mixin/MixinMinecraftServer.java | 3 + .../playbackhooks/MixinEntityRenderer.java | 2 + .../savestates/MixinChunkProviderClient.java | 6 +- .../savestates/MixinChunkProviderServer.java | 6 +- .../savestates/SavestateHandlerClient.java | 8 +-- .../handlers/SavestateWorldHandler.java | 2 +- .../tasmod/util/ShieldDownloader.java | 2 +- .../tasmod/util/TabCompletionUtils.java | 2 +- src/main/resources/tasmod.accesswidener | 6 +- 16 files changed, 76 insertions(+), 62 deletions(-) diff --git a/build.gradle b/build.gradle index 3e4015a3..0dacea1f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,11 @@ plugins { // loom plugin - id "fabric-loom" version "${loom_version}" - // legacy looming (loom plugin improvements) - id "legacy-looming" version "${loom_version}" - id "com.palantir.git-version" version "4.2.0" - id "com.diffplug.spotless" version "8.1.0" + id "fabric-loom" version "${loom_version}" + id "ploceus" version "${loom_version}" + id "com.palantir.git-version" version "4.2.0" + id "com.diffplug.spotless" version "8.1.0" } - // set basic properties def hash = "" if(project.release=="false") { @@ -34,34 +32,38 @@ loom { // dependency repositories repositories { - mavenCentral() - maven { url = "https://maven.minecrafttas.com/main" } - //maven { url = "https://maven.minecrafttas.com/snapshots" } - maven { url = "https://raw.githubusercontent.com/BleachDev/cursed-mappings/main/" } - maven { url = "https://jitpack.io" } - maven { url = "https://repo.spongepowered.org/maven" } + mavenCentral() + maven { url = "https://maven.minecrafttas.com/main" } + maven { url = "https://maven.legacyfabric.net/" } + //maven { url = "https://maven.minecrafttas.com/snapshots" } + maven { url = "https://jitpack.io" } + maven { url = "https://repo.spongepowered.org/maven" } } // dependency configurations configurations { - // embed dependency included in build - implementation.extendsFrom(embed) + // embed dependency included in build + implementation.extendsFrom(embed) +} + +ploceus { + setIntermediaryGeneration(2) } // dependencies dependencies { - // tasmod dependencies - embed "com.dselent:bigarraylist:1.6" - embed "com.github.KaptainWutax:SeedUtils:b6a383113c" + // tasmod dependencies + embed "com.dselent:bigarraylist:1.6" + embed "com.github.KaptainWutax:SeedUtils:b6a383113c" // loom dependencies - minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.legacyfabric:yarn:${project.minecraft_version}+build.mcp" + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings ploceus.mcpMappings(project.mcp_channel, project.mcp_mcversion, project.mcp_build) modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - + // testing dependencies - testImplementation "org.junit.jupiter:junit-jupiter:5.14.1" - testRuntimeOnly "org.junit.platform:junit-platform-launcher" + testImplementation "org.junit.jupiter:junit-jupiter:5.14.1" + testRuntimeOnly "org.junit.platform:junit-platform-launcher" } @@ -71,12 +73,12 @@ compileJava { // process fabric mod json processResources { - inputs.property "version", project.version - inputs.property "mcversion", project.minecraft_version - - filesMatching("fabric.mod.json") { - expand "mod_url": project.mod_url, "name": project.mod_name, "mod_version": project.version, "mod_description": project.mod_description, "mod_sources": project.mod_sources, "mod_email": project.mod_email - } + inputs.property "version", project.version + inputs.property "mcversion", project.minecraft_version + + filesMatching("fabric.mod.json") { + expand "mod_url": project.mod_url, "name": project.mod_name, "mod_version": project.version, "mod_description": project.mod_description, "mod_sources": project.mod_sources, "mod_email": project.mod_email + } } // configure jar file @@ -85,14 +87,14 @@ jar { // pack embedded stuff from { configurations.embed.collect { it.isDirectory() ? it : zipTree(it) } - } { - exclude "LICENSE.txt", "META-INF/MANIFSET.MF", "META-INF/maven/**", "META-INF/*.RSA", "META-INF/*.SF" + } { + exclude "LICENSE.txt", "META-INF/MANIFSET.MF", "META-INF/maven/**", "META-INF/*.RSA", "META-INF/*.SF" } } // configure testing tasks.named("test", Test) { - useJUnitPlatform() + useJUnitPlatform() testLogging { events "passed", "skipped", "failed" @@ -103,8 +105,8 @@ spotless { encoding "UTF-8" lineEndings "UNIX" java { - importOrderFile("formatter/TASmodImportorder.txt") - eclipse().configFile("formatter/TASmodFormatter.xml") + importOrderFile("formatter/TASmodImportorder.txt") + eclipse().configFile("formatter/TASmodFormatter.xml") } enforceCheck false } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 3c84fd0f..19e25ce6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,10 @@ org.gradle.jvmargs=-Xmx3G # Fabric properties minecraft_version=1.12.2 loader_version=0.18.4 -loom_version=1.14-SNAPSHOT +loom_version=1.15-SNAPSHOT +mcp_channel=stable +mcp_build=39 +mcp_mcversion=1.12 # Mod properties mod_name=Tool-Assisted Speedrun Mod diff --git a/settings.gradle b/settings.gradle index cdc97026..b5fd3644 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,7 +4,8 @@ pluginManagement { repositories { maven { url = "https://maven.minecrafttas.com/main" } maven { url = "https://maven.fabricmc.net/" } - maven { url = "https://repo.legacyfabric.net/repository/legacyfabric/" } + maven { url = "https://maven.ornithemc.net/releases" } + maven { url = "https://maven.ornithemc.net/snapshots" } mavenCentral() gradlePluginPortal() } diff --git a/src/main/java/com/minecrafttas/mctcommon/mixin/MixinNetHandlerPlayClient.java b/src/main/java/com/minecrafttas/mctcommon/mixin/MixinNetHandlerPlayClient.java index 84b5d226..ef700e40 100644 --- a/src/main/java/com/minecrafttas/mctcommon/mixin/MixinNetHandlerPlayClient.java +++ b/src/main/java/com/minecrafttas/mctcommon/mixin/MixinNetHandlerPlayClient.java @@ -20,11 +20,11 @@ @Mixin(NetHandlerPlayClient.class) public class MixinNetHandlerPlayClient { @Shadow - private Minecraft gameController; + private Minecraft client; @Inject(method = "handleJoinGame", at = @At(value = "RETURN")) public void clientJoinServerEvent(CallbackInfo ci) throws ConnectException { - EventListenerRegistry.fireEvent(EventPlayerJoinedClientSide.class, gameController.player); + EventListenerRegistry.fireEvent(EventPlayerJoinedClientSide.class, client.player); } @Inject(method = "handlePlayerListItem", at = @At(value = "HEAD")) diff --git a/src/main/java/com/minecrafttas/tasmod/TASmodClient.java b/src/main/java/com/minecrafttas/tasmod/TASmodClient.java index a7046987..7bdc1279 100644 --- a/src/main/java/com/minecrafttas/tasmod/TASmodClient.java +++ b/src/main/java/com/minecrafttas/tasmod/TASmodClient.java @@ -66,9 +66,9 @@ public class TASmodClient implements ClientModInitializer, EventClientInit, Even public static TickSyncClient ticksyncClient; - public final static Path tasfiledirectory = Minecraft.getMinecraft().mcDataDir.toPath().resolve("saves").resolve("tasfiles"); + public final static Path tasfiledirectory = Minecraft.getMinecraft().gameDir.toPath().resolve("saves").resolve("tasfiles"); - public final static Path savestatedirectory = Minecraft.getMinecraft().mcDataDir.toPath().resolve("saves").resolve("savestates"); + public final static Path savestatedirectory = Minecraft.getMinecraft().gameDir.toPath().resolve("saves").resolve("savestates"); public static InfoHud hud; @@ -353,7 +353,7 @@ private void registerConfigValues() { } private void loadConfig(Minecraft mc) { - Path configDir = mc.mcDataDir.toPath().resolve("config"); + Path configDir = mc.gameDir.toPath().resolve("config"); if (!Files.exists(configDir)) { try { Files.createDirectory(configDir); diff --git a/src/main/java/com/minecrafttas/tasmod/commands/CommandRestartAndPlay.java b/src/main/java/com/minecrafttas/tasmod/commands/CommandRestartAndPlay.java index accfd551..382cd872 100644 --- a/src/main/java/com/minecrafttas/tasmod/commands/CommandRestartAndPlay.java +++ b/src/main/java/com/minecrafttas/tasmod/commands/CommandRestartAndPlay.java @@ -57,7 +57,7 @@ public List getTabCompletions(MinecraftServer server, ICommandSender sen public List getFilenames() { List tab = new ArrayList(); - File folder = new File(Minecraft.getMinecraft().mcDataDir, "saves" + File.separator + "tasfiles"); + File folder = new File(Minecraft.getMinecraft().gameDir, "saves" + File.separator + "tasfiles"); File[] listOfFiles = folder.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { diff --git a/src/main/java/com/minecrafttas/tasmod/gui/InfoHud.java b/src/main/java/com/minecrafttas/tasmod/gui/InfoHud.java index 0269a886..99887c80 100644 --- a/src/main/java/com/minecrafttas/tasmod/gui/InfoHud.java +++ b/src/main/java/com/minecrafttas/tasmod/gui/InfoHud.java @@ -23,7 +23,6 @@ import com.minecrafttas.tasmod.playback.filecommands.builtin.DesyncMonitorFileCommandExtension; import com.minecrafttas.tasmod.virtual.VirtualInput; import com.minecrafttas.tasmod.virtual.VirtualInterpolationHandler.MouseInterpolation; -import com.mojang.realmsclient.gui.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; @@ -199,7 +198,7 @@ private void saveConfig() { return; } try { - File tasmodDir = new File(Minecraft.getMinecraft().mcDataDir, "tasmod"); + File tasmodDir = new File(Minecraft.getMinecraft().gameDir, "tasmod"); tasmodDir.mkdir(); File configFile = new File(tasmodDir, "infogui2.cfg"); if (!configFile.exists()) @@ -228,7 +227,7 @@ public boolean checkInit() { try { configuration = new Properties(); if (!resetLayout) { - File tasmodDir = new File(Minecraft.getMinecraft().mcDataDir, "tasmod"); + File tasmodDir = new File(Minecraft.getMinecraft().gameDir, "tasmod"); tasmodDir.mkdir(); File configFile = new File(tasmodDir, "infogui2.cfg"); if (!configFile.exists()) @@ -368,17 +367,17 @@ public boolean checkInit() { return "State"; } else { TASstate state = TASmodClient.controller.getState(); - ChatFormatting format = ChatFormatting.WHITE; + TextFormatting format = TextFormatting.WHITE; String out = ""; if (state == TASstate.PLAYBACK) { out = "Playback"; - format = ChatFormatting.GREEN; + format = TextFormatting.GREEN; } else if (state == TASstate.RECORDING) { out = "Recording"; - format = ChatFormatting.RED; + format = TextFormatting.RED; } else if (state == TASstate.PAUSED) { out = "Paused"; - format = ChatFormatting.YELLOW; + format = TextFormatting.YELLOW; } else if (state == TASstate.NONE) { out = ""; } diff --git a/src/main/java/com/minecrafttas/tasmod/mixin/MixinMinecraftServer.java b/src/main/java/com/minecrafttas/tasmod/mixin/MixinMinecraftServer.java index 5a57d75d..acdca43a 100644 --- a/src/main/java/com/minecrafttas/tasmod/mixin/MixinMinecraftServer.java +++ b/src/main/java/com/minecrafttas/tasmod/mixin/MixinMinecraftServer.java @@ -3,6 +3,7 @@ import java.util.Queue; import java.util.concurrent.FutureTask; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -52,9 +53,11 @@ public long redirectMathMax(long oneLong, long i) { @Shadow private long currentTime; + @Final @Shadow private Queue> futureTaskQueue; + @Final @Shadow private NetworkSystem networkSystem; diff --git a/src/main/java/com/minecrafttas/tasmod/mixin/playbackhooks/MixinEntityRenderer.java b/src/main/java/com/minecrafttas/tasmod/mixin/playbackhooks/MixinEntityRenderer.java index 5c1a36de..8af79e42 100644 --- a/src/main/java/com/minecrafttas/tasmod/mixin/playbackhooks/MixinEntityRenderer.java +++ b/src/main/java/com/minecrafttas/tasmod/mixin/playbackhooks/MixinEntityRenderer.java @@ -1,5 +1,6 @@ package com.minecrafttas.tasmod.mixin.playbackhooks; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -37,6 +38,7 @@ @Mixin(EntityRenderer.class) public class MixinEntityRenderer implements SubtickDuck { + @Final @Shadow private Minecraft mc; @Shadow diff --git a/src/main/java/com/minecrafttas/tasmod/mixin/savestates/MixinChunkProviderClient.java b/src/main/java/com/minecrafttas/tasmod/mixin/savestates/MixinChunkProviderClient.java index 7859b968..a9949b50 100644 --- a/src/main/java/com/minecrafttas/tasmod/mixin/savestates/MixinChunkProviderClient.java +++ b/src/main/java/com/minecrafttas/tasmod/mixin/savestates/MixinChunkProviderClient.java @@ -20,7 +20,7 @@ public class MixinChunkProviderClient implements ChunkProviderDuck { @Shadow @Final - private Long2ObjectMap chunkMapping; + private Long2ObjectMap loadedChunks; /** *

Unloads chunk data on the client. @@ -28,13 +28,13 @@ public class MixinChunkProviderClient implements ChunkProviderDuck { */ @Override public void unloadAllChunks() { - ObjectIterator objectiterator = this.chunkMapping.values().iterator(); + ObjectIterator objectiterator = this.loadedChunks.values().iterator(); while (objectiterator.hasNext()) { Chunk chunk = (Chunk) objectiterator.next(); chunk.onUnload(); } - chunkMapping.clear(); + loadedChunks.clear(); } } diff --git a/src/main/java/com/minecrafttas/tasmod/mixin/savestates/MixinChunkProviderServer.java b/src/main/java/com/minecrafttas/tasmod/mixin/savestates/MixinChunkProviderServer.java index b0e829dc..5ff18e87 100644 --- a/src/main/java/com/minecrafttas/tasmod/mixin/savestates/MixinChunkProviderServer.java +++ b/src/main/java/com/minecrafttas/tasmod/mixin/savestates/MixinChunkProviderServer.java @@ -24,7 +24,7 @@ public abstract class MixinChunkProviderServer implements ChunkProviderDuck { */ @Shadow @Final - private Long2ObjectMap id2ChunkMap; + private Long2ObjectMap loadedChunks; /** *

Saves and unloads chunk data. @@ -34,7 +34,7 @@ public abstract class MixinChunkProviderServer implements ChunkProviderDuck { */ @Override public void unloadAllChunks() { - ObjectIterator objectiterator = this.id2ChunkMap.values().iterator(); + ObjectIterator objectiterator = this.loadedChunks.values().iterator(); while (objectiterator.hasNext()) { Chunk chunk = (Chunk) objectiterator.next(); @@ -42,7 +42,7 @@ public void unloadAllChunks() { this.saveChunkExtraData(chunk); chunk.onUnload(); } - id2ChunkMap.clear(); + loadedChunks.clear(); } @Shadow diff --git a/src/main/java/com/minecrafttas/tasmod/savestates/SavestateHandlerClient.java b/src/main/java/com/minecrafttas/tasmod/savestates/SavestateHandlerClient.java index 1d650125..24e23965 100644 --- a/src/main/java/com/minecrafttas/tasmod/savestates/SavestateHandlerClient.java +++ b/src/main/java/com/minecrafttas/tasmod/savestates/SavestateHandlerClient.java @@ -28,7 +28,6 @@ import com.minecrafttas.tasmod.util.Ducks.ChunkProviderDuck; import com.minecrafttas.tasmod.util.Ducks.WorldClientDuck; import com.minecrafttas.tasmod.util.LoggerMarkers; -import com.mojang.realmsclient.gui.ChatFormatting; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -37,6 +36,7 @@ import net.minecraft.client.multiplayer.ChunkProviderClient; import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextFormatting; import net.minecraft.world.chunk.Chunk; /** @@ -93,7 +93,7 @@ public void onClientLoadstateComplete() { LOGGER.trace(LoggerMarkers.Savestate, "Add player {} to loaded entity list", player.getName()); int i = MathHelper.floor(player.posX / 16.0D); int j = MathHelper.floor(player.posZ / 16.0D); - Chunk chunk = Minecraft.getMinecraft().world.getChunkFromChunkCoords(i, j); + Chunk chunk = Minecraft.getMinecraft().world.getChunk(i, j); for (int k = 0; k < chunk.getEntityLists().length; k++) { if (chunk.getEntityLists()[k].contains(player)) { return; @@ -181,8 +181,8 @@ public static void loadstate(String nameOfSavestate) throws Exception { savestateContainerList = PlaybackSerialiser.loadFromFile(targetfile, state != TASstate.PLAYBACK); } else { controller.setTASStateClient(TASstate.NONE, false); - Minecraft.getMinecraft().player.sendMessage(new TextComponentString(ChatFormatting.YELLOW + "Inputs could not be loaded for this savestate,")); - Minecraft.getMinecraft().player.sendMessage(new TextComponentString(ChatFormatting.YELLOW + "since the file doesn't exist. Stopping!")); + Minecraft.getMinecraft().player.sendMessage(new TextComponentString(TextFormatting.YELLOW + "Inputs could not be loaded for this savestate,")); + Minecraft.getMinecraft().player.sendMessage(new TextComponentString(TextFormatting.YELLOW + "since the file doesn't exist. Stopping!")); LOGGER.warn(LoggerMarkers.Savestate, "Inputs could not be loaded for this savestate, since the file doesn't exist."); return; } diff --git a/src/main/java/com/minecrafttas/tasmod/savestates/handlers/SavestateWorldHandler.java b/src/main/java/com/minecrafttas/tasmod/savestates/handlers/SavestateWorldHandler.java index fc5fd636..acb87ed8 100644 --- a/src/main/java/com/minecrafttas/tasmod/savestates/handlers/SavestateWorldHandler.java +++ b/src/main/java/com/minecrafttas/tasmod/savestates/handlers/SavestateWorldHandler.java @@ -74,7 +74,7 @@ public void addPlayerToServerChunk(EntityPlayerMP player) { int i = MathHelper.floor(player.posX / 16.0D); int j = MathHelper.floor(player.posZ / 16.0D); WorldServer world = player.getServerWorld(); - Chunk chunk = world.getChunkFromChunkCoords(i, j); + Chunk chunk = world.getChunk(i, j); for (int k = 0; k < chunk.getEntityLists().length; k++) { if (chunk.getEntityLists()[k].contains(player)) { return; diff --git a/src/main/java/com/minecrafttas/tasmod/util/ShieldDownloader.java b/src/main/java/com/minecrafttas/tasmod/util/ShieldDownloader.java index ab61d305..8c2aebcd 100644 --- a/src/main/java/com/minecrafttas/tasmod/util/ShieldDownloader.java +++ b/src/main/java/com/minecrafttas/tasmod/util/ShieldDownloader.java @@ -166,7 +166,7 @@ private String getShieldName(String uuid) { @Deprecated private Map downloadNames() { - File feil = new File(Minecraft.getMinecraft().mcDataDir + File.separator + "playerstt.txt"); + File feil = new File(Minecraft.getMinecraft().gameDir + File.separator + "playerstt.txt"); URL url; Map uuids = Maps.newHashMap(); diff --git a/src/main/java/com/minecrafttas/tasmod/util/TabCompletionUtils.java b/src/main/java/com/minecrafttas/tasmod/util/TabCompletionUtils.java index c820aa5e..e4238cd4 100644 --- a/src/main/java/com/minecrafttas/tasmod/util/TabCompletionUtils.java +++ b/src/main/java/com/minecrafttas/tasmod/util/TabCompletionUtils.java @@ -99,7 +99,7 @@ public void onClientPacket(PacketID id, ByteBuffer buf, String username) throws private List getFilenames() { List tab = new ArrayList(); - File folder = new File(Minecraft.getMinecraft().mcDataDir, "saves" + File.separator + "tasfiles"); + File folder = new File(Minecraft.getMinecraft().gameDir, "saves" + File.separator + "tasfiles"); File[] listOfFiles = folder.listFiles(new FileFilter() { @Override diff --git a/src/main/resources/tasmod.accesswidener b/src/main/resources/tasmod.accesswidener index 0029bc11..8c6948d2 100644 --- a/src/main/resources/tasmod.accesswidener +++ b/src/main/resources/tasmod.accesswidener @@ -11,4 +11,8 @@ accessible field net/minecraft/world/World worldInfo Lnet/minecraft/world/storag accessible method net/minecraft/world/storage/SaveHandler setSessionLock ()V -accessible field net/minecraft/client/settings/KeyBinding CATEGORY_ORDER Ljava/util/Map; \ No newline at end of file +accessible field net/minecraft/client/settings/KeyBinding CATEGORY_ORDER Ljava/util/Map; + +accessible method net/minecraft/server/MinecraftServer saveAllWorlds (Z)V +accessible method net/minecraft/server/MinecraftServer convertMapIfNeeded (Ljava/lang/String;)V +accessible method net/minecraft/server/MinecraftServer setResourcePackFromWorld (Ljava/lang/String;Lnet/minecraft/world/storage/ISaveHandler;)V \ No newline at end of file