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
This commit is contained in:
embeddedt 2023-02-20 11:43:26 -05:00
parent c7f2d41695
commit aa963f4d1a
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
2 changed files with 29 additions and 0 deletions

View File

@ -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<T> {
@SuppressWarnings("rawtypes")
@Shadow @Mutable
@Final private List wrappers;
@Inject(method = "<init>", at = @At("RETURN"))
private void useCOWArrayList(Function<TagContainer, TagCollection<T>> function, CallbackInfo ci) {
this.wrappers = new CopyOnWriteArrayList<>();
}
}

View File

@ -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",