Skip to content

Commit

Permalink
Basic debug anticheat
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Dec 25, 2023
1 parent cc4d2be commit 8cfda32
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/main/java/net/coderbot/iris/Iris.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.glfw.GLFW;
Expand Down Expand Up @@ -249,11 +250,15 @@ public static void handleKeybinds(Minecraft minecraft) {
}
} else if (shaderpackScreenKeybind.consumeClick()) {
minecraft.setScreen(new ShaderPackScreen(null));
} else if (wireframeKeybind.consumeClick()) {
if (irisConfig.areDebugOptionsEnabled() && minecraft.player != null && !Minecraft.getInstance().isLocalServer()) {
minecraft.player.displayClientMessage(new TextComponent("No cheating; wireframe only in singleplayer!"), false);
}
}
}

public static boolean shouldActivateWireframe() {
return wireframeKeybind.isDown();
return irisConfig.areDebugOptionsEnabled() && wireframeKeybind.isDown();
}

public static void toggleShaders(Minecraft minecraft, boolean enabled) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class MixinGlStateManager_DepthColorOverride {
}
}

@Redirect(method = "_drawElements", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glDrawElements(IIIJ)V"))
@Redirect(method = "_drawElements", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glDrawElements(IIIJ)V"), remap = false)
private static void iris$modify(int mode, int count, int type, long indices) {
if (mode == GL43C.GL_TRIANGLES && ImmediateState.usingTessellation) {
mode = GL43C.GL_PATCHES;
Expand All @@ -37,7 +37,7 @@ public class MixinGlStateManager_DepthColorOverride {
GL43C.glDrawElements(mode, count, type, indices);
}

@Inject(method = "_glUseProgram", at = @At("TAIL"))
@Inject(method = "_glUseProgram", at = @At("TAIL"), remap = false)
private static void iris$resetTessellation(int pInt0, CallbackInfo ci) {
ImmediateState.usingTessellation = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import java.util.function.IntFunction;

@Mixin(GlProgram.class)
@Mixin(value = GlProgram.class, remap = false)
public class MixinGlProgram extends GlObject implements ShaderBindingContextExt {
public <U extends GlUniform<?>> U bindUniformIfPresent(String name, IntFunction<U> factory) {
int index = GlStateManager._glGetUniformLocation(this.handle(), name);
Expand Down

0 comments on commit 8cfda32

Please sign in to comment.