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
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ jobs:
matrix:
# Use these Java versions
java: [
21, # Current Java LTS
25, # Current Java LTS
]
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: validate gradle wrapper
uses: gradle/actions/wrapper-validation@v4
uses: gradle/actions/wrapper-validation@v5
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
java-version: ${{ matrix.java }}
distribution: 'microsoft'
Expand All @@ -30,8 +30,8 @@ jobs:
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ matrix.java == '21' }} # Only upload artifacts built from latest java
uses: actions/upload-artifact@v4
if: ${{ matrix.java == '25' }} # Only upload artifacts built from latest java
uses: actions/upload-artifact@v7
with:
name: Artifacts
path: build/libs/
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=26.1-snapshot-1
loader_version=0.18.4
minecraft_version=26.3-snapshot-4
loader_version=0.19.3

# Mod Properties
mod_version=1.2.0+26.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class NbtOpsExtender {
target = "Ljava/util/Optional;orElseGet(Ljava/util/function/Supplier;)Ljava/lang/Object;"
)
)
private Supplier<DataResult<Number>> notANumberUseBetterErrorMessage(Supplier<DataResult<Number>> supplier, @Local(argsOnly = true) final Tag input) {
private Supplier<DataResult<Number>> notANumberUseBetterErrorMessage(Supplier<DataResult<Number>> supplier, @Local(argsOnly = true, name = "input") final Tag input) {
return () -> DataResult.error(() -> "Element is not a number: " + input);
}

Expand All @@ -34,7 +34,7 @@ private Supplier<DataResult<Number>> notANumberUseBetterErrorMessage(Supplier<Da
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
)
)
private Supplier<String> notAStringUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true) final Tag input) {
private Supplier<String> notAStringUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true, name = "input") final Tag input) {
return () -> "Element is not a string: " + input;
}

Expand All @@ -45,7 +45,7 @@ private Supplier<String> notAStringUseBetterErrorMessage(Supplier<String> messag
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
)
)
private Supplier<String> notAMapUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true) final Tag input) {
private Supplier<String> notAMapUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true, name = "input") final Tag input) {
return () -> "Element is not a map: " + input;
}

Expand All @@ -56,7 +56,7 @@ private Supplier<String> notAMapUseBetterErrorMessage(Supplier<String> message,
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
)
)
private Supplier<String> notAListUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true) final Tag input) {
private Supplier<String> notAListUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true, name = "input") final Tag input) {
return () -> "Element is not a list: " + input;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package net.errorcraft.codecium.mixin.minecraft.resources;

import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.datafixers.util.Pair;
import com.mojang.serialization.DataResult;
import com.mojang.serialization.DynamicOps;
import net.minecraft.core.Holder;
import net.minecraft.core.HolderSet;
import net.minecraft.core.Registry;
import net.minecraft.resources.HolderSetCodec;
Expand All @@ -13,11 +9,8 @@
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.function.Supplier;

Expand All @@ -27,55 +20,49 @@ public class HolderSetCodecExtender<E> {
@Final
private ResourceKey<? extends Registry<E>> registryKey;

@Unique
private static ResourceKey<? extends Registry<?>> tempRegistryKey;

@ModifyArg(
method = "lambda$lookupTag$0",
method = "lambda$decode$1",
at = @At(
value = "INVOKE",
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
)
)
private static <E> Supplier<String> unknownRegistryTagUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true) TagKey<E> tag) {
return () -> "Cannot get a registry tag with id " + tag.location();
private Supplier<String> decodeInaccessibleRegistryUseBetterErrorMessage(Supplier<String> message) {
return () -> "Registry " + this.registryKey.identifier() + " is inaccessible";
}

@ModifyArg(
method = "encode(Lnet/minecraft/core/HolderSet;Lcom/mojang/serialization/DynamicOps;Ljava/lang/Object;)Lcom/mojang/serialization/DataResult;",
method = "lambda$lookupTag$0",
at = @At(
value = "INVOKE",
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
)
)
private Supplier<String> invalidOwnerUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true) HolderSet<E> holderSet) {
return () -> "Registry tag " + holderSet.unwrapKey().orElseThrow().location() + " is not part of the current registry set";
}

