Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f9e3723
[core] add IOSupplier
SpaceWalkerRS Mar 28, 2026
4e38ec4
[core] add Unit
SpaceWalkerRS Mar 28, 2026
3819212
[core] add some async utils
SpaceWalkerRS Mar 28, 2026
75b02bf
[resource loader] initial work on V2
SpaceWalkerRS Mar 28, 2026
657d0db
[resource loader] run custom reloaders on game start-up
SpaceWalkerRS May 3, 2026
5d5b051
[resource loader] fix crash in findResources
SpaceWalkerRS May 3, 2026
36d4cbf
[core] add MinecraftVersion
SpaceWalkerRS May 5, 2026
b9d00ca
[branding] use Core's MinecraftVersion
SpaceWalkerRS May 5, 2026
b1a7ebb
[resource loader] use Mixin plugin instead of abusing Pseudo
SpaceWalkerRS May 5, 2026
244bdfc
[resource loader] fix mc dep for the 1.3-1.5 impl
SpaceWalkerRS May 5, 2026
4f890ef
[resource loader] some fixes
SpaceWalkerRS May 5, 2026
9a7809c
[resource loader] add context to events
SpaceWalkerRS May 7, 2026
f0d3db0
[resource loader] yeet unnecessary generics
SpaceWalkerRS May 7, 2026
02cf00d
[resource loader] add ClientPackSource/ServerPackSource
SpaceWalkerRS May 7, 2026
96b2291
[resource loader] 1.13+ ClientPackSource/ServerPackSource
SpaceWalkerRS May 8, 2026
35c74d6
[resource loader] resolve pack format through mc version
SpaceWalkerRS May 8, 2026
3487bed
[resource loader] fix version range for LegacyResourcePack mixin
SpaceWalkerRS May 8, 2026
8701414
[resource loader] some clean up
SpaceWalkerRS May 9, 2026
7605fd2
[resource loader] fix errors during reloads being suppressed
SpaceWalkerRS May 9, 2026
81a36aa
[resource loader] add ProfiledResourceReload
SpaceWalkerRS May 9, 2026
8fd362c
[resource loader] fix ProfiledResourceReload
SpaceWalkerRS May 9, 2026
7bc232a
[resource loader] add ResourceManager.getResourcePacks
SpaceWalkerRS May 11, 2026
f13dc25
[resource loader] fix resource manager/pack repository not resetting …
SpaceWalkerRS May 13, 2026
878b360
[core] add ModLoader for querying current mod loader
SpaceWalkerRS May 17, 2026
583a258
[resource loader] improve handling of pack ids
SpaceWalkerRS May 15, 2026
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 @@ -4,11 +4,10 @@
import joptsimple.OptionSet;
import joptsimple.OptionSpec;

import net.fabricmc.loader.api.FabricLoader;

