Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bugs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ patched 268420 client basic
patched 280220 client basic
patched 298225 client basic
patched 298558 client basic
patched 157252 client basic

patched 7569 server basic
patched 8187 server gameplay
Expand Down
1 change: 1 addition & 0 deletions PATCHED.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
| Basic | [MC-122627](https://mojira.dev/MC-122627) | Tab suggestion box has missing padding on right side | No |
| Basic | [MC-127970](https://mojira.dev/MC-127970) | Using Riptide on a trident with an item in your off-hand causes visual glitch with said item | No |
| Basic | [MC-143474](https://mojira.dev/MC-143474) | Respawning causes your hotbar to reset to the first space | No |
| Basic | [MC-157252](https://mojira.dev/MC-157252) | Crosshair is not centered on the screen | No |
| Gameplay | [MC-159163](https://mojira.dev/MC-159163) | Quickly pressing the sneak key causes the sneak animation to play twice | No |
| Basic | [MC-165306](https://mojira.dev/MC-165306) | Beacon beams are transparent from the inside | No |
| Basic | [MC-165381](https://mojira.dev/MC-165381) | Block breaking can be delayed by dropping/throwing the tool while breaking a block | No |
Expand Down
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ val modManifest = manifests.fabricModJson {
Ampflower's 2x2 Surrounded Saplings Fix - Code used licensed under Zlib
NoahvdAa's Thorium - Code used licensed under LGPLv3
Moulberry's MoulberryTweaks - Code used licensed under MIT
JustAlittleWolf's Centered Crosshair - Code used licensed under MIT
""".trimIndent()
}
authors.add("isXander")
Expand Down Expand Up @@ -168,6 +169,9 @@ tasks.withType<Jar>().configureEach {
from(rootProject.file("LICENSE")) {
into("META-INF")
}
from(rootProject.file("licenses/centered-crosshair-MIT.txt")) {
into("META-INF/licenses")
}
}

// Ensure sub-par javadoc doesn't fail the build
Expand Down
21 changes: 21 additions & 0 deletions licenses/centered-crosshair-MIT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2023 JustAlittleWolf

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (C) 2026 The Debugify Contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* Based on Centered Crosshair by JustAlittleWolf (MIT).
* https://github.com/JustAlittleWolf/centered-crosshair
*/
package dev.isxander.debugify.client.helpers.mc157252;

import com.mojang.renderpearl.api.pipeline.RenderPipeline;
import net.minecraft.resources.Identifier;

public interface DrawContextFloatDrawTexture {
default void debugify$blitSprite(RenderPipeline renderPipeline, Identifier location, float x, float y, int width, int height) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright (C) 2026 The Debugify Contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* Based on Centered Crosshair by JustAlittleWolf (MIT).
* https://github.com/JustAlittleWolf/centered-crosshair
*/
package dev.isxander.debugify.client.helpers.mc157252;

import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.renderpearl.api.pipeline.RenderPipeline;
import net.minecraft.client.gui.navigation.ScreenRectangle;
import net.minecraft.client.gui.render.TextureSetup;
import net.minecraft.client.renderer.state.gui.GuiElementRenderState;
import org.joml.Matrix3x2f;

public record SubpixelPositionedTexturedQuadGuiElementRenderState(
RenderPipeline pipeline,
TextureSetup textureSetup,
Matrix3x2f pose,
float x1,
float y1,
float x2,
float y2,
float u1,
float u2,
float v1,
float v2,
int color,
ScreenRectangle scissorArea,
ScreenRectangle bounds
) implements GuiElementRenderState {
public SubpixelPositionedTexturedQuadGuiElementRenderState(
RenderPipeline pipeline,
TextureSetup textureSetup,
Matrix3x2f pose,
float x1,
float y1,
float x2,
float y2,
float u1,
float u2,
float v1,
float v2,
int color,
ScreenRectangle scissorArea
) {
this(pipeline, textureSetup, pose, x1, y1, x2, y2, u1, u2, v1, v2, color, scissorArea,
createBounds(x1, y1, x2, y2, pose, scissorArea));
}

@Override
public void buildVertices(VertexConsumer vertices) {
vertices.addVertexWith2DPose(this.pose(), this.x1(), this.y1()).setUv(this.u1(), this.v1()).setColor(this.color());
vertices.addVertexWith2DPose(this.pose(), this.x1(), this.y2()).setUv(this.u1(), this.v2()).setColor(this.color());
vertices.addVertexWith2DPose(this.pose(), this.x2(), this.y2()).setUv(this.u2(), this.v2()).setColor(this.color());
vertices.addVertexWith2DPose(this.pose(), this.x2(), this.y1()).setUv(this.u2(), this.v1()).setColor(this.color());
}

private static ScreenRectangle createBounds(float x1, float y1, float x2, float y2, Matrix3x2f pose, ScreenRectangle scissorArea) {
ScreenRectangle screenRect = new ScreenRectangle(Math.round(x1), Math.round(y1), Math.round(x2 - x1), Math.round(y2 - y1))
.transformMaxBounds(pose);
return scissorArea != null ? scissorArea.intersection(screenRect) : screenRect;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Copyright (C) 2026 The Debugify Contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* Based on Centered Crosshair by JustAlittleWolf (MIT).
* https://github.com/JustAlittleWolf/centered-crosshair
*/
package dev.isxander.debugify.client.mixins.basic.mc157252;

import com.mojang.renderpearl.api.pipeline.RenderPipeline;
import dev.isxander.debugify.client.helpers.mc157252.DrawContextFloatDrawTexture;
import dev.isxander.debugify.client.helpers.mc157252.SubpixelPositionedTexturedQuadGuiElementRenderState;
import dev.isxander.debugify.fixes.BugFix;
import dev.isxander.debugify.fixes.FixCategory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.render.TextureSetup;
import net.minecraft.client.renderer.state.gui.GuiRenderState;
import net.minecraft.client.renderer.texture.AbstractTexture;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.resources.Identifier;
import org.joml.Matrix3x2f;
import org.joml.Matrix3x2fStack;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;

@BugFix(id = "MC-157252", category = FixCategory.BASIC, env = BugFix.Env.CLIENT,
description = "Center the crosshair on the exact screen center")
@Mixin(GuiGraphicsExtractor.class)
public abstract class GuiGraphicsExtractorMixin implements DrawContextFloatDrawTexture {
@Shadow
@Final
private TextureAtlas guiSprites;

@Shadow
@Final
private GuiRenderState guiRenderState;

@Shadow
@Final
private Minecraft minecraft;

@Shadow
@Final
private Matrix3x2fStack pose;

@Shadow
@Final
private GuiGraphicsExtractor.ScissorStack scissorStack;

@Override
@Unique
public void debugify$blitSprite(RenderPipeline renderPipeline, Identifier location, float x, float y, int width, int height) {
if (width == 0 || height == 0) return;

TextureAtlasSprite sprite = this.guiSprites.getSprite(location);
this.debugify$blitSprite(
renderPipeline,
sprite.atlasLocation(),
x,
x + width,
y,
y + height,
sprite.getU0() + (1 / 32768f),
sprite.getU1() + (1 / 32768f),
sprite.getV0() - (1 / 32768f),
sprite.getV1() - (1 / 32768f),
-1
);
}

@Unique
private void debugify$blitSprite(RenderPipeline renderPipeline, Identifier location,
float x1, float x2, float y1, float y2,
float u1, float u2, float v1, float v2, int color) {
AbstractTexture texture = this.minecraft.getTextureManager().getTexture(location);
this.guiRenderState.addGuiElement(new SubpixelPositionedTexturedQuadGuiElementRenderState(
renderPipeline,
TextureSetup.singleTexture(texture.getTextureView(), texture.getSampler()),
new Matrix3x2f(this.pose),
x1, y1, x2, y2,
u1, u2, v1, v2,
color,
this.scissorStack.peek()
));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (C) 2026 The Debugify Contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* Based on Centered Crosshair by JustAlittleWolf (MIT).
* https://github.com/JustAlittleWolf/centered-crosshair
*/
package dev.isxander.debugify.client.mixins.basic.mc157252;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mojang.renderpearl.api.pipeline.RenderPipeline;
import dev.isxander.debugify.client.helpers.mc157252.DrawContextFloatDrawTexture;
import dev.isxander.debugify.fixes.BugFix;
import dev.isxander.debugify.fixes.FixCategory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.Hud;
import net.minecraft.resources.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@BugFix(id = "MC-157252", category = FixCategory.BASIC, env = BugFix.Env.CLIENT,
description = "Center the crosshair on the exact screen center")
@Mixin(Hud.class)
public abstract class HudMixin {
@WrapOperation(
method = "extractCrosshair",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/GuiGraphicsExtractor;blitSprite(Lcom/mojang/renderpearl/api/pipeline/RenderPipeline;Lnet/minecraft/resources/Identifier;IIII)V",
ordinal = 0
)
)
private void debugify$centerCrosshair(GuiGraphicsExtractor instance, RenderPipeline renderPipeline,
Identifier location, int x, int y, int width, int height,
Operation<Void> original) {
float scaleFactor = (float) Minecraft.getInstance().getWindow().getGuiScale();
float scaledCenterX = (Minecraft.getInstance().getWindow().getWidth() / scaleFactor) / 2f;
float scaledCenterY = (Minecraft.getInstance().getWindow().getHeight() / scaleFactor) / 2f;

((DrawContextFloatDrawTexture) instance).debugify$blitSprite(
renderPipeline,
location,
Math.round((scaledCenterX - 7.5f) * 4) / 4f,
Math.round((scaledCenterY - 7.5f) * 4) / 4f,
15,
15
);
}
}
4 changes: 3 additions & 1 deletion src/client/resources/debugify.client.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
"basic.mc80859.AbstractContainerScreenMixin",
"basic.mc90683.ClientPacketListenerMixin",
"basic.mc93384.LivingEntityMixin",
"gameplay.mc159163.ClientPacketListenerMixin"
"gameplay.mc159163.ClientPacketListenerMixin",
"basic.mc157252.GuiGraphicsExtractorMixin",
"basic.mc157252.HudMixin"
],
"mixins": [
"basic.mc118740.PlayerMixin",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/debugify.ct
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ accessible class net/minecraft/client/gui/screens/telemetry/TelemetryEventWidget
accessible class net/minecraft/client/gui/screens/telemetry/TelemetryEventWidget$Content
accessible class net/minecraft/client/gui/screens/achievement/StatsScreen$ItemStatisticsList
accessible class net/minecraft/server/MinecraftServer$ReloadableResources
accessible class net/minecraft/client/gui/GuiGraphicsExtractor$ScissorStack