diff --git a/.github/workflows/format-java.yml b/.github/workflows/format-java.yml
new file mode 100644
index 00000000..3b15c202
--- /dev/null
+++ b/.github/workflows/format-java.yml
@@ -0,0 +1,47 @@
+# Runs formatting requirements
+name: Java Formatting
+
+on:
+ push:
+ branches: ['1.20.1', '1.21.1']
+ paths: ['src/main/java/**', 'src/test/**']
+ pull_request:
+ paths: ['**']
+
+concurrency:
+ group: formatting-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ formatting:
+ name: Formatting
+ runs-on: ubuntu-latest
+ permissions:
+ pull-requests: read
+ steps:
+ - name: Checkout Repository
+ uses: actions/checkout@v6
+ with:
+ fetch-depth: 0 # do a full checkout instead of a shallow clone of HEAD so spotless's ratchetFrom works
+ - name: Check Path Filter
+ uses: dorny/paths-filter@v3
+ id: filter
+ with:
+ filters: |
+ code:
+ - 'src/main/java/**'
+ - 'src/test/**'
+ - name: Setup Java
+ if: steps.filter.outputs.code == 'true'
+ uses: actions/setup-java@v5
+ with:
+ distribution: 'temurin'
+ java-version: '21'
+ - name: Setup Gradle
+ if: steps.filter.outputs.code == 'true'
+ uses: gradle/actions/setup-gradle@v4
+ with:
+ cache-read-only: true
+ - name: Run Spotless Formatting Check with Gradle
+ if: steps.filter.outputs.code == 'true'
+ run: chmod +x ./gradlew && ./gradlew spotlessCheck --warning-mode all
diff --git a/build.gradle b/build.gradle
index ac53a560..a79d0f02 100755
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ plugins {
id 'maven-publish'
alias libs.plugins.modDevGradle
//alias libs.plugins.shadow
- alias libs.plugins.editorconfig
+ alias libs.plugins.spotless
alias libs.plugins.lombok
}
@@ -66,7 +66,7 @@ apply from: "$rootDir/gradle/scripts/repositories.gradle"
apply from: "$rootDir/dependencies.gradle"
apply from: "$rootDir/gradle/scripts/resources.gradle"
apply from: "$rootDir/gradle/scripts/publishing.gradle"
-apply from: "$rootDir/gradle/scripts/formatting.gradle"
+apply from: "$rootDir/gradle/scripts/spotless.gradle"
apply from: "$rootDir/gradle/scripts/docs.gradle"
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 11cd6f38..6e9d33bd 100755
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -5,7 +5,7 @@ neoForge = "21.1.265"
loader = "4"
parchment = "2024.11.17" # https://parchmentmc.org/docs/getting-started
shadow = "8.3.5"
-editorconfig = "0.1.0"
+spotless = "8.1.0"
modDevGradle = "2.0.86"
lombok = "8.14"
@@ -27,5 +27,5 @@ mcdevAnnotations = { module = "com.demonwav.mcdev:annotations", version.ref = "m
[plugins]
modDevGradle = { id = "net.neoforged.moddev", version.ref = "modDevGradle" }
shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
-editorconfig = { id = "org.ec4j.editorconfig", version.ref = "editorconfig" }
+spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
lombok = { id = "io.freefair.lombok", version.ref = "lombok" }
diff --git a/gradle/scripts/formatting.gradle b/gradle/scripts/formatting.gradle
deleted file mode 100644
index 677adf1c..00000000
--- a/gradle/scripts/formatting.gradle
+++ /dev/null
@@ -1,6 +0,0 @@
-// EditorConfig auto-formatter
-// See https://github.com/ec4j/editorconfig-gradle-plugin
-// Can be locally toggled via @formatter:off/@formatter:on comments
-editorconfig {
- includes = ['*']
-}
diff --git a/gradle/scripts/spotless.gradle b/gradle/scripts/spotless.gradle
new file mode 100644
index 00000000..225a5a8f
--- /dev/null
+++ b/gradle/scripts/spotless.gradle
@@ -0,0 +1,27 @@
+// Spotless auto-formatter
+// See https://github.com/diffplug/spotless/tree/main/plugin-gradle
+// Can be locally toggled via spotless:off/spotless:on comments
+spotless {
+ encoding 'UTF-8'
+ ratchetFrom 'origin/1.21.1'
+
+ format 'misc', {
+ target '.gitignore'
+
+ trimTrailingWhitespace()
+ leadingTabsToSpaces()
+ endWithNewline()
+ }
+ java {
+ target 'src/main/java/**/*.java', 'src/test/java/**/*.java'
+
+ def orderFile = file("$rootDir/spotless/spotless.importorder")
+ def formatFile = file("$rootDir/spotless/spotless.eclipseformat.xml")
+
+ toggleOffOn()
+ importOrderFile(orderFile)
+ removeUnusedImports('cleanthat-javaparser-unnecessaryimport')
+ endWithNewline()
+ eclipse('4.36').configFile(formatFile)
+ }
+}
diff --git a/spotless/spotless.eclipseformat.xml b/spotless/spotless.eclipseformat.xml
new file mode 100644
index 00000000..8db01de4
--- /dev/null
+++ b/spotless/spotless.eclipseformat.xml
@@ -0,0 +1,400 @@
+
+
parentSize * relativeValue - selfSize * anchor.
*
* @param val relative left edge to parent left edge distance
- * @param anchor determines the relative position which is used to calculate the actual position with the relative value
+ * @param anchor determines the relative position which is used to calculate the actual position with the relative
+ * value
* @return this
*/
default W leftRelAnchor(float val, float anchor) {
@@ -281,17 +301,22 @@ default W leftRelAnchor(float val, float anchor) {
}
/**
- * Sets the relative distance from this widgets left edge to the resizers widget left edge (usually between 0.0 and 1.0) with an offset
+ * Sets the relative distance from this widgets left edge to the resizers widget left edge (usually between 0.0 and
+ * 1.0) with an offset
* and an anchor.
- * 0.0 for the relative value means the left edge touches the parent left edge. 1.0 means the right edge touches the parent right edge.
- * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be negative.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget. By default,
+ * 0.0 for the relative value means the left edge touches the parent left edge. 1.0 means the right edge touches the
+ * parent right edge.
+ * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be
+ * negative.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget. By default,
* the anchor is equal to the relative value. The formular for calculating the position is
* parentSize * relativeValue - selfSize * anchor.
*
* @param val relative left edge to parent left edge distance
* @param offset additional distance offset in pixel
- * @param anchor determines the relative position which is used to calculate the actual position with the relative value
+ * @param anchor determines the relative position which is used to calculate the actual position with the relative
+ * value
* @return this
*/
default W leftRel(float val, int offset, float anchor) {
@@ -300,18 +325,24 @@ default W leftRel(float val, int offset, float anchor) {
}
/**
- * Sets the relative distance from this widgets left edge to the resizers widget left edge (usually between 0.0 and 1.0) with an offset
+ * Sets the relative distance from this widgets left edge to the resizers widget left edge (usually between 0.0 and
+ * 1.0) with an offset
* and an anchor.
- * 0.0 for the relative value means the left edge touches the parent left edge. 1.0 means the right edge touches the parent right edge.
- * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be negative.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget. By default,
+ * 0.0 for the relative value means the left edge touches the parent left edge. 1.0 means the right edge touches the
+ * parent right edge.
+ * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be
+ * negative.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget. By default,
* the anchor is equal to the relative value. The formular for calculating the position is
* parentSize * relativeValue - selfSize * anchor.
*
* @param val left edge to parent left edge distance
* @param offset additional distance offset in pixel
- * @param anchor determines the relative position which is used to calculate the actual position with the relative value
- * @param measure determines if the val param should be a relative value or in pixel, the anchor does nothing in pixel
+ * @param anchor determines the relative position which is used to calculate the actual position with the relative
+ * value
+ * @param measure determines if the val param should be a relative value or in pixel, the anchor does
+ * nothing in pixel
* @return this
*/
default W left(float val, int offset, float anchor, Unit.Measure measure) {
@@ -332,9 +363,12 @@ default W left(DoubleSupplier val, Unit.Measure measure) {
}
/**
- * Sets the relative distance from this widgets left edge to the resizers widget left edge (usually between 0.0 and 1.0) with an offset.
- * 0.0 for the relative value means the left edge touches the parent left edge. 1.0 means the right edge touches the parent right edge.
- * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be negative.
+ * Sets the relative distance from this widgets left edge to the resizers widget left edge (usually between 0.0 and
+ * 1.0) with an offset.
+ * 0.0 for the relative value means the left edge touches the parent left edge. 1.0 means the right edge touches the
+ * parent right edge.
+ * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be
+ * negative.
*
* @param val relative left edge to parent left edge distance function which is called on every resize
* @param offset additional distance offset in pixel
@@ -346,14 +380,18 @@ default W leftRelOffset(DoubleSupplier val, int offset) {
}
/**
- * Sets the relative distance from this widgets left edge to the resizers widget left edge (usually between 0.0 and 1.0) with an anchor.
- * 0.0 for the relative value means the left edge touches the parent left edge. 1.0 means the right edge touches the parent right edge.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget. By default,
+ * Sets the relative distance from this widgets left edge to the resizers widget left edge (usually between 0.0 and
+ * 1.0) with an anchor.
+ * 0.0 for the relative value means the left edge touches the parent left edge. 1.0 means the right edge touches the
+ * parent right edge.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget. By default,
* the anchor is equal to the relative value. The formular for calculating the position is
* parentSize * relativeValue - selfSize * anchor.
*
* @param val relative left edge to parent left edge distance function which is called on every resize
- * @param anchor determines the relative position which is used to calculate the actual position with the relative value
+ * @param anchor determines the relative position which is used to calculate the actual position with the relative
+ * value
* @return this
*/
default W leftRelAnchor(DoubleSupplier val, float anchor) {
@@ -362,17 +400,22 @@ default W leftRelAnchor(DoubleSupplier val, float anchor) {
}
/**
- * Sets the relative distance from this widgets left edge to the resizers widget left edge (usually between 0.0 and 1.0) with an offset
+ * Sets the relative distance from this widgets left edge to the resizers widget left edge (usually between 0.0 and
+ * 1.0) with an offset
* and an anchor.
- * 0.0 for the relative value means the left edge touches the parent left edge. 1.0 means the right edge touches the parent right edge.
- * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be negative.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget. By default,
+ * 0.0 for the relative value means the left edge touches the parent left edge. 1.0 means the right edge touches the
+ * parent right edge.
+ * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be
+ * negative.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget. By default,
* the anchor is equal to the relative value. The formular for calculating the position is
* parentSize * relativeValue - selfSize * anchor.
*
* @param val relative left edge to parent left edge distance
* @param offset additional distance offset in pixel
- * @param anchor determines the relative position which is used to calculate the actual position with the relative value
+ * @param anchor determines the relative position which is used to calculate the actual position with the relative
+ * value
* @return this
*/
default W leftRel(DoubleSupplier val, int offset, float anchor) {
@@ -392,7 +435,8 @@ default W right(int val) {
}
/**
- * Sets the relative distance from this widgets right edge to the resizers widget right edge (usually between 0.0 and 1.0).
+ * Sets the relative distance from this widgets right edge to the resizers widget right edge (usually between 0.0
+ * and 1.0).
* 0.0 means the right edge touches the parent right edge. 1.0 means the left edge touches the parent left edge.
*
* @param val relative right edge to parent right edge distance
@@ -404,9 +448,12 @@ default W rightRel(float val) {
}
/**
- * Sets the relative distance from this widgets right edge to the resizers widget right edge (usually between 0.0 and 1.0) with an offset.
- * 0.0 for the relative value means the right edge touches the parent right edge. 1.0 means the left edge touches the parent left edge.
- * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be negative.
+ * Sets the relative distance from this widgets right edge to the resizers widget right edge (usually between 0.0
+ * and 1.0) with an offset.
+ * 0.0 for the relative value means the right edge touches the parent right edge. 1.0 means the left edge touches
+ * the parent left edge.
+ * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be
+ * negative.
*
* @param val relative right edge to parent right edge distance
* @param offset additional distance offset in pixel
@@ -418,14 +465,18 @@ default W rightRelOffset(float val, int offset) {
}
/**
- * Sets the relative distance from this widgets right edge to the resizers widget right edge (usually between 0.0 and 1.0) with an anchor.
- * 0.0 for the relative value means the right edge touches the parent right edge. 1.0 means the left edge touches the parent left edge.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget. By default,
+ * Sets the relative distance from this widgets right edge to the resizers widget right edge (usually between 0.0
+ * and 1.0) with an anchor.
+ * 0.0 for the relative value means the right edge touches the parent right edge. 1.0 means the left edge touches
+ * the parent left edge.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget. By default,
* the anchor is equal to the relative value. The formular for calculating the position is
* parentSize * relativeValue - selfSize * anchor.
*
* @param val relative right edge to parent right edge distance
- * @param anchor determines the relative position which is used to calculate the actual position with the relative value
+ * @param anchor determines the relative position which is used to calculate the actual position with the relative
+ * value
* @return this
*/
default W rightRelAnchor(float val, float anchor) {
@@ -434,17 +485,22 @@ default W rightRelAnchor(float val, float anchor) {
}
/**
- * Sets the relative distance from this widgets right edge to the resizers widget right edge (usually between 0.0 and 1.0) with an offset
+ * Sets the relative distance from this widgets right edge to the resizers widget right edge (usually between 0.0
+ * and 1.0) with an offset
* and an anchor.
- * 0.0 for the relative value means the right edge touches the parent right edge. 1.0 means the left edge touches the parent left edge.
- * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be negative.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget. By default,
+ * 0.0 for the relative value means the right edge touches the parent right edge. 1.0 means the left edge touches
+ * the parent left edge.
+ * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be
+ * negative.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget. By default,
* the anchor is equal to the relative value. The formular for calculating the position is
* parentSize * relativeValue - selfSize * anchor.
*
* @param val relative right edge to parent right edge distance
* @param offset additional distance offset in pixel
- * @param anchor determines the relative position which is used to calculate the actual position with the relative value
+ * @param anchor determines the relative position which is used to calculate the actual position with the relative
+ * value
* @return this
*/
default W rightRel(float val, int offset, float anchor) {
@@ -453,18 +509,24 @@ default W rightRel(float val, int offset, float anchor) {
}
/**
- * Sets the relative distance from this widgets right edge to the resizers widget right edge (usually between 0.0 and 1.0) with an offset
+ * Sets the relative distance from this widgets right edge to the resizers widget right edge (usually between 0.0
+ * and 1.0) with an offset
* and an anchor.
- * 0.0 for the relative value means the right edge touches the parent right edge. 1.0 means the left edge touches the parent left edge.
- * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be negative.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget. By default,
+ * 0.0 for the relative value means the right edge touches the parent right edge. 1.0 means the left edge touches
+ * the parent left edge.
+ * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be
+ * negative.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget. By default,
* the anchor is equal to the relative value. The formular for calculating the position is
* parentSize * relativeValue - selfSize * anchor.
*
* @param val right edge to parent right edge distance
* @param offset additional distance offset in pixel
- * @param anchor determines the relative position which is used to calculate the actual position with the relative value
- * @param measure determines if the val param should be a relative value or in pixel, the anchor does nothing in pixel
+ * @param anchor determines the relative position which is used to calculate the actual position with the relative
+ * value
+ * @param measure determines if the val param should be a relative value or in pixel, the anchor does
+ * nothing in pixel
* @return this
*/
default W right(float val, int offset, float anchor, Unit.Measure measure) {
@@ -485,9 +547,12 @@ default W right(DoubleSupplier val, Unit.Measure measure) {
}
/**
- * Sets the relative distance from this widgets right edge to the resizers widget right edge (usually between 0.0 and 1.0) with an offset.
- * 0.0 for the relative value means the right edge touches the parent right edge. 1.0 means the left edge touches the parent left edge.
- * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be negative.
+ * Sets the relative distance from this widgets right edge to the resizers widget right edge (usually between 0.0
+ * and 1.0) with an offset.
+ * 0.0 for the relative value means the right edge touches the parent right edge. 1.0 means the left edge touches
+ * the parent left edge.
+ * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be
+ * negative.
*
* @param val relative right edge to parent right edge distance function which is called on every resize
* @param offset additional distance offset in pixel
@@ -499,14 +564,18 @@ default W rightRelOffset(DoubleSupplier val, int offset) {
}
/**
- * Sets the relative distance from this widgets right edge to the resizers widget right edge (usually between 0.0 and 1.0) with an anchor.
- * 0.0 for the relative value means the right edge touches the parent right edge. 1.0 means the left edge touches the parent left edge.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget. By default,
+ * Sets the relative distance from this widgets right edge to the resizers widget right edge (usually between 0.0
+ * and 1.0) with an anchor.
+ * 0.0 for the relative value means the right edge touches the parent right edge. 1.0 means the left edge touches
+ * the parent left edge.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget. By default,
* the anchor is equal to the relative value. The formular for calculating the position is
* parentSize * relativeValue - selfSize * anchor.
*
* @param val relative right edge to parent right edge distance function which is called on every resize
- * @param anchor determines the relative position which is used to calculate the actual position with the relative value
+ * @param anchor determines the relative position which is used to calculate the actual position with the relative
+ * value
* @return this
*/
default W rightRelAnchor(DoubleSupplier val, float anchor) {
@@ -515,17 +584,22 @@ default W rightRelAnchor(DoubleSupplier val, float anchor) {
}
/**
- * Sets the relative distance from this widgets right edge to the resizers widget right edge (usually between 0.0 and 1.0) with an offset
+ * Sets the relative distance from this widgets right edge to the resizers widget right edge (usually between 0.0
+ * and 1.0) with an offset
* and an anchor.
- * 0.0 for the relative value means the right edge touches the parent right edge. 1.0 means the left edge touches the parent left edge.
- * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be negative.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget. By default,
+ * 0.0 for the relative value means the right edge touches the parent right edge. 1.0 means the left edge touches
+ * the parent left edge.
+ * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be
+ * negative.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget. By default,
* the anchor is equal to the relative value. The formular for calculating the position is
* parentSize * relativeValue - selfSize * anchor.
*
* @param val relative right edge to parent right edge distance
* @param offset additional distance offset in pixel
- * @param anchor determines the relative position which is used to calculate the actual position with the relative value
+ * @param anchor determines the relative position which is used to calculate the actual position with the relative
+ * value
* @return this
*/
default W rightRel(DoubleSupplier val, int offset, float anchor) {
@@ -545,7 +619,8 @@ default W top(int val) {
}
/**
- * Sets the relative distance from this widgets top edge to the resizers widget top edge (usually between 0.0 and 1.0).
+ * Sets the relative distance from this widgets top edge to the resizers widget top edge (usually between 0.0 and
+ * 1.0).
* 0.0 means the top edge touches the parent top edge. 1.0 means the bottom edge touches the parent bottom edge.
*
* @param val relative top edge to parent top edge distance
@@ -557,9 +632,12 @@ default W topRel(float val) {
}
/**
- * Sets the relative distance from this widgets top edge to the resizers widget top edge (usually between 0.0 and 1.0) with an offset.
- * 0.0 for the relative value means the top edge touches the parent top edge. 1.0 means the bottom edge touches the parent bottom edge.
- * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be negative.
+ * Sets the relative distance from this widgets top edge to the resizers widget top edge (usually between 0.0 and
+ * 1.0) with an offset.
+ * 0.0 for the relative value means the top edge touches the parent top edge. 1.0 means the bottom edge touches the
+ * parent bottom edge.
+ * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be
+ * negative.
*
* @param val relative top edge to parent top edge distance
* @param offset additional distance offset in pixel
@@ -571,14 +649,18 @@ default W topRelOffset(float val, int offset) {
}
/**
- * Sets the relative distance from this widgets top edge to the resizers widget top edge (usually between 0.0 and 1.0) with an anchor.
- * 0.0 for the relative value means the top edge touches the parent top edge. 1.0 means the bottom edge touches the parent bottom edge.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget. By default,
+ * Sets the relative distance from this widgets top edge to the resizers widget top edge (usually between 0.0 and
+ * 1.0) with an anchor.
+ * 0.0 for the relative value means the top edge touches the parent top edge. 1.0 means the bottom edge touches the
+ * parent bottom edge.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget. By default,
* the anchor is equal to the relative value. The formular for calculating the position is
* parentSize * relativeValue - selfSize * anchor.
*
* @param val relative top edge to parent top edge distance
- * @param anchor determines the relative position which is used to calculate the actual position with the relative value
+ * @param anchor determines the relative position which is used to calculate the actual position with the relative
+ * value
* @return this
*/
default W topRelAnchor(float val, float anchor) {
@@ -587,17 +669,22 @@ default W topRelAnchor(float val, float anchor) {
}
/**
- * Sets the relative distance from this widgets top edge to the resizers widget top edge (usually between 0.0 and 1.0) with an offset
+ * Sets the relative distance from this widgets top edge to the resizers widget top edge (usually between 0.0 and
+ * 1.0) with an offset
* and an anchor.
- * 0.0 for the relative value means the top edge touches the parent top edge. 1.0 means the bottom edge touches the parent bottom edge.
- * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be negative.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget. By default,
+ * 0.0 for the relative value means the top edge touches the parent top edge. 1.0 means the bottom edge touches the
+ * parent bottom edge.
+ * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be
+ * negative.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget. By default,
* the anchor is equal to the relative value. The formular for calculating the position is
* parentSize * relativeValue - selfSize * anchor.
*
* @param val relative top edge to parent top edge distance
* @param offset additional distance offset in pixel
- * @param anchor determines the relative position which is used to calculate the actual position with the relative value
+ * @param anchor determines the relative position which is used to calculate the actual position with the relative
+ * value
* @return this
*/
default W topRel(float val, int offset, float anchor) {
@@ -606,18 +693,24 @@ default W topRel(float val, int offset, float anchor) {
}
/**
- * Sets the relative distance from this widgets top edge to the resizers widget top edge (usually between 0.0 and 1.0) with an offset
+ * Sets the relative distance from this widgets top edge to the resizers widget top edge (usually between 0.0 and
+ * 1.0) with an offset
* and an anchor.
- * 0.0 for the relative value means the top edge touches the parent top edge. 1.0 means the bottom edge touches the parent bottom edge.
- * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be negative.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget. By default,
+ * 0.0 for the relative value means the top edge touches the parent top edge. 1.0 means the bottom edge touches the
+ * parent bottom edge.
+ * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be
+ * negative.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget. By default,
* the anchor is equal to the relative value. The formular for calculating the position is
* parentSize * relativeValue - selfSize * anchor.
*
* @param val top edge to parent top edge distance
* @param offset additional distance offset in pixel
- * @param anchor determines the relative position which is used to calculate the actual position with the relative value
- * @param measure determines if the val param should be a relative value or in pixel, the anchor does nothing in pixel
+ * @param anchor determines the relative position which is used to calculate the actual position with the relative
+ * value
+ * @param measure determines if the val param should be a relative value or in pixel, the anchor does
+ * nothing in pixel
* @return this
*/
default W top(float val, int offset, float anchor, Unit.Measure measure) {
@@ -638,9 +731,12 @@ default W top(DoubleSupplier val, Unit.Measure measure) {
}
/**
- * Sets the relative distance from this widgets top edge to the resizers widget top edge (usually between 0.0 and 1.0) with an offset.
- * 0.0 for the relative value means the top edge touches the parent top edge. 1.0 means the bottom edge touches the parent bottom edge.
- * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be negative.
+ * Sets the relative distance from this widgets top edge to the resizers widget top edge (usually between 0.0 and
+ * 1.0) with an offset.
+ * 0.0 for the relative value means the top edge touches the parent top edge. 1.0 means the bottom edge touches the
+ * parent bottom edge.
+ * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be
+ * negative.
*
* @param val relative top edge to parent top edge distance function which is called on every resize
* @param offset additional distance offset in pixel
@@ -652,14 +748,18 @@ default W topRelOffset(DoubleSupplier val, int offset) {
}
/**
- * Sets the relative distance from this widgets top edge to the resizers widget top edge (usually between 0.0 and 1.0) with an anchor.
- * 0.0 for the relative value means the top edge touches the parent top edge. 1.0 means the bottom edge touches the parent bottom edge.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget. By default,
+ * Sets the relative distance from this widgets top edge to the resizers widget top edge (usually between 0.0 and
+ * 1.0) with an anchor.
+ * 0.0 for the relative value means the top edge touches the parent top edge. 1.0 means the bottom edge touches the
+ * parent bottom edge.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget. By default,
* the anchor is equal to the relative value. The formular for calculating the position is
* parentSize * relativeValue - selfSize * anchor.
*
* @param val relative top edge to parent top edge distance function which is called on every resize
- * @param anchor determines the relative position which is used to calculate the actual position with the relative value
+ * @param anchor determines the relative position which is used to calculate the actual position with the relative
+ * value
* @return this
*/
default W topRelAnchor(DoubleSupplier val, float anchor) {
@@ -668,17 +768,22 @@ default W topRelAnchor(DoubleSupplier val, float anchor) {
}
/**
- * Sets the relative distance from this widgets top edge to the resizers widget top edge (usually between 0.0 and 1.0) with an offset
+ * Sets the relative distance from this widgets top edge to the resizers widget top edge (usually between 0.0 and
+ * 1.0) with an offset
* and an anchor.
- * 0.0 for the relative value means the top edge touches the parent top edge. 1.0 means the bottom edge touches the parent bottom edge.
- * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be negative.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget. By default,
+ * 0.0 for the relative value means the top edge touches the parent top edge. 1.0 means the bottom edge touches the
+ * parent bottom edge.
+ * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be
+ * negative.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget. By default,
* the anchor is equal to the relative value. The formular for calculating the position is
* parentSize * relativeValue - selfSize * anchor.
*
* @param val relative top edge to parent top edge distance
* @param offset additional distance offset in pixel
- * @param anchor determines the relative position which is used to calculate the actual position with the relative value
+ * @param anchor determines the relative position which is used to calculate the actual position with the relative
+ * value
* @return this
*/
default W topRel(DoubleSupplier val, int offset, float anchor) {
@@ -698,7 +803,8 @@ default W bottom(int val) {
}
/**
- * Sets the relative distance from this widgets bottom edge to the resizers widget bottom edge (usually between 0.0 and 1.0).
+ * Sets the relative distance from this widgets bottom edge to the resizers widget bottom edge (usually between 0.0
+ * and 1.0).
* 0.0 means the bottom edge touches the parent bottom edge. 1.0 means the top edge touches the parent top edge.
*
* @param val relative bottom edge to parent bottom edge distance
@@ -710,9 +816,12 @@ default W bottomRel(float val) {
}
/**
- * Sets the relative distance from this widgets bottom edge to the resizers widget bottom edge (usually between 0.0 and 1.0) with an offset.
- * 0.0 for the relative value means the bottom edge touches the parent bottom edge. 1.0 means the top edge touches the parent top edge.
- * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be negative.
+ * Sets the relative distance from this widgets bottom edge to the resizers widget bottom edge (usually between 0.0
+ * and 1.0) with an offset.
+ * 0.0 for the relative value means the bottom edge touches the parent bottom edge. 1.0 means the top edge touches
+ * the parent top edge.
+ * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be
+ * negative.
*
* @param val relative bottom edge to parent bottom edge distance
* @param offset additional distance offset in pixel
@@ -724,14 +833,18 @@ default W bottomRelOffset(float val, int offset) {
}
/**
- * Sets the relative distance from this widgets bottom edge to the resizers widget bottom edge (usually between 0.0 and 1.0) with an anchor.
- * 0.0 for the relative value means the bottom edge touches the parent bottom edge. 1.0 means the top edge touches the parent top edge.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget. By default,
+ * Sets the relative distance from this widgets bottom edge to the resizers widget bottom edge (usually between 0.0
+ * and 1.0) with an anchor.
+ * 0.0 for the relative value means the bottom edge touches the parent bottom edge. 1.0 means the top edge touches
+ * the parent top edge.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget. By default,
* the anchor is equal to the relative value. The formular for calculating the position is
* parentSize * relativeValue - selfSize * anchor.
*
* @param val relative bottom edge to parent bottom edge distance
- * @param anchor determines the relative position which is used to calculate the actual position with the relative value
+ * @param anchor determines the relative position which is used to calculate the actual position with the relative
+ * value
* @return this
*/
default W bottomRelAnchor(float val, float anchor) {
@@ -740,17 +853,22 @@ default W bottomRelAnchor(float val, float anchor) {
}
/**
- * Sets the relative distance from this widgets bottom edge to the resizers widget bottom edge (usually between 0.0 and 1.0) with an offset
+ * Sets the relative distance from this widgets bottom edge to the resizers widget bottom edge (usually between 0.0
+ * and 1.0) with an offset
* and an anchor.
- * 0.0 for the relative value means the bottom edge touches the parent bottom edge. 1.0 means the top edge touches the parent top edge.
- * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be negative.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget. By default,
+ * 0.0 for the relative value means the bottom edge touches the parent bottom edge. 1.0 means the top edge touches
+ * the parent top edge.
+ * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be
+ * negative.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget. By default,
* the anchor is equal to the relative value. The formular for calculating the position is
* parentSize * relativeValue - selfSize * anchor.
*
* @param val relative bottom edge to parent bottom edge distance
* @param offset additional distance offset in pixel
- * @param anchor determines the relative position which is used to calculate the actual position with the relative value
+ * @param anchor determines the relative position which is used to calculate the actual position with the relative
+ * value
* @return this
*/
default W bottomRel(float val, int offset, float anchor) {
@@ -759,18 +877,24 @@ default W bottomRel(float val, int offset, float anchor) {
}
/**
- * Sets the relative distance from this widgets bottom edge to the resizers widget bottom edge (usually between 0.0 and 1.0) with an offset
+ * Sets the relative distance from this widgets bottom edge to the resizers widget bottom edge (usually between 0.0
+ * and 1.0) with an offset
* and an anchor.
- * 0.0 for the relative value means the bottom edge touches the parent bottom edge. 1.0 means the top edge touches the parent top edge.
- * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be negative.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget. By default,
+ * 0.0 for the relative value means the bottom edge touches the parent bottom edge. 1.0 means the top edge touches
+ * the parent top edge.
+ * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be
+ * negative.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget. By default,
* the anchor is equal to the relative value. The formular for calculating the position is
* parentSize * relativeValue - selfSize * anchor.
*
* @param val bottom edge to parent bottom edge distance
* @param offset additional distance offset in pixel
- * @param anchor determines the relative position which is used to calculate the actual position with the relative value
- * @param measure determines if the val param should be a relative value or in pixel, the anchor does nothing in pixel
+ * @param anchor determines the relative position which is used to calculate the actual position with the relative
+ * value
+ * @param measure determines if the val param should be a relative value or in pixel, the anchor does
+ * nothing in pixel
* @return this
*/
default W bottom(float val, int offset, float anchor, Unit.Measure measure) {
@@ -779,7 +903,8 @@ default W bottom(float val, int offset, float anchor, Unit.Measure measure) {
}
/**
- * Sets the distance from this widgets bottom edge to the resizers widget bottom edge in pixel or as a relative value.
+ * Sets the distance from this widgets bottom edge to the resizers widget bottom edge in pixel or as a relative
+ * value.
*
* @param val bottom edge to parent bottom edge distance function which is called on every resize
* @param measure determines if the val param should be a relative value or in pixel
@@ -791,9 +916,12 @@ default W bottom(DoubleSupplier val, Unit.Measure measure) {
}
/**
- * Sets the relative distance from this widgets bottom edge to the resizers widget bottom edge (usually between 0.0 and 1.0) with an offset.
- * 0.0 for the relative value means the left edge touches the parent left edge. 1.0 means the top edge touches the parent top edge.
- * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be negative.
+ * Sets the relative distance from this widgets bottom edge to the resizers widget bottom edge (usually between 0.0
+ * and 1.0) with an offset.
+ * 0.0 for the relative value means the left edge touches the parent left edge. 1.0 means the top edge touches the
+ * parent top edge.
+ * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be
+ * negative.
*
* @param val relative bottom edge to parent bottom edge distance function which is called on every resize
* @param offset additional distance offset in pixel
@@ -805,14 +933,18 @@ default W bottomRelOffset(DoubleSupplier val, int offset) {
}
/**
- * Sets the relative distance from this widgets bottom edge to the resizers widget bottom edge (usually between 0.0 and 1.0) with an anchor.
- * 0.0 for the relative value means the bottom edge touches the parent left bottom. 1.0 means the top edge touches the parent top edge.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget. By default,
+ * Sets the relative distance from this widgets bottom edge to the resizers widget bottom edge (usually between 0.0
+ * and 1.0) with an anchor.
+ * 0.0 for the relative value means the bottom edge touches the parent left bottom. 1.0 means the top edge touches
+ * the parent top edge.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget. By default,
* the anchor is equal to the relative value. The formular for calculating the position is
* parentSize * relativeValue - selfSize * anchor.
*
* @param val relative bottom edge to parent bottom edge distance function which is called on every resize
- * @param anchor determines the relative position which is used to calculate the actual position with the relative value
+ * @param anchor determines the relative position which is used to calculate the actual position with the relative
+ * value
* @return this
*/
default W bottomRelAnchor(DoubleSupplier val, float anchor) {
@@ -821,17 +953,22 @@ default W bottomRelAnchor(DoubleSupplier val, float anchor) {
}
/**
- * Sets the relative distance from this widgets bottom edge to the resizers widget bottom edge (usually between 0.0 and 1.0) with an offset
+ * Sets the relative distance from this widgets bottom edge to the resizers widget bottom edge (usually between 0.0
+ * and 1.0) with an offset
* and an anchor.
- * 0.0 for the relative value means the bottom edge touches the parent bottom edge. 1.0 means the top edge touches the parent top edge.
- * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be negative.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget. By default,
+ * 0.0 for the relative value means the bottom edge touches the parent bottom edge. 1.0 means the top edge touches
+ * the parent top edge.
+ * The offset is in pixel and is added after the position with the relative value is calculated. The offset can be
+ * negative.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget. By default,
* the anchor is equal to the relative value. The formular for calculating the position is
* parentSize * relativeValue - selfSize * anchor.
*
* @param val relative bottom edge to parent bottom edge distance
* @param offset additional distance offset in pixel
- * @param anchor determines the relative position which is used to calculate the actual position with the relative value
+ * @param anchor determines the relative position which is used to calculate the actual position with the relative
+ * value
* @return this
*/
default W bottomRel(DoubleSupplier val, int offset, float anchor) {
@@ -863,7 +1000,8 @@ default W widthRel(float val) {
/**
* Sets the relative width of this widget with an offset. 1.0 is the same size as the resizer parent.
- * The offset is in pixel and is added after the size with the relative value is calculated. The offset can be negative.
+ * The offset is in pixel and is added after the size with the relative value is calculated. The offset can be
+ * negative.
*
* @param val relative width
* @param offset additional size offset in pixel
@@ -888,7 +1026,8 @@ default W width(float val, Unit.Measure measure) {
/**
* Sets the width of this widget in pixel or as a relative value with an offset.
- * The offset is in pixel and is added after the size with the relative value is calculated. The offset can be negative.
+ * The offset is in pixel and is added after the size with the relative value is calculated. The offset can be
+ * negative.
*
* @param val relative width function which is called on every resize
* @param offset additional size offset in pixel
@@ -947,7 +1086,8 @@ default W height(float val, Unit.Measure measure) {
/**
* Sets the relative height of this widget with an offset. 1.0 is the same size as the resizer parent.
- * The offset is in pixel and is added after the size with the relative value is calculated. The offset can be negative.
+ * The offset is in pixel and is added after the size with the relative value is calculated. The offset can be
+ * negative.
*
* @param val relative height
* @param offset additional size offset in pixel
@@ -960,7 +1100,8 @@ default W heightRelOffset(float val, int offset) {
/**
* Sets the width of this widget in pixel or as a relative value with an offset.
- * The offset is in pixel and is added after the size with the relative value is calculated. The offset can be negative.
+ * The offset is in pixel and is added after the size with the relative value is calculated. The offset can be
+ * negative.
*
* @param val relative width function which is called on every resize
* @param offset additional size offset in pixel
@@ -1008,7 +1149,8 @@ default W posRel(float x, float y) {
}
/**
- * Sets the relative position with an {@link Alignment}. Combines {@link #leftRel(float)} and {@link #topRel(float)}.
+ * Sets the relative position with an {@link Alignment}. Combines {@link #leftRel(float)} and
+ * {@link #topRel(float)}.
*
* @param alignment relative position
* @return this
@@ -1031,7 +1173,8 @@ default W size(int w, int h) {
}
/**
- * Sets the relative width and height of this widget. Combines {@link #widthRel(float)} and {@link #heightRel(float)}.
+ * Sets the relative width and height of this widget. Combines {@link #widthRel(float)} and
+ * {@link #heightRel(float)}.
*
* @param w relative width
* @param h relative height
@@ -1053,7 +1196,8 @@ default W size(int val) {
}
/**
- * Sets the relative width and height of this widget. Combines {@link #widthRel(float)} and {@link #heightRel(float)}.
+ * Sets the relative width and height of this widget. Combines {@link #widthRel(float)} and
+ * {@link #heightRel(float)}.
*
* @param val relative width and height
* @return this
@@ -1091,7 +1235,8 @@ default W full() {
/**
* Sets the anchor on the left side of the widget.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget.
*
* @param val anchor on the left side
* @return this
@@ -1103,7 +1248,8 @@ default W anchorLeft(float val) {
/**
* Sets the anchor on the right side of the widget.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget.
*
* @param val anchor on the right side
* @return this
@@ -1115,7 +1261,8 @@ default W anchorRight(float val) {
/**
* Sets the anchor on the top side of the widget.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget.
*
* @param val anchor on the top side
* @return this
@@ -1127,7 +1274,8 @@ default W anchorTop(float val) {
/**
* Sets the anchor on the bottom side of the widget.
- * The anchor determines what relative position inside this widget is used to calculate the relative position of the widget.
+ * The anchor determines what relative position inside this widget is used to calculate the relative position of the
+ * widget.
*
* @param val anchor on the bottom side
* @return this
diff --git a/src/main/java/brachy/modularui/api/widget/IWidget.java b/src/main/java/brachy/modularui/api/widget/IWidget.java
index a7278df5..0b7cdfe6 100644
--- a/src/main/java/brachy/modularui/api/widget/IWidget.java
+++ b/src/main/java/brachy/modularui/api/widget/IWidget.java
@@ -13,9 +13,8 @@
import brachy.modularui.widget.sizer.Area;
import brachy.modularui.widget.sizer.StandardResizer;
-import com.mojang.serialization.Codec;
-
import com.google.common.base.CharMatcher;
+import com.mojang.serialization.Codec;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import it.unimi.dsi.fastutil.objects.ObjectList;
import org.jetbrains.annotations.NotNull;
@@ -75,7 +74,8 @@ default boolean hasParent() {
/**
* @return the panel this widget is in
*/
- @NotNull ModularPanel> getPanel();
+ @NotNull
+ ModularPanel> getPanel();
/**
* @return the area this widget occupies
@@ -298,6 +298,7 @@ default WidgetThemeEntry> getWidgetThemeEntry(ITheme theme) {
/**
* Gets the theme that is currently in use for this widget.
+ *
* @return The gui theme.
*/
ITheme getTheme();
diff --git a/src/main/java/brachy/modularui/api/widget/Interactable.java b/src/main/java/brachy/modularui/api/widget/Interactable.java
index 1985c28e..72874b72 100755
--- a/src/main/java/brachy/modularui/api/widget/Interactable.java
+++ b/src/main/java/brachy/modularui/api/widget/Interactable.java
@@ -4,10 +4,10 @@
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.sounds.SoundEvents;
-import com.mojang.blaze3d.platform.InputConstants;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
+import com.mojang.blaze3d.platform.InputConstants;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.glfw.GLFW;
@@ -22,8 +22,8 @@ public interface Interactable {
*
* @param button mouse button that was pressed.
* @return result that determines what happens to other widgets
- * {@link #onMouseTapped(int)} is only called if this returns {@link Result#ACCEPT} or
- * {@link Result#SUCCESS}
+ * {@link #onMouseTapped(int)} is only called if this returns {@link Result#ACCEPT} or
+ * {@link Result#SUCCESS}
*/
@NotNull
default Result onMousePressed(int button) {
@@ -35,7 +35,7 @@ default Result onMousePressed(int button) {
*
* @param button mouse button that was released.
* @return whether other widgets should get called to. If this returns false,
- * {@link #onMouseTapped(int)} will NOT be called.
+ * {@link #onMouseTapped(int)} will NOT be called.
*/
default boolean onMouseReleased(int button) {
return false;
@@ -46,9 +46,9 @@ default boolean onMouseReleased(int button) {
*
* @param button mouse button that was pressed.
* @return result that determines if other widgets should get tapped to
- * {@link Result#IGNORE IGNORE} and {@link Result#ACCEPT ACCEPT} will both "ignore" the result and
- * {@link Result#STOP STOP} and {@link Result#SUCCESS SUCCESS} will both stop other widgets
- * from getting tapped.
+ * {@link Result#IGNORE IGNORE} and {@link Result#ACCEPT ACCEPT} will both "ignore" the result and
+ * {@link Result#STOP STOP} and {@link Result#SUCCESS SUCCESS} will both stop other widgets
+ * from getting tapped.
*/
@NotNull
default Result onMouseTapped(int button) {
@@ -62,8 +62,8 @@ default Result onMouseTapped(int button) {
* @param scanCode character that was pressed.
* @param modifiers any modifiers that were used.
* @return result that determines what happens to other widgets
- * {@link #onKeyTapped(int, int, int)} is only called if this returns {@link Result#ACCEPT} or
- * {@link Result#SUCCESS}
+ * {@link #onKeyTapped(int, int, int)} is only called if this returns {@link Result#ACCEPT} or
+ * {@link Result#SUCCESS}
*/
@NotNull
default Result onKeyPressed(int keyCode, int scanCode, int modifiers) {
@@ -77,7 +77,7 @@ default Result onKeyPressed(int keyCode, int scanCode, int modifiers) {
* @param scanCode character that was pressed.
* @param modifiers any modifiers that were used.
* @return whether other widgets should get called too. If this returns false, {@link #onKeyTapped(int, int, int)}
- * will NOT be called.
+ * will NOT be called.
*/
default boolean onKeyReleased(int keyCode, int scanCode, int modifiers) {
return false;
@@ -90,8 +90,8 @@ default boolean onKeyReleased(int keyCode, int scanCode, int modifiers) {
* @param scanCode character that was pressed.
* @param modifiers any modifiers that were used.
* @return result that determines if other widgets should get tapped to
- * {@link Result#IGNORE} and {@link Result#ACCEPT} will both "ignore" the result and {@link Result#STOP} and
- * {@link Result#SUCCESS} will both stop other widgets from getting tapped.
+ * {@link Result#IGNORE} and {@link Result#ACCEPT} will both "ignore" the result and {@link Result#STOP} and
+ * {@link Result#SUCCESS} will both stop other widgets from getting tapped.
*/
@NotNull
default Result onKeyTapped(int keyCode, int scanCode, int modifiers) {
@@ -104,8 +104,8 @@ default Result onKeyTapped(int keyCode, int scanCode, int modifiers) {
* @param codePoint character that was typed
* @param modifiers any modifiers that were used.
* @return result that determines what happens to other widgets
- * {@link #onKeyTapped(int, int, int)} is only called if this returns {@link Result#ACCEPT} or
- * {@link Result#SUCCESS}
+ * {@link #onKeyTapped(int, int, int)} is only called if this returns {@link Result#ACCEPT} or
+ * {@link Result#SUCCESS}
*/
@NotNull
default Result onCharTyped(char codePoint, int modifiers) {
diff --git a/src/main/java/brachy/modularui/client/ModularUIClient.java b/src/main/java/brachy/modularui/client/ModularUIClient.java
index ddb0dba9..a5e522a0 100644
--- a/src/main/java/brachy/modularui/client/ModularUIClient.java
+++ b/src/main/java/brachy/modularui/client/ModularUIClient.java
@@ -18,13 +18,10 @@
import brachy.modularui.screen.ModularContainerMenu;
import brachy.modularui.test.TestHandler;
import brachy.modularui.theme.ThemeManager;
+import brachy.modularui.utils.CursorHandler;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.Minecraft;
-
-import brachy.modularui.utils.CursorHandler;
-
-import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
import net.minecraft.world.entity.player.Player;
import net.neoforged.api.distmarker.Dist;
@@ -36,13 +33,13 @@
import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent;
import net.neoforged.neoforge.client.event.RegisterClientTooltipComponentFactoriesEvent;
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent;
+import net.neoforged.neoforge.common.NeoForge;
+import net.neoforged.neoforge.event.level.LevelEvent;
+import com.mojang.blaze3d.systems.RenderSystem;
import it.unimi.dsi.fastutil.floats.FloatUnaryOperator;
import lombok.Getter;
-import net.neoforged.neoforge.common.NeoForge;
-import net.neoforged.neoforge.event.level.LevelEvent;
-
import java.util.function.Function;
@Mod(value = ModularUI.MOD_ID, dist = Dist.CLIENT)
diff --git a/src/main/java/brachy/modularui/core/mixins/client/AbstractWidgetMixin.java b/src/main/java/brachy/modularui/core/mixins/client/AbstractWidgetMixin.java
index 113647fb..78d0ff43 100644
--- a/src/main/java/brachy/modularui/core/mixins/client/AbstractWidgetMixin.java
+++ b/src/main/java/brachy/modularui/core/mixins/client/AbstractWidgetMixin.java
@@ -23,8 +23,8 @@ public abstract class AbstractWidgetMixin {
@Inject(method = "render",
at = @At(value = "FIELD",
- opcode = Opcodes.PUTFIELD,
- target = "Lnet/minecraft/client/gui/components/AbstractWidget;isHovered:Z"))
+ opcode = Opcodes.PUTFIELD,
+ target = "Lnet/minecraft/client/gui/components/AbstractWidget;isHovered:Z"))
public void mui$fixHoveredState(GuiGraphics guiGraphics, int mouseX, int mouseY,
float partialTick, CallbackInfo ci) {
// fixes buttons being hovered when an overlay element is already hovered
diff --git a/src/main/java/brachy/modularui/core/mixins/client/GuiGraphicsMixin.java b/src/main/java/brachy/modularui/core/mixins/client/GuiGraphicsMixin.java
index b18f1f68..72bdcff2 100644
--- a/src/main/java/brachy/modularui/core/mixins/client/GuiGraphicsMixin.java
+++ b/src/main/java/brachy/modularui/core/mixins/client/GuiGraphicsMixin.java
@@ -1,115 +1,103 @@
package brachy.modularui.core.mixins.client;
-import brachy.modularui.ModularUIConfig;
-import brachy.modularui.drawable.text.FontRenderHelper;
-import brachy.modularui.screen.RichTooltip;
-import brachy.modularui.screen.viewport.GuiContext;
-
-import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
-import net.minecraft.network.chat.Component;
-import net.minecraft.network.chat.FormattedText;
-import net.minecraft.util.FormattedCharSequence;
-import net.minecraft.world.inventory.tooltip.TooltipComponent;
-import net.minecraft.world.item.ItemStack;
-import com.llamalad7.mixinextras.sugar.Local;
import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
-import org.spongepowered.asm.mixin.Unique;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Collectors;
@Mixin(GuiGraphics.class)
public abstract class GuiGraphicsMixin {
-/*
- @Shadow(remap = false)
- private ItemStack tooltipStack;
-
- @Inject(method = "renderTooltip(Lnet/minecraft/client/gui/Font;Ljava/util/List;Ljava/util/Optional;II)V",
- at = @At(value = "HEAD"),
- cancellable = true)
- private void mui$replaceWithRichTooltip(Font font, List
- * If the texture is part of the GUI atlas, the atlas will be used for drawing and the UV coordinates will be scaled to the atlas texture.
- * Note that the atlas JSON should be kept, as MC 1.21 only adds textures in gui/sprites to the atlas. We want all of them.
+ * Note that the atlas JSON should be kept, as MC 1.21 only adds textures in gui/sprites to the atlas. We want
+ * all of them.
*/
public class GuiSpriteManager extends TextureAtlasHolder {
@@ -45,5 +46,4 @@ public static GuiSpriteManager getInstance() {
public @NotNull TextureAtlasSprite getSprite(@NotNull ResourceLocation location) {
return super.getSprite(location);
}
-
}
diff --git a/src/main/java/brachy/modularui/drawable/GuiTextures.java b/src/main/java/brachy/modularui/drawable/GuiTextures.java
index fde66650..a31ab1d4 100644
--- a/src/main/java/brachy/modularui/drawable/GuiTextures.java
+++ b/src/main/java/brachy/modularui/drawable/GuiTextures.java
@@ -205,8 +205,12 @@ public interface GuiTextures {
UITexture ANIMATED_TEXTURE_TEST = UITexture.fullImage(ModularUI.id("gui/icons/animated_gradient"));
- TabTexture TAB_TOP = TabTexture.of(UITexture.fullImage(ModularUI.id("gui/tab/tabs_top"), ColorType.DEFAULT), GuiAxis.Y, false, 28, 32, 4);
- TabTexture TAB_BOTTOM = TabTexture.of(UITexture.fullImage(ModularUI.id("gui/tab/tabs_bottom"), ColorType.DEFAULT), GuiAxis.Y, true, 28, 32, 4);
- TabTexture TAB_LEFT = TabTexture.of(UITexture.fullImage(ModularUI.id("gui/tab/tabs_left"), ColorType.DEFAULT), GuiAxis.X, false, 32, 28, 4);
- TabTexture TAB_RIGHT = TabTexture.of(UITexture.fullImage(ModularUI.id("gui/tab/tabs_right"), ColorType.DEFAULT), GuiAxis.X, true, 32, 28, 4);
+ TabTexture TAB_TOP = TabTexture.of(UITexture.fullImage(ModularUI.id("gui/tab/tabs_top"), ColorType.DEFAULT),
+ GuiAxis.Y, false, 28, 32, 4);
+ TabTexture TAB_BOTTOM = TabTexture.of(UITexture.fullImage(ModularUI.id("gui/tab/tabs_bottom"), ColorType.DEFAULT),
+ GuiAxis.Y, true, 28, 32, 4);
+ TabTexture TAB_LEFT = TabTexture.of(UITexture.fullImage(ModularUI.id("gui/tab/tabs_left"), ColorType.DEFAULT),
+ GuiAxis.X, false, 32, 28, 4);
+ TabTexture TAB_RIGHT = TabTexture.of(UITexture.fullImage(ModularUI.id("gui/tab/tabs_right"), ColorType.DEFAULT),
+ GuiAxis.X, true, 32, 28, 4);
}
diff --git a/src/main/java/brachy/modularui/drawable/Icon.java b/src/main/java/brachy/modularui/drawable/Icon.java
index a938d649..87959fe1 100644
--- a/src/main/java/brachy/modularui/drawable/Icon.java
+++ b/src/main/java/brachy/modularui/drawable/Icon.java
@@ -9,10 +9,10 @@
import brachy.modularui.utils.serialization.codec.MutableObjectCodec;
import brachy.modularui.widget.sizer.Box;
-import com.mojang.serialization.Codec;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
+import com.mojang.serialization.Codec;
import lombok.Getter;
/**
@@ -29,11 +29,16 @@ public class Icon implements IIcon {
.addOpt("margin", Icon::margin, Icon::getMargin, Box.CODEC, Box.ZERO)
.build();
- @Getter private IDrawable drawable;
- @Getter private int width = 0, height = 0;
- @Getter private float aspectRatio = 0;
- @Getter private Alignment alignment = Alignment.Center;
- @Getter private final Box margin = new Box();
+ @Getter
+ private IDrawable drawable;
+ @Getter
+ private int width = 0, height = 0;
+ @Getter
+ private float aspectRatio = 0;
+ @Getter
+ private Alignment alignment = Alignment.Center;
+ @Getter
+ private final Box margin = new Box();
private Icon() {
this.drawable = IDrawable.EMPTY;
diff --git a/src/main/java/brachy/modularui/drawable/InteractableIcon.java b/src/main/java/brachy/modularui/drawable/InteractableIcon.java
index 6d3d4b95..3977a922 100644
--- a/src/main/java/brachy/modularui/drawable/InteractableIcon.java
+++ b/src/main/java/brachy/modularui/drawable/InteractableIcon.java
@@ -3,7 +3,6 @@
import brachy.modularui.api.drawable.IIcon;
import brachy.modularui.api.widget.IGuiAction;
import brachy.modularui.api.widget.Interactable;
-
import brachy.modularui.screen.viewport.GuiContext;
import lombok.Getter;
diff --git a/src/main/java/brachy/modularui/drawable/ItemDrawable.java b/src/main/java/brachy/modularui/drawable/ItemDrawable.java
index f04a8c3b..c039cb17 100755
--- a/src/main/java/brachy/modularui/drawable/ItemDrawable.java
+++ b/src/main/java/brachy/modularui/drawable/ItemDrawable.java
@@ -11,16 +11,13 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.ItemLike;
+import net.neoforged.api.distmarker.Dist;
+import net.neoforged.api.distmarker.OnlyIn;
import com.google.gson.JsonObject;
-
import com.google.gson.JsonParseException;
-
import com.mojang.serialization.Codec;
import com.mojang.serialization.JsonOps;
-import net.neoforged.api.distmarker.Dist;
-import net.neoforged.api.distmarker.OnlyIn;
-
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@@ -36,7 +33,8 @@
public class ItemDrawable implements IDrawable {
public static final MutableObjectCodec
+ * If the texture is part of the GUI atlas, the atlas will be used for drawing and the UV coordinates will be scaled
+ * to the atlas texture.
* If it's not part of the GUI atlas, nothing special is done.
*
* @param location the texture file's location, e.g. {@code "modularui:textures/gui/slot/item.png"}
@@ -222,7 +228,7 @@ public static void drawRoundedRect(GuiGraphics graphics, float x0, float y0, flo
* @param u1 u1 UV coordinate
* @param v1 v1 UV coordinate
* @return If texture is in the GUI atlas, rescaled UV coordinates {@code u0, v0, u1, v1}.
- * If not, the same coordinates that were passed in.
+ * If not, the same coordinates that were passed in.
*/
public static RectangleF setupTexture(ResourceLocation location, float u0, float v0, float u1, float v1) {
TextureAtlasSprite sprite = Minecraft.getInstance().getGuiSprites()
@@ -241,7 +247,8 @@ public static RectangleF setupTexture(ResourceLocation location, float u0, float
public static boolean isGuiAtlasSprite(ResourceLocation location) {
location = GUI_TEXTURE_ID_CONVERTER.fileToId(location);
- return GuiSpriteManager.getInstance().getSprite(location).atlasLocation() != MissingTextureAtlasSprite.getLocation();
+ return GuiSpriteManager.getInstance().getSprite(location).atlasLocation() !=
+ MissingTextureAtlasSprite.getLocation();
}
public static void drawTexture(Matrix4f pose, ResourceLocation location, float x, float y, float w, float h,
@@ -354,7 +361,8 @@ public static void drawTexture(Matrix4f pose, VertexConsumer buffer, float x0, f
}
public static void drawTiledTexture(Matrix4f pose, ResourceLocation location, float x, float y, float w, float h,
- int u, int v, int tileWidth, int tileHeight, int textureWidth, int textureHeight, float z) {
+ int u, int v, int tileWidth, int tileHeight, int textureWidth,
+ int textureHeight, float z) {
if (!isGuiAtlasSprite(location)) {
RenderSystem.setShaderTexture(0, location);
drawTiledTexture(pose, x, y, w, h, u, v, tileWidth, tileHeight, textureWidth, textureHeight, z);
@@ -401,7 +409,8 @@ public static void drawTiledTexture(Matrix4f pose, ResourceLocation location, fl
RectangleF newUvs = setupTexture(location, u0, v0, u1, v1);
- drawTiledTexture(pose, x, y, w, h, newUvs.u0(), newUvs.v0(), newUvs.u1(), newUvs.v1(), textureWidth, textureHeight, z);
+ drawTiledTexture(pose, x, y, w, h, newUvs.u0(), newUvs.v0(), newUvs.u1(), newUvs.v1(), textureWidth,
+ textureHeight, z);
RenderSystem.disableBlend();
}
@@ -659,7 +668,8 @@ public static void drawFluidTexture(GuiGraphics graphics, FluidStack content,
public static void drawStandardSlotAmountText(GuiContext context, int amount, String format, Area area,
float z) {
- drawAmountText(context.getMuiContext(), amount, format, 0, 0, area.width, area.height, Alignment.BottomRight, z);
+ drawAmountText(context.getMuiContext(), amount, format, 0, 0, area.width, area.height, Alignment.BottomRight,
+ z);
}
public static void drawAmountText(ModularGuiContext context, int amount, String format,
@@ -994,7 +1004,8 @@ public static void drawText(GuiGraphics graphics, FormattedCharSequence text, fl
@SuppressWarnings("UnstableApiUsage")
public static void drawTooltipBackground(GuiContext context, ItemStack stack, List
* Here in 1.20 land, though, we have to implement it ourselves.
*