Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 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
d4ad996
[resource loader] improve handling of pack ids
SpaceWalkerRS May 15, 2026
bf5c23c
[localization] initial work on API and two impls
SpaceWalkerRS May 12, 2026
1ffb005
[localization] use only loaded packs when reloading lang manager
SpaceWalkerRS May 13, 2026
fd9daa2
[localization] fix fallback translations
SpaceWalkerRS May 13, 2026
4da3ddd
[localization] getId -> getName
SpaceWalkerRS May 17, 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
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ def setUpLibrary(project) {
implementation "org.apache.logging.log4j:log4j-api:2.19.0"
implementation "org.apache.logging.log4j:log4j-core:2.19.0"

implementation "org.quiltmc.parsers:json:${project.rootProject.quilt_parsers_version}"

implementation project.dependencies.project(path: ':libraries:core', configuration: 'namedElements')

libraries.each { libraryPath ->
Expand Down
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,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);
}
}
3 changes: 3 additions & 0 deletions libraries/localization/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Localization API

The Localization API provides a consistent access point for localized text, and adds support for localization in versions that do not natively do so.
5 changes: 5 additions & 0 deletions libraries/localization/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
setUpLibrary(project)

dependencies {
implementation 'com.google.code.gson:gson:2.8.0'
}
6 changes: 6 additions & 0 deletions libraries/localization/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
library_id = localization
library_name = Localization
library_description = Localization API and events.
library_version = 0.1.0-alpha.1

osl_dependencies = core:>=0.7.0,executors:>=0.1.0,text-components:>=0.1.0-,resource-loader:>=0.7.0-
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
min_mc_version = 11w49a
max_mc_version = 1.5.2
minecraft_dependency = >=1.1-alpha.11.49.a <=1.5.2

minecraft_version = 1.5.2
client_nests_build = 6
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package net.ornithemc.osl.localization.impl.mixin.client;

import java.util.Properties;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

import net.minecraft.locale.Language;

@Mixin(Language.class)
public interface LanguageAccess {

@Accessor("translations")
Properties accessTranslations();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package net.ornithemc.osl.localization.impl.mixin.client;

import java.util.Properties;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import com.llamalad7.mixinextras.sugar.Local;

import net.minecraft.locale.Language;

import net.ornithemc.osl.localization.impl.Localization;
import net.ornithemc.osl.resource.loader.api.resource.manager.ResourceManager;

@Mixin(Language.class)
public class LanguageMixin {

@Shadow
private static Language INSTANCE;

@Shadow
private Properties translations;
@Shadow
private String currentCode;

@Inject(
method = "<clinit>",
at = @At(
value = "TAIL"
)
)
private static void osl$localization$initLocale(CallbackInfo ci) {
Localization.getLocale().wrap(((LanguageAccess) INSTANCE).accessTranslations());
}

@Inject(
method = "load",
at = @At(
value = "TAIL"
)
)
private void osl$localization$reloadLanguageManager(CallbackInfo ci) {
// each ServerPlayerEntity also holds an instance of this class
if ((Language) (Object) this == INSTANCE) {
Localization.reloadLanguageManager();
}
}

@Inject(
method = "loadLanguage",
at = @At(
value = "HEAD"
)
)
private void osl$localization$setLanguage(CallbackInfo ci) {
// each ServerPlayerEntity also holds an instance of this class
if ((Language) (Object) this == INSTANCE) {
Localization.getLanguageManager().setSelectedLanguage(this.currentCode);
}
}

@Inject(
method = "loadLanguage",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/locale/Language;loadTranslations(Ljava/util/Properties;Ljava/lang/String;)V"
)
)
private void osl$localization$loadExtraTranslations(CallbackInfo ci, @Local String language, @Local Properties translations) {
// each ServerPlayerEntity also holds an instance of this class
if ((Language) (Object) this == INSTANCE) {
// the translations map is replaced with each reload
Localization.getLocale().wrap(translations);
Localization.getLocale().loadLanguage(ResourceManager.client(), language);
}
}

@Inject(
method = "loadLanguage",
at = @At(
value = "TAIL"
)
)
private void osl$localization$localeReloaded(CallbackInfo ci) {
// each ServerPlayerEntity also holds an instance of this class
if ((Language) (Object) this == INSTANCE) {
Localization.getLocale().setLastUpdateTime();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"schemaVersion": 1,
"id": "osl-localization",
"version": "0.1.0-alpha.1+mc11w49a-mc1.5.2",
"environment": "*",
"mixins": [
"osl.localization.mixins.json"
],
"depends": {
"fabricloader": "\u003e\u003d0.18.0",
"minecraft": "\u003e\u003d1.1-alpha.11.49.a \u003c\u003d1.5.2",
"osl-core": "\u003e\u003d0.7.0",
"osl-executors": "\u003e\u003d0.1.0",
"osl-text-components": "\u003e\u003d0.1.0-",
"osl-resource-loader": "\u003e\u003d0.7.0-"
},
"name": "OSL Localization",
"description": "Localization API and events.",
"authors": [
"OrnitheMC"
],
"contact": {
"homepage": "https://ornithemc.net/",
"issues": "https://github.com/OrnitheMC/ornithe-standard-libraries/issues",
"sources": "https://github.com/OrnitheMC/ornithe-standard-libraries"
},
"license": "Apache-2.0"
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"required": true,
"minVersion": "0.8",
"package": "net.ornithemc.osl.resource.loader.impl.mixin",
"package": "net.ornithemc.osl.localization.impl.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
],
"client": [
"client.TexturePackMixin",
"client.LanguageAccess",
"client.LanguageMixin"
],
"server": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
min_mc_version = 13w26a
max_mc_version = 18w01a
minecraft_dependency = >=1.6-alpha.13.26.a <=1.13-alpha.18.1.a

minecraft_version = 1.8.2-pre4
raven_build = 1
sparrow_build = 1
nests_build = 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.ornithemc.osl.localization.impl.access;

import net.ornithemc.osl.core.api.util.NamespacedIdentifier;

public interface SimpleResourceAccess {

NamespacedIdentifier osl$localization$getLocation();

}
Loading
Loading