Skip to content

Commit 486b802

Browse files
committed
Merge branch 'Simplify-SliderWidget'
2 parents d3a2dcb + c92911b commit 486b802

File tree

21 files changed

+276
-78
lines changed

21 files changed

+276
-78
lines changed

build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ tasks.jar {
151151
archiveClassifier = "dev"
152152
}
153153

154+
if (stonecutter.current.isActive) {
155+
rootProject.tasks.register("runActive") {
156+
group = "project"
157+
dependsOn(tasks.named("runClient"))
158+
}
159+
}
160+
154161
tasks.processResources {
155162
properties(listOf("fabric.mod.json"),
156163
"id" to mod.id,

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ org.gradle.parallel=false
77
#org.gradle.configureondemand=true
88

99
# Mod properties
10-
mod.version=2.0.1
10+
mod.version=2.0.3
1111
mod.group=io.github.jumperonjava
1212
mod.id=customcursor
1313
mod.name=Custom cursor
@@ -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.9
25+
deps.fabric_loader=0.16.13
2626
deps.fabric_version=[VERSIONED]
2727

2828
deps.forge_loader=[VERSIONED]

settings.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ 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", )
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" )
2525
mc("forge","1.20.1",)
26-
mc("neoforge", "1.20.4", "1.21.1", "1.21.3", "1.21.4")
26+
mc("neoforge", "1.20.4", "1.21.1", "1.21.3", "1.21.4","1.21.5", "1.21.6","1.21.7")
2727
}
2828
create(rootProject)
2929
}

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import com.mojang.blaze3d.systems.RenderSystem;
44
import io.github.jumperonjava.customcursor.util.*;
5+
//? if >= 1.21.6
6+
/*import net.minecraft.client.gl.RenderPipelines;*/
57
import net.minecraft.client.gui.DrawContext;
68
import net.minecraft.client.gui.screen.Screen;
79
import net.minecraft.client.gui.widget.ButtonWidget;
@@ -60,7 +62,7 @@ protected void init() {
6062
var folderButton = new ButtonWidget.Builder(Text.translatable("customcursor.edit.folder"), (b) -> {
6163
FolderTextureAskList.ask(
6264
new FolderTextureAskList(
63-
CustomCursorInit.TEXTURE_FOLDER,
65+
CustomCursorInit.getTextureFolder(),
6466
this::setIdentifier
6567
)
6668
);
@@ -197,6 +199,10 @@ private void renderCheckerboard(DrawContext context, int mouseX, int mouseY, flo
197199

198200

199201
var cellsize = previewSize/8;
202+
203+
204+
//? if < 1.21.6 {
205+
200206
context.getMatrices().push();
201207
context.getMatrices().translate(
202208
(previewPosX + MathHelper.floorMod(bgx, cellsize) - cellsize),
@@ -214,6 +220,29 @@ private void renderCheckerboard(DrawContext context, int mouseX, int mouseY, flo
214220

215221
context.getMatrices().pop();
216222
context.disableScissor();
223+
//?} else {
224+
225+
226+
/*context.getMatrices().pushMatrix();
227+
context.getMatrices().translate(
228+
(previewPosX + MathHelper.floorMod(bgx, cellsize) - cellsize),
229+
(previewPosY + MathHelper.floorMod(bgy, cellsize) - cellsize));
230+
231+
232+
233+
int color = VersionFunctions.ColorHelper.getArgb(255, (int) (r*255), (int) (g*255), (int) (b*255));
234+
235+
int checkerRenderSize = previewSize + cellsize;
236+
context.drawTexture(RenderPipelines.GUI_TEXTURED, Identifier.of("customcursor", "textures/gui/backgroundcheckerboard.png"),
237+
0,
238+
0,
239+
0,
240+
0, checkerRenderSize, checkerRenderSize, checkerRenderSize, checkerRenderSize, color);
241+
242+
context.getMatrices().popMatrix();
243+
context.disableScissor();
244+
245+
*///?}
217246
}
218247

219248
public static CursorEditScreen createCursorEditScreen(Screen parent) {
Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,51 @@
11
package io.github.jumperonjava.customcursor;
22

3-
import com.mojang.blaze3d.systems.RenderSystem;
43
import net.minecraft.client.MinecraftClient;
4+
//? if >= 1.21.6 {
5+
/*import net.minecraft.client.gl.RenderPipelines;
6+
*///?} else {
7+
import com.mojang.blaze3d.systems.RenderSystem;
8+
//?}
59
import net.minecraft.client.gui.DrawContext;
610
import net.minecraft.client.render.RenderLayer;
711
import org.lwjgl.glfw.GLFW;
812
import org.lwjgl.opengl.GL11;
913

10-
import static io.github.jumperonjava.customcursor.CustomCursorInit.client;
11-
1214
public class CursorRenderer {
13-
public static void render(DrawContext context, int mouseX, int mouseY, float delta) {
15+
public static void render(DrawContext context, int mouseX, int mouseY, float donotuse_delta) {
1416
var config = CustomCursorInit.getConfig().pointer;
1517
if (MinecraftClient.getInstance().currentScreen == null)
16-
return;;
17-
if (config.enabled) {
18-
var scale = client.getWindow().getScaleFactor();
19-
RenderSystem.depthFunc(GL11.GL_ALWAYS);
20-
var identifier = config.identifier;
21-
var x = (int) Math.round(mouseX - config.size * config.x / scale);
22-
var y = (int) Math.round(mouseY - config.size * config.y / scale);
23-
var u = (float) 0;
24-
var v = (float) 0;
25-
var width = (int) (config.size / scale);
26-
var height = (int) (config.size / scale);
27-
var textureWidth = (int) (config.size / scale);
28-
var textureHeight = (int) (config.size / scale);
29-
//? if < 1.21.3 {
30-
context.drawTexture(identifier,x,y,u,v,width,height,textureWidth,textureHeight);
31-
//?} else {
32-
/*context.drawTexture(RenderLayer::getGuiTexturedOverlay,identifier,x,y,u,v,width,height,textureWidth,textureHeight);
33-
*///?}
34-
RenderSystem.depthFunc(GL11.GL_LEQUAL);
35-
36-
//for debugging
37-
//context.drawTexture(new Identifier("customcursor","textures/gui/pointer.png"), (int) (mouseX-4), (int) (mouseY-4),0,0,8,8,8,8);
38-
GLFW.glfwSetInputMode(client.getWindow().getHandle(), GLFW.GLFW_CURSOR, GLFW.GLFW_CURSOR_HIDDEN);
39-
} else {
40-
GLFW.glfwSetInputMode(client.getWindow().getHandle(), GLFW.GLFW_CURSOR, GLFW.GLFW_CURSOR_NORMAL);
18+
return;
19+
if (!config.enabled) {
20+
GLFW.glfwSetInputMode(MinecraftClient.getInstance().getWindow().getHandle(), GLFW.GLFW_CURSOR, GLFW.GLFW_CURSOR_NORMAL);
21+
return;
4122
}
23+
var scale = MinecraftClient.getInstance().getWindow().getScaleFactor();
24+
//? if < 1.21.5
25+
RenderSystem.depthFunc(GL11.GL_ALWAYS);
26+
var identifier = config.identifier;
27+
var x = (int) Math.round(mouseX - config.size * config.x / scale);
28+
var y = (int) Math.round(mouseY - config.size * config.y / scale);
29+
var u = (float) 0;
30+
var v = (float) 0;
31+
var width = (int) (config.size / scale);
32+
var height = (int) (config.size / scale);
33+
var textureWidth = (int) (config.size / scale);
34+
var textureHeight = (int) (config.size / scale);
35+
//? if < 1.21.3 {
36+
context.drawTexture(identifier,x,y,u,v,width,height,textureWidth,textureHeight);
37+
//?} else if < 1.21.6 {
38+
/*context.drawTexture(RenderLayer::getGuiTexturedOverlay, identifier, x, y, u, v, width, height, textureWidth, textureHeight);
39+
*///?} else {
40+
/*context.drawTexture(RenderPipelines.GUI_TEXTURED, identifier, x, y, u, v, width, height, textureWidth, textureHeight);
41+
42+
*///?}
43+
//? if < 1.21.5
44+
RenderSystem.depthFunc(GL11.GL_LEQUAL);
45+
46+
//for debugging
47+
//context.drawTexture(new Identifier("customcursor","textures/gui/pointer.png"), (int) (mouseX-4), (int) (mouseY-4),0,0,8,8,8,8);
48+
GLFW.glfwSetInputMode(MinecraftClient.getInstance().getWindow().getHandle(), GLFW.GLFW_CURSOR, GLFW.GLFW_CURSOR_HIDDEN);
49+
4250
}
4351
}

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@
1414
public class CustomCursorInit
1515
{
1616
public static final String MOD_ID = "customcursorcomm";
17-
public static final MinecraftClient client = MinecraftClient.getInstance();
1817
public static final Logger LOGGER = LoggerFactory.getLogger("CustomCursor");
19-
public static final TextureFolder TEXTURE_FOLDER = new TextureFolder(
20-
client.runDirectory.toPath().resolve("cursors"),
21-
"cursorfolder"
22-
);
18+
private static TextureFolder TEXTURE_FOLDER;
19+
2320
private static CursorConfigStorage config;
2421
private static Gson gson = new GsonBuilder().setPrettyPrinting().create();
2522

@@ -36,7 +33,7 @@ private static CursorConfigStorage loadConfig() {
3633
}
3734

3835
private static File getConfigFile(){
39-
return client.getResourcePackDir().resolve("../config/customcursor.json").toFile();
36+
return MinecraftClient.getInstance().runDirectory.toPath().resolve("config/customcursor.json").toFile();
4037
}
4138

4239
public static CursorConfigStorage getConfig() {
@@ -50,4 +47,15 @@ public static void setConfig(CursorConfigStorage config){
5047
FileReadWrite.write(getConfigFile(),json);
5148
CustomCursorInit.config = config;
5249
}
50+
//on neoforge 1.21.6+ itcre
51+
public static TextureFolder getTextureFolder() {
52+
if(TEXTURE_FOLDER==null)
53+
{
54+
TEXTURE_FOLDER = new TextureFolder(
55+
MinecraftClient.getInstance().runDirectory.toPath().resolve("cursors"),
56+
"cursorfolder"
57+
);
58+
}
59+
return TEXTURE_FOLDER;
60+
}
5361
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public class CobblemonFix {
2424
void lock(DrawContext context, float tickDelta, CallbackInfo ci){
2525
//?} else {
2626
/*void lock(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) {
27-
var tickDelta = tickCounter.getLastDuration();
2827
*///?}
2928
if (client.currentScreen == null) {
3029
if (locked)

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,24 @@ void renderCursor(float tickDelta, long startTime, boolean tick, CallbackInfo ci
4343
void renderCursor(RenderTickCounter tickCounter, boolean tick, CallbackInfo ci, @Local(ordinal = 0) int i, @Local(ordinal = 1) int j, @Local DrawContext drawContext){
4444
CursorRenderer.render(drawContext,i,j,tickCounter.getLastDuration());
4545
}
46-
*///?} else {
46+
*///?} elif < 1.21.6 {
4747
/*@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;draw()V", shift = At.Shift.BEFORE))
4848
void renderCursor(RenderTickCounter tickCounter, boolean tick, CallbackInfo ci, @Local(ordinal = 0) int i, @Local(ordinal = 1) int j, @Local DrawContext drawContext){
49-
CursorRenderer.render(drawContext,i,j,tickCounter.getLastDuration());
49+
CursorRenderer.render(drawContext,i,j,0);
5050
}
51+
*///?} else {
52+
53+
/*//? if fabric {
54+
@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))
55+
void renderCursor(RenderTickCounter tickCounter, boolean tick, CallbackInfo ci, @Local(ordinal = 0) int i, @Local(ordinal = 1) int j, @Local DrawContext drawContext){
56+
CursorRenderer.render(drawContext,i,j,0);
57+
}
58+
//?} 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))
60+
void renderCursor(RenderTickCounter tickCounter, boolean tick, CallbackInfo ci, @Local(ordinal = 0) int i, @Local(ordinal = 1) int j, @Local DrawContext drawContext){
61+
CursorRenderer.render(drawContext,i,j,0);
62+
}
63+
^///?}
64+
5165
*///?}
5266
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
public class LoadFolderTexturesEventMixin {
1313
@Inject(method = "init",at=@At("HEAD"))
1414
void init(CallbackInfo ci){
15-
CustomCursorInit.TEXTURE_FOLDER.redefineTextures();
15+
CustomCursorInit.getTextureFolder().redefineTextures();
1616
}
1717

1818
}

src/main/java/io/github/jumperonjava/customcursor/neoforge/CustomCursorNeoForge.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,46 @@
33
44
import io.github.jumperonjava.customcursor.CursorEditScreen;
55
import io.github.jumperonjava.customcursor.CustomCursorInit;
6+
import net.minecraft.client.MinecraftClient;
67
import net.minecraft.client.gui.screen.Screen;
8+
import net.neoforged.bus.api.IEventBus;
79
import net.neoforged.fml.ModList;
810
import net.neoforged.fml.ModLoadingContext;
911
import net.neoforged.fml.common.Mod;
1012
//? if <1.21 {
1113
import net.neoforged.neoforge.client.ConfigScreenHandler;
1214
//?} else {
1315
/^import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
16+
import net.neoforged.neoforge.common.NeoForge;
17+
18+
^///?}
19+
20+
//? if >= 1.21.6 {
21+
22+
/^import net.neoforged.neoforge.client.event.lifecycle.ClientStartedEvent;
23+
1424
^///?}
1525
@Mod("customcursor")
1626
public class CustomCursorNeoForge {
17-
public CustomCursorNeoForge() {
27+
28+
//? if >= 1.21.6 {
29+
30+
/^public CustomCursorNeoForge(IEventBus bus) {
31+
NeoForge.EVENT_BUS.addListener((ClientStartedEvent event)->{this.entrypoint();});
32+
}
33+
34+
^///?} else {
35+
36+
public CustomCursorNeoForge() {
37+
this.entrypoint();
38+
}
39+
40+
//?}
41+
42+
43+
44+
45+
public void entrypoint() {
1846
CustomCursorInit.entrypoint((s)-> ModList.get().isLoaded(s));
1947
ModLoadingContext.get().registerExtensionPoint(
2048
//? if <1.21 {

0 commit comments

Comments
 (0)