Skip to content

Commit e3817ce

Browse files
committed
Fix black panorama
1 parent cb6dfee commit e3817ce

File tree

5 files changed

+76
-11
lines changed

5 files changed

+76
-11
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2023 - 2025 dima_dencep.
3+
*
4+
* Licensed under the Open Software License, Version 3.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
*
7+
* You may obtain a copy of the License at
8+
* https://spdx.org/licenses/OSL-3.0.txt
9+
*/
10+
11+
package org.redlance.dima_dencep.mods.rrls.mixins.compat;
12+
13+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
14+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
15+
import net.minecraft.client.renderer.CubeMap;
16+
import net.minecraft.client.renderer.texture.AbstractTexture;
17+
import net.minecraft.client.renderer.texture.ReloadableTexture;
18+
import net.minecraft.client.renderer.texture.TextureManager;
19+
import net.minecraft.resources.ResourceLocation;
20+
import org.redlance.dima_dencep.mods.rrls.utils.OverlayHelper;
21+
import org.redlance.dima_dencep.mods.rrls.utils.TextureUtils;
22+
import org.spongepowered.asm.mixin.Mixin;
23+
import org.spongepowered.asm.mixin.injection.At;
24+
25+
@Mixin(CubeMap.class)
26+
public class CubeMapMixin {
27+
@WrapOperation(
28+
method = "registerTextures",
29+
at = @At(
30+
value = "INVOKE",
31+
target = "Lnet/minecraft/client/renderer/texture/TextureManager;register(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/renderer/texture/AbstractTexture;)V"
32+
)
33+
)
34+
public void rrls$earlyRegister(TextureManager instance, ResourceLocation path, AbstractTexture texture, Operation<Void> original) {
35+
original.call(instance, path, texture);
36+
37+
if (OverlayHelper.isCurrentRenderingState() && texture instanceof ReloadableTexture reloadableTexture) {
38+
TextureUtils.reloadTexture(instance.resourceManager, path, reloadableTexture);
39+
}
40+
}
41+
}

common/src/main/java/org/redlance/dima_dencep/mods/rrls/mixins/workaround/TextureManagerMixin.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@
1212

1313
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
1414
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
15-
import net.minecraft.Util;
16-
import net.minecraft.client.Minecraft;
1715
import net.minecraft.client.renderer.texture.AbstractTexture;
1816
import net.minecraft.client.renderer.texture.ReloadableTexture;
1917
import net.minecraft.client.renderer.texture.TextureManager;
2018
import net.minecraft.resources.ResourceLocation;
2119
import net.minecraft.server.packs.resources.ResourceManager;
22-
import org.redlance.dima_dencep.mods.rrls.Rrls;
2320
import org.redlance.dima_dencep.mods.rrls.utils.OverlayHelper;
21+
import org.redlance.dima_dencep.mods.rrls.utils.TextureUtils;
2422
import org.spongepowered.asm.mixin.Final;
2523
import org.spongepowered.asm.mixin.Mixin;
2624
import org.spongepowered.asm.mixin.Shadow;
@@ -43,12 +41,7 @@ public abstract class TextureManagerMixin {
4341
original.call(instance, path, texture);
4442

4543
if (OverlayHelper.isCurrentRenderingState() && texture instanceof ReloadableTexture reloadableTexture) {
46-
TextureManager.PendingReload reload = TextureManager.scheduleLoad(
47-
this.resourceManager, path, reloadableTexture, Util.backgroundExecutor()
48-
);
49-
Rrls.LOGGER.info("Reloading texture '{}'!", path);
50-
reload.newContents().thenAcceptAsync(textureContents -> reload.texture()
51-
.apply(textureContents), Minecraft.getInstance());
44+
TextureUtils.reloadTexture(this.resourceManager, path, reloadableTexture);
5245
}
5346
}
5447
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2023 - 2025 dima_dencep.
3+
*
4+
* Licensed under the Open Software License, Version 3.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
*
7+
* You may obtain a copy of the License at
8+
* https://spdx.org/licenses/OSL-3.0.txt
9+
*/
10+
11+
package org.redlance.dima_dencep.mods.rrls.utils;
12+
13+
import net.minecraft.Util;
14+
import net.minecraft.client.Minecraft;
15+
import net.minecraft.client.renderer.texture.ReloadableTexture;
16+
import net.minecraft.client.renderer.texture.TextureManager;
17+
import net.minecraft.resources.ResourceLocation;
18+
import net.minecraft.server.packs.resources.ResourceManager;
19+
import org.redlance.dima_dencep.mods.rrls.Rrls;
20+
21+
public class TextureUtils {
22+
public static void reloadTexture(ResourceManager manager, ResourceLocation rl, ReloadableTexture texture) {
23+
TextureManager.PendingReload reload = TextureManager.scheduleLoad(manager, rl, texture, Util.backgroundExecutor());
24+
Rrls.LOGGER.info("Reloading texture '{}'!", rl);
25+
26+
reload.newContents().thenAcceptAsync(textureContents -> reload.texture()
27+
.apply(textureContents),Minecraft.getInstance());
28+
}
29+
}

common/src/main/resources/rrls.accesswidener

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ accessible class net/minecraft/client/renderer/ShaderManager$CompilationCache
4040
accessible method net/minecraft/client/renderer/texture/TextureManager scheduleLoad (Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/renderer/texture/ReloadableTexture;Ljava/util/concurrent/Executor;)Lnet/minecraft/client/renderer/texture/TextureManager$PendingReload;
4141
accessible class net/minecraft/client/renderer/texture/TextureManager$PendingReload
4242
accessible method net/minecraft/client/Minecraft buildInitialScreens (Lnet/minecraft/client/Minecraft$GameLoadCookie;)Ljava/lang/Runnable;
43+
accessible field net/minecraft/client/renderer/texture/TextureManager resourceManager Lnet/minecraft/server/packs/resources/ResourceManager;

common/src/main/resources/rrls.mixins.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@
88
"LoadingOverlayMixin",
99
"MinecraftClientMixin",
1010
"TitleScreenMixin",
11+
"compat.CubeMapMixin",
1112
"compat.OverlayMixin",
1213
"compat.RendererKeyboardMouseMixin",
1314
"compat.ServerPackManagerMixin",
14-
"workaround.textures.AbstractTextureMixin",
1515
"workaround.CompilationCacheMixin",
1616
"workaround.EntityRenderDispatcherMixin",
1717
"workaround.GlCommandEncoderMixin",
1818
"workaround.GuiGraphicsMixin",
1919
"workaround.ReloadableResourceManagerMixin",
20-
"workaround.TextureManagerMixin"
20+
"workaround.TextureManagerMixin",
21+
"workaround.textures.AbstractTextureMixin"
2122
],
2223
"injectors": {
2324
"defaultRequire": 1

0 commit comments

Comments
 (0)