Skip to content

Commit

Permalink
Merge pull request #6 from moehreag/main
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkKronicle committed Jul 4, 2023
2 parents 02a4eaf + 5b10689 commit 05c4c57
Show file tree
Hide file tree
Showing 20 changed files with 147 additions and 141 deletions.
12 changes: 8 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.0.0-m2"
id "io.freefair.lombok" version "8.0.1"
}

apply from: 'https://raw.githubusercontent.com/DarkKronicle/GradleScripts/main/gradle/publish.gradle'
Expand All @@ -14,7 +14,7 @@ repositories {
maven { url 'https://jitpack.io' }
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 @@ -34,10 +34,14 @@ dependencies {
implementation "com.github.DarkKronicle.Konstruct:addons:${project.konstruct_version}"
implementation "com.github.DarkKronicle.Konstruct:core:${project.konstruct_version}"

modImplementation "io.github.ladysnake:satin:${satin_version}"
modImplementation ("io.github.ladysnake:satin:${satin_version}"){
exclude group: "net.fabricmc.fabric-api"
}

include "io.github.ladysnake:satin:${satin_version}"

modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}"

include "com.github.DarkKronicle.Konstruct:addons:${project.konstruct_version}"
include "com.github.DarkKronicle.Konstruct:core:${project.konstruct_version}"

Expand Down
10 changes: 6 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
org.gradle.jvmargs=-Xmx1G

minecraft_version=1.19.4
yarn_mappings=1.19.4+build.1
loader_version=0.14.10
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.1
loader_version=0.14.21

mod_version=0.3.5
maven_group=io.github.darkkronicle
archives_base_name=DarkKore

night_config_version=3.6.5
konstruct_version=2.0.3-build1
satin_version=1.11.0
satin_version=1.13.0
mod_menu_version=6.1.0-rc.4
# the FAPI version packaged with Satin is version locked to 1.20
fabric_api_version=0.84.0+1.20.1

# Uploading data
curseforge_slug=darkkore
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.3-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 @@ -7,8 +7,8 @@
import io.github.darkkronicle.darkkore.util.render.RenderUtil;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -34,13 +34,13 @@ public void addComponent(Component component) {
components.add(component);
}

public void renderComponents(MatrixStack matrices, int mouseX, int mouseY) {
public void renderComponents(DrawContext context, int mouseX, int mouseY) {
for (Component component : components) {
component.render(matrices, null, 0, 0, mouseX, mouseY);
component.render(context, null, 0, 0, mouseX, mouseY);
}
for (Component component : components) {
if (component.shouldPostRender()) {
component.postRender(matrices, null, 0, 0, mouseX, mouseY);
component.postRender(context, null, 0, 0, mouseX, mouseY);
}
}
}
Expand All @@ -54,13 +54,13 @@ protected void init() {
public abstract void initImpl();

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) {
public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) {
if (client.world != null) {
RenderUtil.drawRectangle(matrices, 0, 0, this.width, this.height, backgroundColor);
RenderUtil.drawRectangle(context, 0, 0, this.width, this.height, backgroundColor);
} else {
renderBackgroundTexture(matrices);
renderBackgroundTexture(context);
}
renderComponents(matrices, mouseX, mouseY);
renderComponents(context, mouseX, mouseY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
import org.jetbrains.annotations.Nullable;

import java.util.function.Consumer;
Expand Down Expand Up @@ -171,31 +171,31 @@ public boolean mouseClickedImpl(int x, int y, int mouseX, int mouseY, int button
}

/**
* An implementation of {@link Component#render(MatrixStack, PositionedRectangle, int, int, int, int)}.
* An implementation of {@link Component#render(DrawContext, PositionedRectangle, int, int, int, int)}.
* This render method automatically handles {@link #backgroundColor}, {@link #outlineColor}, {@link #selected},
* {@link #hovered}, and other various utilities.
*
* <p>You shouldn't override this. Instead override {@link #renderComponent(MatrixStack, PositionedRectangle, int, int, int, int)}
* @param matrices {@link MatrixStack} to invoke other render methods
* <p>You shouldn't override this. Instead override {@link #renderComponent(DrawContext, PositionedRectangle, int, int, int, int)}
* @param context {@link DrawContext} to invoke other render methods
* @param renderBounds {@link PositionedRectangle} an object that contains the boundaries of the object being rendered
* @param x The x value where the component should render
* @param y The y value where the component should render
* @param mouseX The x value of the mouse
* @param mouseY The y value of the mouse
*/
@Override
public void render(MatrixStack matrices, PositionedRectangle renderBounds, int x, int y, int mouseX, int mouseY) {
matrices.push();
public void render(DrawContext context, PositionedRectangle renderBounds, int x, int y, int mouseX, int mouseY) {
context.getMatrices().push();
if (zOffset != 0) {
matrices.translate(0, 0, zOffset);
context.getMatrices().translate(0, 0, zOffset);
}
if (backgroundColor != null) {
Rectangle bounds = getBoundingBox();
RenderUtil.drawRectangle(matrices, x, y, bounds.width(), bounds.height(), backgroundColor);
RenderUtil.drawRectangle(context, x, y, bounds.width(), bounds.height(), backgroundColor);
}
if (outlineColor != null) {
Rectangle bounds = getBoundingBox();
RenderUtil.drawOutline(matrices, x, y, bounds.width(), bounds.height(), outlineColor);
RenderUtil.drawOutline(context, x, y, bounds.width(), bounds.height(), outlineColor);
}
if (checkIfHovered(renderBounds, x, y, mouseX, mouseY)) {
hovered = true;
Expand All @@ -210,20 +210,20 @@ public void render(MatrixStack matrices, PositionedRectangle renderBounds, int x
}
previouslyHovered = false;
}
renderComponent(matrices, renderBounds, x, y, mouseX, mouseY);
matrices.pop();
renderComponent(context, renderBounds, x, y, mouseX, mouseY);
context.getMatrices().pop();
}

/**
* A method to render the component. This should be used in almost all cases.
* @param matrices {@link MatrixStack} to invoke other render methods
* @param context {@link DrawContext} to invoke other render methods
* @param renderBounds {@link PositionedRectangle} an object that contains the boundaries of the object being rendered
* @param x The x value where the component should render
* @param y The y value where the component should render
* @param mouseX The x value of the mouse
* @param mouseY The y value of the mouse
*/
public abstract void renderComponent(MatrixStack matrices, PositionedRectangle renderBounds, int x, int y, int mouseX, int mouseY);
public abstract void renderComponent(DrawContext context, PositionedRectangle renderBounds, int x, int y, int mouseX, int mouseY);

/**
* Checks to see if the current component is hovered by the mouse given values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.github.darkkronicle.darkkore.util.PositionedRectangle;
import io.github.darkkronicle.darkkore.util.Rectangle;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.gui.DrawContext;

/**
* An interface for handling GUI components within DarkKore.
Expand All @@ -16,14 +16,14 @@ public interface Component {
* Renders the component. Components should not have a position assigned to them. They should take in whatever
* x/y value is assigned and then render based off that position.
* If position is needed use {@link io.github.darkkronicle.darkkore.gui.components.transform.PositionedComponent}
* @param matrices {@link MatrixStack} to invoke other render methods
* @param context {@link DrawContext} to invoke other render methods
* @param renderBounds {@link PositionedRectangle} an object that contains the boundaries of the object being rendered
* @param x The x value where the component should render
* @param y The y value where the component should render
* @param mouseX The x value of the mouse
* @param mouseY The y value of the mouse
*/
void render(MatrixStack matrices, PositionedRectangle renderBounds, int x, int y, int mouseX, int mouseY);
void render(DrawContext context, PositionedRectangle renderBounds, int x, int y, int mouseX, int mouseY);

/**
* The bounding box (width height) of the component. This does not contain x/y data.
Expand All @@ -34,17 +34,17 @@ public interface Component {
/**
* Renders the component after everything has already been rendered. This should be used if overlapping is needed.
* This is used for hover descriptions.
* @param matrices {@link MatrixStack} to invoke other render methods
* @param context {@link DrawContext} to invoke other render methods
* @param renderBounds {@link PositionedRectangle} an object that contains the boundaries of the object being rendered
* @param x The x value where the component should render
* @param y The y value where the component should render
* @param mouseX The x value of the mouse
* @param mouseY The y value of the mouse
*/
default void postRender(MatrixStack matrices, PositionedRectangle renderBounds, int x, int y, int mouseX, int mouseY) {}
default void postRender(DrawContext context, PositionedRectangle renderBounds, int x, int y, int mouseX, int mouseY) {}

/**
* Whether this component should render post. If false {@link #postRender(MatrixStack, PositionedRectangle, int, int, int, int)}
* Whether this component should render post. If false {@link #postRender(DrawContext, PositionedRectangle, int, int, int, int)}
* won't be called
* @return True if should post render
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
import io.github.darkkronicle.darkkore.util.PositionedRectangle;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;

import java.util.function.Consumer;
Expand All @@ -35,10 +34,9 @@ public IconButtonComponent(Screen parent, Identifier icon, int width, int height
}

@Override
public void renderComponent(MatrixStack matrices, PositionedRectangle renderBounds, int x, int y, int mouseX, int mouseY) {
public void renderComponent(DrawContext context, PositionedRectangle renderBounds, int x, int y, int mouseX, int mouseY) {
RenderSystem.setShaderColor(shaderColor.red() / 255f, shaderColor.green() / 255f, shaderColor.blue() / 255f, shaderColor.alpha() / 255f);
RenderSystem.setShaderTexture(0, icon);
DrawableHelper.drawTexture(matrices, x + leftPadding, y + topPadding, width - (leftPadding + rightPadding), height - (topPadding - rightPadding), 0, 0, iconWidth, iconHeight, iconWidth, iconHeight);
context.drawTexture(icon, x + leftPadding, y + topPadding, width - (leftPadding + rightPadding), height - (topPadding - rightPadding), 0, 0, iconWidth, iconHeight, iconWidth, iconHeight);
RenderSystem.setShaderColor(1, 1, 1,1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import io.github.darkkronicle.darkkore.util.render.RenderUtil;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -47,10 +47,10 @@ public ItemComponent(Screen parent) {

/** {@inheritDoc} */
@Override
public void renderComponent(MatrixStack matrices, PositionedRectangle renderBounds, int x, int y, int mouseX, int mouseY) {
public void renderComponent(DrawContext context, PositionedRectangle renderBounds, int x, int y, int mouseX, int mouseY) {
ItemStack stack = getStack();
if (stack != null) {
RenderUtil.drawItem(matrices, stack, x + 1, y + 1, true);
RenderUtil.drawItem(context, stack, x + 1, y + 1, true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
import org.jetbrains.annotations.Nullable;

import java.util.function.Consumer;
Expand Down Expand Up @@ -95,10 +95,10 @@ public void setText(String text) {

/** {@inheritDoc} */
@Override
public void renderComponent(MatrixStack matrices, PositionedRectangle renderBounds, int x, int y, int mouseX, int mouseY) {
public void renderComponent(DrawContext context, PositionedRectangle renderBounds, int x, int y, int mouseX, int mouseY) {
textField.setX(x + 3);
textField.setY(y + 3);
textField.render(matrices, mouseX, mouseY, 0);
textField.render(context, mouseX, mouseY, 0);
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;

import java.util.List;
Expand Down Expand Up @@ -118,19 +118,19 @@ protected void updateHeight() {

/** {@inheritDoc} */
@Override
public void renderComponent(MatrixStack matrices, PositionedRectangle renderBounds, int x, int y, int mouseX, int mouseY) {
public void renderComponent(DrawContext context, PositionedRectangle renderBounds, int x, int y, int mouseX, int mouseY) {
int renderY = y + topPadding;
for (Text line : lines) {
if (center) {
// To center we get the middle value then subtract half the width
int width = MinecraftClient.getInstance().textRenderer.getWidth(line);
MinecraftClient.getInstance().textRenderer.drawWithShadow(
matrices, line,
x + leftPadding + (int) ((this.width - rightPadding) / 2) - (int) (width / 2),
context.drawTextWithShadow(MinecraftClient.getInstance().textRenderer, line,
x + leftPadding + ((this.width - rightPadding) / 2) - (width / 2),
renderY + topPadding, -1
);
} else {
MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, line, x + leftPadding, renderY + topPadding, -1);
context.drawTextWithShadow(MinecraftClient.getInstance().textRenderer,
line, x + leftPadding, renderY + topPadding, -1);
}
renderY += MinecraftClient.getInstance().textRenderer.fontHeight + linePadding;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.github.darkkronicle.darkkore.gui.components.impl;

import io.github.darkkronicle.darkkore.util.*;
import io.github.darkkronicle.darkkore.util.Color;
import io.github.darkkronicle.darkkore.util.FluidText;
import io.github.darkkronicle.darkkore.util.StringUtil;
import io.github.darkkronicle.darkkore.util.search.StringMatch;
import io.github.darkkronicle.darkkore.util.text.StyleFormatter;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import io.github.darkkronicle.darkkore.util.Rectangle;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;

/**
* A {@link MultiComponent} that automatically lists {@link Component}s with specified spacing and can handle
Expand Down Expand Up @@ -109,7 +109,7 @@ public void updateHeight() {

/** {@inheritDoc} */
@Override
public void renderComponent(MatrixStack matrices, PositionedRectangle renderBounds, int x, int y, int mouseX, int mouseY) {
public void renderComponent(DrawContext context, PositionedRectangle renderBounds, int x, int y, int mouseX, int mouseY) {
// Setup left margin
int offsetRenderX = leftPad;
// Setup top margin
Expand All @@ -128,7 +128,7 @@ public void renderComponent(MatrixStack matrices, PositionedRectangle renderBoun
}
if (renderBounds == null || new PositionedRectangle(x + offsetRenderX, renderY, bounds.width(), bounds.height()).intersects(renderBounds)) {
// Check if we are within the render bounds. Makes it so we don't render things off-screen.
component.render(matrices, renderBounds, x + offsetRenderX, renderY, mouseX, mouseY);
component.render(context, renderBounds, x + offsetRenderX, renderY, mouseX, mouseY);
}
// Move to the right
offsetRenderX += bounds.width() + componentXPad;
Expand All @@ -147,7 +147,7 @@ public boolean shouldPostRender() {

/** {@inheritDoc} */
@Override
public void postRender(MatrixStack matrices, PositionedRectangle renderBounds, int x, int y, int mouseX, int mouseY) {
public void postRender(DrawContext context, PositionedRectangle renderBounds, int x, int y, int mouseX, int mouseY) {
// We do the same thing as normal render again
int offsetRenderX = leftPad;
int renderY = y + topPad;
Expand All @@ -161,7 +161,7 @@ public void postRender(MatrixStack matrices, PositionedRectangle renderBounds, i
maxHeight = 0;
}
if (component.shouldPostRender() && (renderBounds == null || new PositionedRectangle(x + offsetRenderX, renderY, bounds.width(), bounds.height()).intersects(renderBounds))) {
component.postRender(matrices, renderBounds, x + offsetRenderX, renderY, mouseX, mouseY);
component.postRender(context, renderBounds, x + offsetRenderX, renderY, mouseX, mouseY);
}
offsetRenderX += bounds.width() + componentXPad;
maxHeight = Math.max(maxHeight, bounds.height());
Expand Down

0 comments on commit 05c4c57

Please sign in to comment.