@Inject(
method = "decodeWithoutRegistry",
at = @At("HEAD")
)
private <T> void storeTemporaryRegistryKey(DynamicOps<T> ops, T input, CallbackInfoReturnable<DataResult<Pair<HolderSet<E>, T>>> info) {
HolderSetCodecExtender.tempRegistryKey = this.registryKey;
private static <E> Supplier<String> unknownRegistryTagUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true, name = "key") TagKey<E> key) {
return () -> "Cannot get a registry tag with id " + key.location();
}

@ModifyArg(
method = "lambda$decodeWithoutRegistry$0",
method = "encode(Lnet/minecraft/core/HolderSet;Lcom/mojang/serialization/DynamicOps;Ljava/lang/Object;)Lcom/mojang/serialization/DataResult;",
at = @At(
value = "INVOKE",
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;",
ordinal = 0
)
)
private static <R> Supplier<String> inaccessibleRegistryUseBetterErrorMessage(Supplier<String> message, @Local(name = "holder") Holder<R> holder) {
return () -> "Registry " + HolderSetCodecExtender.tempRegistryKey.identifier() + " is inaccessible for " + holder.unwrapKey().orElseThrow();
private Supplier<String> invalidOwnerUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true, name = "input") HolderSet<E> input) {
return () -> "Registry tag " + input.unwrapKey().orElseThrow().location() + " is not part of the current registry set";
}

@Inject(
method = "decodeWithoutRegistry",
at = @At("TAIL")
@ModifyArg(
method = "encode(Lnet/minecraft/core/HolderSet;Lcom/mojang/serialization/DynamicOps;Ljava/lang/Object;)Lcom/mojang/serialization/DataResult;",
at = @At(
value = "INVOKE",
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;",
ordinal = 1
)
)
private <T> void removeTemporaryRegistryKey(DynamicOps<T> ops, T input, CallbackInfoReturnable<DataResult<Pair<HolderSet<E>, T>>> info) {
HolderSetCodecExtender.tempRegistryKey = null;
private Supplier<String> encodeInaccessibleRegistryUseBetterErrorMessage(Supplier<String> message) {
return () -> "Registry " + this.registryKey.identifier() + " is inaccessible";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public abstract class IdentifierExtender {
public static char NAMESPACE_SEPARATOR;

@Shadow
private static boolean validNamespaceChar(char character) {
private static boolean validNamespaceChar(char c) {
return false;
}

@Shadow
public static boolean validPathChar(char character) {
public static boolean validPathChar(char c) {
return false;
}

Expand All @@ -36,8 +36,8 @@ public static boolean validPathChar(char character) {
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
)
)
private static Supplier<String> identifierExceptionUseBetterMessage(Supplier<String> message, @Local(argsOnly = true) String id, @Local(name = "e") IdentifierException exception) {
return () -> ((IdentifierExceptionAccess) exception).codecium$messageWithoutId() + ": " + id;
private static Supplier<String> identifierExceptionUseBetterMessage(Supplier<String> message, @Local(argsOnly = true, name = "input") String input, @Local(name = "e") IdentifierException e) {
return () -> ((IdentifierExceptionAccess) e).codecium$messageWithoutId() + ": " + input;
}

@Redirect(
Expand All @@ -47,7 +47,7 @@ private static Supplier<String> identifierExceptionUseBetterMessage(Supplier<Str
target = "Lnet/minecraft/resources/Identifier;isValidNamespace(Ljava/lang/String;)Z"
)
)
private static boolean validateNamespaceUseBetterMessage(String namespace, String path) {
private static boolean validateNamespaceUseBetterMessage(String namespace, @Local(argsOnly = true, name = "path") String path) {
for (int i = 0; i < namespace.length(); i++) {
if (!validNamespaceChar(namespace.charAt(i))) {
IdentifierException exception = new IdentifierException("Invalid character '" + namespace.charAt(i) + "' in namespace of resource location");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public class RegistryFileCodecExtender<E> {
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
)
)
private Supplier<String> invalidOwnerUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true) Holder<E> registryEntry) {
return () -> "Holder " + registryEntry.unwrapKey().orElseThrow().identifier() + " is not part of the current registry set";
private Supplier<String> invalidOwnerUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true, name = "input") Holder<E> input) {
return () -> "Holder " + input.unwrapKey().orElseThrow().identifier() + " is not part of the current registry set";
}

@ModifyArg(
Expand Down Expand Up @@ -61,7 +61,7 @@ private Supplier<String> inlinedHoldersDisallowedUseBetterErrorMessage(Supplier<
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
)
)
private static <E> Supplier<String> unknownHolderUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true) ResourceKey<E> key) {
return () -> "Cannot get a holder with id " + key.identifier();
private static <E> Supplier<String> unknownHolderUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true, name = "elementKey") ResourceKey<E> elementKey) {
return () -> "Cannot get a holder with id " + elementKey.identifier();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public class RegistryFixedCodecExtender<E> {
ordinal = 0
)
)
private Supplier<String> invalidOwnerUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true) Holder<E> registryEntry) {
return () -> "Holder " + registryEntry.unwrapKey().orElseThrow().identifier() + " is not part of the current registry set";
private Supplier<String> invalidOwnerUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true, name = "input") Holder<E> input) {
return () -> "Holder " + input.unwrapKey().orElseThrow().identifier() + " is not part of the current registry set";
}

