Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
modmuss50 committed Jan 21, 2025
1 parent 5d70584 commit 0fd8be5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ public static void registerDynamicEntries(List<RegistryLoader.Loader<?>> registr
}

Registry<TestInstance> testInstances = (Registry<TestInstance>) registries.get(RegistryKeys.TEST_INSTANCE);

if (testInstances == null) {
// Not the correct dyn registry
return;
}

Registry<TestEnvironmentDefinition> testEnvironmentDefinitionRegistry = (Registry<TestEnvironmentDefinition>) Objects.requireNonNull(registries.get(RegistryKeys.TEST_ENVIRONMENT));

for (TestAnnotationLocator.TestMethod testMethod : locator.getTestMethods()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,33 @@

package net.fabricmc.fabric.mixin.gametest;

import java.util.List;

import com.llamalad7.mixinextras.sugar.Local;
import net.fabricmc.fabric.impl.gametest.FabricGameTestModInitializer;

Check failure on line 20 in fabric-gametest-api-v1/src/main/java/net/fabricmc/fabric/mixin/gametest/RegistryLoaderMixin.java

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

'net.fabricmc.fabric.impl.gametest.FabricGameTestModInitializer' should be separated from previous imports.
import net.minecraft.registry.DynamicRegistryManager;

Check failure on line 21 in fabric-gametest-api-v1/src/main/java/net/fabricmc/fabric/mixin/gametest/RegistryLoaderMixin.java

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

Wrong order for 'net.minecraft.registry.DynamicRegistryManager' import.
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.RegistryLoader;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.resource.ResourceManager;
import org.spongepowered.asm.mixin.Mixin;

Check failure on line 26 in fabric-gametest-api-v1/src/main/java/net/fabricmc/fabric/mixin/gametest/RegistryLoaderMixin.java

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

Wrong order for 'org.spongepowered.asm.mixin.Mixin' import.
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Coerce;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.registry.RegistryLoader;
import net.minecraft.registry.RegistryWrapper;

import net.fabricmc.fabric.impl.gametest.FabricGameTestModInitializer;
import java.util.List;

Check failure on line 33 in fabric-gametest-api-v1/src/main/java/net/fabricmc/fabric/mixin/gametest/RegistryLoaderMixin.java

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

Wrong order for 'java.util.List' import.
import java.util.concurrent.atomic.AtomicBoolean;

@Mixin(RegistryLoader.class)
public class RegistryLoaderMixin {
@Unique
private static final AtomicBoolean LOADING_DYNAMIC_REGISTRIES = new AtomicBoolean(false);

@Inject(method = "loadFromResource(Lnet/minecraft/resource/ResourceManager;Ljava/util/List;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;", at = @At("HEAD"))
private static void loadFromResources(ResourceManager resourceManager, List<RegistryWrapper.Impl<?>> registries, List<RegistryLoader.Entry<?>> entries, CallbackInfoReturnable<DynamicRegistryManager.Immutable> cir) {
LOADING_DYNAMIC_REGISTRIES.set(entries.stream().anyMatch(entry -> entry.key() == RegistryKeys.TEST_INSTANCE));
}

@Inject(
method = "load(Lnet/minecraft/registry/RegistryLoader$RegistryLoadable;Ljava/util/List;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;",
at = @At(
Expand All @@ -42,6 +52,8 @@ public class RegistryLoaderMixin {
)
)
private static void beforeFreeze(@Coerce Object loadable, List<RegistryWrapper.Impl<?>> wrappers, List<RegistryLoader.Entry<?>> entries, CallbackInfoReturnable<DynamicRegistryManager.Immutable> cir, @Local(ordinal = 2) List<RegistryLoader.Loader<?>> registriesList) {
FabricGameTestModInitializer.registerDynamicEntries(registriesList);
if (LOADING_DYNAMIC_REGISTRIES.getAndSet(false)) {
FabricGameTestModInitializer.registerDynamicEntries(registriesList);
}
}
}

0 comments on commit 0fd8be5

Please sign in to comment.