Skip to content

Commit 980dee9

Browse files
Merge pull request #7 from tanishisherewithhh/master
Update to 1.21.5
2 parents d7b51c5 + 7b1a2fa commit 980dee9

34 files changed

+977
-845
lines changed

build.gradle

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
plugins {
2-
id 'fabric-loom' version '1.9-SNAPSHOT'
2+
id 'fabric-loom' version '1.10-SNAPSHOT'
33
id 'maven-publish'
44
}
55

6+
version = project.mod_version
7+
group = project.maven_group
8+
9+
base {
10+
archivesName = project.archives_base_name
11+
}
12+
613
allprojects {
714
apply plugin: "java"
815
apply plugin: "maven-publish"
916

1017
archivesBaseName = rootProject.archives_base_name
11-
version = rootProject.mod_version
12-
group = rootProject.maven_group
1318
}
1419

1520
repositories {
@@ -23,7 +28,6 @@ repositories {
2328
name 'Xander Maven'
2429
url 'https://maven.isxander.dev/releases'
2530
}
26-
maven { url "https://maven.terraformersmc.com/releases" }
2731
}
2832

2933
dependencies {
@@ -38,14 +42,17 @@ dependencies {
3842

3943
processResources {
4044
inputs.property "version", project.version
41-
inputs.property "minecraft_version", project.minecraft_version
4245
inputs.property "loader_version", project.loader_version
43-
filteringCharset "UTF-8"
46+
inputs.property "minecraft_version", project.minecraft_version
47+
inputs.property "yacl_version", project.yacl_version
4448

4549
filesMatching("fabric.mod.json") {
46-
expand "version": project.version,
47-
"minecraft_version": project.minecraft_version,
48-
"loader_version": project.loader_version
50+
expand([
51+
"version": inputs.properties.version,
52+
"loader_version": inputs.properties.loader_version,
53+
"minecraft_version": inputs.properties.minecraft_version,
54+
"yacl_version": inputs.properties.yacl_version
55+
])
4956
}
5057
}
5158

@@ -65,8 +72,10 @@ java {
6572
}
6673

6774
jar {
75+
inputs.property "archivesName", project.base.archivesName
76+
6877
from("LICENSE") {
69-
rename { "${it}_${project.archivesBaseName}"}
78+
rename { "${it}_${inputs.properties.archivesName}"}
7079
}
7180
}
7281

gradle.properties

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ org.gradle.parallel=true
44

55
# Fabric Properties
66
# check these on https://fabricmc.net/develop
7-
minecraft_version=1.21.4
8-
yarn_mappings=1.21.4+build.1
9-
loader_version=0.16.9
7+
minecraft_version=1.21.5
8+
yarn_mappings=1.21.5+build.1
9+
loader_version=0.16.10
1010

1111
# Mod Properties
1212
# need versioning system
13-
mod_version = 3.0.0
13+
mod_version = 3.1.0
1414
maven_group = com.tanishisherewith
1515
archives_base_name = dynamichud
1616

1717
# Dependencies
18-
fabric_version=0.111.0+1.21.4
19-
yacl_version=3.6.6+1.21.4-fabric
18+
fabric_version=0.119.5+1.21.5
19+
yacl_version=3.6.6+1.21.5-fabric
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

gradlew

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -83,10 +85,8 @@ done
8385
# This is normally unused
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
86-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
87-
88-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
88+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
9090

9191
# Use the maximum available, or set MAX_FD != -1 to use that value.
9292
MAX_FD=maximum
@@ -133,26 +133,29 @@ location of your Java installation."
133133
fi
134134
else
135135
JAVACMD=java
136-
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
136+
if ! command -v java >/dev/null 2>&1
137+
then
138+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137139
138140
Please set the JAVA_HOME variable in your environment to match the
139141
location of your Java installation."
142+
fi
140143
fi
141144

142145
# Increase the maximum file descriptors if we can.
143146
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144147
case $MAX_FD in #(
145148
max*)
146149
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147-
# shellcheck disable=SC3045
150+
# shellcheck disable=SC2039,SC3045
148151
MAX_FD=$( ulimit -H -n ) ||
149152
warn "Could not query maximum file descriptor limit"
150153
esac
151154
case $MAX_FD in #(
152155
'' | soft) :;; #(
153156
*)
154157
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155-
# shellcheck disable=SC3045
158+
# shellcheck disable=SC2039,SC3045
156159
ulimit -n "$MAX_FD" ||
157160
warn "Could not set maximum file descriptor limit to $MAX_FD"
158161
esac
@@ -197,11 +200,15 @@ if "$cygwin" || "$msys" ; then
197200
done
198201
fi
199202