@ModifyArg(
Expand Down Expand Up @@ -73,7 +73,7 @@ private Supplier<String> decodeInaccessibleRegistryUseBetterErrorMessage(Supplie
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
)
)
private static Supplier<String> unknownHolderUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true) Identifier id) {
private static Supplier<String> unknownHolderUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true, name = "id") Identifier id) {
return () -> "Cannot get a holder with id " + id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class ExtraCodecsExtender {
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
)
)
private static Supplier<String> unsignedByteTooLarge(Supplier<String> message, @Local(argsOnly = true) final Integer value) {
return () -> "Unsigned byte must be at most 255: " + value;
private static Supplier<String> unsignedByteTooLarge(Supplier<String> message, @Local(argsOnly = true, name = "integer") final Integer integer) {
return () -> "Unsigned byte must be at most 255: " + integer;
}

@ModifyArg(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class JavaOpsExtender {
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
)
)
private Supplier<String> notANumberUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true) final Object input) {
private Supplier<String> notANumberUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true, name = "input") final Object input) {
return () -> "Element is not a number: " + input;
}

Expand All @@ -32,7 +32,7 @@ private Supplier<String> notANumberUseBetterErrorMessage(Supplier<String> messag
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
)
)
private Supplier<String> notABooleanUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true) final Object input) {
private Supplier<String> notABooleanUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true, name = "input") final Object input) {
return () -> "Element is not a boolean: " + input;
}

Expand All @@ -43,7 +43,7 @@ private Supplier<String> notABooleanUseBetterErrorMessage(Supplier<String> messa
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
)
)
private Supplier<String> notAStringUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true) final Object input) {
private Supplier<String> notAStringUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true, name = "input") final Object input) {
return () -> "Element is not a string: " + input;
}

Expand All @@ -54,7 +54,7 @@ private Supplier<String> notAStringUseBetterErrorMessage(Supplier<String> messag
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
)
)
private Supplier<String> notAMapUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true, ordinal = 0) final Object input) {
private Supplier<String> notAMapUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true, name = "input") final Object input) {
return () -> "Element is not a map: " + input;
}

Expand All @@ -65,7 +65,7 @@ private Supplier<String> notAMapUseBetterErrorMessage(Supplier<String> message,
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
)
)
private Supplier<String> notAListUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true, ordinal = 0) final Object input) {
private Supplier<String> notAListUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true, name = "input") final Object input) {
return () -> "Element is not a list: " + input;
}

Expand Down
Loading