From cdac22ba4543d16445148fe77e7adca08163ef54 Mon Sep 17 00:00:00 2001 From: IlmarsXd <74308163+IlmarsXd@users.noreply.github.com> Date: Sat, 23 Dec 2023 15:25:29 +0200 Subject: Fixed ConcurrentModificationException in Texture Manager (#974) * Fixed ConcurrentModificationException in Texture Manager caused by other mods and NEU loading a player on a different thread * Change comment * Add more info about issue --- .../mixins/MixinTextureManager.java | 25 ++++++++++++++++++++++ .../notenoughupdates/profileviewer/BasicPage.java | 1 + 2 files changed, 26 insertions(+) (limited to 'src/main') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTextureManager.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTextureManager.java index d8a48ecd..01c053b8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTextureManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTextureManager.java @@ -19,20 +19,45 @@ package io.github.moulberry.notenoughupdates.mixins; +import com.google.common.collect.Lists; import io.github.moulberry.notenoughupdates.miscfeatures.ItemCustomizeManager; +import io.github.moulberry.notenoughupdates.profileviewer.BasicPage; +import net.minecraft.client.renderer.texture.ITickable; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; +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.Collections; +import java.util.List; + @Mixin(TextureManager.class) public class MixinTextureManager { + + @Mutable + @Final + @Shadow + private List listTickables; + @Inject(method = "bindTexture", at = @At("HEAD"), cancellable = true) public void bindTexture(ResourceLocation location, CallbackInfo ci) { if (ItemCustomizeManager.disableTextureBinding) { ci.cancel(); } } + + /** + Fixes ConcurrentModificationException in TextureManager#tick + This is caused by NEU loading a player asynchronously which can cause issues with other mods (5zig in this case) + @see BasicPage#drawPage at profileLoader.submit() + */ + @Inject(method = "", at = @At("RETURN")) + public void constructor(CallbackInfo ci) { + listTickables = Collections.synchronizedList(Lists.newArrayList()); + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java index 0011272f..d10acea9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java @@ -471,6 +471,7 @@ public class BasicPage extends GuiProfileViewerPage { loadingProfile = true; UUID playerUUID = UUID.fromString(niceUuid(profile.getUuid())); + // Loads the player asynchronously profileLoader.submit(() -> { GameProfile fakeProfile = Minecraft .getMinecraft() -- cgit