diff options
author | IlmarsXd <74308163+IlmarsXd@users.noreply.github.com> | 2023-12-23 15:25:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-23 14:25:29 +0100 |
commit | cdac22ba4543d16445148fe77e7adca08163ef54 (patch) | |
tree | c4ed8e0722cfb2eafebb1dfa525f97c4f154844a | |
parent | 81a78588acd3fe8db9d042fe2b497037170f37bf (diff) | |
download | NotEnoughUpdates-cdac22ba4543d16445148fe77e7adca08163ef54.tar.gz NotEnoughUpdates-cdac22ba4543d16445148fe77e7adca08163ef54.tar.bz2 NotEnoughUpdates-cdac22ba4543d16445148fe77e7adca08163ef54.zip |
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
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTextureManager.java | 25 | ||||
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java | 1 |
2 files changed, 26 insertions, 0 deletions
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<ITickable> 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 = "<init>", 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() |