diff --git a/src/main/java/me/zeroeightsix/kami/mixin/client/gui/MixinGuiIngameForge.java b/src/main/java/me/zeroeightsix/kami/mixin/client/gui/MixinGuiIngameForge.java new file mode 100644 index 000000000..2ab8a1635 --- /dev/null +++ b/src/main/java/me/zeroeightsix/kami/mixin/client/gui/MixinGuiIngameForge.java @@ -0,0 +1,42 @@ +package me.zeroeightsix.kami.mixin.client.gui; + +import me.zeroeightsix.kami.module.modules.player.Freecam; +import me.zeroeightsix.kami.util.Wrapper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.client.GuiIngameForge; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + +@Mixin(value = GuiIngameForge.class, remap = false) +public class MixinGuiIngameForge { + @ModifyVariable(method = "renderAir", at = @At(value = "STORE", ordinal = 0)) + private EntityPlayer renderAir$getRenderViewEntity(EntityPlayer renderViewEntity) { + return gerRenderViewEntity(renderViewEntity); + } + + @ModifyVariable(method = "renderHealth", at = @At(value = "STORE", ordinal = 0)) + private EntityPlayer renderHealth$getRenderViewEntity(EntityPlayer renderViewEntity) { + return gerRenderViewEntity(renderViewEntity); + } + + @ModifyVariable(method = "renderFood", at = @At(value = "STORE", ordinal = 0)) + private EntityPlayer renderFood$getRenderViewEntity(EntityPlayer renderViewEntity) { + return gerRenderViewEntity(renderViewEntity); + } + + @ModifyVariable(method = "renderHealthMount", at = @At(value = "STORE", ordinal = 0)) + private EntityPlayer renderHealthMount$getRenderViewEntity(EntityPlayer renderViewEntity) { + return gerRenderViewEntity(renderViewEntity); + } + + private EntityPlayer gerRenderViewEntity(EntityPlayer renderViewEntity) { + EntityPlayer player = Wrapper.getPlayer(); + + if (Freecam.INSTANCE.isEnabled() && player != null) { + return player; + } else { + return renderViewEntity; + } + } +} diff --git a/src/main/resources/mixins.kami.json b/src/main/resources/mixins.kami.json index 240476a29..8be7922cd 100644 --- a/src/main/resources/mixins.kami.json +++ b/src/main/resources/mixins.kami.json @@ -34,6 +34,7 @@ "entity.MixinEntityPig", "gui.MixinGuiChat", "gui.MixinGuiContainer", + "gui.MixinGuiIngameForge", "gui.MixinGuiIngameMenu", "gui.MixinGuiInventory", "gui.MixinGuiNewChat",