Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,8 @@
import java.util.stream.Stream;

public final class SFMinecraftDownloader {
public static final boolean IS_OBFUSCATED_RELEASE = Boolean.parseBoolean(System.getProperty("sf.obfuscatedRelease", "false"));
public static final String CLIENT_URL_OVERRIDE = System.getProperty("sf.clientUrlOverride", "https://piston-data.mojang.com/v1/objects/4509ee9b65f226be61142d37bf05f8d28b03417b/client.jar");
private static final String MINECRAFT_VERSION = System.getProperty("sf.mcVersionOverride", "1.21.11_unobfuscated");
private static final String MINECRAFT_VERSION = System.getProperty("sf.mcVersionOverride", "26.1");
private static final String MINECRAFT_CLIENT_JAR_NAME = "minecraft-%s-client.jar".formatted(MINECRAFT_VERSION);
private static final String MINECRAFT_CLIENT_MAPPINGS_PROGUARD_NAME = "minecraft-%s-client-mappings.txt".formatted(MINECRAFT_VERSION);
private static final String MINECRAFT_CLIENT_MAPPINGS_TINY_NAME = "minecraft-%s-client-mappings.tiny".formatted(MINECRAFT_VERSION);
private static final String MANIFEST_URL = "https://piston-meta.mojang.com/mc/game/version_manifest_v2.json";

private SFMinecraftDownloader() {
Expand All @@ -72,14 +68,6 @@ private static Path getMinecraftClientJarPath(Path basePath) {
return getAndCreateDownloadDirectory(basePath).resolve(MINECRAFT_CLIENT_JAR_NAME);
}

private static Path getMinecraftClientMappingsProguardPath(Path basePath) {
return getAndCreateDownloadDirectory(basePath).resolve(MINECRAFT_CLIENT_MAPPINGS_PROGUARD_NAME);
}

private static Path getMinecraftClientMappingsTinyPath(Path basePath) {
return getAndCreateDownloadDirectory(basePath).resolve(MINECRAFT_CLIENT_MAPPINGS_TINY_NAME);
}

private static JsonObject getUrl(String url) {
try (var client = HttpClient.newHttpClient()) {
var response = client.send(HttpRequest.newBuilder(URI.create(url)).build(),
Expand Down Expand Up @@ -117,9 +105,7 @@ private static void setRemapClasspath(Path basePath) {
@SneakyThrows
public static void loadAndInjectMinecraftJar(Path basePath) {
var minecraftJarPath = getMinecraftClientJarPath(basePath);
var minecraftMappingsProguardPath = getMinecraftClientMappingsProguardPath(basePath);
if (Files.exists(minecraftJarPath)
&& (!IS_OBFUSCATED_RELEASE || Files.exists(minecraftMappingsProguardPath))) {
if (Files.exists(minecraftJarPath)) {
IO.println("Minecraft already downloaded, continuing");
} else {
IO.println("Downloading Minecraft...");
Expand All @@ -137,11 +123,11 @@ public static void loadAndInjectMinecraftJar(Path basePath) {
});

if (!Files.exists(minecraftJarPath)) {
var clientUrl = CLIENT_URL_OVERRIDE.isBlank() ? versionInfo.get()
var clientUrl = versionInfo.get()
.getAsJsonObject("downloads")
.getAsJsonObject("client")
.get("url")
.getAsString() : CLIENT_URL_OVERRIDE;
.getAsString();

IO.println("Downloading Minecraft client jar from: " + clientUrl);
var tempJarPath = Files.createTempFile("sf-mc-jar-download-", "-" + MINECRAFT_CLIENT_JAR_NAME);
Expand All @@ -156,63 +142,10 @@ public static void loadAndInjectMinecraftJar(Path basePath) {
Files.deleteIfExists(tempJarPath);
IO.println("Minecraft client jar downloaded and saved to: " + minecraftJarPath);
}

if (IS_OBFUSCATED_RELEASE && !Files.exists(minecraftMappingsProguardPath)) {
var clientMappingsUrl = versionInfo.get()
.getAsJsonObject("downloads")
.getAsJsonObject("client_mappings")
.get("url")
.getAsString();

IO.println("Downloading Minecraft client mappings from: " + clientMappingsUrl);
var tempMappingsPath = Files.createTempFile("sf-mc-mappings-download-", ".txt");
try (var in = URI.create(clientMappingsUrl).toURL().openStream()) {
Files.copy(in, tempMappingsPath, StandardCopyOption.REPLACE_EXISTING);
} catch (Exception e) {
Files.deleteIfExists(tempMappingsPath);
throw new RuntimeException("Failed to download Minecraft client mappings from " + clientMappingsUrl, e);
}

Files.copy(tempMappingsPath, minecraftMappingsProguardPath);
Files.deleteIfExists(tempMappingsPath);
IO.println("Minecraft client mappings downloaded and saved to: " + minecraftMappingsProguardPath);
}
}

var minecraftMappingsTinyPath = getMinecraftClientMappingsTinyPath(basePath);
if (IS_OBFUSCATED_RELEASE && !Files.exists(minecraftMappingsTinyPath)) {
try (var proguardReader = Files.newBufferedReader(minecraftMappingsProguardPath);
var intermediaryReader = new InputStreamReader(
Objects.requireNonNull(
MappingConfiguration.class.getClassLoader().getResourceAsStream(
"mappings/mappings.tiny"
)
)
);
var writer = Files.newBufferedWriter(minecraftMappingsTinyPath)) {
var mappingTree = new MemoryMappingTree();
ProGuardFileReader.read(proguardReader, "named", "official", mappingTree);
Tiny2FileReader.read(intermediaryReader, mappingTree);

var tiny2Writer = new Tiny2FileWriter(writer, false);
mappingTree.accept(tiny2Writer);
} catch (Exception e) {
throw new RuntimeException("Failed to read/write mappings", e);
}
}

System.setProperty(SystemProperties.GAME_MAPPING_NAMESPACE, "official");
System.setProperty(SystemProperties.GAME_JAR_PATH_CLIENT, minecraftJarPath.toString());
if (IS_OBFUSCATED_RELEASE) {
System.setProperty(SystemProperties.MAPPING_PATH, minecraftMappingsTinyPath.toAbsolutePath().toString());
if (Boolean.getBoolean("sf.remapToNamed")) {
System.setProperty(SystemProperties.RUNTIME_MAPPING_NAMESPACE, "named");
setRemapClasspath(basePath);
} else {
System.setProperty(SystemProperties.RUNTIME_MAPPING_NAMESPACE, "intermediary");
}
} else {
System.setProperty(SystemProperties.RUNTIME_MAPPING_NAMESPACE, "official");
}
System.setProperty(SystemProperties.RUNTIME_MAPPING_NAMESPACE, "official");
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions mod/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ dependencies {

compileOnly(projects.shared)

minecraft("com.mojang:minecraft:1.21.11_unobfuscated")
minecraft("com.mojang:minecraft:26.1")
implementation("net.fabricmc:fabric-loader:0.18.5")

val viaFabricPlusNotation = "com.viaversion:viafabricplus:4.4.8-SNAPSHOT-UNOBF"
val viaFabricPlusNotation = "com.viaversion:viafabricplus:4.5.0"
implementation(viaFabricPlusNotation) {
exclude("org.lz4")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@
*/
package com.soulfiremc.mod.mixin.headless.rendering;

import net.minecraft.client.renderer.block.BlockModelShaper;
import net.minecraft.client.renderer.block.model.BlockStateModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.block.BlockStateModelSet;
import net.minecraft.client.renderer.block.dispatch.BlockStateModel;
import net.minecraft.client.resources.model.sprite.Material;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(BlockModelShaper.class)
@Mixin(BlockStateModelSet.class)
public class MixinBlockModelShaper {
@Inject(method = "getParticleIcon", at = @At("HEAD"), cancellable = true)
private void getParticleIcon(BlockState state, CallbackInfoReturnable<TextureAtlasSprite> cir) {
@Inject(method = "getParticleMaterial", at = @At("HEAD"), cancellable = true)
private void getParticleIcon(BlockState state, CallbackInfoReturnable<Material.Baked> cir) {
cir.setReturnValue(null);
}

@Inject(method = "getBlockModel", at = @At("HEAD"), cancellable = true)
@Inject(method = "get", at = @At("HEAD"), cancellable = true)
private void getBlockModel(BlockState state, CallbackInfoReturnable<BlockStateModel> cir) {
cir.setReturnValue(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package com.soulfiremc.mod.mixin.headless.rendering;

import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.screens.Screen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -26,8 +26,8 @@

@Mixin(Screen.class)
public class MixinScreen {
@Inject(method = "renderTransparentBackground", at = @At("HEAD"), cancellable = true)
private void renderTransparentBackgroundHook(GuiGraphics guiGraphics, CallbackInfo ci) {
@Inject(method = "extractTransparentBackground", at = @At("HEAD"), cancellable = true)
private void renderTransparentBackgroundHook(GuiGraphicsExtractor guiGraphics, CallbackInfo ci) {
ci.cancel();
}

Expand Down

This file was deleted.

Loading
Loading