Skip to content

Commit

Permalink
all point versions
Browse files Browse the repository at this point in the history
  • Loading branch information
BluCobalt committed Jan 11, 2024
1 parent 727b329 commit 3bfb0e9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
45 changes: 34 additions & 11 deletions base/src/main/java/dev/blucobalt/realmsfix/Entrypoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,54 @@
package dev.blucobalt.realmsfix;


import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.SemanticVersion;
import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.mixin.Mixins;

import java.util.Map;
import java.util.HashMap;


public class Entrypoint
implements PreLaunchEntrypoint
{
private static final HashMap<String, String> VERSION_MAP;
private static final Logger LOGGER = LogManager.getLogger("realmsfix");

static {
VERSION_MAP = new HashMap<>();
VERSION_MAP.put("1.20", "1.20.4");
VERSION_MAP.put("1.19", "1.19.4");
VERSION_MAP.put("1.18", "1.18.2");
VERSION_MAP.put("1.17", "1.17.1");
VERSION_MAP.put("1.16", "1.16.5");
VERSION_MAP.put("1.15", "1.15.2");
VERSION_MAP.put("1.14", "1.14.4");
VERSION_MAP.put("1.13", "1.13.2");
VERSION_MAP.put("1.12", "1.12.2");
VERSION_MAP.put("1.11", "1.11.2");
VERSION_MAP.put("1.10", "1.10.2");
VERSION_MAP.put("1.9", "1.9.4");
VERSION_MAP.put("1.8", "1.8.9");
VERSION_MAP.put("1.7", "1.7.10");
}

private static String computedVersion;

@Override
public void onPreLaunch()
{
@SuppressWarnings("OptionalGetWithoutIsPresent") // minecraft is always going to be present
String version = FabricLoader.getInstance().getModContainer("minecraft").get().getMetadata().getVersion().getFriendlyString();
final String version = FabricLoader.getInstance().getModContainer("minecraft").get().getMetadata().getVersion().getFriendlyString();

// all point versions of the latest will be supported, but only the final point release will be supported for older major versions
if (version.contains("1.20"))
{
version = "1.20.4";
}
VERSION_MAP.forEach((major, point) -> {
if (version.startsWith(major)) {
computedVersion = point;
}
});

System.out.println("resolved config: " + "realmsfix-" + version + ".mixins.json");
Mixins.addConfiguration("realmsfix-" + version + ".mixins.json");
LOGGER.info("resolved config: " + "realmsfix-" + computedVersion + ".mixins.json");
Mixins.addConfiguration("realmsfix-" + computedVersion + ".mixins.json");
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx8G
org.gradle.caching=true
#fabric.loom.multiProjectOptimisation=true

version = 2.0.1
version = 2.0.2
yarn_1_20_4 = 1.20.4+build.3
yarn_1_19_4 = 1.19.4+build.2
yarn_1_18_2 = 1.18.2+build.4
Expand Down

0 comments on commit 3bfb0e9

Please sign in to comment.