Skip to content

Commit

Permalink
1.21 update
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishisherewithhh committed Jul 6, 2024
1 parent 13717c8 commit 6ccb876
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 103 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish'
}

Expand Down Expand Up @@ -35,7 +35,7 @@ dependencies {

modImplementation "dev.isxander:yet-another-config-lib:${project.yacl_version}"

modApi "com.terraformersmc:modmenu:10.0.0-beta.1"
modApi "com.terraformersmc:modmenu:11.0.1"
}

processResources {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1
loader_version=0.15.10
minecraft_version=1.21
yarn_mappings=1.21+build.2
loader_version=0.15.11

# Mod Properties
mod_version = 2.1.0
maven_group = com.tanishisherewith
archives_base_name = dynamichud

# Dependencies
fabric_version=0.97.8+1.20.6
yacl_version=3.4.4+1.20.6-fabric
fabric_version=0.100.3+1.21
yacl_version=3.5.0+1.21-fabric
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 4 additions & 2 deletions src/main/java/com/tanishisherewith/dynamichud/HudRender.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
import com.tanishisherewith.dynamichud.widget.WidgetRenderer;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.RenderTickCounter;

/**
* Using the fabric event {@link HudRenderCallback} to render widgets in the game HUD.
* Mouse positions are passed in the negatives even though theoretically it's in the centre of the screen.
*/
public class HudRender implements HudRenderCallback {
public class HudRender implements HudRenderCallback{

@Override
public void onHudRender(DrawContext drawContext, float tickDelta) {
public void onHudRender(DrawContext drawContext, RenderTickCounter tickCounter) {
for (WidgetRenderer widgetRenderer : DynamicHUD.getWidgetRenderers()) {
widgetRenderer.renderWidgets(drawContext, -120, -120);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public final class GlobalConfig {
public static final ConfigClassHandler<GlobalConfig> HANDLER = ConfigClassHandler.createBuilder(GlobalConfig.class)
.id(new Identifier("dynamichud", "dynamichud_config"))
.id(Identifier.of("dynamichud", "dynamichud_config"))
.serializer(config -> GsonConfigSerializerBuilder.create(config)
.setPath(FabricLoader.getInstance().getConfigDir().resolve("dynamichud.json5"))
.setJson5(true)
Expand Down
165 changes: 79 additions & 86 deletions src/main/java/com/tanishisherewith/dynamichud/helpers/DrawHelper.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.Framebuffer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.util.GlAllocationUtils;
import org.lwjgl.opengl.GL11;

import java.awt.*;
Expand Down Expand Up @@ -79,7 +78,7 @@ public void render(DrawContext drawContext, int x1, int y1) {
int y = (int) ((client.getWindow().getScaledHeight() - mouseY) * framebuffer.textureHeight / client.getWindow().getScaledHeight());

//Read the pixel color at x,y pos to buffer
ByteBuffer buffer = GlAllocationUtils.allocateByteBuffer(4);
ByteBuffer buffer = ByteBuffer.allocate(4);
GL11.glReadPixels(x, y, 1, 1, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer);
int red = buffer.get(0) & 0xFF;
int green = buffer.get(1) & 0xFF;
Expand Down Expand Up @@ -109,7 +108,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
int x = (int) (mouseX * framebuffer.textureWidth / client.getWindow().getScaledWidth());
int y = (int) ((client.getWindow().getScaledHeight() - mouseY) * framebuffer.textureHeight / client.getWindow().getScaledHeight());

ByteBuffer buffer = GlAllocationUtils.allocateByteBuffer(4);
ByteBuffer buffer = ByteBuffer.allocate(4);
GL11.glReadPixels(x, y, 1, 1, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer);
int red = buffer.get(0) & 0xFF;
int green = buffer.get(1) & 0xFF;
Expand Down
3 changes: 0 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
"license": "All-Rights-Reserved",
"environment": "client",
"entrypoints": {
"dynamicHud": [
"com.tanishisherewith.dynamichud.DynamicHudTest"
],
"client": [
"com.tanishisherewith.dynamichud.DynamicHUD"
],
Expand Down

0 comments on commit 6ccb876

Please sign in to comment.