Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #145 from moehreag/master
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkKronicle authored Jul 4, 2023
2 parents bfa812a + ca01177 commit c173c71
Show file tree
Hide file tree
Showing 29 changed files with 316 additions and 401 deletions.
9 changes: 5 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id "fabric-loom" version "1.0-SNAPSHOT"
id "fabric-loom" version "1.2-SNAPSHOT"
id "maven-publish"
id "io.freefair.lombok" version "6.1.0-m2"
id "io.freefair.lombok" version "8.0.1"
}

apply from: 'https://raw.githubusercontent.com/DarkKronicle/GradleScripts/main/gradle/publish.gradle'
Expand All @@ -24,7 +24,7 @@ repositories {
maven { url "https://maven.terraformersmc.com/releases" }
maven {
name = 'Ladysnake Mods'
url = 'https://ladysnake.jfrog.io/artifactory/mods'
url = 'https://maven.ladysnake.org/releases'
content {
includeGroup 'io.github.ladysnake'
includeGroupByRegex 'io\\.github\\.onyxstudios.*'
Expand All @@ -43,7 +43,8 @@ dependencies {

// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
modImplementation "com.github.DarkKronicle:DarkKore:${project.darkkore_version}"
//modImplementation "com.github.DarkKronicle:DarkKore:${project.darkkore_version}" // 1.20.1 version not yet published
modCompileOnly files("run/mods/DarkKore-0.3.5-1.20.1.jar")

modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/versions.html
minecraft_version=1.19.4
yarn_mappings=1.19.4+build.1
loader_version=0.14.9
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.1
loader_version=0.14.21
# Mod Properties
mod_version=2.2.6
maven_group=io.github.darkkronicle
archives_base_name=KronHUD
# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.76.0+1.19.4
fabric_version=0.84.0+1.20.1
darkkore_version=ab012735d8
modmenu_version=6.1.0-rc.4
modmenu_version=7.1.0

# Uploading data
curseforge_slug=kronhud
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import io.github.darkkronicle.darkkore.config.options.Option;
import io.github.darkkronicle.darkkore.gui.Tab;
import io.github.darkkronicle.kronhud.config.*;
import io.github.darkkronicle.kronhud.config.DefaultOptions;
import io.github.darkkronicle.kronhud.config.KronBoolean;
import io.github.darkkronicle.kronhud.config.KronConfig;
import io.github.darkkronicle.kronhud.config.KronDouble;
import io.github.darkkronicle.kronhud.gui.component.HudEntry;
import io.github.darkkronicle.kronhud.util.ColorUtil;
import io.github.darkkronicle.kronhud.util.DrawPosition;
Expand All @@ -11,7 +14,7 @@
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.util.math.MathHelper;

import java.util.ArrayList;
Expand Down Expand Up @@ -54,13 +57,13 @@ public static float intToFloat(int current, int max, int offset) {

public void init() {}

public void renderPlaceholderBackground(MatrixStack matrices) {
public void renderPlaceholderBackground(DrawContext context) {
if (hovered) {
fillRect(matrices, getTrueBounds(), ColorUtil.SELECTOR_BLUE.withAlpha(100));
fillRect(context, getTrueBounds(), ColorUtil.SELECTOR_BLUE.withAlpha(100));
} else {
fillRect(matrices, getTrueBounds(), ColorUtil.WHITE.withAlpha(50));
fillRect(context, getTrueBounds(), ColorUtil.WHITE.withAlpha(50));
}
outlineRect(matrices, getTrueBounds(), ColorUtil.BLACK);
outlineRect(context, getTrueBounds(), ColorUtil.BLACK);
}

public int getRawX() {
Expand Down Expand Up @@ -101,9 +104,9 @@ public float getScale() {
return scale.getValue().floatValue();
}

public void scale(MatrixStack matrices) {
public void scale(DrawContext context) {
float scale = getScale();
matrices.scale(scale, scale, 1);
context.getMatrices().scale(scale, scale, 1);
}

@Override
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/io/github/darkkronicle/kronhud/gui/HudManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.util.Identifier;

import java.util.*;
Expand Down Expand Up @@ -72,20 +72,20 @@ public HudEntry get(Identifier identifier) {
return entries.get(identifier);
}

public void render(MatrixStack matrices, float delta) {
public void render(DrawContext context, float delta) {
if (!(client.currentScreen instanceof HudEditScreen) && !client.options.debugEnabled) {
for (HudEntry hud : getEntries()) {
if (hud.isEnabled()) {
hud.render(matrices, delta);
hud.render(context, delta);
}
}
}
}

public void renderPlaceholder(MatrixStack matrices, float delta) {
public void renderPlaceholder(DrawContext context, float delta) {
for (HudEntry hud : getEntries()) {
if (hud.isEnabled()) {
hud.renderPlaceholder(matrices, delta);
hud.renderPlaceholder(context, delta);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.github.darkkronicle.kronhud.gui.component;

import io.github.darkkronicle.kronhud.util.DrawPosition;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.gui.DrawContext;

public interface HudEntry extends Identifiable, Configurable, Positionable {

Expand All @@ -25,9 +24,9 @@ default double getDefaultY() {
return 0;
}

void render(MatrixStack matrices, float delta);
void render(DrawContext context, float delta);

void renderPlaceholder(MatrixStack matrices, float delta);
void renderPlaceholder(DrawContext context, float delta);

void setHovered(boolean hovered);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.github.darkkronicle.kronhud.config.KronExtendedColor;
import io.github.darkkronicle.kronhud.gui.AbstractHudEntry;
import io.github.darkkronicle.kronhud.util.ColorUtil;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.util.math.MatrixStack;

import java.util.List;
Expand Down Expand Up @@ -44,35 +45,35 @@ public List<KronConfig<?>> getConfigurationOptions() {
}

@Override
public void render(MatrixStack matrices, float delta) {
matrices.push();
scale(matrices);
public void render(DrawContext context, float delta) {
context.getMatrices().push();
scale(context);
if (backgroundAllowed) {
if (background.getValue() && backgroundColor.getValue().alpha() > 0) {
fillRect(matrices, getBounds(), backgroundColor.getValue());
fillRect(context, getBounds(), backgroundColor.getValue());
}
if (outline.getValue() && outlineColor.getValue().alpha() > 0) {
outlineRect(matrices, getBounds(), outlineColor.getValue());
outlineRect(context, getBounds(), outlineColor.getValue());
}
}
renderComponent(matrices, delta);
matrices.pop();
renderComponent(context, delta);
context.getMatrices().pop();
}

public abstract void renderComponent(MatrixStack matrices, float delta);
public abstract void renderComponent(DrawContext context, float delta);

@Override
public void renderPlaceholder(MatrixStack matrices, float delta) {
matrices.push();
renderPlaceholderBackground(matrices);
outlineRect(matrices, getTrueBounds(), ColorUtil.BLACK);
scale(matrices);
renderPlaceholderComponent(matrices, delta);
matrices.pop();
public void renderPlaceholder(DrawContext context, float delta) {
context.getMatrices().push();
renderPlaceholderBackground(context);
outlineRect(context, getTrueBounds(), ColorUtil.BLACK);
scale(context);
renderPlaceholderComponent(context, delta);
context.getMatrices().pop();
hovered = false;
}

public abstract void renderPlaceholderComponent(MatrixStack matrices, float delta);
public abstract void renderPlaceholderComponent(DrawContext context, float delta);

@Override
public boolean movable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.github.darkkronicle.kronhud.gui.layout.AnchorPoint;
import io.github.darkkronicle.kronhud.gui.layout.Justification;
import io.github.darkkronicle.kronhud.util.DrawPosition;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;

Expand Down Expand Up @@ -38,7 +39,7 @@ protected SimpleTextHudEntry(int width, int height, boolean backgroundAllowed) {
}

@Override
public void renderComponent(MatrixStack matrices, float delta) {
public void renderComponent(DrawContext context, float delta) {
RenderSystem.enableBlend();
RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
DrawPosition pos = getPos();
Expand All @@ -58,7 +59,7 @@ public void renderComponent(MatrixStack matrices, float delta) {
onBoundsUpdate();
}
drawString(
matrices, client.textRenderer, Text.literal(value),
context, client.textRenderer, Text.literal(value),
pos.x() + justification.getValue().getXOffset(valueWidth, getWidth() - 4) + 2,
pos.y() + (Math.round((float) getHeight() / 2)) - 4,
getTextColor().color(), shadow.getValue()
Expand All @@ -71,11 +72,11 @@ public Color getTextColor() {
}

@Override
public void renderPlaceholderComponent(MatrixStack matrices, float delta) {
public void renderPlaceholderComponent(DrawContext context, float delta) {
DrawPosition pos = getPos();
String value = getPlaceholder();
drawString(
matrices, client.textRenderer, Text.literal(value),
context, client.textRenderer, Text.literal(value),
pos.x() + justification.getValue().getXOffset(value, getWidth() - 4) + 2,
pos.y() + (Math.round((float) getHeight() / 2)) - 4,
textColor.getValue().color(), shadow.getValue()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.github.darkkronicle.kronhud.gui.layout.AnchorPoint;
import io.github.darkkronicle.kronhud.util.DrawPosition;
import io.github.darkkronicle.kronhud.util.DrawUtil;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
Expand Down Expand Up @@ -48,16 +49,16 @@ public Identifier getId() {
}

@Override
public void renderComponent(MatrixStack matrices, float delta) {
renderCompass(matrices, delta);
public void renderComponent(DrawContext context, float delta) {
renderCompass(context, delta);
}

@Override
public void renderPlaceholderComponent(MatrixStack matrices, float delta) {
renderCompass(matrices, delta);
public void renderPlaceholderComponent(DrawContext context, float delta) {
renderCompass(context, delta);
}

public void renderCompass(MatrixStack matrices, float delta) {
public void renderCompass(DrawContext context, float delta) {
// N = 0
// E = 90
// S = 180
Expand All @@ -79,18 +80,18 @@ public void renderCompass(MatrixStack matrices, float delta) {
DrawPosition pos = getPos();
int x = pos.x();
int y = pos.y() + 1;
RenderUtil.drawRectangle(matrices, pos.x() + (int) halfWidth - 1, pos.y(), 3, 11, lookingBox.getValue());
RenderUtil.drawRectangle(context, pos.x() + (int) halfWidth - 1, pos.y(), 3, 11, lookingBox.getValue());
if (showDegrees.getValue()) {
DrawUtil.drawCenteredString(
matrices, client.textRenderer, Text.literal(Integer.toString((int) degrees)), x + (int) halfWidth, y + 20, degreesColor.getValue(),
context, client.textRenderer, Text.literal(Integer.toString((int) degrees)), x + (int) halfWidth, y + 20, degreesColor.getValue(),
shadow.getValue()
);
}
float shift = (startIndicator - start) / 15f * dist;
if (invert.getValue()) {
shift = dist - shift;
}
matrices.translate(shift, 0, 0);
context.getMatrices().translate(shift, 0, 0);
for (int i = 0; i < amount; i++) {
int d;
if (invert.getValue()) {
Expand All @@ -111,27 +112,27 @@ public void renderCompass(MatrixStack matrices, float delta) {
RenderSystem.setShaderColor(1, 1, 1, targetOpacity);
if (indicator == Indicator.CARDINAL) {
// We have to call .color() here so that transparency stays
RenderUtil.drawRectangle(matrices, innerX, y, 1, 9, majorIndicatorColor.getValue().color());
RenderUtil.drawRectangle(context, innerX, y, 1, 9, majorIndicatorColor.getValue().color());
Color color = cardinalColor.getValue();
color = color.withAlpha((int) (color.alpha() * targetOpacity));
if (color.alpha() > 0) {
DrawUtil.drawCenteredString(
matrices, client.textRenderer, Text.literal(getCardString(indicator, d)), innerX + 1, y + 10, color, shadow.getValue());
context, client.textRenderer, Text.literal(getCardString(indicator, d)), innerX + 1, y + 10, color, shadow.getValue());
}
} else if (indicator == Indicator.SEMI_CARDINAL) {
Color color = semiCardinalColor.getValue();
color = color.withAlpha((int) (color.alpha() * targetOpacity));
if (color.alpha() > 0) {
DrawUtil.drawCenteredString(
matrices, client.textRenderer, Text.literal(getCardString(indicator, d)), innerX + 1, y + 1, color, shadow.getValue());
context, client.textRenderer, Text.literal(getCardString(indicator, d)), innerX + 1, y + 1, color, shadow.getValue());
}
} else {
// We have to call .color() here so that transparency stays
RenderUtil.drawRectangle(matrices, innerX, y, 1, 5, minorIndicatorColor.getValue().color());
RenderUtil.drawRectangle(context, innerX, y, 1, 5, minorIndicatorColor.getValue().color());
}
}
RenderSystem.setShaderColor(1, 1, 1, 1);
matrices.translate(-shift, 0, 0);
context.getMatrices().translate(-shift, 0, 0);
}

private static Indicator getIndicator(int degrees) {
Expand Down
Loading

0 comments on commit c173c71

Please sign in to comment.