Use GameRenderer.renderHand boolean field instead of mixin
Should be more compatible with mods which replace the entire renderHand method (thereby making our mixin non-applicable), at least as long as these mods check `renderHand` as well (Iris explicitly does). This will become important once #638 is fixed.
This commit is contained in:
@@ -8,6 +8,7 @@ import com.replaymod.render.Setting;
|
||||
import com.replaymod.render.capturer.CaptureData;
|
||||
import com.replaymod.render.capturer.RenderInfo;
|
||||
import com.replaymod.render.capturer.WorldRenderer;
|
||||
import com.replaymod.render.mixin.GameRendererAccessor;
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
import de.johni0702.minecraft.gui.utils.EventRegistrations;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
@@ -81,11 +82,16 @@ public class EntityRendererHandler extends EventRegistrations implements WorldRe
|
||||
//#endif
|
||||
|
||||
if (mc.world != null && mc.player != null) {
|
||||
GameRendererAccessor gameRenderer = (GameRendererAccessor) mc.gameRenderer;
|
||||
Screen orgScreen = mc.currentScreen;
|
||||
boolean orgPauseOnLostFocus = mc.options.pauseOnLostFocus;
|
||||
boolean orgRenderHand = gameRenderer.getRenderHand();
|
||||
try {
|
||||
mc.currentScreen = null; // do not want to render the current screen (that'd just be the progress gui)
|
||||
mc.options.pauseOnLostFocus = false; // do not want the pause menu to open if the window is unfocused
|
||||
if (omnidirectional) {
|
||||
gameRenderer.setRenderHand(false); // makes no sense, we wouldn't even know where to put it
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
mc.gameRenderer.render(partialTicks, finishTimeNano, true);
|
||||
@@ -100,6 +106,7 @@ public class EntityRendererHandler extends EventRegistrations implements WorldRe
|
||||
} finally {
|
||||
mc.currentScreen = orgScreen;
|
||||
mc.options.pauseOnLostFocus = orgPauseOnLostFocus;
|
||||
gameRenderer.setRenderHand(orgRenderHand);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.replaymod.render.mixin;
|
||||
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(GameRenderer.class)
|
||||
public interface GameRendererAccessor {
|
||||
@Accessor
|
||||
boolean getRenderHand();
|
||||
@Accessor
|
||||
void setRenderHand(boolean value);
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.replaymod.render.mixin;
|
||||
|
||||
import com.replaymod.render.hooks.EntityRendererHandler;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(GameRenderer.class)
|
||||
public abstract class Mixin_Omnidirectional_SkipHand implements EntityRendererHandler.IEntityRenderer {
|
||||
@Inject(method = "renderHand", at = @At("HEAD"), cancellable = true)
|
||||
private void replayModRender_renderSpectatorHand(
|
||||
//#if MC>=11500
|
||||
MatrixStack matrixStack,
|
||||
//#endif
|
||||
//#if MC>=11400
|
||||
Camera camera,
|
||||
//#endif
|
||||
float partialTicks,
|
||||
//#if MC<11400
|
||||
//$$ int renderPass,
|
||||
//#endif
|
||||
CallbackInfo ci
|
||||
) {
|
||||
EntityRendererHandler handler = replayModRender_getHandler();
|
||||
if (handler != null && handler.omnidirectional) {
|
||||
// No spectator hands during 360° view, we wouldn't even know where to put it
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user