From 7b7f103f69188a9fb6b5aaf513679639e4106876 Mon Sep 17 00:00:00 2001 From: Su5eD Date: Sun, 21 Jul 2024 10:37:20 +0200 Subject: [PATCH 1/3] Avoid early setup on invalid loading state Fixes #1255 --- gradle.properties | 2 +- .../service/ConnectorLoaderService.java | 28 ++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/gradle.properties b/gradle.properties index 3293f03..800f2fd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=true # Versions -versionConnector=1.0.0-beta.44 +versionConnector=1.0.0-beta.45 versionAdapter=1.11.55-1.20.1-20240428.153904 versionAdapterDefinition=1.11.65 versionAdapterRuntime=1.0.0 diff --git a/src/main/java/org/sinytra/connector/service/ConnectorLoaderService.java b/src/main/java/org/sinytra/connector/service/ConnectorLoaderService.java index d026c77..ac9d2ae 100644 --- a/src/main/java/org/sinytra/connector/service/ConnectorLoaderService.java +++ b/src/main/java/org/sinytra/connector/service/ConnectorLoaderService.java @@ -8,14 +8,14 @@ import cpw.mods.modlauncher.api.ITransformationService; import cpw.mods.modlauncher.api.ITransformer; import cpw.mods.modlauncher.serviceapi.ILaunchPluginService; -import org.sinytra.connector.loader.ConnectorEarlyLoader; -import org.sinytra.connector.service.hacks.ConnectorForkJoinThreadFactory; -import org.sinytra.connector.service.hacks.LenientRuntimeEnumExtender; -import org.sinytra.connector.service.hacks.ModuleLayerMigrator; import net.minecraftforge.fml.loading.ImmediateWindowHandler; import net.minecraftforge.fml.loading.ImmediateWindowProvider; import net.minecraftforge.fml.loading.LoadingModList; import net.minecraftforge.fml.unsafe.UnsafeHacks; +import org.sinytra.connector.loader.ConnectorEarlyLoader; +import org.sinytra.connector.service.hacks.ConnectorForkJoinThreadFactory; +import org.sinytra.connector.service.hacks.LenientRuntimeEnumExtender; +import org.sinytra.connector.service.hacks.ModuleLayerMigrator; import org.slf4j.Logger; import java.lang.invoke.VarHandle; @@ -55,16 +55,17 @@ public void initialize(IEnvironment environment) { ImmediateWindowProvider original = (ImmediateWindowProvider) provider.get(); ImmediateWindowProvider newProvider = new ImmediateWindowProvider() { - @Override public void updateModuleReads(ModuleLayer layer) { - // Setup entrypoints - ConnectorEarlyLoader.setup(); - // Invoke mixin on a dummy class to initialize mixin plugins - // Necessary to avoid duplicate class definition errors when a plugin loads the class that is being transformed - uncheck(() -> Class.forName("org.sinytra.connector.mod.DummyTarget", false, Thread.currentThread().getContextClassLoader())); - // Run preLaunch - ConnectorEarlyLoader.preLaunch(); + if (!ConnectorEarlyLoader.hasEncounteredException()) { + // Setup entrypoints + ConnectorEarlyLoader.setup(); + // Invoke mixin on a dummy class to initialize mixin plugins + // Necessary to avoid duplicate class definition errors when a plugin loads the class that is being transformed + uncheck(() -> Class.forName("org.sinytra.connector.mod.DummyTarget", false, Thread.currentThread().getContextClassLoader())); + // Run preLaunch + ConnectorEarlyLoader.preLaunch(); + } original.updateModuleReads(layer); } @@ -116,7 +117,8 @@ public void onLoad(IEnvironment env, Set otherServices) { public List completeScan(IModuleLayerManager layerManager) { if (LoadingModList.get().getBrokenFiles().isEmpty()) { LoadingModList.get().getErrors().addAll(ConnectorEarlyLoader.getLoadingExceptions()); - } else { + } + else { LOGGER.warn("Broken FML mod files found, not adding Connector locator errors"); } return List.of(new Resource(IModuleLayerManager.Layer.GAME, List.of( From 8ea98b1e36e6fe96be677ea1535ce1748348203b Mon Sep 17 00:00:00 2001 From: Su5eD Date: Wed, 24 Jul 2024 12:00:54 +0200 Subject: [PATCH 2/3] Resetting owners causes race condition on serialization Fix #1263 --- gradle.properties | 2 +- .../mixin/registries/ForgeRegistryMixin.java | 21 +------------------ 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/gradle.properties b/gradle.properties index 800f2fd..10b444f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ org.gradle.daemon=true # Versions versionConnector=1.0.0-beta.45 versionAdapter=1.11.55-1.20.1-20240428.153904 -versionAdapterDefinition=1.11.65 +versionAdapterDefinition=1.11.67-1.20.1 versionAdapterRuntime=1.0.0 versionMc=1.20.1 diff --git a/src/mod/java/org/sinytra/connector/mod/mixin/registries/ForgeRegistryMixin.java b/src/mod/java/org/sinytra/connector/mod/mixin/registries/ForgeRegistryMixin.java index bdcb235..6673a62 100644 --- a/src/mod/java/org/sinytra/connector/mod/mixin/registries/ForgeRegistryMixin.java +++ b/src/mod/java/org/sinytra/connector/mod/mixin/registries/ForgeRegistryMixin.java @@ -1,30 +1,20 @@ package org.sinytra.connector.mod.mixin.registries; -import com.google.common.collect.BiMap; import com.mojang.serialization.Lifecycle; -import org.sinytra.connector.mod.ConnectorLoader; import net.minecraft.core.Holder; import net.minecraft.core.MappedRegistry; import net.minecraftforge.registries.ForgeRegistry; import net.minecraftforge.registries.GameData; import net.minecraftforge.registries.IForgeRegistry; -import org.spongepowered.asm.mixin.Final; +import org.sinytra.connector.mod.ConnectorLoader; 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.Desc; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.util.HashMap; -import java.util.Map; - @Mixin(ForgeRegistry.class) public abstract class ForgeRegistryMixin implements IForgeRegistry { - @Shadow - @Final - private BiMap owners; - // Mixin AP complained about not finding the target method, so we use @Desc instead of a string @Inject(target = @Desc(value = "getDelegateOrThrow", args = Object.class, ret = Holder.Reference.class), at = @At("HEAD"), cancellable = true, remap = false) private void getDelegateOrThrow(V value, CallbackInfoReturnable> cir) { @@ -41,13 +31,4 @@ private void getDelegateOrThrow(V value, CallbackInfoReturnable cir) { - // When POI Types have their blockstate lists modified by mods, it breaks value -> key lookup - // Resetting the owners map hash cache fixes the issue - Map copy = new HashMap<>(this.owners); - this.owners.clear(); - this.owners.putAll(copy); - } } From 4c7d95a9eef34202e94c9eb8f198d83d9ed6f15c Mon Sep 17 00:00:00 2001 From: Su5eD Date: Wed, 7 Aug 2024 20:38:33 +0200 Subject: [PATCH 3/3] Fix gems mistakenly ending up tagged as tools Fixes #1267 --- .../java/org/sinytra/connector/mod/compat/TagConverter.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mod/java/org/sinytra/connector/mod/compat/TagConverter.java b/src/mod/java/org/sinytra/connector/mod/compat/TagConverter.java index a8921d8..32840b2 100644 --- a/src/mod/java/org/sinytra/connector/mod/compat/TagConverter.java +++ b/src/mod/java/org/sinytra/connector/mod/compat/TagConverter.java @@ -25,7 +25,8 @@ public final class TagConverter { private static final Pattern RAW_ORES_PATTERN = Pattern.compile("^raw_(.+?)_ores$"); private static final String TAG_ENTRY_SPLITTER = "_(?!.*_)"; private static final Collection COMMON_TYPES = Set.of("small_dusts"); - private static final Collection COMMON_GROUP_PREFIXES = Set.of("tools", "gems"); + private static final Collection COMMON_GROUP_PREFIXES = Set.of("tools"); + private static final Collection COMMON_GROUP_PREFIXES_NO_ENTRYPATH = Set.of("gems"); private static final Map ALIASES = Map.of( "blocks", "storage_blocks", "raw_ores", "raw_materials" @@ -83,7 +84,8 @@ public static ResourceLocation getNormalizedTagName(String path, Collection forge:gems/diamond) // This will handle existing tags, but won't be able to detect nonexisted tag names like c:rubies -> forge:gems/ruby // Well, it's better than nothing I guess