Skip to content

Commit

Permalink
Fix panorama
Browse files Browse the repository at this point in the history
  • Loading branch information
dima-dencep committed Dec 30, 2024
1 parent 642feb5 commit 08662c9
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ private static int replaceAlpha(int color, int alpha) {
target = "Lnet/minecraft/client/Minecraft;setOverlay(Lnet/minecraft/client/gui/screens/Overlay;)V"
)
)
public void rrls$onLoadDone(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick, CallbackInfo ci)
{
public void rrls$onLoadDone(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick, CallbackInfo ci) {
this.rrls$textWidget = null;
}

Expand Down Expand Up @@ -176,10 +175,11 @@ private static int replaceAlpha(int color, int alpha) {
remap = false
)
)
public void rrls$_clear(int i, Operation<Void> original) {
if (!rrls$getState().isRendering()) {
original.call(i);
public void rrls$_clear(int i, Operation<Void> original, @Local(argsOnly = true) GuiGraphics graphics) {
if (graphics instanceof DummyGuiGraphics) {
return;
}
original.call(i);
}

@WrapOperation(
Expand All @@ -190,10 +190,11 @@ private static int replaceAlpha(int color, int alpha) {
remap = false
)
)
public void rrls$_clearColor(float red, float green, float blue, float alpha, Operation<Void> original) {
if (!rrls$getState().isRendering()) {
original.call(red, green, blue, alpha);
public void rrls$_clearColor(float red, float green, float blue, float alpha, Operation<Void> original, @Local(argsOnly = true) GuiGraphics graphics) {
if (graphics instanceof DummyGuiGraphics) {
return;
}
original.call(red, green, blue, alpha);
}

@WrapOperation(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright 2023 - 2024 dima_dencep.
*
* Licensed under the Open Software License, Version 3.0 (the "License");
* you may not use this file except in compliance with the License.
*
* You may obtain a copy of the License at
* https://spdx.org/licenses/OSL-3.0.txt
*/

package org.redlance.dima_dencep.mods.rrls.mixins.workaround;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.AbstractTexture;
import net.minecraft.client.renderer.texture.ReloadableTexture;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager;
import org.redlance.dima_dencep.mods.rrls.Rrls;
import org.redlance.dima_dencep.mods.rrls.RrlsConfig;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(TextureManager.class)
public abstract class TextureManagerMixin {
@Shadow
@Final
private ResourceManager resourceManager;

@WrapOperation(
method = "registerForNextReload",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/texture/TextureManager;register(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/renderer/texture/AbstractTexture;)V"
)
)
public void rrls$earlyRegister(TextureManager instance, ResourceLocation path, AbstractTexture texture, Operation<Void> original) {
original.call(instance, path, texture);

if (RrlsConfig.hideType().forceClose() && texture instanceof ReloadableTexture reloadableTexture) {
TextureManager.PendingReload reload = TextureManager.scheduleLoad(
this.resourceManager, path, reloadableTexture, Util.backgroundExecutor()
);
Rrls.LOGGER.info("Reloading texture '{}'!", path);
reload.newContents().thenAcceptAsync(textureContents -> reload.texture()
.apply(textureContents), Minecraft.getInstance());
}
}
}
2 changes: 2 additions & 0 deletions common/src/main/resources/rrls.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ accessible field net/minecraft/client/resources/SplashManager splashes Ljava/uti
accessible field net/minecraft/client/renderer/ShaderManager compilationCache Lnet/minecraft/client/renderer/ShaderManager$CompilationCache;
accessible field net/minecraft/client/renderer/ShaderManager$CompilationCache configs Lnet/minecraft/client/renderer/ShaderManager$Configs;
accessible class net/minecraft/client/renderer/ShaderManager$CompilationCache
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;
accessible class net/minecraft/client/renderer/texture/TextureManager$PendingReload
3 changes: 2 additions & 1 deletion common/src/main/resources/rrls.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"workaround.CompilationCacheMixin",
"workaround.EntityRenderDispatcherMixin",
"workaround.GuiGraphicsMixin",
"workaround.ReloadableResourceManagerMixin"
"workaround.ReloadableResourceManagerMixin",
"workaround.TextureManagerMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 08662c9

Please sign in to comment.