Skip to content

Commit 82598c8

Browse files
committed
1.21.9
1 parent 486b802 commit 82598c8

16 files changed

+184
-90
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dependencies {
3434
if (loader == "fabric") {
3535
modImplementation("net.fabricmc:fabric-loader:${mod.dep("fabric_loader")}")
3636
mappings("net.fabricmc:yarn:$minecraft+build.${mod.dep("yarn_build")}:v2")
37-
modImplementation("com.terraformersmc:modmenu:${mod.dep("modmenu_version")}")
37+
modCompileOnly("com.terraformersmc:modmenu:${mod.dep("modmenu_version")}")
3838

3939
//some features (like automatic resource loading from non vanilla namespaces) work only with fabric API installed
4040
//for example translations from assets/modid/lang/en_us.json won't be working, same stuff with textures

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mod.mc_targets=[VERSIONED]
2222

2323
# Mod setup
2424
deps.mixin_extras=0.4.1
25-
deps.fabric_loader=0.16.13
25+
deps.fabric_loader=0.17.0
2626
deps.fabric_version=[VERSIONED]
2727

2828
deps.forge_loader=[VERSIONED]

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ stonecutter {
2121
fun mc(loader: String, vararg versions: String) {
2222
for (version in versions) vers("$version-$loader", version)
2323
}
24-
mc("fabric","1.20.1","1.20.4", "1.21.1", "1.21.3", "1.21.4","1.21.5", "1.21.6","1.21.7" )
24+
mc("fabric","1.20.1","1.20.4", "1.21.1", "1.21.3", "1.21.4","1.21.5", "1.21.6","1.21.7","1.21.9-rc1" )
2525
mc("forge","1.20.1",)
2626
mc("neoforge", "1.20.4", "1.21.1", "1.21.3", "1.21.4","1.21.5", "1.21.6","1.21.7")
2727
}

src/main/java/io/github/jumperonjava/customcursor/CursorEditScreen.java

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import com.mojang.blaze3d.systems.RenderSystem;
44
import io.github.jumperonjava.customcursor.util.*;
55
//? if >= 1.21.6
6-
/*import net.minecraft.client.gl.RenderPipelines;*/
6+
import net.minecraft.client.gl.RenderPipelines;
77
import net.minecraft.client.gui.DrawContext;
8+
import net.minecraft.client.gui.cursor.Cursor;
9+
import net.minecraft.client.gui.cursor.StandardCursors;
810
import net.minecraft.client.gui.screen.Screen;
911
import net.minecraft.client.gui.widget.ButtonWidget;
1012
import net.minecraft.client.gui.widget.TextFieldWidget;
@@ -19,6 +21,7 @@
1921
public class CursorEditScreen extends Screen {
2022
private final Consumer<CursorSettings> onSuccess;
2123
private final CursorSettings targetConfig;
24+
private final CursorSettings.CursorSprite targetCursor;
2225
private final Screen parent;
2326

2427
public CursorEditScreen(Screen parent, CursorSettings cursorConfig, Consumer<CursorSettings> onSuccess) {
@@ -103,15 +106,15 @@ protected void init() {
103106
var maxsize = 256.;
104107
var imagePathField = new TextFieldWidget(client.textRenderer, columns[0], rows[4], twoColumnSizePadding, rowSizePadding, Text.empty());
105108
var sizeSlider = new SliderWidget(columns[0], rows[1], twoColumnSizePadding, rowSizePadding, Text.translatable("customcursor.edit.size"), this.targetConfig.size,0, maxsize, 256);
106-
var xPosSlider = new SliderWidget(columns[0], rows[2], columnSizePadding, rowSizePadding, Text.translatable("customcursor.edit.x"), this.targetConfig.x,0., 1., 64);
107-
var yPosSlider = new SliderWidget(columns[1], rows[2], columnSizePadding, rowSizePadding, Text.translatable("customcursor.edit.y"), this.targetConfig.y,0., 1., 64);
109+
var xPosSlider = new SliderWidget(columns[0], rows[2], columnSizePadding, rowSizePadding, Text.translatable("customcursor.edit.x"), this.targetCursor.x,0., 1., 64);
110+
var yPosSlider = new SliderWidget(columns[1], rows[2], columnSizePadding, rowSizePadding, Text.translatable("customcursor.edit.y"), this.targetCursor.y,0., 1., 64);
108111

109-
xPosSlider.setChangedListener(d -> this.targetConfig.x = (float) (double) d);
110-
yPosSlider.setChangedListener(d -> this.targetConfig.y = (float) (double) d);
112+
xPosSlider.setChangedListener(d -> this.targetCursor.x = (float) (double) d);
113+
yPosSlider.setChangedListener(d -> this.targetCursor.y = (float) (double) d);
111114
sizeSlider.setChangedListener(d -> this.targetConfig.size = (int) (double) d);
112115

113116
imagePathField.setMaxLength(512);
114-
imagePathField.setText(this.targetConfig.identifier.toString());
117+
imagePathField.setText(this.targetCursor.identifier.toString());
115118
imagePathField.setChangedListener((s) -> {
116119
try {
117120
setIdentifier(Identifier.tryParse(s));
@@ -130,10 +133,16 @@ protected void init() {
130133
addDrawableChild(yPosSlider);
131134
addDrawable(this::renderCheckerboard);
132135
addDrawable(this::renderPreview);
136+
addDrawable(this::testcursor);
137+
}
138+
139+
float time = 0;
140+
private void testcursor(DrawContext context, int mouseX, int mouseY, float delta) {
141+
context.setCursor(StandardCursors.CROSSHAIR);
133142
}
134143

135144
private void setIdentifier(Identifier identifier) {
136-
this.targetConfig.identifier = identifier;
145+
this.targetCursor.identifier = identifier;
137146
}
138147

139148
private void confirm(ButtonWidget buttonWidget) {
@@ -147,21 +156,20 @@ private void confirm(ButtonWidget buttonWidget) {
147156

148157

149158
//? if <= 1.20.1 {
150-
@Override
159+
/*@Override
151160
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
152161
renderBackground(context);
153162
super.render(context, mouseX, mouseY, delta);
154163
}
155-
//?}
164+
*///?}
156165

157166
private void renderPreview(DrawContext context, int mouseX, int mouseY, float delta){
158-
159-
VersionFunctions.drawTexture(context, this.targetConfig.identifier, previewPosX, previewPosY, 0, 0, previewSize, previewSize, previewSize, previewSize);
167+
VersionFunctions.drawTexture(context, this.targetCursor.identifier, previewPosX, previewPosY, 0, 0, previewSize, previewSize, previewSize, previewSize);
160168
VersionFunctions.drawTexture(
161169
context,
162170
Identifier.of("customcursor", "textures/gui/pointer.png"),
163-
(int) (previewPosX + this.targetConfig.x * previewSize) - 4,
164-
(int) (previewPosY + this.targetConfig.y * previewSize) - 4,
171+
(int) (previewPosX + this.targetCursor.x * previewSize) - 4,
172+
(int) (previewPosY + this.targetCursor.y * previewSize) - 4,
165173
0, 0,
166174
8, 8,
167175
8, 8);
@@ -203,7 +211,7 @@ private void renderCheckerboard(DrawContext context, int mouseX, int mouseY, flo
203211

204212
//? if < 1.21.6 {
205213

206-
context.getMatrices().push();
214+
/*context.getMatrices().push();
207215
context.getMatrices().translate(
208216
(previewPosX + MathHelper.floorMod(bgx, cellsize) - cellsize),
209217
(previewPosY + MathHelper.floorMod(bgy, cellsize) - cellsize),
@@ -220,10 +228,10 @@ private void renderCheckerboard(DrawContext context, int mouseX, int mouseY, flo
220228
221229
context.getMatrices().pop();
222230
context.disableScissor();
223-
//?} else {
231+
*///?} else {
224232

225233

226-
/*context.getMatrices().pushMatrix();
234+
context.getMatrices().pushMatrix();
227235
context.getMatrices().translate(
228236
(previewPosX + MathHelper.floorMod(bgx, cellsize) - cellsize),
229237
(previewPosY + MathHelper.floorMod(bgy, cellsize) - cellsize));
@@ -242,7 +250,7 @@ private void renderCheckerboard(DrawContext context, int mouseX, int mouseY, flo
242250
context.getMatrices().popMatrix();
243251
context.disableScissor();
244252

245-
*///?}
253+
//?}
246254
}
247255

248256
public static CursorEditScreen createCursorEditScreen(Screen parent) {

src/main/java/io/github/jumperonjava/customcursor/CursorRenderer.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import net.minecraft.client.MinecraftClient;
44
//? if >= 1.21.6 {
5-
/*import net.minecraft.client.gl.RenderPipelines;
6-
*///?} else {
7-
import com.mojang.blaze3d.systems.RenderSystem;
8-
//?}
5+
import net.minecraft.client.gl.RenderPipelines;
6+
//?} else {
7+
/*import com.mojang.blaze3d.systems.RenderSystem;
8+
*///?}
99
import net.minecraft.client.gui.DrawContext;
1010
import net.minecraft.client.render.RenderLayer;
1111
import org.lwjgl.glfw.GLFW;
@@ -22,7 +22,7 @@ public static void render(DrawContext context, int mouseX, int mouseY, float don
2222
}
2323
var scale = MinecraftClient.getInstance().getWindow().getScaleFactor();
2424
//? if < 1.21.5
25-
RenderSystem.depthFunc(GL11.GL_ALWAYS);
25+
/*RenderSystem.depthFunc(GL11.GL_ALWAYS);*/
2626
var identifier = config.identifier;
2727
var x = (int) Math.round(mouseX - config.size * config.x / scale);
2828
var y = (int) Math.round(mouseY - config.size * config.y / scale);
@@ -33,15 +33,15 @@ public static void render(DrawContext context, int mouseX, int mouseY, float don
3333
var textureWidth = (int) (config.size / scale);
3434
var textureHeight = (int) (config.size / scale);
3535
//? if < 1.21.3 {
36-
context.drawTexture(identifier,x,y,u,v,width,height,textureWidth,textureHeight);
37-
//?} else if < 1.21.6 {
36+
/*context.drawTexture(identifier,x,y,u,v,width,height,textureWidth,textureHeight);
37+
*///?} else if < 1.21.6 {
3838
/*context.drawTexture(RenderLayer::getGuiTexturedOverlay, identifier, x, y, u, v, width, height, textureWidth, textureHeight);
3939
*///?} else {
40-
/*context.drawTexture(RenderPipelines.GUI_TEXTURED, identifier, x, y, u, v, width, height, textureWidth, textureHeight);
40+
context.drawTexture(RenderPipelines.GUI_TEXTURED, identifier, x, y, u, v, width, height, textureWidth, textureHeight);
4141

42-
*///?}
42+
//?}
4343
//? if < 1.21.5
44-
RenderSystem.depthFunc(GL11.GL_LEQUAL);
44+
/*RenderSystem.depthFunc(GL11.GL_LEQUAL);*/
4545

4646
//for debugging
4747
//context.drawTexture(new Identifier("customcursor","textures/gui/pointer.png"), (int) (mouseX-4), (int) (mouseY-4),0,0,8,8,8,8);

src/main/java/io/github/jumperonjava/customcursor/CursorSettings.java

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,71 @@
22

33

44
import com.google.gson.Gson;
5+
import net.minecraft.client.gui.cursor.Cursor;
6+
import net.minecraft.client.gui.cursor.StandardCursors;
57
import net.minecraft.util.Identifier;
68

9+
import java.util.Objects;
10+
711
public class CursorSettings implements Cloneable{
8-
public float x=1f;
9-
public float y;
1012
public int size=32;
1113
public boolean enabled=false;
12-
public Identifier identifier = PLACEHOLDER_CURSOR;
13-
public final static Identifier PLACEHOLDER_CURSOR = Identifier.of("minecraft","textures/item/diamond_sword.png");
14+
15+
CursorSprite pointer = new CursorSprite(1,9, 0, false,Identifier.ofVanilla("textures/item/diamond_sword.png"));
16+
CursorSprite arrow = new CursorSprite(0,0, 0, false,Identifier.ofVanilla("textures/item/arrow.png"));
17+
CursorSprite ibeam = new CursorSprite(0,0, 0, false,Identifier.ofVanilla("textures/item/ink_sac.png"));
18+
CursorSprite crosshair = new CursorSprite(0,0, 0, false,Identifier.ofVanilla("textures/item/lead.png"));
19+
CursorSprite pointing_hand = new CursorSprite(0,0, 0, false,Identifier.ofVanilla("textures/item/rabbit_foot.png"));
20+
CursorSprite resize_ns = new CursorSprite(0,0, 0, false,Identifier.ofVanilla("textures/item/golden_hoe.png"));
21+
CursorSprite resize_ew = new CursorSprite(0,0, 0, false,Identifier.ofVanilla("textures/item/copper_hoe.png"));
22+
CursorSprite resize_all = new CursorSprite(0,0, 0, false,Identifier.ofVanilla("textures/item/nether_star.png"));
23+
CursorSprite not_allowed = new CursorSprite(0,0, 0, false,Identifier.ofVanilla("textures/item/barrier.png"));
1424

1525
public CursorSettings clone() {
1626
return new Gson().fromJson(new Gson().toJson(this), CursorSettings.class);
1727
}
28+
29+
public static final class CursorSprite {
30+
public float x;
31+
public float y;
32+
public float rotation;
33+
public boolean mirror;
34+
public Identifier identifier;
35+
36+
public CursorSprite(float x, float y, float rotation, boolean mirror, Identifier identifier) {
37+
this.x = x;
38+
this.y = y;
39+
this.rotation = rotation;
40+
this.mirror = mirror;
41+
this.identifier = identifier;
42+
}
43+
@Override
44+
public boolean equals(Object obj) {
45+
if (obj == this) return true;
46+
if (obj == null || obj.getClass() != this.getClass()) return false;
47+
var that = (CursorSprite) obj;
48+
return Float.floatToIntBits(this.x) == Float.floatToIntBits(that.x) &&
49+
Float.floatToIntBits(this.y) == Float.floatToIntBits(that.y) &&
50+
Float.floatToIntBits(this.rotation) == Float.floatToIntBits(that.rotation) &&
51+
this.mirror == that.mirror &&
52+
Objects.equals(this.identifier, that.identifier);
53+
}
54+
55+
@Override
56+
public int hashCode() {
57+
return Objects.hash(x, y, rotation, mirror, identifier);
58+
}
59+
60+
@Override
61+
public String toString() {
62+
return "CursorSprite[" +
63+
"x=" + x + ", " +
64+
"y=" + y + ", " +
65+
"rotation=" + rotation + ", " +
66+
"mirror=" + mirror + ", " +
67+
"identifier=" + identifier + ']';
68+
}
69+
70+
}
71+
1872
}

src/main/java/io/github/jumperonjava/customcursor/mixin/CobblemonFix.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ public class CobblemonFix {
2121

2222
@Inject(method = "render", at = @At("HEAD"))
2323
//? if < 1.21 {
24-
void lock(DrawContext context, float tickDelta, CallbackInfo ci){
25-
//?} else {
26-
/*void lock(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) {
27-
*///?}
24+
/*void lock(DrawContext context, float tickDelta, CallbackInfo ci){
25+
*///?} else {
26+
void lock(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) {
27+
//?}
2828
if (client.currentScreen == null) {
2929
if (locked)
3030
return;
3131
client.mouse.lockCursor();
3232
locked = true;
3333
var x = (double) (this.client.getWindow().getWidth() / 2);
3434
var y = (double) (this.client.getWindow().getHeight() / 2);
35-
InputUtil.setCursorParameters(this.client.getWindow().getHandle(), 212995, x, y);
35+
InputUtil.setCursorParameters(this.client.getWindow(), 212995, x, y);
3636
} else {
3737
locked = false;
3838
}

src/main/java/io/github/jumperonjava/customcursor/mixin/GameRendererMixin.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ public class GameRendererMixin {
2828

2929

3030
//? if = 1.20.1 {
31-
@Inject(method = "render",at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;push(Ljava/lang/String;)V",ordinal = 1),locals = LocalCapture.CAPTURE_FAILHARD)
31+
/*@Inject(method = "render",at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;push(Ljava/lang/String;)V",ordinal = 1),locals = LocalCapture.CAPTURE_FAILHARD)
3232
void renderCursor(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int i, int j, Window window, Matrix4f matrix4f, MatrixStack matrixStack, DrawContext drawContext){
3333
CursorRenderer.render(drawContext,i,j,tickDelta);
3434
}
35-
//?} elif = 1.20.4 {
35+
*///?} elif = 1.20.4 {
3636
/*@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;draw()V", shift = At.Shift.BEFORE))
3737
void renderCursor(float tickDelta, long startTime, boolean tick, CallbackInfo ci, @Local(ordinal = 0) int i, @Local(ordinal = 1) int j, @Local DrawContext drawContext){
3838
CursorRenderer.render(drawContext,i,j,tickDelta);
@@ -50,17 +50,17 @@ void renderCursor(RenderTickCounter tickCounter, boolean tick, CallbackInfo ci,
5050
}
5151
*///?} else {
5252

53-
/*//? if fabric {
53+
//? if fabric {
5454
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;renderWithTooltip(Lnet/minecraft/client/gui/DrawContext;IIF)V", shift = At.Shift.AFTER))
5555
void renderCursor(RenderTickCounter tickCounter, boolean tick, CallbackInfo ci, @Local(ordinal = 0) int i, @Local(ordinal = 1) int j, @Local DrawContext drawContext){
5656
CursorRenderer.render(drawContext,i,j,0);
5757
}
5858
//?} else if neoforge {
59-
/^@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/neoforged/neoforge/client/ClientHooks;drawScreen(Lnet/minecraft/client/gui/screen/Screen;Lnet/minecraft/client/gui/DrawContext;IIF)V", shift = At.Shift.AFTER))
59+
/*@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/neoforged/neoforge/client/ClientHooks;drawScreen(Lnet/minecraft/client/gui/screen/Screen;Lnet/minecraft/client/gui/DrawContext;IIF)V", shift = At.Shift.AFTER))
6060
void renderCursor(RenderTickCounter tickCounter, boolean tick, CallbackInfo ci, @Local(ordinal = 0) int i, @Local(ordinal = 1) int j, @Local DrawContext drawContext){
6161
CursorRenderer.render(drawContext,i,j,0);
6262
}
63-
^///?}
64-
6563
*///?}
64+
65+
//?}
6666
}

src/main/java/io/github/jumperonjava/customcursor/mixin/MouseOptionsScreenMixin.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected MouseOptionsScreenMixin() {
2727
}
2828

2929
//? if < 1.21 {
30-
@Inject(method = "init",at = @At("HEAD"),locals = LocalCapture.CAPTURE_FAILHARD)
30+
/*@Inject(method = "init",at = @At("HEAD"),locals = LocalCapture.CAPTURE_FAILHARD)
3131
void inject(CallbackInfo ci){
3232
int k = this.height / 6 - 12 + 24 * 3;
3333
var cursorEditScreenButton = new ButtonWidget.Builder(Text.translatable("customcursor.openbutton"),(buttonWidget)->{
@@ -52,8 +52,8 @@ void inject(CallbackInfo ci){
5252
int injected(int k){
5353
return k+24;
5454
}
55-
//?} else {
56-
/*@Inject(method = "addOptions", at = @At("TAIL"))
55+
*///?} else {
56+
@Inject(method = "addOptions", at = @At("TAIL"))
5757
public void addOptions(CallbackInfo ci) {
5858
this.body.addWidgetEntry
5959
(
@@ -63,5 +63,5 @@ public void addOptions(CallbackInfo ci) {
6363
(buttonWidget) -> client.setScreen(CursorEditScreen.createCursorEditScreen(this))).dimensions(0,0,0,0).build()
6464
);
6565
}
66-
*///?}
66+
//?}
6767
}

src/main/java/io/github/jumperonjava/customcursor/util/FolderTextureAskList.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ private void refreshListByFilter(String s) {
108108
lastFilter = s;
109109
list.children().clear();
110110
//? if < 1.21.4 {
111-
list.setScrollAmount(0);
112-
//?} else {
113-
/*list.setScrollY(0);
114-
*///?}
111+
/*list.setScrollAmount(0);
112+
*///?} else {
113+
list.setScrollY(0);
114+
//?}
115115
for (var key : textures) {
116116
extracted(s, key);
117117
}
@@ -130,12 +130,12 @@ private void extracted(String s, Identifier key) {
130130
}
131131

132132
//? if <= 1.20.1 {
133-
@Override
133+
/*@Override
134134
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
135135
renderBackground(context);
136136
super.render(context, mouseX, mouseY, delta);
137137
}
138-
//?}
138+
*///?}
139139

140140
public void success(Identifier ret) {
141141
onSuccess.accept(ret);

0 commit comments

Comments
 (0)