200-
# Collect all arguments for the java command;
201-
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
202-
# shell script including quotes and variable substitutions, so put them in
203-
# double quotes to make sure that they get re-expanded; and
204-
# * put everything else in single quotes, so that it's not re-expanded.
203+
204+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
205+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
206+
207+
# Collect all arguments for the java command:
208+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
209+
# and any embedded shellness will be escaped.
210+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
211+
# treated as '${Hostname}' itself on the command line.
205212

206213
set -- \
207214
"-Dorg.gradle.appname=$APP_BASE_NAME" \
@@ -241,4 +248,4 @@ eval "set -- $(
241248
tr '\n' ' '
242249
)" '"$@"'
243250

244-
exec "$JAVACMD" "$@"
251+
exec "$JAVACMD" "$@"

gradlew.bat

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
@rem See the License for the specific language governing permissions and
1414
@rem limitations under the License.
1515
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
1618

1719
@if "%DEBUG%"=="" @echo off
1820
@rem ##########################################################################
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
4345
%JAVA_EXE% -version >NUL 2>&1
4446
if %ERRORLEVEL% equ 0 goto execute
4547

46-
echo.
47-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48-
echo.
49-
echo Please set the JAVA_HOME variable in your environment to match the
50-
echo location of your Java installation.
48+
echo. 1>&2
49+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50+
echo. 1>&2
51+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52+
echo location of your Java installation. 1>&2
5153

5254
goto fail
5355

@@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
5759

5860
if exist "%JAVA_EXE%" goto execute
5961

60-
echo.
61-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62-
echo.
63-
echo Please set the JAVA_HOME variable in your environment to match the
64-
echo location of your Java installation.
62+
echo. 1>&2
63+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64+
echo. 1>&2
65+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66+
echo location of your Java installation. 1>&2
6567

6668
goto fail
6769

@@ -89,4 +91,4 @@ exit /b %EXIT_CODE%
8991
:mainEnd
9092
if "%OS%"=="Windows_NT" endlocal
9193

92-
:omega
94+
:omega

src/main/java/com/tanishisherewith/dynamichud/DynamicHUD.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package com.tanishisherewith.dynamichud;
22

33
import com.tanishisherewith.dynamichud.config.GlobalConfig;
4+
import com.tanishisherewith.dynamichud.helpers.MouseColorQuery;
45
import com.tanishisherewith.dynamichud.integration.IntegrationManager;
56
import net.fabricmc.api.ClientModInitializer;
67
import net.fabricmc.api.EnvType;
78
import net.fabricmc.api.Environment;
89
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
10+
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
11+
import net.fabricmc.fabric.api.client.rendering.v1.HudLayerRegistrationCallback;
912
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
1013
import net.minecraft.client.MinecraftClient;
1114
import org.slf4j.Logger;
@@ -35,6 +38,7 @@ public void onInitializeClient() {
3538
IntegrationManager.integrate();
3639

3740
//In game screen render.
38-
HudRenderCallback.EVENT.register(new HudRender());
41+
HudLayerRegistrationCallback.EVENT.register(new HudRender());
42+
ClientTickEvents.END_CLIENT_TICK.register(mc-> MouseColorQuery.processIfPending());
3943
}
4044
}

src/main/java/com/tanishisherewith/dynamichud/HudRender.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,29 @@
22

33
import com.tanishisherewith.dynamichud.integration.IntegrationManager;
44
import com.tanishisherewith.dynamichud.widget.WidgetRenderer;
5+
import net.fabricmc.fabric.api.client.rendering.v1.HudLayerRegistrationCallback;
56
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
7+
import net.fabricmc.fabric.api.client.rendering.v1.IdentifiedLayer;
8+
import net.fabricmc.fabric.api.client.rendering.v1.LayeredDrawerWrapper;
69
import net.minecraft.client.gui.DrawContext;
710
import net.minecraft.client.render.RenderTickCounter;
11+
import net.minecraft.util.Identifier;
812

