From aa963f4d1ab38b3195b9c3af6e30467e8c02e348 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Mon, 20 Feb 2023 11:43:26 -0500 Subject: [PATCH] Allow COW in StaticTagHelper Seems that some mods bind tags at runtime. This is a hack but it should fix the persistent CME I get when launching ATM6 --- .../concurrency/StaticTagHelperMixin.java | 28 +++++++++++++++++++ src/main/resources/modernfix.mixins.json | 1 + 2 files changed, 29 insertions(+) create mode 100644 src/main/java/org/embeddedt/modernfix/mixin/bugfix/concurrency/StaticTagHelperMixin.java diff --git a/src/main/java/org/embeddedt/modernfix/mixin/bugfix/concurrency/StaticTagHelperMixin.java b/src/main/java/org/embeddedt/modernfix/mixin/bugfix/concurrency/StaticTagHelperMixin.java new file mode 100644 index 00000000..17d1d698 --- /dev/null +++ b/src/main/java/org/embeddedt/modernfix/mixin/bugfix/concurrency/StaticTagHelperMixin.java @@ -0,0 +1,28 @@ +package org.embeddedt.modernfix.mixin.bugfix.concurrency; + +import net.minecraft.tags.StaticTagHelper; +import net.minecraft.tags.TagCollection; +import net.minecraft.tags.TagContainer; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +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 java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.function.Function; + +@Mixin(StaticTagHelper.class) +public class StaticTagHelperMixin { + @SuppressWarnings("rawtypes") + @Shadow @Mutable + @Final private List wrappers; + + @Inject(method = "", at = @At("RETURN")) + private void useCOWArrayList(Function> function, CallbackInfo ci) { + this.wrappers = new CopyOnWriteArrayList<>(); + } +} diff --git a/src/main/resources/modernfix.mixins.json b/src/main/resources/modernfix.mixins.json index 06b9688f..452ed23a 100644 --- a/src/main/resources/modernfix.mixins.json +++ b/src/main/resources/modernfix.mixins.json @@ -55,6 +55,7 @@ "perf.skip_first_datapack_reload.MinecraftMixin", "bugfix.concurrency.RenderTypeMixin", "bugfix.concurrency.MinecraftMixin", + "bugfix.concurrency.StaticTagHelperMixin", "perf.parallelize_model_loading.ModelBakeryMixin", "perf.parallelize_model_loading.OBJLoaderMixin", "perf.parallelize_model_loading.multipart.MultipartMixin",