Skip to content

Commit

Permalink
Fix mixins
Browse files Browse the repository at this point in the history
  • Loading branch information
connorslade committed Jun 28, 2024
1 parent 749aba8 commit 84f7fdc
Show file tree
Hide file tree
Showing 11 changed files with 319 additions and 279 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,43 @@
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.LightmapTextureManager;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.render.RenderTickCounter;
import org.joml.Matrix4f;

public class WorldRender {
public static class PostWorldRenderEvent extends WorldRenderEvent {
public PostWorldRenderEvent(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer,
LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix) {
super(matrices, tickDelta, limitTime, renderBlockOutline, camera, gameRenderer, lightmapTextureManager, positionMatrix);
public PostWorldRenderEvent(RenderTickCounter renderTickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, Matrix4f projectionMatrix) {
super(renderTickCounter, renderBlockOutline, camera, gameRenderer, lightmapTextureManager, positionMatrix, projectionMatrix);
}
}

public static class PreWorldRenderEvent extends WorldRenderEvent {
public PreWorldRenderEvent(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer,
LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix) {
super(matrices, tickDelta, limitTime, renderBlockOutline, camera, gameRenderer, lightmapTextureManager, positionMatrix);
public PreWorldRenderEvent(RenderTickCounter renderTickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, Matrix4f projectionMatrix) {
super(renderTickCounter, renderBlockOutline, camera, gameRenderer, lightmapTextureManager, positionMatrix, projectionMatrix);
}
}

public static abstract class WorldRenderEvent extends Cancellable {
MatrixStack matrices;
float tickDelta;
long limitTime;
RenderTickCounter renderTickCounter;
boolean renderBlockOutline;
Camera camera;
GameRenderer gameRenderer;
LightmapTextureManager lightmapTextureManager;
Matrix4f positionMatrix;
Matrix4f projectionMatrix;

public WorldRenderEvent(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer,
LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix) {
this.matrices = matrices;
this.tickDelta = tickDelta;
this.limitTime = limitTime;
public WorldRenderEvent(RenderTickCounter renderTickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, Matrix4f projectionMatrix) {
this.renderTickCounter = renderTickCounter;
this.renderBlockOutline = renderBlockOutline;
this.camera = camera;
this.gameRenderer = gameRenderer;
this.lightmapTextureManager = lightmapTextureManager;
this.positionMatrix = positionMatrix;
this.projectionMatrix = projectionMatrix;
}

public MatrixStack getMatrices() {
return matrices;
}

public float getTickDelta() {
return tickDelta;
}

public long getLimitTime() {
return limitTime;
public RenderTickCounter getRenderTickCounter() {
return renderTickCounter;
}

public boolean isRenderBlockOutline() {
Expand All @@ -75,5 +62,9 @@ public LightmapTextureManager getLightmapTextureManager() {
public Matrix4f getPositionMatrix() {
return positionMatrix;
}

public Matrix4f getProjectionMatrix() {
return projectionMatrix;
}
}
}
31 changes: 18 additions & 13 deletions src/main/java/com/connorcode/sigmautils/mixin/CameraMixin.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
package com.connorcode.sigmautils.mixin;

import com.connorcode.sigmautils.config.Config;
import com.connorcode.sigmautils.modules.misc.CameraClip;
import com.connorcode.sigmautils.modules.misc.CameraDistance;
import net.minecraft.client.render.Camera;
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.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(Camera.class)
public class CameraMixin {
// @ModifyVariable(method = "clipToSpace", at = @At("HEAD"), argsOnly = true)
// double clipToSpace(double desiredCameraDistance) {
// if (!Config.getEnabled(CameraDistance.class))
// return desiredCameraDistance;
// return CameraDistance.getDistance();
// }
//
// @Inject(method = "clipToSpace", at = @At("HEAD"), cancellable = true)
// void onClipToSpace(double desiredCameraDistance, CallbackInfoReturnable<Double> cir) {
// if (!Config.getEnabled(CameraClip.class))
// return;
// cir.setReturnValue(desiredCameraDistance);
// }
@ModifyVariable(method = "clipToSpace", at = @At("HEAD"), argsOnly = true)
float clipToSpace(float desiredCameraDistance) {
if (!Config.getEnabled(CameraDistance.class)) return desiredCameraDistance;
return CameraDistance.getDistance();
}

@Inject(method = "clipToSpace", at = @At("HEAD"), cancellable = true)
void onClipToSpace(float desiredCameraDistance, CallbackInfoReturnable<Float> cir) {
if (!Config.getEnabled(CameraClip.class)) return;
cir.setReturnValue(desiredCameraDistance);
}
}
31 changes: 17 additions & 14 deletions src/main/java/com/connorcode/sigmautils/mixin/ChatHudMixin.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
package com.connorcode.sigmautils.mixin;

import com.connorcode.sigmautils.config.Config;
import com.connorcode.sigmautils.modules._interface.NoChatFade;
import com.connorcode.sigmautils.modules.chat.NoMessageHiding;
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.network.message.MessageSignatureData;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ChatHud.class)
public abstract class ChatHudMixin {
@Shadow
protected abstract boolean isChatFocused();
@ModifyVariable(method = "render", at = @At("HEAD"), argsOnly = true)
boolean isFocused(boolean focused) {
if (Config.getEnabled(NoChatFade.class)) return true;
return focused;
}

// @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;isChatFocused()Z"))
// boolean isChatFocused(ChatHud instance) {
// if (Config.getEnabled(NoChatFade.class))
// return true;
// return isChatFocused();
// }
//
// @Inject(method = "removeMessage", at = @At("HEAD"), cancellable = true)
// void onHideMessage(MessageSignatureData signature, CallbackInfo ci) {
// if (Config.getEnabled(NoMessageHiding.class)) ci.cancel();
// }
@Inject(method = "removeMessage", at = @At("HEAD"), cancellable = true)
void onHideMessage(MessageSignatureData signature, CallbackInfo ci) {
if (Config.getEnabled(NoMessageHiding.class)) ci.cancel();
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
package com.connorcode.sigmautils.mixin;

import com.connorcode.sigmautils.config.Config;
import com.connorcode.sigmautils.modules.rendering.Deadmau5Ears;
import com.connorcode.sigmautils.modules.rendering.Titles;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import net.minecraft.entity.passive.AbstractHorseEntity;
import net.minecraft.entity.passive.TameableEntity;
import net.minecraft.text.Text;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(EntityRenderer.class)
public class EntityRendererMixin<T extends Entity> {
// TODO: fix
// @Redirect(method = "renderLabelIfPresent", at = @At(value = "INVOKE", target = "Ljava/lang/String;equals(Ljava/lang/Object;)Z"))
// private boolean isDeadmau5(String stringA, Object stringB) {
// if (Config.getEnabled(Deadmau5Ears.class))
// return true;
// return stringA.equals(stringB);
// }
//
// @Inject(method = "renderLabelIfPresent", at = @At("HEAD"), cancellable = true)
// private void renderLabelIfPresent(T entity, Text text, MatrixStack matrices, VertexConsumerProvider vertexConsumers,
// int light, CallbackInfo ci) {
// if (Titles.tamableOwner.value() && (entity instanceof TameableEntity || entity instanceof AbstractHorseEntity))
// ci.cancel();
// }
@Redirect(method = "renderLabelIfPresent", at = @At(value = "INVOKE", target = "Ljava/lang/String;equals(Ljava/lang/Object;)Z"))
private boolean isDeadmau5(String stringA, Object stringB) {
if (Config.getEnabled(Deadmau5Ears.class)) return true;
return stringA.equals(stringB);
}

@Inject(method = "renderLabelIfPresent", at = @At("HEAD"), cancellable = true)
private void renderLabelIfPresent(T entity, Text text, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, float tickDelta, CallbackInfo ci) {
if (Titles.tamableOwner.value() && (entity instanceof TameableEntity || entity instanceof AbstractHorseEntity))
ci.cancel();
}
}
Loading

0 comments on commit 84f7fdc

Please sign in to comment.