Fix lack of hand when spectating player in replay on 1.13+

This commit is contained in:
Jonas Herzig
2019-05-25 19:35:17 +02:00
parent cfdc4b9713
commit e7d96fca2a
3 changed files with 40 additions and 1 deletions

View File

@@ -0,0 +1,36 @@
//#if MC>=11300
package com.replaymod.replay.mixin;
import com.replaymod.replay.camera.CameraEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerInteractionManager;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.world.GameMode;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(GameRenderer.class)
public abstract class MixinGameRenderer {
@Accessor
abstract MinecraftClient getClient();
@Redirect(
method = "renderHand",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;getCurrentGameMode()Lnet/minecraft/world/GameMode;"
)
)
private GameMode getGameMode(ClientPlayerInteractionManager interactionManager) {
ClientPlayerEntity camera = getClient().player;
if (camera instanceof CameraEntity) {
// alternative doesn't really matter, the caller only checks for equality to SPECTATOR
return camera.isSpectator() ? GameMode.SPECTATOR : GameMode.SURVIVAL;
}
return interactionManager.getCurrentGameMode();
}
}
//#endif

View File

@@ -9,7 +9,9 @@
"MixinInGameHud", "MixinInGameHud",
//#endif //#endif
"EntityLivingBaseAccessor", "EntityLivingBaseAccessor",
//#if MC<11300 //#if MC>=11300
"MixinGameRenderer",
//#else
//$$ "EntityOtherPlayerMPAccessor", //$$ "EntityOtherPlayerMPAccessor",
//#endif //#endif
"EntityPlayerAccessor", "EntityPlayerAccessor",

View File

@@ -85,6 +85,7 @@ net.minecraft.client.network.ClientPlayerInteractionManager net.minecraft.client
net.minecraft.client.network.ClientPlayerInteractionManager client mc net.minecraft.client.network.ClientPlayerInteractionManager client mc
net.minecraft.client.network.ClientPlayerInteractionManager networkHandler connection net.minecraft.client.network.ClientPlayerInteractionManager networkHandler connection
net.minecraft.client.network.ClientPlayerInteractionManager isFlyingLocked() isSpectatorMode() net.minecraft.client.network.ClientPlayerInteractionManager isFlyingLocked() isSpectatorMode()
net.minecraft.client.network.ClientPlayerInteractionManager getCurrentGameMode() getCurrentGameType()
com.mojang.blaze3d.platform.GLX net.minecraft.client.renderer.OpenGlHelper com.mojang.blaze3d.platform.GLX net.minecraft.client.renderer.OpenGlHelper
com.mojang.blaze3d.platform.GLX isUsingFBOs() isFramebufferEnabled() com.mojang.blaze3d.platform.GLX isUsingFBOs() isFramebufferEnabled()
net.minecraft.entity.data.TrackedData net.minecraft.network.datasync.DataParameter net.minecraft.entity.data.TrackedData net.minecraft.network.datasync.DataParameter