import net.ornithemc.osl.branding.api.BrandingContext;
import net.ornithemc.osl.branding.api.BrandingPatchEvents;
import net.ornithemc.osl.branding.api.Operation;
import net.ornithemc.osl.core.impl.util.MinecraftVersion;
import net.ornithemc.osl.entrypoints.api.client.ClientModInitializer;
import net.ornithemc.osl.entrypoints.api.launch.LaunchEvents;
import net.ornithemc.osl.entrypoints.api.launch.OptionsConsumer;
Expand All @@ -21,7 +20,7 @@ public class BrandingPatchImpl implements ClientModInitializer {

public static String getGameVersion() {
if (gameVersion == null) {
gameVersion = FabricLoader.getInstance().getRawGameVersion();
gameVersion = MinecraftVersion.resolve().gameVersion();

if (gameVersion.charAt(0) == 'a') {
gameVersion = "Alpha v" + gameVersion.substring(1);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package net.ornithemc.osl.core.api.util;

public enum Unit {

INSTANCE

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.ornithemc.osl.core.api.util.function;

import java.io.IOException;

public interface IOSupplier<T> {

T get() throws IOException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package net.ornithemc.osl.core.impl.util;

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

import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.fabricmc.loader.api.SemanticVersion;
import net.fabricmc.loader.api.Version;
import net.fabricmc.loader.api.VersionParsingException;
import net.fabricmc.loader.impl.game.minecraft.McVersionLookup;

public final class MinecraftVersion {

private static MinecraftVersion INSTANCE;

public static MinecraftVersion resolve() {
if (INSTANCE == null) {
Optional<ModContainer> mod = FabricLoader.getInstance().getModContainer("minecraft");

if (!mod.isPresent()) {
throw new IllegalStateException("Minecraft not loaded!");
}

ModContainer minecraft = mod.get();
String gameVersion = FabricLoader.getInstance().getRawGameVersion();
SemanticVersion semanticVersion = resolveSemanticVersion(minecraft.getMetadata().getVersion());

INSTANCE = new MinecraftVersion(gameVersion, semanticVersion);
}

return INSTANCE;
}

private final String gameVersion;
private final SemanticVersion semanticVersion;

// semantic versions for other game versions
private final Map<String, SemanticVersion> semanticVersions = new HashMap<>();

private MinecraftVersion(String gameVersion, SemanticVersion semanticVersion) {
this.gameVersion = gameVersion;
this.semanticVersion = semanticVersion;
}

public String gameVersion() {
return this.gameVersion;
}

public String semanticVersion() {
return this.semanticVersion.toString();
}

public int compareTo(String gameVersion) {
return this.semanticVersion.compareTo((Version) this.semanticVersions.computeIfAbsent(gameVersion, MinecraftVersion::resolveSemanticVersion));
}

private static SemanticVersion resolveSemanticVersion(Version gameVersion) {
if (gameVersion instanceof SemanticVersion) {
return (SemanticVersion) gameVersion;
} else {
return resolveSemanticVersion(gameVersion.toString());
}
}

private static SemanticVersion resolveSemanticVersion(String gameVersion) {
String releaseVersion = McVersionLookup.getRelease(gameVersion);
String normalizedVersion = McVersionLookup.normalizeVersion(gameVersion, releaseVersion);

try {
return SemanticVersion.parse(normalizedVersion);
} catch (VersionParsingException e) {
throw new IllegalStateException("Unable to parse Minecraft version " + gameVersion, e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package net.ornithemc.osl.core.impl.util;

import net.fabricmc.loader.api.FabricLoader;

public enum ModLoader {

FABRIC("fabric", "fabricloader", "Fabric"),
QUILT ("quilt" , "quilt_loader", "Quilt");

public static ModLoader INSTANCE;

public static ModLoader resolve() {
if (INSTANCE == null) {
// Quilt also provides fabricloader as a mod so quiltloader must be checked first
if (FabricLoader.getInstance().isModLoaded(QUILT.modId)) {
INSTANCE = QUILT;
} else if (FabricLoader.getInstance().isModLoaded(FABRIC.modId)) {
INSTANCE = FABRIC;
} else {
throw new RuntimeException("Neither Fabric Loader nor Quilt Loader are loaded?! How is this even running?!");
}
}

return INSTANCE;
}

private final String id;
private final String modId;
private final String displayName;

private ModLoader(String id, String modId, String displayName) {
this.id = id;
this.modId = modId;
this.displayName = displayName;
}

public String id() {
return this.id;
}

public String modId() {
return this.modId;
}

public String displayName() {
return this.displayName;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package net.ornithemc.osl.core.impl.util;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;

public final class Util {

public static <V> CompletableFuture<List<V>> sequence(List<? extends CompletableFuture<? extends V>> futures) {
List<V> results = new ArrayList<>(futures.size());

CompletableFuture<?>[] sequence = new CompletableFuture[futures.size()];
CompletableFuture<Void> failure = new CompletableFuture<>();

futures.forEach(future -> {
int i = results.size();
results.add(null);

sequence[i] = future.whenComplete((result, exception) -> {
if (exception != null) {
failure.completeExceptionally(exception);
} else {
results.set(i, result);
}
});
});

return CompletableFuture.allOf(sequence).applyToEither(failure, v -> results);
}
}
Loading
Loading