913
/**
10-
* Using the fabric event {@link HudRenderCallback} to render widgets in the game HUD.
14+
* Using the fabric event {@link HudLayerRegistrationCallback} to render widgets in the game HUD.
1115
* Mouse positions are passed in the negatives even though theoretically it's in the centre of the screen.
1216
*/
13-
public class HudRender implements HudRenderCallback {
14-
17+
public class HudRender implements HudLayerRegistrationCallback {
1518
@Override
16-
public void onHudRender(DrawContext drawContext, RenderTickCounter tickCounter) {
17-
for (WidgetRenderer widgetRenderer : IntegrationManager.getWidgetRenderers()) {
18-
widgetRenderer.renderWidgets(drawContext, -120, -120);
19-
}
19+
public void register(LayeredDrawerWrapper layeredDrawer) {
20+
layeredDrawer.attachLayerAfter(
21+
IdentifiedLayer.MISC_OVERLAYS,
22+
IdentifiedLayer.of(Identifier.of("dynamichud","hudrender_callback"),
23+
(context, tickCounter) -> {
24+
for (WidgetRenderer widgetRenderer : IntegrationManager.getWidgetRenderers()) {
25+
widgetRenderer.renderWidgets(context, -120, -120);
26+
}
27+
})
28+
);
2029
}
2130
}

src/main/java/com/tanishisherewith/dynamichud/helpers/ColorHelper.java

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package com.tanishisherewith.dynamichud.helpers;
22

3+
import com.mojang.blaze3d.systems.RenderSystem;
34
import net.minecraft.client.MinecraftClient;
45
import net.minecraft.client.gl.Framebuffer;
56
import net.minecraft.client.util.Window;
67
import net.minecraft.util.math.MathHelper;
8+
import org.lwjgl.BufferUtils;
79
import org.lwjgl.opengl.GL11;
810
import org.lwjgl.opengl.GL30;
911

@@ -174,47 +176,8 @@ public static Color changeAlpha(Color color, int alpha) {
174176
return new Color(0);
175177
}
176178

177-
public static int[] getMousePixelColor(double mouseX, double mouseY) {
178-
MinecraftClient client = MinecraftClient.getInstance();
179-
Framebuffer framebuffer = client.getFramebuffer();
180-
Window window = client.getWindow();
181-
182-
// Get the window and framebuffer dimensions
183-
int windowWidth = window.getWidth();
184-
int windowHeight = window.getHeight();
185-
int framebufferWidth = framebuffer.textureWidth;
186-
int framebufferHeight = framebuffer.textureHeight;
187-
188-
// Calculate scaling factors
189-
double scaleX = (double) framebufferWidth / windowWidth;
190-
double scaleY = (double) framebufferHeight / windowHeight;
191-
192-
// Convert mouse coordinates to framebuffer coordinates
193-
int x = (int) (mouseX * scaleX);
194-
int y = (int) ((windowHeight - mouseY) * scaleY);
195-
196-
// Ensure the coordinates are within the framebuffer bounds
197-
if (x < 0 || x >= framebufferWidth || y < 0 || y >= framebufferHeight) {
198-
System.err.println("Mouse coordinates are out of bounds");
199-
return null;
200-
}
201-
202-
// Allocate a buffer to store the pixel data
203-
ByteBuffer buffer = ByteBuffer.allocateDirect(4); // 4 bytes for RGBA
204-
205-
// Bind the framebuffer for reading
206-
GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, framebuffer.fbo);
207-
208-
// Read the pixel at the mouse position
209-
GL11.glReadPixels(x, y, 1, 1, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer);
210-
211-
// Extract the color components from the buffer
212-
int red = buffer.get(0) & 0xFF;
213-
int green = buffer.get(1) & 0xFF;
214-
int blue = buffer.get(2) & 0xFF;
215-
int alpha = buffer.get(3) & 0xFF;
216-
217-
return new int[]{red, green, blue, alpha};
179+
public static Color changeAlpha(int color, int alpha) {
180+
return changeAlpha(new Color(color),alpha);
218181
}
219182

220183
public static int fromRGBA(int r, int g, int b, int a) {

0 commit comments

Comments
 (0)