Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64b0fbc0aa | ||
|
|
9476ecbcc5 | ||
|
|
778ae7ddd9 | ||
|
|
08c3b4b42d | ||
|
|
28d47a0cbb | ||
|
|
00cb48b929 | ||
|
|
b75cfc45d8 | ||
|
|
ca44da71e7 | ||
|
|
8570bde282 |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -20,7 +20,7 @@ build
|
|||||||
# other
|
# other
|
||||||
eclipse
|
eclipse
|
||||||
run
|
run
|
||||||
logs/*
|
runs
|
||||||
|
run-data
|
||||||
|
|
||||||
# Files from Forge MDK
|
repo
|
||||||
forge*changelog.txt
|
|
||||||
164
build.gradle
164
build.gradle
@@ -1,92 +1,68 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
maven { url = 'https://maven.minecraftforge.net' }
|
|
||||||
mavenCentral()
|
|
||||||
jcenter()
|
|
||||||
maven { url = 'https://repo.spongepowered.org/repository/maven-public' }
|
|
||||||
maven { url = 'https://maven.parchmentmc.org' }
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath "net.minecraftforge.gradle:ForgeGradle:${forgegradle_version}"
|
|
||||||
classpath "org.spongepowered:mixingradle:${mixingradle_version}"
|
|
||||||
classpath "org.parchmentmc:librarian:${librarian_version}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
|
id 'java-library'
|
||||||
|
id 'eclipse'
|
||||||
|
id 'idea'
|
||||||
|
id 'maven-publish'
|
||||||
|
id 'net.neoforged.gradle.userdev' version "${neogradle_version}"
|
||||||
id 'com.matthewprenger.cursegradle' version "${cursegradle_version}"
|
id 'com.matthewprenger.cursegradle' version "${cursegradle_version}"
|
||||||
}
|
}
|
||||||
apply plugin: 'net.minecraftforge.gradle'
|
|
||||||
apply plugin: 'org.parchmentmc.librarian.forgegradle'
|
|
||||||
apply plugin: 'eclipse'
|
|
||||||
apply plugin: 'maven-publish'
|
|
||||||
apply plugin: 'org.spongepowered.mixin'
|
|
||||||
|
|
||||||
jarJar.enable()
|
boolean ponderInWorkspace = findProject(':Ponder') != null
|
||||||
|
|
||||||
boolean flywheelInWorkspace = findProject(':Flywheel') != null
|
|
||||||
|
|
||||||
ext.buildNumber = System.getenv('BUILD_NUMBER')
|
ext.buildNumber = System.getenv('BUILD_NUMBER')
|
||||||
|
|
||||||
version = mod_version
|
version = mod_version
|
||||||
group = 'nl.requios.effortlessbuilding'
|
group = 'nl.requios.effortlessbuilding'
|
||||||
archivesBaseName = "effortlessbuilding-${artifact_minecraft_version}"
|
base {
|
||||||
|
archivesName = "effortlessbuilding-${artifact_minecraft_version}"
|
||||||
|
}
|
||||||
|
|
||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
|
||||||
|
|
||||||
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + ' (' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
|
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + ' (' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
|
||||||
|
|
||||||
minecraft {
|
minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||||
mappings channel: 'parchment', version: "${parchment_version}-${minecraft_version}"
|
|
||||||
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
runs {
|
||||||
|
// applies to all the run configs below
|
||||||
|
configureEach { net.neoforged.gradle.dsl.common.runs.run.Run run ->
|
||||||
|
// Recommended logging data for a userdev environment
|
||||||
|
systemProperty 'forge.logging.markers', 'REGISTRIES'
|
||||||
|
|
||||||
|
// Recommended logging level for the console
|
||||||
|
systemProperty 'forge.logging.console.level', 'debug'
|
||||||
|
|
||||||
|
//Limit ram usage for the dev environment to 4GB
|
||||||
|
jvmArgument '-Xmx4G'
|
||||||
|
if (run.project.javaToolchains.launcherFor(java.toolchain).map { it.metadata.vendor }.getOrElse("").contains("JetBrains")) {
|
||||||
|
jvmArgument '-XX:+AllowEnhancedClassRedefinition'
|
||||||
|
}
|
||||||
|
|
||||||
|
modSource project.sourceSets.main
|
||||||
|
}
|
||||||
|
|
||||||
runs {
|
|
||||||
client {
|
client {
|
||||||
workingDirectory project.file('run')
|
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
||||||
arg '-mixin.config=flywheel.mixins.json'
|
systemProperty 'neoforge.enabledGameTestNamespaces', "effortlessbuilding"
|
||||||
//jvmArgs '-XX:+UnlockCommercialFeatures' // uncomment for profiling
|
|
||||||
property 'forge.logging.console.level', 'info'
|
|
||||||
|
|
||||||
mods {
|
if (ponderInWorkspace) {
|
||||||
effortlessbuilding {
|
dependencies {
|
||||||
source sourceSets.main
|
runtime project(':Ponder')
|
||||||
}
|
|
||||||
|
|
||||||
if (flywheelInWorkspace) {
|
|
||||||
flywheel {
|
|
||||||
source project(":Flywheel").sourceSets.main
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
workingDirectory project.file('run/server')
|
systemProperty 'neoforge.enabledGameTestNamespaces', "effortlessbuilding"
|
||||||
property 'forge.logging.console.level', 'info'
|
programArgument '--nogui'
|
||||||
mods {
|
|
||||||
effortlessbuilding {
|
|
||||||
source sourceSets.main
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data {
|
data {
|
||||||
workingDirectory project.file('run')
|
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
|
||||||
property 'forge.logging.markers', 'REGISTRIES,REGISTRYDUMP'
|
// workingDirectory project.file('run-data')
|
||||||
property 'forge.logging.console.level', 'debug'
|
|
||||||
args '--mod', 'effortlessbuilding', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources')
|
|
||||||
mods {
|
|
||||||
effortlessbuilding {
|
|
||||||
source sourceSets.main
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flywheelInWorkspace) {
|
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
|
||||||
flywheel {
|
programArguments.addAll '--mod', "effortlessbuilding", '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
|
||||||
source project(":Flywheel").sourceSets.main
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,10 +72,18 @@ repositories {
|
|||||||
name = 'tterrag maven'
|
name = 'tterrag maven'
|
||||||
url = 'https://maven.tterrag.com'
|
url = 'https://maven.tterrag.com'
|
||||||
}
|
}
|
||||||
|
|
||||||
maven {
|
maven {
|
||||||
url = 'https://www.cursemaven.com'
|
// Ponder, Flywheel
|
||||||
content {
|
url = "https://maven.createmod.net"
|
||||||
|
}
|
||||||
|
maven { url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven" } // NeoForge config api port, needed by ponder
|
||||||
|
exclusiveContent {
|
||||||
|
forRepository {
|
||||||
|
maven {
|
||||||
|
url "https://cursemaven.com"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
filter {
|
||||||
includeGroup "curse.maven"
|
includeGroup "curse.maven"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,22 +102,24 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
implementation "net.neoforged:neoforge:${neo_version}"
|
||||||
|
|
||||||
jarJar("com.jozufozu.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}") {
|
jarJar("net.createmod.ponder:Ponder-NeoForge-${minecraft_version}:${ponder_version}")
|
||||||
jarJar.ranged(it, '[0.6.9,0.6.10)')
|
|
||||||
|
compileOnly("dev.engine-room.flywheel:flywheel-neoforge-api-${flywheel_minecraft_version}:${flywheel_version}")
|
||||||
|
runtimeOnly(jarJar("dev.engine-room.flywheel:flywheel-neoforge-${flywheel_minecraft_version}:${flywheel_version}") {
|
||||||
|
version {
|
||||||
|
strictly "[1.0,2.0)"
|
||||||
|
prefer flywheel_version
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
runtimeOnly("dev.engine-room.vanillin:vanillin-neoforge-${flywheel_minecraft_version}:${vanillin_version}")
|
||||||
|
|
||||||
if (flywheelInWorkspace) {
|
if (ponderInWorkspace) {
|
||||||
implementation project(':Flywheel')
|
implementation(project(":ponder:Common"))
|
||||||
|
implementation(project(":ponder:NeoForge"))
|
||||||
} else {
|
} else {
|
||||||
implementation fg.deobf("com.jozufozu.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}")
|
implementation("net.createmod.ponder:Ponder-NeoForge-${minecraft_version}:${ponder_version}")
|
||||||
}
|
|
||||||
|
|
||||||
// Prevent Mixin annotation processor from getting into IntelliJ's annotation processor settings
|
|
||||||
// This allows 'Settings > Build, Execution, and Deployment > Build Tools > Gradle > Build and run using' set to IntelliJ to work correctly
|
|
||||||
if (!Boolean.getBoolean('idea.sync.active')) {
|
|
||||||
annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,6 +131,14 @@ tasks.withType(JavaCompile).configureEach {
|
|||||||
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
|
||||||
|
idea {
|
||||||
|
module {
|
||||||
|
downloadSources = true
|
||||||
|
downloadJavadoc = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
compileJava {
|
compileJava {
|
||||||
options.compilerArgs = ['-Xdiags:verbose']
|
options.compilerArgs = ['-Xdiags:verbose']
|
||||||
}
|
}
|
||||||
@@ -155,7 +149,7 @@ jar {
|
|||||||
"Specification-Title": "effortlessbuilding",
|
"Specification-Title": "effortlessbuilding",
|
||||||
"Specification-Vendor": "requios",
|
"Specification-Vendor": "requios",
|
||||||
"Specification-Version": "1",
|
"Specification-Version": "1",
|
||||||
"Implementation-Title": project.jar.archiveBaseName,
|
"Implementation-Title": project.name,
|
||||||
"Implementation-Version": project.jar.archiveVersion,
|
"Implementation-Version": project.jar.archiveVersion,
|
||||||
"Implementation-Vendor" :"requios",
|
"Implementation-Vendor" :"requios",
|
||||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||||
@@ -167,7 +161,7 @@ task jarJarRelease {
|
|||||||
group = 'jarjar'
|
group = 'jarjar'
|
||||||
doLast {
|
doLast {
|
||||||
tasks.jarJar {
|
tasks.jarJar {
|
||||||
archiveClassifier = ''
|
classifier = ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finalizedBy tasks.jarJar
|
finalizedBy tasks.jarJar
|
||||||
@@ -178,17 +172,15 @@ java {
|
|||||||
withJavadocJar()
|
withJavadocJar()
|
||||||
}
|
}
|
||||||
|
|
||||||
jar.finalizedBy('reobfJar')
|
tasks.build.dependsOn tasks.jarJar
|
||||||
tasks.jarJar.finalizedBy('reobfJarJar')
|
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
mavenJava(MavenPublication) {
|
mavenJava(MavenPublication) {
|
||||||
artifactId = archivesBaseName
|
artifactId = base.archivesName.get()
|
||||||
|
|
||||||
from components.java
|
from components.java
|
||||||
fg.component(it)
|
// fg.component(it)
|
||||||
jarJar.component(it)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,18 +3,19 @@
|
|||||||
org.gradle.jvmargs=-Xmx3G
|
org.gradle.jvmargs=-Xmx3G
|
||||||
org.gradle.daemon=false
|
org.gradle.daemon=false
|
||||||
|
|
||||||
mod_version = 3.4
|
mod_version = 3.10
|
||||||
artifact_minecraft_version = 1.20.1
|
artifact_minecraft_version = 1.21.1
|
||||||
|
|
||||||
minecraft_version = 1.20.1
|
minecraft_version = 1.21.1
|
||||||
forge_version = 47.0.43
|
neo_version = 21.1.129
|
||||||
|
neogradle.subsystems.parchment.minecraftVersion = 1.21.1
|
||||||
|
neogradle.subsystems.parchment.mappingsVersion = 2024.11.17
|
||||||
|
neogradle.subsystems.conventions.runs.create-default-run-per-type = false
|
||||||
|
|
||||||
forgegradle_version = 6.0.6
|
neogradle_version = 7.0.181
|
||||||
mixingradle_version = 0.7-SNAPSHOT
|
|
||||||
mixin_version = 0.8.5
|
|
||||||
librarian_version = 1.+
|
|
||||||
cursegradle_version = 1.4.0
|
cursegradle_version = 1.4.0
|
||||||
parchment_version = 2023.06.26
|
|
||||||
|
|
||||||
flywheel_minecraft_version = 1.20.1
|
flywheel_minecraft_version = 1.21.1
|
||||||
flywheel_version = 0.6.9-5
|
flywheel_version = 1.0.2
|
||||||
|
vanillin_version = 1.0.0-beta-11
|
||||||
|
ponder_version = 1.0.46
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,7 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
54
gradlew
vendored
54
gradlew
vendored
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright <EFBFBD> 2015-2021 the original authors.
|
# Copyright © 2015-2021 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -15,6 +15,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
@@ -32,10 +34,10 @@
|
|||||||
# Busybox and similar reduced shells will NOT work, because this script
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
# requires all of these POSIX shell features:
|
# requires all of these POSIX shell features:
|
||||||
# * functions;
|
# * functions;
|
||||||
# * expansions <EFBFBD>$var<EFBFBD>, <EFBFBD>${var}<EFBFBD>, <EFBFBD>${var:-default}<EFBFBD>, <EFBFBD>${var+SET}<EFBFBD>,
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
# <EFBFBD>${var#prefix}<EFBFBD>, <EFBFBD>${var%suffix}<EFBFBD>, and <EFBFBD>$( cmd )<EFBFBD>;
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
# * compound commands having a testable exit status, especially <EFBFBD>case<EFBFBD>;
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
# * various built-in commands including <EFBFBD>command<EFBFBD>, <EFBFBD>set<EFBFBD>, and <EFBFBD>ulimit<EFBFBD>.
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
#
|
#
|
||||||
# Important for patching:
|
# Important for patching:
|
||||||
#
|
#
|
||||||
@@ -55,7 +57,7 @@
|
|||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (3) This script is generated from the Groovy template
|
||||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
@@ -80,13 +82,12 @@ do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
' "$PWD" ) || exit
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
@@ -133,22 +134,29 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
'' | soft) :;; #(
|
'' | soft) :;; #(
|
||||||
*)
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
ulimit -n "$MAX_FD" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
@@ -193,11 +201,15 @@ if "$cygwin" || "$msys" ; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
# double quotes to make sure that they get re-expanded; and
|
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
@@ -205,6 +217,12 @@ set -- \
|
|||||||
org.gradle.wrapper.GradleWrapperMain \
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
# Use "xargs" to parse quoted args.
|
||||||
#
|
#
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
|||||||
37
gradlew.bat
vendored
37
gradlew.bat
vendored
@@ -13,8 +13,10 @@
|
|||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@@ -25,7 +27,8 @@
|
|||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
@@ -56,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
@@ -75,13 +78,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|||||||
@@ -1 +1,13 @@
|
|||||||
rootProject.name = 'EffortlessBuilding'
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
gradlePluginPortal()
|
||||||
|
maven {
|
||||||
|
name = 'Official NeoForge Maven'
|
||||||
|
url = 'https://maven.neoforged.net/releases'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
|
||||||
|
}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
package nl.requios.effortlessbuilding;
|
package nl.requios.effortlessbuilding;
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import net.createmod.catnip.gui.UIRenderHelper;
|
||||||
|
import net.createmod.catnip.gui.element.ScreenElement;
|
||||||
|
import net.createmod.catnip.theme.Color;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.UIRenderHelper;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.ScreenElement;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
|
||||||
|
|
||||||
public enum AllGuiTextures implements ScreenElement {
|
public enum AllGuiTextures implements ScreenElement {
|
||||||
ARRAY_ENTRY("modifiers", 226, 64),
|
ARRAY_ENTRY("modifiers", 226, 64),
|
||||||
@@ -35,7 +35,7 @@ public enum AllGuiTextures implements ScreenElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private AllGuiTextures(String namespace, String location, int startX, int startY, int width, int height) {
|
private AllGuiTextures(String namespace, String location, int startX, int startY, int width, int height) {
|
||||||
this.location = new ResourceLocation(namespace, "textures/gui/" + location + ".png");
|
this.location = ResourceLocation.fromNamespaceAndPath(namespace, "textures/gui/" + location + ".png");
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.startX = startX;
|
this.startX = startX;
|
||||||
@@ -48,14 +48,14 @@ public enum AllGuiTextures implements ScreenElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void render(GuiGraphics graphics, int x, int y) {
|
@Override
|
||||||
bind();
|
public void render(GuiGraphics ms, int x, int y) {
|
||||||
graphics.blit(location, x, y, startX, startY, width, height, width, height);
|
ms.blit(location, x, y, 0, startX, startY, width, height, 256, 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void render(GuiGraphics graphics, int x, int y, Color c) {
|
public void render(GuiGraphics ms, int x, int y, Color c) {
|
||||||
bind();
|
bind();
|
||||||
UIRenderHelper.drawColoredTexture(graphics, c, x, y, startX, startY, width, height);
|
UIRenderHelper.drawColoredTexture(ms, c, x, y, startX, startY, width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,23 @@
|
|||||||
package nl.requios.effortlessbuilding;
|
package nl.requios.effortlessbuilding;
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
|
import net.createmod.catnip.gui.element.DelegatedStencilElement;
|
||||||
|
import net.createmod.catnip.gui.element.ScreenElement;
|
||||||
|
import net.createmod.catnip.theme.Color;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import org.joml.Matrix4f;
|
|
||||||
import net.minecraft.client.renderer.LightTexture;
|
import net.minecraft.client.renderer.LightTexture;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import nl.requios.effortlessbuilding.create.Create;
|
import org.joml.Matrix4f;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.DelegatedStencilElement;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.ScreenElement;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
|
||||||
|
|
||||||
public class AllIcons implements ScreenElement {
|
public class AllIcons implements ScreenElement {
|
||||||
|
|
||||||
public static final ResourceLocation ICON_ATLAS = Create.asResource("textures/gui/icons.png");
|
public static final ResourceLocation ICON_ATLAS = EffortlessBuilding.asResource("textures/gui/icons.png");
|
||||||
public static final int ICON_ATLAS_SIZE = 256;
|
public static final int ICON_ATLAS_SIZE = 256;
|
||||||
private static int x = 0, y = -1;
|
private static int x = 0, y = -1;
|
||||||
private int iconX;
|
private int iconX;
|
||||||
@@ -102,15 +100,8 @@ public class AllIcons implements ScreenElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void bind() {
|
public void render(GuiGraphics guiGraphics, int x, int y) {
|
||||||
RenderSystem.setShaderTexture(0, ICON_ATLAS);
|
guiGraphics.blit(ICON_ATLAS, x, y, 0, iconX, iconY, 16, 16, 256, 256);
|
||||||
}
|
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
@Override
|
|
||||||
public void render(GuiGraphics graphics, int x, int y) {
|
|
||||||
bind();
|
|
||||||
graphics.blit(ICON_ATLAS, x, y, 0, iconX, iconY, 16, 16, 256, 256);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@@ -138,11 +129,10 @@ public class AllIcons implements ScreenElement {
|
|||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
private void vertex(VertexConsumer builder, Matrix4f matrix, Vec3 vec, Color rgb, float u, float v, int light) {
|
private void vertex(VertexConsumer builder, Matrix4f matrix, Vec3 vec, Color rgb, float u, float v, int light) {
|
||||||
builder.vertex(matrix, (float) vec.x, (float) vec.y, (float) vec.z)
|
builder.addVertex(matrix, (float) vec.x, (float) vec.y, (float) vec.z)
|
||||||
.color(rgb.getRed(), rgb.getGreen(), rgb.getBlue(), 255)
|
.setColor(rgb.getRed(), rgb.getGreen(), rgb.getBlue(), 255)
|
||||||
.uv(u, v)
|
.setUv(u, v)
|
||||||
.uv2(light)
|
.setLight(light);
|
||||||
.endVertex();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
package nl.requios.effortlessbuilding;
|
package nl.requios.effortlessbuilding;
|
||||||
|
|
||||||
import net.minecraftforge.common.ForgeConfigSpec;
|
import net.neoforged.neoforge.common.ModConfigSpec;
|
||||||
|
|
||||||
import static net.minecraftforge.common.ForgeConfigSpec.*;
|
import static net.neoforged.neoforge.common.ModConfigSpec.BooleanValue;
|
||||||
|
import static net.neoforged.neoforge.common.ModConfigSpec.Builder;
|
||||||
|
import static net.neoforged.neoforge.common.ModConfigSpec.IntValue;
|
||||||
|
|
||||||
public class ClientConfig {
|
public class ClientConfig {
|
||||||
|
|
||||||
private static final Builder builder = new Builder();
|
private static final Builder builder = new Builder();
|
||||||
public static final Visuals visuals = new Visuals(builder);
|
public static final Visuals visuals = new Visuals(builder);
|
||||||
public static final ForgeConfigSpec spec = builder.build();
|
public static final ModConfigSpec spec = builder.build();
|
||||||
|
|
||||||
public static class Visuals {
|
public static class Visuals {
|
||||||
public final BooleanValue showBlockPreviews;
|
public final BooleanValue showBlockPreviews;
|
||||||
|
|||||||
@@ -6,21 +6,21 @@ import net.minecraft.client.Minecraft;
|
|||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.client.player.LocalPlayer;
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.minecraftforge.client.event.InputEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
|
import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
import net.minecraftforge.client.event.ScreenEvent;
|
import net.neoforged.neoforge.client.event.ClientTickEvent;
|
||||||
import net.minecraftforge.client.settings.KeyConflictContext;
|
import net.neoforged.neoforge.client.event.InputEvent;
|
||||||
import net.minecraftforge.client.settings.KeyModifier;
|
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent;
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.neoforged.neoforge.client.event.ScreenEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.neoforged.neoforge.client.settings.KeyConflictContext;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
import net.neoforged.neoforge.client.settings.KeyModifier;
|
||||||
|
import nl.requios.effortlessbuilding.attachment.AttachmentHandler;
|
||||||
import nl.requios.effortlessbuilding.buildmode.BuildModeEnum;
|
import nl.requios.effortlessbuilding.buildmode.BuildModeEnum;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||||
import nl.requios.effortlessbuilding.gui.buildmode.PlayerSettingsGui;
|
import nl.requios.effortlessbuilding.gui.buildmode.PlayerSettingsGui;
|
||||||
import nl.requios.effortlessbuilding.gui.buildmode.RadialMenu;
|
import nl.requios.effortlessbuilding.gui.buildmode.RadialMenu;
|
||||||
import nl.requios.effortlessbuilding.gui.buildmodifier.ModifiersScreen;
|
import nl.requios.effortlessbuilding.gui.buildmodifier.ModifiersScreen;
|
||||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
@EventBusSubscriber(Dist.CLIENT)
|
@EventBusSubscriber(Dist.CLIENT)
|
||||||
@@ -55,33 +55,33 @@ public class ClientEvents {
|
|||||||
// @SubscribeEvent
|
// @SubscribeEvent
|
||||||
// public static void registerShaders(RegisterShadersEvent event) throws IOException {
|
// public static void registerShaders(RegisterShadersEvent event) throws IOException {
|
||||||
// event.registerShader(new ShaderInstance(event.getResourceManager(),
|
// event.registerShader(new ShaderInstance(event.getResourceManager(),
|
||||||
// new ResourceLocation(EffortlessBuilding.MODID, "dissolve"),
|
// EffortlessBuilding.modLoc("dissolve"),
|
||||||
// DefaultVertexFormat.BLOCK),
|
// DefaultVertexFormat.BLOCK),
|
||||||
// shaderInstance -> BuildRenderTypes.dissolveShaderInstance = shaderInstance);
|
// shaderInstance -> BuildRenderTypes.dissolveShaderInstance = shaderInstance);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onClientTick(TickEvent.ClientTickEvent event) {
|
public static void onClientTickPre(ClientTickEvent.Pre event) {
|
||||||
if (!isGameActive()) return;
|
if (!isGameActive()) return;
|
||||||
|
|
||||||
if (event.phase == TickEvent.Phase.START) {
|
|
||||||
|
|
||||||
EffortlessBuildingClient.BUILDER_CHAIN.onTick();
|
EffortlessBuildingClient.BUILDER_CHAIN.onTick();
|
||||||
|
|
||||||
onMouseInput();
|
onMouseInput();
|
||||||
|
|
||||||
EffortlessBuildingClient.BLOCK_PREVIEWS.onTick();
|
EffortlessBuildingClient.BLOCK_PREVIEWS.onTick();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onClientTickPost(ClientTickEvent.Post event) {
|
||||||
|
if (!isGameActive()) return;
|
||||||
|
|
||||||
} else if (event.phase == TickEvent.Phase.END) {
|
|
||||||
Screen gui = Minecraft.getInstance().screen;
|
Screen gui = Minecraft.getInstance().screen;
|
||||||
if (gui == null || !gui.isPauseScreen()) {
|
if (gui == null || !gui.isPauseScreen()) {
|
||||||
ticksInGame++;
|
ticksInGame++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void onMouseInput() {
|
private static void onMouseInput() {
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
LocalPlayer player = mc.player;
|
LocalPlayer player = mc.player;
|
||||||
@@ -134,7 +134,7 @@ public class ClientEvents {
|
|||||||
|
|
||||||
//Radial menu
|
//Radial menu
|
||||||
if (keyBindings[0].isDown()) {
|
if (keyBindings[0].isDown()) {
|
||||||
if (!EffortlessBuildingClient.POWER_LEVEL.isDisabled(player)) {
|
if (!AttachmentHandler.isDisabled(player)) {
|
||||||
if (!RadialMenu.instance.isVisible()) {
|
if (!RadialMenu.instance.isVisible()) {
|
||||||
Minecraft.getInstance().setScreen(RadialMenu.instance);
|
Minecraft.getInstance().setScreen(RadialMenu.instance);
|
||||||
}
|
}
|
||||||
@@ -175,7 +175,7 @@ public class ClientEvents {
|
|||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
|
||||||
//Disabled if max reach is 0, might be set in the config that way.
|
//Disabled if max reach is 0, might be set in the config that way.
|
||||||
if (EffortlessBuildingClient.POWER_LEVEL.isDisabled(player)) {
|
if (AttachmentHandler.isDisabled(player)) {
|
||||||
EffortlessBuilding.log(player, "Build modifiers are disabled until your power level has increased. Increase your power level by consuming certain items.");
|
EffortlessBuilding.log(player, "Build modifiers are disabled until your power level has increased. Increase your power level by consuming certain items.");
|
||||||
} else {
|
} else {
|
||||||
mc.setScreen(new ModifiersScreen());
|
mc.setScreen(new ModifiersScreen());
|
||||||
@@ -188,7 +188,7 @@ public class ClientEvents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onGuiOpen(ScreenEvent event) {
|
public static void onGuiOpen(ScreenEvent.Opening event) {
|
||||||
Player player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
EffortlessBuildingClient.BUILDER_CHAIN.cancel();
|
EffortlessBuildingClient.BUILDER_CHAIN.cancel();
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
package nl.requios.effortlessbuilding;
|
package nl.requios.effortlessbuilding;
|
||||||
|
|
||||||
import net.minecraftforge.common.ForgeConfigSpec;
|
import net.neoforged.neoforge.common.ModConfigSpec;
|
||||||
|
|
||||||
import static net.minecraftforge.common.ForgeConfigSpec.*;
|
import static net.neoforged.neoforge.common.ModConfigSpec.Builder;
|
||||||
|
import static net.neoforged.neoforge.common.ModConfigSpec.IntValue;
|
||||||
|
|
||||||
public class CommonConfig {
|
public class CommonConfig {
|
||||||
|
|
||||||
@@ -11,7 +12,7 @@ public class CommonConfig {
|
|||||||
public static final MaxBlocksPlacedAtOnce maxBlocksPlacedAtOnce = new MaxBlocksPlacedAtOnce(builder);
|
public static final MaxBlocksPlacedAtOnce maxBlocksPlacedAtOnce = new MaxBlocksPlacedAtOnce(builder);
|
||||||
public static final MaxBlocksPerAxis maxBlocksPerAxis = new MaxBlocksPerAxis(builder);
|
public static final MaxBlocksPerAxis maxBlocksPerAxis = new MaxBlocksPerAxis(builder);
|
||||||
public static final MaxMirrorRadius maxMirrorRadius = new MaxMirrorRadius(builder);
|
public static final MaxMirrorRadius maxMirrorRadius = new MaxMirrorRadius(builder);
|
||||||
public static final ForgeConfigSpec spec = builder.build();
|
public static final ModConfigSpec spec = builder.build();
|
||||||
|
|
||||||
public static class Reach {
|
public static class Reach {
|
||||||
public final IntValue creative;
|
public final IntValue creative;
|
||||||
|
|||||||
@@ -5,19 +5,18 @@ import net.minecraft.world.InteractionHand;
|
|||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.BlockItem;
|
import net.minecraft.world.item.BlockItem;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraftforge.common.CreativeModeTabRegistry;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraftforge.common.util.FakePlayer;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.neoforged.neoforge.common.util.FakePlayer;
|
||||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||||
import net.minecraftforge.event.level.BlockEvent;
|
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.neoforged.neoforge.event.level.BlockEvent;
|
||||||
import net.minecraftforge.fml.LogicalSide;
|
import net.neoforged.neoforge.event.tick.LevelTickEvent;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
import nl.requios.effortlessbuilding.attachment.PowerLevel;
|
||||||
import net.minecraftforge.network.PacketDistributor;
|
|
||||||
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
||||||
import nl.requios.effortlessbuilding.network.ModifierSettingsPacket;
|
import nl.requios.effortlessbuilding.network.message.ModifierSettingsPacket;
|
||||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
import nl.requios.effortlessbuilding.network.message.PowerLevelPacket;
|
||||||
import nl.requios.effortlessbuilding.systems.ServerBuildState;
|
import nl.requios.effortlessbuilding.systems.ServerBuildState;
|
||||||
import nl.requios.effortlessbuilding.utilities.PowerLevelCommand;
|
import nl.requios.effortlessbuilding.utilities.PowerLevelCommand;
|
||||||
|
|
||||||
@@ -25,7 +24,7 @@ import nl.requios.effortlessbuilding.utilities.PowerLevelCommand;
|
|||||||
public class CommonEvents {
|
public class CommonEvents {
|
||||||
|
|
||||||
//Mod Bus Events
|
//Mod Bus Events
|
||||||
@EventBusSubscriber(bus = EventBusSubscriber.Bus.MOD)
|
// @EventBusSubscriber(bus = EventBusSubscriber.Bus.MOD)
|
||||||
public static class ModBusEvents {
|
public static class ModBusEvents {
|
||||||
|
|
||||||
|
|
||||||
@@ -37,9 +36,10 @@ public class CommonEvents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onTick(TickEvent.LevelTickEvent event) {
|
public static void onTick(LevelTickEvent.Pre event) {
|
||||||
if (event.phase != TickEvent.Phase.START) return;
|
Level level = event.getLevel();
|
||||||
if (event.side == LogicalSide.CLIENT) return;
|
if (level.isClientSide) return;
|
||||||
|
if (!level.dimension().equals(Level.OVERWORLD)) return;
|
||||||
|
|
||||||
EffortlessBuilding.SERVER_BLOCK_PLACER.tick();
|
EffortlessBuilding.SERVER_BLOCK_PLACER.tick();
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,8 @@ public class CommonEvents {
|
|||||||
//Don't cancel event if our custom logic is breaking blocks
|
//Don't cancel event if our custom logic is breaking blocks
|
||||||
if (EffortlessBuilding.SERVER_BLOCK_PLACER.isPlacingOrBreakingBlocks()) return;
|
if (EffortlessBuilding.SERVER_BLOCK_PLACER.isPlacingOrBreakingBlocks()) return;
|
||||||
|
|
||||||
if (!ServerBuildState.isLikeVanilla(player) && EffortlessBuilding.SERVER_POWER_LEVEL.canBreakFar(player)) {
|
PowerLevel powerLevel = player.getData(EffortlessBuilding.POWER_LEVEL);
|
||||||
|
if (!ServerBuildState.isLikeVanilla(player) && powerLevel.canBreakFar(player)) {
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,8 +95,24 @@ public class CommonEvents {
|
|||||||
|
|
||||||
ServerBuildState.handleNewPlayer(player);
|
ServerBuildState.handleNewPlayer(player);
|
||||||
|
|
||||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new ModifierSettingsPacket(player));
|
((ServerPlayer)player).connection.send(new ModifierSettingsPacket(player));
|
||||||
EffortlessBuilding.SERVER_POWER_LEVEL.sendToClient(player);
|
|
||||||
|
PowerLevel powerLevel = player.getData(EffortlessBuilding.POWER_LEVEL);
|
||||||
|
((ServerPlayer)player).connection.send(new PowerLevelPacket(powerLevel.getPowerLevel()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onClone(PlayerEvent.Clone event) {
|
||||||
|
// If not dead, player is returning from the End
|
||||||
|
if (!event.isWasDeath()) return;
|
||||||
|
|
||||||
|
Player original = event.getOriginal();
|
||||||
|
Player clone = event.getEntity();
|
||||||
|
|
||||||
|
// Copy the power level from the original player to the clone
|
||||||
|
if (event.isWasDeath() && event.getOriginal().hasData(EffortlessBuilding.POWER_LEVEL)) {
|
||||||
|
event.getEntity().setData(EffortlessBuilding.POWER_LEVEL, event.getOriginal().getData(EffortlessBuilding.POWER_LEVEL));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.CreativeModeTab;
|
|
||||||
|
|
||||||
public class EBCreativeModeTab implements CreativeModeTab.DisplayItemsGenerator {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(CreativeModeTab.ItemDisplayParameters pParameters, CreativeModeTab.Output pOutput) {
|
|
||||||
pOutput.accept(EffortlessBuilding.RANDOMIZER_BAG_ITEM.get());
|
|
||||||
pOutput.accept(EffortlessBuilding.GOLDEN_RANDOMIZER_BAG_ITEM.get());
|
|
||||||
pOutput.accept(EffortlessBuilding.DIAMOND_RANDOMIZER_BAG_ITEM.get());
|
|
||||||
|
|
||||||
pOutput.accept(EffortlessBuilding.REACH_UPGRADE_1_ITEM.get());
|
|
||||||
pOutput.accept(EffortlessBuilding.REACH_UPGRADE_2_ITEM.get());
|
|
||||||
pOutput.accept(EffortlessBuilding.REACH_UPGRADE_3_ITEM.get());
|
|
||||||
|
|
||||||
pOutput.accept(EffortlessBuilding.MUSCLES_ITEM.get());
|
|
||||||
pOutput.accept(EffortlessBuilding.ELASTIC_HAND_ITEM.get());
|
|
||||||
pOutput.accept(EffortlessBuilding.BUILDING_TECHNIQUES_BOOK_ITEM.get());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,45 +1,57 @@
|
|||||||
package nl.requios.effortlessbuilding;
|
package nl.requios.effortlessbuilding;
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.MapCodec;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.flag.FeatureFlagSet;
|
import net.minecraft.world.flag.FeatureFlags;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.MenuType;
|
import net.minecraft.world.inventory.MenuType;
|
||||||
import net.minecraft.world.item.CreativeModeTab;
|
import net.minecraft.world.item.CreativeModeTabs;
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.neoforged.bus.api.IEventBus;
|
||||||
import net.minecraftforge.common.loot.IGlobalLootModifier;
|
import net.neoforged.fml.ModContainer;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.neoforged.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.neoforged.fml.config.ModConfig;
|
||||||
import net.minecraftforge.fml.ModLoadingContext;
|
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.neoforged.fml.loading.FMLEnvironment;
|
||||||
import net.minecraftforge.fml.config.ModConfig;
|
import net.neoforged.neoforge.attachment.AttachmentType;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.neoforged.neoforge.client.gui.ConfigurationScreen;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
||||||
import net.minecraftforge.network.IContainerFactory;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
import net.neoforged.neoforge.common.loot.IGlobalLootModifier;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent;
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
import net.neoforged.neoforge.network.IContainerFactory;
|
||||||
|
import net.neoforged.neoforge.registries.DeferredItem;
|
||||||
|
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||||
|
import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
||||||
|
import nl.requios.effortlessbuilding.attachment.PowerLevel;
|
||||||
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
||||||
import nl.requios.effortlessbuilding.gui.DiamondRandomizerBagContainer;
|
import nl.requios.effortlessbuilding.gui.DiamondRandomizerBagContainer;
|
||||||
import nl.requios.effortlessbuilding.gui.GoldenRandomizerBagContainer;
|
import nl.requios.effortlessbuilding.gui.GoldenRandomizerBagContainer;
|
||||||
import nl.requios.effortlessbuilding.gui.RandomizerBagContainer;
|
import nl.requios.effortlessbuilding.gui.RandomizerBagContainer;
|
||||||
import nl.requios.effortlessbuilding.item.*;
|
import nl.requios.effortlessbuilding.item.DiamondRandomizerBagItem;
|
||||||
|
import nl.requios.effortlessbuilding.item.GoldenRandomizerBagItem;
|
||||||
|
import nl.requios.effortlessbuilding.item.PowerLevelItem;
|
||||||
|
import nl.requios.effortlessbuilding.item.RandomizerBagItem;
|
||||||
|
import nl.requios.effortlessbuilding.item.ReachUpgrade1Item;
|
||||||
|
import nl.requios.effortlessbuilding.item.ReachUpgrade2Item;
|
||||||
|
import nl.requios.effortlessbuilding.item.ReachUpgrade3Item;
|
||||||
|
import nl.requios.effortlessbuilding.item.SingleItemLootModifier;
|
||||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
import nl.requios.effortlessbuilding.network.PacketHandler;
|
||||||
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
||||||
import nl.requios.effortlessbuilding.proxy.IProxy;
|
|
||||||
import nl.requios.effortlessbuilding.proxy.ServerProxy;
|
import nl.requios.effortlessbuilding.proxy.ServerProxy;
|
||||||
import nl.requios.effortlessbuilding.systems.ItemUsageTracker;
|
import nl.requios.effortlessbuilding.systems.ItemUsageTracker;
|
||||||
import nl.requios.effortlessbuilding.systems.ServerBlockPlacer;
|
import nl.requios.effortlessbuilding.systems.ServerBlockPlacer;
|
||||||
import nl.requios.effortlessbuilding.systems.ServerPowerLevel;
|
|
||||||
import nl.requios.effortlessbuilding.systems.UndoRedo;
|
import nl.requios.effortlessbuilding.systems.UndoRedo;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@Mod(EffortlessBuilding.MODID)
|
@Mod(EffortlessBuilding.MODID)
|
||||||
public class EffortlessBuilding {
|
public class EffortlessBuilding {
|
||||||
|
|
||||||
@@ -47,73 +59,73 @@ public class EffortlessBuilding {
|
|||||||
public static final Logger logger = LogManager.getLogger();
|
public static final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
public static EffortlessBuilding instance;
|
public static EffortlessBuilding instance;
|
||||||
public static IProxy proxy = DistExecutor.unsafeRunForDist(() -> ClientProxy::new, () -> ServerProxy::new);
|
|
||||||
|
|
||||||
public static final ServerBlockPlacer SERVER_BLOCK_PLACER = new ServerBlockPlacer();
|
public static final ServerBlockPlacer SERVER_BLOCK_PLACER = new ServerBlockPlacer();
|
||||||
public static final UndoRedo UNDO_REDO = new UndoRedo();
|
public static final UndoRedo UNDO_REDO = new UndoRedo();
|
||||||
public static final ItemUsageTracker ITEM_USAGE_TRACKER = new ItemUsageTracker();
|
public static final ItemUsageTracker ITEM_USAGE_TRACKER = new ItemUsageTracker();
|
||||||
public static final ServerPowerLevel SERVER_POWER_LEVEL = new ServerPowerLevel();
|
|
||||||
|
|
||||||
//Registration
|
//Registration
|
||||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
private static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(MODID);
|
||||||
private static final DeferredRegister<MenuType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.MENU_TYPES, EffortlessBuilding.MODID);
|
private static final DeferredRegister<MenuType<?>> CONTAINERS = DeferredRegister.create(BuiltInRegistries.MENU, EffortlessBuilding.MODID);
|
||||||
public static final DeferredRegister<Codec<? extends IGlobalLootModifier>> LOOT_MODIFIERS = DeferredRegister.create(ForgeRegistries.Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS, EffortlessBuilding.MODID);
|
private static final DeferredRegister<MapCodec<? extends IGlobalLootModifier>> LOOT_MODIFIERS = DeferredRegister.create(NeoForgeRegistries.Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS, EffortlessBuilding.MODID);
|
||||||
private static final DeferredRegister<CreativeModeTab> CREATIVE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, EffortlessBuilding.MODID);
|
private static final DeferredRegister<AttachmentType<?>> ATTACHMENT_TYPES = DeferredRegister.create(NeoForgeRegistries.Keys.ATTACHMENT_TYPES, EffortlessBuilding.MODID);
|
||||||
|
|
||||||
public static final RegistryObject<Item> RANDOMIZER_BAG_ITEM = ITEMS.register("randomizer_bag", RandomizerBagItem::new);
|
public static final DeferredItem<RandomizerBagItem> RANDOMIZER_BAG_ITEM = ITEMS.register("randomizer_bag", RandomizerBagItem::new);
|
||||||
public static final RegistryObject<Item> GOLDEN_RANDOMIZER_BAG_ITEM = ITEMS.register("golden_randomizer_bag", GoldenRandomizerBagItem::new);
|
public static final DeferredItem<GoldenRandomizerBagItem> GOLDEN_RANDOMIZER_BAG_ITEM = ITEMS.register("golden_randomizer_bag", GoldenRandomizerBagItem::new);
|
||||||
public static final RegistryObject<Item> DIAMOND_RANDOMIZER_BAG_ITEM = ITEMS.register("diamond_randomizer_bag", DiamondRandomizerBagItem::new);
|
public static final DeferredItem<DiamondRandomizerBagItem> DIAMOND_RANDOMIZER_BAG_ITEM = ITEMS.register("diamond_randomizer_bag", DiamondRandomizerBagItem::new);
|
||||||
public static final RegistryObject<Item> REACH_UPGRADE_1_ITEM = ITEMS.register("reach_upgrade1", ReachUpgrade1Item::new);
|
public static final DeferredItem<ReachUpgrade1Item> REACH_UPGRADE_1_ITEM = ITEMS.register("reach_upgrade1", ReachUpgrade1Item::new);
|
||||||
public static final RegistryObject<Item> REACH_UPGRADE_2_ITEM = ITEMS.register("reach_upgrade2", ReachUpgrade2Item::new);
|
public static final DeferredItem<ReachUpgrade2Item> REACH_UPGRADE_2_ITEM = ITEMS.register("reach_upgrade2", ReachUpgrade2Item::new);
|
||||||
public static final RegistryObject<Item> REACH_UPGRADE_3_ITEM = ITEMS.register("reach_upgrade3", ReachUpgrade3Item::new);
|
public static final DeferredItem<ReachUpgrade3Item> REACH_UPGRADE_3_ITEM = ITEMS.register("reach_upgrade3", ReachUpgrade3Item::new);
|
||||||
public static final RegistryObject<Item> MUSCLES_ITEM = ITEMS.register("muscles", PowerLevelItem::new);
|
public static final DeferredItem<PowerLevelItem> MUSCLES_ITEM = ITEMS.register("muscles", PowerLevelItem::new);
|
||||||
public static final RegistryObject<Item> ELASTIC_HAND_ITEM = ITEMS.register("elastic_hand", PowerLevelItem::new);
|
public static final DeferredItem<PowerLevelItem> ELASTIC_HAND_ITEM = ITEMS.register("elastic_hand", PowerLevelItem::new);
|
||||||
public static final RegistryObject<Item> BUILDING_TECHNIQUES_BOOK_ITEM = ITEMS.register("building_techniques_book", PowerLevelItem::new);
|
public static final DeferredItem<PowerLevelItem> BUILDING_TECHNIQUES_BOOK_ITEM = ITEMS.register("building_techniques_book", PowerLevelItem::new);
|
||||||
|
|
||||||
public static final RegistryObject<MenuType<RandomizerBagContainer>> RANDOMIZER_BAG_CONTAINER = CONTAINERS.register("randomizer_bag", () -> registerContainer(RandomizerBagContainer::new));
|
public static final Supplier<MenuType<RandomizerBagContainer>> RANDOMIZER_BAG_CONTAINER = CONTAINERS.register("randomizer_bag", () -> registerContainer(RandomizerBagContainer::new));
|
||||||
public static final RegistryObject<MenuType<GoldenRandomizerBagContainer>> GOLDEN_RANDOMIZER_BAG_CONTAINER = CONTAINERS.register("golden_randomizer_bag", () -> registerContainer(GoldenRandomizerBagContainer::new));
|
public static final Supplier<MenuType<GoldenRandomizerBagContainer>> GOLDEN_RANDOMIZER_BAG_CONTAINER = CONTAINERS.register("golden_randomizer_bag", () -> registerContainer(GoldenRandomizerBagContainer::new));
|
||||||
public static final RegistryObject<MenuType<DiamondRandomizerBagContainer>> DIAMOND_RANDOMIZER_BAG_CONTAINER = CONTAINERS.register("diamond_randomizer_bag", () -> registerContainer(DiamondRandomizerBagContainer::new));
|
public static final Supplier<MenuType<DiamondRandomizerBagContainer>> DIAMOND_RANDOMIZER_BAG_CONTAINER = CONTAINERS.register("diamond_randomizer_bag", () -> registerContainer(DiamondRandomizerBagContainer::new));
|
||||||
|
|
||||||
public static final RegistryObject<CreativeModeTab> CREATIVE_TAB = CREATIVE_TABS.register("effortlessbuilding",
|
public static final Supplier<MapCodec<SingleItemLootModifier>> SINGLE_ITEM_LOOT_MODIFIER = EffortlessBuilding.LOOT_MODIFIERS.register("single_item_loot_modifier", SingleItemLootModifier.CODEC);
|
||||||
() -> CreativeModeTab.builder()
|
|
||||||
.title(Component.translatable("key.effortlessbuilding.category"))
|
|
||||||
.icon(() -> new ItemStack(RANDOMIZER_BAG_ITEM.get()))
|
|
||||||
.displayItems(new EBCreativeModeTab())
|
|
||||||
.build());
|
|
||||||
|
|
||||||
public EffortlessBuilding() {
|
public static final Supplier<AttachmentType<PowerLevel>> POWER_LEVEL = ATTACHMENT_TYPES.register("power_level", () -> AttachmentType.serializable(PowerLevel::new).build());
|
||||||
|
|
||||||
|
public EffortlessBuilding(IEventBus modEventBus, ModContainer container, Dist dist) {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
ModLoadingContext modLoadingContext = ModLoadingContext.get();
|
IEventBus forgeEventBus = NeoForge.EVENT_BUS;
|
||||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
|
||||||
IEventBus forgeEventBus = MinecraftForge.EVENT_BUS;
|
|
||||||
|
|
||||||
modEventBus.addListener(EffortlessBuilding::setup);
|
modEventBus.addListener(EffortlessBuilding::setup);
|
||||||
|
modEventBus.addListener(EffortlessBuilding::addTabContents);
|
||||||
|
modEventBus.addListener(PacketHandler::setupPackets);
|
||||||
|
|
||||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> EffortlessBuildingClient.onConstructorClient(modEventBus, forgeEventBus));
|
ITEMS.register(modEventBus);
|
||||||
|
CONTAINERS.register(modEventBus);
|
||||||
|
|
||||||
ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
|
LOOT_MODIFIERS.register(modEventBus);
|
||||||
CONTAINERS.register(FMLJavaModLoadingContext.get().getModEventBus());
|
ATTACHMENT_TYPES.register(modEventBus);
|
||||||
|
|
||||||
var singleItemLootModifier = SingleItemLootModifier.CODEC; //load this class to register the loot modifier
|
|
||||||
LOOT_MODIFIERS.register(FMLJavaModLoadingContext.get().getModEventBus());
|
|
||||||
|
|
||||||
CREATIVE_TABS.register(FMLJavaModLoadingContext.get().getModEventBus());
|
|
||||||
|
|
||||||
//Register config
|
//Register config
|
||||||
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, CommonConfig.spec);
|
container.registerConfig(ModConfig.Type.COMMON, CommonConfig.spec);
|
||||||
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ClientConfig.spec);
|
container.registerConfig(ModConfig.Type.SERVER, ServerConfig.spec);
|
||||||
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, ServerConfig.spec);
|
if (dist.isClient()) {
|
||||||
|
container.registerConfig(ModConfig.Type.CLIENT, ClientConfig.spec);
|
||||||
|
container.registerExtensionPoint(IConfigScreenFactory.class, ConfigurationScreen::new);
|
||||||
|
EffortlessBuildingClient.onConstructorClient(modEventBus, forgeEventBus);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setup(final FMLCommonSetupEvent event) {
|
public static void setup(final FMLCommonSetupEvent event) {
|
||||||
PacketHandler.register();
|
|
||||||
|
|
||||||
CompatHelper.setup();
|
CompatHelper.setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends AbstractContainerMenu> MenuType<T> registerContainer(IContainerFactory<T> fact){
|
public static void addTabContents(final BuildCreativeModeTabContentsEvent event) {
|
||||||
MenuType<T> type = new MenuType<T>(fact, FeatureFlagSet.of());
|
if (event.getTabKey() == CreativeModeTabs.TOOLS_AND_UTILITIES) {
|
||||||
|
List<ItemStack> stacks = ITEMS.getEntries().stream().map(reg -> new ItemStack(reg.get())).toList();
|
||||||
|
event.acceptAll(stacks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T extends AbstractContainerMenu> MenuType<T> registerContainer(IContainerFactory<T> fact) {
|
||||||
|
MenuType<T> type = new MenuType<T>(fact, FeatureFlags.REGISTRY.allFlags());
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,11 +143,18 @@ public class EffortlessBuilding {
|
|||||||
|
|
||||||
//Log with translation supported, call either on client or server (which then sends a message)
|
//Log with translation supported, call either on client or server (which then sends a message)
|
||||||
public static void logTranslate(Player player, String prefix, String translationKey, String suffix, boolean actionBar) {
|
public static void logTranslate(Player player, String prefix, String translationKey, String suffix, boolean actionBar) {
|
||||||
proxy.logTranslate(player, prefix, translationKey, suffix, actionBar);
|
if (FMLEnvironment.dist.isClient()) {
|
||||||
|
ClientProxy.logTranslate(player, prefix, translationKey, suffix, actionBar);
|
||||||
|
} else {
|
||||||
|
ServerProxy.logTranslate(player, prefix, translationKey, suffix, actionBar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void logError(String msg) {
|
public static void logError(String msg) {
|
||||||
logger.error(msg);
|
logger.error(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ResourceLocation asResource(String path) {
|
||||||
|
return ResourceLocation.fromNamespaceAndPath(MODID, path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
package nl.requios.effortlessbuilding;
|
package nl.requios.effortlessbuilding;
|
||||||
|
|
||||||
import net.minecraft.client.gui.screens.MenuScreens;
|
import net.neoforged.bus.api.IEventBus;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
|
||||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.BuildModifiers;
|
import nl.requios.effortlessbuilding.buildmodifier.BuildModifiers;
|
||||||
import nl.requios.effortlessbuilding.gui.DiamondRandomizerBagScreen;
|
import nl.requios.effortlessbuilding.gui.DiamondRandomizerBagScreen;
|
||||||
import nl.requios.effortlessbuilding.gui.GoldenRandomizerBagScreen;
|
import nl.requios.effortlessbuilding.gui.GoldenRandomizerBagScreen;
|
||||||
import nl.requios.effortlessbuilding.gui.RandomizerBagScreen;
|
import nl.requios.effortlessbuilding.gui.RandomizerBagScreen;
|
||||||
import nl.requios.effortlessbuilding.render.BlockPreviews;
|
import nl.requios.effortlessbuilding.render.BlockPreviews;
|
||||||
import nl.requios.effortlessbuilding.systems.*;
|
import nl.requios.effortlessbuilding.systems.BuildSettings;
|
||||||
|
import nl.requios.effortlessbuilding.systems.BuilderChain;
|
||||||
|
import nl.requios.effortlessbuilding.systems.BuilderFilter;
|
||||||
|
import nl.requios.effortlessbuilding.systems.ItemUsageTracker;
|
||||||
|
|
||||||
public class EffortlessBuildingClient {
|
public class EffortlessBuildingClient {
|
||||||
|
|
||||||
@@ -20,15 +22,14 @@ public class EffortlessBuildingClient {
|
|||||||
public static final BlockPreviews BLOCK_PREVIEWS = new BlockPreviews();
|
public static final BlockPreviews BLOCK_PREVIEWS = new BlockPreviews();
|
||||||
public static final BuilderFilter BUILDER_FILTER = new BuilderFilter();
|
public static final BuilderFilter BUILDER_FILTER = new BuilderFilter();
|
||||||
public static final ItemUsageTracker ITEM_USAGE_TRACKER = new ItemUsageTracker();
|
public static final ItemUsageTracker ITEM_USAGE_TRACKER = new ItemUsageTracker();
|
||||||
public static final PowerLevel POWER_LEVEL = new PowerLevel();
|
|
||||||
|
|
||||||
public static void onConstructorClient(IEventBus modEventBus, IEventBus forgeEventBus) {
|
public static void onConstructorClient(IEventBus modEventBus, IEventBus forgeEventBus) {
|
||||||
modEventBus.addListener(EffortlessBuildingClient::clientSetup);
|
modEventBus.addListener(EffortlessBuildingClient::registerMenuScreens);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clientSetup(final FMLClientSetupEvent event) {
|
public static void registerMenuScreens(final RegisterMenuScreensEvent event) {
|
||||||
MenuScreens.register(EffortlessBuilding.RANDOMIZER_BAG_CONTAINER.get(), RandomizerBagScreen::new);
|
event.register(EffortlessBuilding.RANDOMIZER_BAG_CONTAINER.get(), RandomizerBagScreen::new);
|
||||||
MenuScreens.register(EffortlessBuilding.GOLDEN_RANDOMIZER_BAG_CONTAINER.get(), GoldenRandomizerBagScreen::new);
|
event.register(EffortlessBuilding.GOLDEN_RANDOMIZER_BAG_CONTAINER.get(), GoldenRandomizerBagScreen::new);
|
||||||
MenuScreens.register(EffortlessBuilding.DIAMOND_RANDOMIZER_BAG_CONTAINER.get(), DiamondRandomizerBagScreen::new);
|
event.register(EffortlessBuilding.DIAMOND_RANDOMIZER_BAG_CONTAINER.get(), DiamondRandomizerBagScreen::new);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
package nl.requios.effortlessbuilding;
|
package nl.requios.effortlessbuilding;
|
||||||
|
|
||||||
import net.minecraftforge.common.ForgeConfigSpec;
|
import net.neoforged.neoforge.common.ModConfigSpec;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.minecraftforge.common.ForgeConfigSpec.*;
|
import static net.neoforged.neoforge.common.ModConfigSpec.BooleanValue;
|
||||||
|
import static net.neoforged.neoforge.common.ModConfigSpec.Builder;
|
||||||
|
import static net.neoforged.neoforge.common.ModConfigSpec.ConfigValue;
|
||||||
|
import static net.neoforged.neoforge.common.ModConfigSpec.IntValue;
|
||||||
|
|
||||||
public class ServerConfig {
|
public class ServerConfig {
|
||||||
private static final Builder builder = new Builder();
|
private static final Builder builder = new Builder();
|
||||||
public static final ServerConfig.Validation validation = new ServerConfig.Validation(builder);
|
public static final ServerConfig.Validation validation = new ServerConfig.Validation(builder);
|
||||||
public static final ServerConfig.Memory memory = new ServerConfig.Memory(builder);
|
public static final ServerConfig.Memory memory = new ServerConfig.Memory(builder);
|
||||||
public static final ForgeConfigSpec spec = builder.build();
|
public static final ModConfigSpec spec = builder.build();
|
||||||
|
|
||||||
public static class Validation {
|
public static class Validation {
|
||||||
public final BooleanValue allowInSurvival;
|
public final BooleanValue allowInSurvival;
|
||||||
|
|||||||
@@ -0,0 +1,130 @@
|
|||||||
|
package nl.requios.effortlessbuilding.attachment;
|
||||||
|
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import nl.requios.effortlessbuilding.CommonConfig;
|
||||||
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
|
import nl.requios.effortlessbuilding.network.message.PowerLevelPacket;
|
||||||
|
|
||||||
|
public class AttachmentHandler {
|
||||||
|
public static final ResourceLocation POWER_LEVEL_CAP = EffortlessBuilding.asResource("power_level");
|
||||||
|
|
||||||
|
public static void syncToClient(Player player) {
|
||||||
|
PowerLevel powerLevel = player.getData(EffortlessBuilding.POWER_LEVEL);
|
||||||
|
if (powerLevel == null) return; //Should never be null but just to be sure
|
||||||
|
|
||||||
|
((ServerPlayer)player).connection.send(new PowerLevelPacket(powerLevel.getPowerLevel()));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Helper methods to reduce boilerplate code
|
||||||
|
public static boolean canReplaceBlocks(Player player) {
|
||||||
|
if (player != null) {
|
||||||
|
PowerLevel powerLevel = player.getData(EffortlessBuilding.POWER_LEVEL);
|
||||||
|
if (powerLevel != null) {
|
||||||
|
return powerLevel.canReplaceBlocks(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getMaxBlocksPerAxis(Player player, boolean nextPowerLevel) {
|
||||||
|
if (player != null) {
|
||||||
|
PowerLevel powerLevel = player.getData(EffortlessBuilding.POWER_LEVEL);
|
||||||
|
if (powerLevel != null) {
|
||||||
|
return powerLevel.getMaxBlocksPerAxis(player, nextPowerLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CommonConfig.maxBlocksPerAxis.level0.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getMaxBlocksPlacedAtOnce(Player player, boolean nextPowerLevel) {
|
||||||
|
if (player != null) {
|
||||||
|
PowerLevel powerLevel = player.getData(EffortlessBuilding.POWER_LEVEL);
|
||||||
|
if (powerLevel != null) {
|
||||||
|
return powerLevel.getMaxBlocksPlacedAtOnce(player, nextPowerLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CommonConfig.maxBlocksPlacedAtOnce.level0.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getMaxMirrorRadius(Player player, boolean nextPowerLevel) {
|
||||||
|
if (player != null) {
|
||||||
|
PowerLevel powerLevel = player.getData(EffortlessBuilding.POWER_LEVEL);
|
||||||
|
if (powerLevel != null) {
|
||||||
|
return powerLevel.getMaxMirrorRadius(player, nextPowerLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CommonConfig.maxMirrorRadius.level0.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getBuildModeReach(Player player) {
|
||||||
|
if (player != null) {
|
||||||
|
PowerLevel powerLevel = player.getData(EffortlessBuilding.POWER_LEVEL);
|
||||||
|
if (powerLevel != null) {
|
||||||
|
return powerLevel.getBuildModeReach(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CommonConfig.maxMirrorRadius.level0.get() + 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getPlacementReach(Player player, boolean nextPowerLevel) {
|
||||||
|
if (player != null) {
|
||||||
|
PowerLevel powerLevel = player.getData(EffortlessBuilding.POWER_LEVEL);
|
||||||
|
if (powerLevel != null) {
|
||||||
|
return powerLevel.getPlacementReach(player, nextPowerLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CommonConfig.reach.level0.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getPowerLevel(Player player) {
|
||||||
|
if (player != null) {
|
||||||
|
PowerLevel powerLevel = player.getData(EffortlessBuilding.POWER_LEVEL);
|
||||||
|
if (powerLevel != null) {
|
||||||
|
return powerLevel.getPowerLevel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getNextPowerLevel(Player player) {
|
||||||
|
if (player != null) {
|
||||||
|
PowerLevel powerLevel = player.getData(EffortlessBuilding.POWER_LEVEL);
|
||||||
|
if (powerLevel != null) {
|
||||||
|
return powerLevel.getNextPowerLevel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean canIncreasePowerLevel(Player player) {
|
||||||
|
if (player != null) {
|
||||||
|
PowerLevel powerLevel = player.getData(EffortlessBuilding.POWER_LEVEL);
|
||||||
|
if (powerLevel != null) {
|
||||||
|
return powerLevel.canIncreasePowerLevel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isDisabled(Player player) {
|
||||||
|
if (player != null) {
|
||||||
|
PowerLevel powerLevel = player.getData(EffortlessBuilding.POWER_LEVEL);
|
||||||
|
if (powerLevel != null) {
|
||||||
|
return powerLevel.isDisabled(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean canBreakFar(Player player) {
|
||||||
|
if (player != null) {
|
||||||
|
PowerLevel powerLevel = player.getData(EffortlessBuilding.POWER_LEVEL);
|
||||||
|
if (powerLevel != null) {
|
||||||
|
return powerLevel.canBreakFar(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,51 +1,41 @@
|
|||||||
package nl.requios.effortlessbuilding.systems;
|
package nl.requios.effortlessbuilding.attachment;
|
||||||
|
|
||||||
|
import net.minecraft.core.HolderLookup.Provider;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.neoforged.neoforge.common.util.INBTSerializable;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
import nl.requios.effortlessbuilding.CommonConfig;
|
import nl.requios.effortlessbuilding.CommonConfig;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
|
||||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
|
||||||
import nl.requios.effortlessbuilding.network.PowerLevelPacket;
|
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
public class PowerLevel implements INBTSerializable<CompoundTag> {
|
||||||
public class PowerLevel {
|
public static final int MAX_POWER_LEVEL = 3; //Common access
|
||||||
|
|
||||||
private int powerLevel;
|
public PowerLevel() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private int powerLevel = 0;
|
||||||
|
|
||||||
public int getPowerLevel() {
|
public int getPowerLevel() {
|
||||||
return powerLevel;
|
return this.powerLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNextPowerLevel() {
|
public int getNextPowerLevel() {
|
||||||
return Math.min(powerLevel + 1, ServerPowerLevel.MAX_POWER_LEVEL);
|
return Math.min(getPowerLevel() + 1, MAX_POWER_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPowerLevel(int powerLevel) {
|
public void setPowerLevel(int powerLevel) {
|
||||||
this.powerLevel = powerLevel;
|
this.powerLevel = powerLevel;
|
||||||
EffortlessBuildingClient.BUILD_MODIFIERS.onPowerLevelChanged(powerLevel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canIncreasePowerLevel() {
|
public boolean canIncreasePowerLevel() {
|
||||||
return getPowerLevel() < ServerPowerLevel.MAX_POWER_LEVEL;
|
return getPowerLevel() < MAX_POWER_LEVEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void increasePowerLevel() {
|
public void increasePowerLevel() {
|
||||||
if (canIncreasePowerLevel()) {
|
if (canIncreasePowerLevel()) {
|
||||||
setPowerLevel(getPowerLevel() + 1);
|
setPowerLevel(getPowerLevel() + 1);
|
||||||
PacketHandler.INSTANCE.sendToServer(new PowerLevelPacket(powerLevel));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public int getMaxReach(Player player) {
|
|
||||||
return getPlacementReach(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPlacementReach(Player player) {
|
|
||||||
return getPlacementReach(player, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPlacementReach(Player player, boolean nextPowerLevel) {
|
public int getPlacementReach(Player player, boolean nextPowerLevel) {
|
||||||
if (player.isCreative()) return CommonConfig.reach.creative.get();
|
if (player.isCreative()) return CommonConfig.reach.creative.get();
|
||||||
return switch (nextPowerLevel ? getNextPowerLevel() : getPowerLevel()) {
|
return switch (nextPowerLevel ? getNextPowerLevel() : getPowerLevel()) {
|
||||||
@@ -59,11 +49,7 @@ public class PowerLevel {
|
|||||||
//How far away we can detect the second and third click of build modes (distance to player)
|
//How far away we can detect the second and third click of build modes (distance to player)
|
||||||
public int getBuildModeReach(Player player) {
|
public int getBuildModeReach(Player player) {
|
||||||
//A bit further than placement reach, so you can build lines when looking to the side without having to move.
|
//A bit further than placement reach, so you can build lines when looking to the side without having to move.
|
||||||
return getPlacementReach(player) + 6;
|
return getPlacementReach(player, false) + 6;
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxBlocksPlacedAtOnce(Player player) {
|
|
||||||
return getMaxBlocksPlacedAtOnce(player, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxBlocksPlacedAtOnce(Player player, boolean nextPowerLevel) {
|
public int getMaxBlocksPlacedAtOnce(Player player, boolean nextPowerLevel) {
|
||||||
@@ -76,10 +62,6 @@ public class PowerLevel {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxBlocksPerAxis(Player player) {
|
|
||||||
return getMaxBlocksPerAxis(player, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxBlocksPerAxis(Player player, boolean nextPowerLevel) {
|
public int getMaxBlocksPerAxis(Player player, boolean nextPowerLevel) {
|
||||||
if (player.isCreative()) return CommonConfig.maxBlocksPerAxis.creative.get();
|
if (player.isCreative()) return CommonConfig.maxBlocksPerAxis.creative.get();
|
||||||
return switch (nextPowerLevel ? getNextPowerLevel() : getPowerLevel()) {
|
return switch (nextPowerLevel ? getNextPowerLevel() : getPowerLevel()) {
|
||||||
@@ -90,10 +72,6 @@ public class PowerLevel {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxMirrorRadius(Player player) {
|
|
||||||
return getMaxMirrorRadius(player, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxMirrorRadius(Player player, boolean nextPowerLevel) {
|
public int getMaxMirrorRadius(Player player, boolean nextPowerLevel) {
|
||||||
if (player.isCreative()) return CommonConfig.maxMirrorRadius.creative.get();
|
if (player.isCreative()) return CommonConfig.maxMirrorRadius.creative.get();
|
||||||
return switch (getPowerLevel() + (nextPowerLevel ? 1 : 0)) {
|
return switch (getPowerLevel() + (nextPowerLevel ? 1 : 0)) {
|
||||||
@@ -105,14 +83,24 @@ public class PowerLevel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDisabled(Player player) {
|
public boolean isDisabled(Player player) {
|
||||||
return getMaxBlocksPlacedAtOnce(player) <= 0 || getMaxBlocksPerAxis(player) <= 0;
|
return getMaxBlocksPlacedAtOnce(player, false) <= 0 || getMaxBlocksPerAxis(player, false) <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canBreakFar(Player player) {
|
public boolean canBreakFar(Player player) {
|
||||||
return player.isCreative();
|
return player.getAbilities().instabuild;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canReplaceBlocks(Player player) {
|
public boolean canReplaceBlocks(Player player) {
|
||||||
return player.isCreative();
|
return player.getAbilities().instabuild;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompoundTag serializeNBT(Provider provider) {
|
||||||
|
CompoundTag tag = new CompoundTag();
|
||||||
|
tag.putInt("powerLevel", getPowerLevel());
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deserializeNBT(Provider provider, CompoundTag nbt) {
|
||||||
|
setPowerLevel(nbt.getInt("powerLevel"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmode;
|
package nl.requios.effortlessbuilding.buildmode;
|
||||||
|
|
||||||
import org.joml.Vector4f;
|
import net.createmod.catnip.theme.Color;
|
||||||
|
|
||||||
public enum BuildModeCategoryEnum {
|
public enum BuildModeCategoryEnum {
|
||||||
BASIC(new Vector4f(0f, .5f, 1f, .8f)),
|
BASIC(new Color(0f, .5f, 1f, .8f)),
|
||||||
DIAGONAL(new Vector4f(0.56f, 0.28f, 0.87f, .8f)),
|
DIAGONAL(new Color(0.56f, 0.28f, 0.87f, .8f)),
|
||||||
CIRCULAR(new Vector4f(0.29f, 0.76f, 0.3f, 1f)),
|
CIRCULAR(new Color(0.29f, 0.76f, 0.3f, 1f)),
|
||||||
ROOF(new Vector4f(0.83f, 0.87f, 0.23f, .8f));
|
ROOF(new Color(0.83f, 0.87f, 0.23f, .8f));
|
||||||
|
|
||||||
public final Vector4f color;
|
public final Color color;
|
||||||
|
|
||||||
BuildModeCategoryEnum(Vector4f color) {
|
BuildModeCategoryEnum(Color color) {
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,18 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmode;
|
package nl.requios.effortlessbuilding.buildmode;
|
||||||
|
|
||||||
import nl.requios.effortlessbuilding.AllIcons;
|
import nl.requios.effortlessbuilding.AllIcons;
|
||||||
import nl.requios.effortlessbuilding.buildmode.buildmodes.*;
|
import nl.requios.effortlessbuilding.buildmode.buildmodes.Circle;
|
||||||
|
import nl.requios.effortlessbuilding.buildmode.buildmodes.Cube;
|
||||||
|
import nl.requios.effortlessbuilding.buildmode.buildmodes.Cylinder;
|
||||||
|
import nl.requios.effortlessbuilding.buildmode.buildmodes.DiagonalLine;
|
||||||
|
import nl.requios.effortlessbuilding.buildmode.buildmodes.DiagonalWall;
|
||||||
|
import nl.requios.effortlessbuilding.buildmode.buildmodes.Disabled;
|
||||||
|
import nl.requios.effortlessbuilding.buildmode.buildmodes.Floor;
|
||||||
|
import nl.requios.effortlessbuilding.buildmode.buildmodes.Line;
|
||||||
|
import nl.requios.effortlessbuilding.buildmode.buildmodes.Single;
|
||||||
|
import nl.requios.effortlessbuilding.buildmode.buildmodes.SlopeFloor;
|
||||||
|
import nl.requios.effortlessbuilding.buildmode.buildmodes.Sphere;
|
||||||
|
import nl.requios.effortlessbuilding.buildmode.buildmodes.Wall;
|
||||||
|
|
||||||
public enum BuildModeEnum {
|
public enum BuildModeEnum {
|
||||||
DISABLED("normal", new Disabled(), BuildModeCategoryEnum.BASIC, AllIcons.I_DISABLE),
|
DISABLED("normal", new Disabled(), BuildModeCategoryEnum.BASIC, AllIcons.I_DISABLE),
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import net.minecraft.world.entity.player.Player;
|
|||||||
import net.minecraft.world.level.ClipContext;
|
import net.minecraft.world.level.ClipContext;
|
||||||
import net.minecraft.world.phys.HitResult;
|
import net.minecraft.world.phys.HitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
import net.neoforged.neoforge.network.PacketDistributor;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.network.IsUsingBuildModePacket;
|
import nl.requios.effortlessbuilding.network.message.IsUsingBuildModePacket;
|
||||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
|
||||||
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@@ -30,7 +30,7 @@ public class BuildModes {
|
|||||||
public void setBuildMode(BuildModeEnum buildMode) {
|
public void setBuildMode(BuildModeEnum buildMode) {
|
||||||
this.buildMode = buildMode;
|
this.buildMode = buildMode;
|
||||||
|
|
||||||
PacketHandler.INSTANCE.sendToServer(new IsUsingBuildModePacket(this.buildMode != BuildModeEnum.DISABLED));
|
PacketDistributor.sendToServer(new IsUsingBuildModePacket(this.buildMode != BuildModeEnum.DISABLED));
|
||||||
|
|
||||||
EffortlessBuilding.log(Minecraft.getInstance().player, I18n.get(buildMode.getNameKey()), true);
|
EffortlessBuilding.log(Minecraft.getInstance().player, I18n.get(buildMode.getNameKey()), true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmode;
|
package nl.requios.effortlessbuilding.buildmode;
|
||||||
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
import net.neoforged.neoforge.network.PacketDistributor;
|
||||||
import nl.requios.effortlessbuilding.AllIcons;
|
import nl.requios.effortlessbuilding.AllIcons;
|
||||||
import nl.requios.effortlessbuilding.ClientEvents;
|
import nl.requios.effortlessbuilding.ClientEvents;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
import nl.requios.effortlessbuilding.network.message.PerformRedoPacket;
|
||||||
import nl.requios.effortlessbuilding.network.PerformRedoPacket;
|
import nl.requios.effortlessbuilding.network.message.PerformUndoPacket;
|
||||||
import nl.requios.effortlessbuilding.network.PerformUndoPacket;
|
|
||||||
import nl.requios.effortlessbuilding.systems.BuildSettings;
|
import nl.requios.effortlessbuilding.systems.BuildSettings;
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@@ -69,8 +69,8 @@ public class ModeOptions {
|
|||||||
if (action == null) return;
|
if (action == null) return;
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case UNDO -> PacketHandler.INSTANCE.sendToServer(new PerformUndoPacket());
|
case UNDO -> PacketDistributor.sendToServer(new PerformUndoPacket());
|
||||||
case REDO -> PacketHandler.INSTANCE.sendToServer(new PerformRedoPacket());
|
case REDO -> PacketDistributor.sendToServer(new PerformRedoPacket());
|
||||||
case OPEN_MODIFIER_SETTINGS -> ClientEvents.openModifierSettings();
|
case OPEN_MODIFIER_SETTINGS -> ClientEvents.openModifierSettings();
|
||||||
case OPEN_PLAYER_SETTINGS -> ClientEvents.openPlayerSettings();
|
case OPEN_PLAYER_SETTINGS -> ClientEvents.openPlayerSettings();
|
||||||
case PREVIOUS_BUILD_MODE -> EffortlessBuildingClient.BUILD_MODES.activatePreviousBuildMode();
|
case PREVIOUS_BUILD_MODE -> EffortlessBuildingClient.BUILD_MODES.activatePreviousBuildMode();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import net.minecraft.core.BlockPos;
|
|||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||||
|
import nl.requios.effortlessbuilding.attachment.AttachmentHandler;
|
||||||
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
||||||
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
||||||
|
|
||||||
@@ -64,7 +65,7 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode {
|
|||||||
if (secondPos == null) return;
|
if (secondPos == null) return;
|
||||||
|
|
||||||
//Limit amount of blocks we can place per row
|
//Limit amount of blocks we can place per row
|
||||||
int axisLimit = EffortlessBuildingClient.POWER_LEVEL.getMaxBlocksPerAxis(player);
|
int axisLimit = AttachmentHandler.getMaxBlocksPerAxis(player, false);
|
||||||
|
|
||||||
int x1 = firstPos.getX(), x2 = secondPos.getX();
|
int x1 = firstPos.getX(), x2 = secondPos.getX();
|
||||||
int y1 = firstPos.getY(), y2 = secondPos.getY();
|
int y1 = firstPos.getY(), y2 = secondPos.getY();
|
||||||
@@ -93,7 +94,7 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode {
|
|||||||
if (thirdPos == null) return;
|
if (thirdPos == null) return;
|
||||||
|
|
||||||
//Limit amount of blocks you can place per row
|
//Limit amount of blocks you can place per row
|
||||||
int axisLimit = EffortlessBuildingClient.POWER_LEVEL.getMaxBlocksPerAxis(player);
|
int axisLimit = AttachmentHandler.getMaxBlocksPerAxis(player, false);
|
||||||
|
|
||||||
int x1 = firstPos.getX(), x2 = secondPos.getX(), x3 = thirdPos.getX();
|
int x1 = firstPos.getX(), x2 = secondPos.getX(), x3 = thirdPos.getX();
|
||||||
int y1 = firstPos.getY(), y2 = secondPos.getY(), y3 = thirdPos.getY();
|
int y1 = firstPos.getY(), y2 = secondPos.getY(), y3 = thirdPos.getY();
|
||||||
@@ -139,7 +140,7 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode {
|
|||||||
criteriaList.add(new HeightCriteria(zBound, secondPos, start));
|
criteriaList.add(new HeightCriteria(zBound, secondPos, start));
|
||||||
|
|
||||||
//Remove invalid criteria
|
//Remove invalid criteria
|
||||||
int reach = EffortlessBuildingClient.POWER_LEVEL.getBuildModeReach(player);
|
int reach = AttachmentHandler.getBuildModeReach(player);
|
||||||
criteriaList.removeIf(criteria -> !criteria.isValid(start, look, reach, player, skipRaytrace));
|
criteriaList.removeIf(criteria -> !criteria.isValid(start, look, reach, player, skipRaytrace));
|
||||||
|
|
||||||
//If none are valid, return empty list of blocks
|
//If none are valid, return empty list of blocks
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import net.minecraft.client.Minecraft;
|
|||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||||
|
import nl.requios.effortlessbuilding.attachment.AttachmentHandler;
|
||||||
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
||||||
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
||||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ public abstract class TwoClicksBuildMode extends BaseBuildMode {
|
|||||||
if (secondPos == null) return;
|
if (secondPos == null) return;
|
||||||
|
|
||||||
//Limit amount of blocks we can place per row
|
//Limit amount of blocks we can place per row
|
||||||
int axisLimit = EffortlessBuildingClient.POWER_LEVEL.getMaxBlocksPerAxis(player);
|
int axisLimit = AttachmentHandler.getMaxBlocksPerAxis(player, false);
|
||||||
|
|
||||||
int x1 = firstPos.getX(), x2 = secondPos.getX();
|
int x1 = firstPos.getX(), x2 = secondPos.getX();
|
||||||
int y1 = firstPos.getY(), y2 = secondPos.getY();
|
int y1 = firstPos.getY(), y2 = secondPos.getY();
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||||
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||||
import nl.requios.effortlessbuilding.buildmode.TwoClicksBuildMode;
|
import nl.requios.effortlessbuilding.buildmode.TwoClicksBuildMode;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||||
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||||
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||||
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||||
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||||
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
import nl.requios.effortlessbuilding.attachment.AttachmentHandler;
|
||||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||||
import nl.requios.effortlessbuilding.buildmode.TwoClicksBuildMode;
|
import nl.requios.effortlessbuilding.buildmode.TwoClicksBuildMode;
|
||||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -25,7 +24,7 @@ public class Floor extends TwoClicksBuildMode {
|
|||||||
criteriaList.add(new Criteria(yBound, start));
|
criteriaList.add(new Criteria(yBound, start));
|
||||||
|
|
||||||
//Remove invalid criteria
|
//Remove invalid criteria
|
||||||
int reach = EffortlessBuildingClient.POWER_LEVEL.getBuildModeReach(player);
|
int reach = AttachmentHandler.getBuildModeReach(player);
|
||||||
criteriaList.removeIf(criteria -> !criteria.isValid(start, look, reach, player, skipRaytrace));
|
criteriaList.removeIf(criteria -> !criteria.isValid(start, look, reach, player, skipRaytrace));
|
||||||
|
|
||||||
//If none are valid, return empty list of blocks
|
//If none are valid, return empty list of blocks
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||||
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
import nl.requios.effortlessbuilding.attachment.AttachmentHandler;
|
||||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||||
import nl.requios.effortlessbuilding.buildmode.TwoClicksBuildMode;
|
import nl.requios.effortlessbuilding.buildmode.TwoClicksBuildMode;
|
||||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -32,7 +31,7 @@ public class Line extends TwoClicksBuildMode {
|
|||||||
criteriaList.add(new Criteria(zBound, firstPos, start));
|
criteriaList.add(new Criteria(zBound, firstPos, start));
|
||||||
|
|
||||||
//Remove invalid criteria
|
//Remove invalid criteria
|
||||||
int reach = EffortlessBuildingClient.POWER_LEVEL.getBuildModeReach(player);
|
int reach = AttachmentHandler.getBuildModeReach(player);
|
||||||
criteriaList.removeIf(criteria -> !criteria.isValid(start, look, reach, player, skipRaytrace));
|
criteriaList.removeIf(criteria -> !criteria.isValid(start, look, reach, player, skipRaytrace));
|
||||||
|
|
||||||
//If none are valid, return empty list of blocks
|
//If none are valid, return empty list of blocks
|
||||||
@@ -90,7 +89,7 @@ public class Line extends TwoClicksBuildMode {
|
|||||||
|
|
||||||
public static void addZLineBlocks(List<BlockPos> list, int z1, int z2, int x, int y) {
|
public static void addZLineBlocks(List<BlockPos> list, int z1, int z2, int x, int y) {
|
||||||
for (int z = z1; z1 < z2 ? z <= z2 : z >= z2; z += z1 < z2 ? 1 : -1) {
|
for (int z = z1; z1 < z2 ? z <= z2 : z >= z2; z += z1 < z2 ? 1 : -1) {
|
||||||
list.add(new BlockPos(x, y, z));
|
list.add(BlockPos.containing(x, y, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||||
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import nl.requios.effortlessbuilding.attachment.AttachmentHandler;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
||||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -16,7 +15,7 @@ public class SlopeFloor extends ThreeClicksBuildMode {
|
|||||||
public static List<BlockPos> getSlopeFloorBlocks(Player player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
public static List<BlockPos> getSlopeFloorBlocks(Player player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||||
List<BlockPos> list = new ArrayList<>();
|
List<BlockPos> list = new ArrayList<>();
|
||||||
|
|
||||||
int axisLimit = EffortlessBuildingClient.POWER_LEVEL.getMaxBlocksPerAxis(player);
|
int axisLimit = AttachmentHandler.getMaxBlocksPerAxis(player, false);
|
||||||
|
|
||||||
//Determine whether to use x or z axis to slope up
|
//Determine whether to use x or z axis to slope up
|
||||||
boolean onXAxis = true;
|
boolean onXAxis = true;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||||
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||||
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
import nl.requios.effortlessbuilding.attachment.AttachmentHandler;
|
||||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||||
import nl.requios.effortlessbuilding.buildmode.TwoClicksBuildMode;
|
import nl.requios.effortlessbuilding.buildmode.TwoClicksBuildMode;
|
||||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -29,7 +28,7 @@ public class Wall extends TwoClicksBuildMode {
|
|||||||
criteriaList.add(new Criteria(zBound, firstPos, start, look));
|
criteriaList.add(new Criteria(zBound, firstPos, start, look));
|
||||||
|
|
||||||
//Remove invalid criteria
|
//Remove invalid criteria
|
||||||
int reach = EffortlessBuildingClient.POWER_LEVEL.getBuildModeReach(player);
|
int reach = AttachmentHandler.getBuildModeReach(player);
|
||||||
criteriaList.removeIf(criteria -> !criteria.isValid(start, look, reach, player, skipRaytrace));
|
criteriaList.removeIf(criteria -> !criteria.isValid(start, look, reach, player, skipRaytrace));
|
||||||
|
|
||||||
//If none are valid, return empty list of blocks
|
//If none are valid, return empty list of blocks
|
||||||
|
|||||||
@@ -1,24 +1,12 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmodifier;
|
package nl.requios.effortlessbuilding.buildmodifier;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.nbt.NbtUtils;
|
|
||||||
import net.minecraft.nbt.Tag;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.world.InteractionHand;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
import net.minecraft.core.Vec3i;
|
import net.minecraft.core.Vec3i;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import nl.requios.effortlessbuilding.item.AbstractRandomizerBagItem;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
||||||
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Array extends BaseModifier {
|
public class Array extends BaseModifier {
|
||||||
|
|
||||||
public Vec3i offset = BlockPos.ZERO;
|
public Vec3i offset = BlockPos.ZERO;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmodifier;
|
package nl.requios.effortlessbuilding.buildmodifier;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.Tag;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmodifier;
|
package nl.requios.effortlessbuilding.buildmodifier;
|
||||||
|
|
||||||
|
import net.createmod.catnip.nbt.NBTHelper;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.NBTHelper;
|
import net.neoforged.neoforge.network.PacketDistributor;
|
||||||
import nl.requios.effortlessbuilding.network.ModifierSettingsPacket;
|
import nl.requios.effortlessbuilding.network.message.ModifierSettingsPacket;
|
||||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
|
||||||
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -96,7 +96,7 @@ public class BuildModifiers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
PacketHandler.INSTANCE.sendToServer(new ModifierSettingsPacket(serializeNBT()));
|
PacketDistributor.sendToServer(new ModifierSettingsPacket(serializeNBT()));
|
||||||
|
|
||||||
//Save locally as well?
|
//Save locally as well?
|
||||||
// var listTag = NBTHelper.writeCompoundList(modifierSettingsList, BaseModifier::serializeNBT);
|
// var listTag = NBTHelper.writeCompoundList(modifierSettingsList, BaseModifier::serializeNBT);
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmodifier;
|
package nl.requios.effortlessbuilding.buildmodifier;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.nbt.NbtUtils;
|
|
||||||
import net.minecraft.nbt.Tag;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import nl.requios.effortlessbuilding.attachment.AttachmentHandler;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
|
||||||
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
||||||
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
||||||
|
|
||||||
@@ -44,7 +41,7 @@ public class Mirror extends BaseModifier {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPowerLevelChanged(int powerLevel) {
|
public void onPowerLevelChanged(int powerLevel) {
|
||||||
radius = EffortlessBuildingClient.POWER_LEVEL.getMaxMirrorRadius(Minecraft.getInstance().player);
|
radius = AttachmentHandler.getMaxMirrorRadius(Minecraft.getInstance().player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void performMirrorX(BlockSet blocks, BlockEntry blockEntry) {
|
private void performMirrorX(BlockSet blocks, BlockEntry blockEntry) {
|
||||||
|
|||||||
@@ -1,26 +1,18 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmodifier;
|
package nl.requios.effortlessbuilding.buildmodifier;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.world.InteractionHand;
|
|
||||||
import net.minecraft.world.level.block.Mirror;
|
import net.minecraft.world.level.block.Mirror;
|
||||||
import net.minecraft.world.level.block.Rotation;
|
import net.minecraft.world.level.block.Rotation;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.util.Mth;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import nl.requios.effortlessbuilding.attachment.AttachmentHandler;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
|
||||||
import nl.requios.effortlessbuilding.item.AbstractRandomizerBagItem;
|
|
||||||
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
||||||
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class RadialMirror extends BaseModifier {
|
public class RadialMirror extends BaseModifier {
|
||||||
|
|
||||||
public Vec3 position = new Vec3(0.5, 64.5, 0.5);
|
public Vec3 position = new Vec3(0.5, 64.5, 0.5);
|
||||||
@@ -51,7 +43,7 @@ public class RadialMirror extends BaseModifier {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPowerLevelChanged(int powerLevel) {
|
public void onPowerLevelChanged(int powerLevel) {
|
||||||
radius = EffortlessBuildingClient.POWER_LEVEL.getMaxMirrorRadius(Minecraft.getInstance().player);
|
radius = AttachmentHandler.getMaxMirrorRadius(Minecraft.getInstance().player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void performRadialMirror(BlockSet blocks, BlockEntry blockEntry) {
|
public void performRadialMirror(BlockSet blocks, BlockEntry blockEntry) {
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package nl.requios.effortlessbuilding.compatibility;
|
package nl.requios.effortlessbuilding.compatibility;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.Blocks;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.item.BlockItem;
|
import net.minecraft.world.item.BlockItem;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.neoforged.neoforge.items.IItemHandler;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.item.ItemHelper;
|
import nl.requios.effortlessbuilding.create.foundation.item.ItemHelper;
|
||||||
import nl.requios.effortlessbuilding.item.AbstractRandomizerBagItem;
|
import nl.requios.effortlessbuilding.item.AbstractRandomizerBagItem;
|
||||||
|
|
||||||
|
|||||||
@@ -1,69 +1,12 @@
|
|||||||
package nl.requios.effortlessbuilding.create;
|
package nl.requios.effortlessbuilding.create;
|
||||||
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.InputConstants;
|
import com.mojang.blaze3d.platform.InputConstants;
|
||||||
|
|
||||||
import net.minecraft.client.KeyMapping;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import org.lwjgl.glfw.GLFW;
|
||||||
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
|
||||||
|
|
||||||
//@EventBusSubscriber(value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD)
|
|
||||||
public class AllKeys {
|
public class AllKeys {
|
||||||
|
|
||||||
// TOOL_MENU("toolmenu", GLFW.GLFW_KEY_LEFT_ALT),
|
|
||||||
// ACTIVATE_TOOL("", GLFW.GLFW_KEY_LEFT_CONTROL),
|
|
||||||
// TOOLBELT("toolbelt", GLFW.GLFW_KEY_LEFT_ALT),
|
|
||||||
//
|
|
||||||
// ;
|
|
||||||
//
|
|
||||||
// private KeyMapping keybind;
|
|
||||||
// private String description;
|
|
||||||
// private int key;
|
|
||||||
// private boolean modifiable;
|
|
||||||
//
|
|
||||||
// private AllKeys(String description, int defaultKey) {
|
|
||||||
// this.description = Create.ID + ".keyinfo." + description;
|
|
||||||
// this.key = defaultKey;
|
|
||||||
// this.modifiable = !description.isEmpty();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @SubscribeEvent
|
|
||||||
// public static void register(RegisterKeyMappingsEvent event) {
|
|
||||||
// for (AllKeys key : values()) {
|
|
||||||
// key.keybind = new KeyMapping(key.description, key.key, Create.NAME);
|
|
||||||
// if (!key.modifiable)
|
|
||||||
// continue;
|
|
||||||
//
|
|
||||||
// event.register(key.keybind);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public KeyMapping getKeybind() {
|
|
||||||
// return keybind;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public boolean isPressed() {
|
|
||||||
// if (!modifiable)
|
|
||||||
// return isKeyDown(key);
|
|
||||||
// return keybind.isDown();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public String getBoundKey() {
|
|
||||||
// return keybind.getTranslatedKeyMessage()
|
|
||||||
// .getString()
|
|
||||||
// .toUpperCase();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public int getBoundCode() {
|
|
||||||
// return keybind.getKey()
|
|
||||||
// .getValue();
|
|
||||||
// }
|
|
||||||
|
|
||||||
public static boolean isKeyDown(int key) {
|
public static boolean isKeyDown(int key) {
|
||||||
return InputConstants.isKeyDown(Minecraft.getInstance()
|
return InputConstants.isKeyDown(Minecraft.getInstance()
|
||||||
.getWindow()
|
.getWindow()
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package nl.requios.effortlessbuilding.create;
|
package nl.requios.effortlessbuilding.create;
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import net.createmod.catnip.render.BindableTexture;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public enum AllSpecialTextures {
|
public enum AllSpecialTextures implements BindableTexture {
|
||||||
|
|
||||||
BLANK("blank.png"),
|
BLANK("blank.png"),
|
||||||
CHECKERED("checkerboard.png"),
|
CHECKERED("checkerboard.png"),
|
||||||
@@ -19,7 +19,7 @@ public enum AllSpecialTextures {
|
|||||||
public static final String ASSET_PATH = "textures/special/";
|
public static final String ASSET_PATH = "textures/special/";
|
||||||
private ResourceLocation location;
|
private ResourceLocation location;
|
||||||
|
|
||||||
private AllSpecialTextures(String filename) {
|
AllSpecialTextures(String filename) {
|
||||||
location = Create.asResource(ASSET_PATH + filename);
|
location = Create.asResource(ASSET_PATH + filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,6 @@ public class Create {
|
|||||||
public static final Logger LOGGER = LogUtils.getLogger();
|
public static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
public static ResourceLocation asResource(String path) {
|
public static ResourceLocation asResource(String path) {
|
||||||
return new ResourceLocation(EffortlessBuilding.MODID, path);
|
return ResourceLocation.fromNamespaceAndPath(EffortlessBuilding.MODID, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
package nl.requios.effortlessbuilding.create;
|
package nl.requios.effortlessbuilding.create;
|
||||||
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.render.SuperByteBufferCache;
|
import net.createmod.catnip.render.SuperByteBufferCache;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.ghost.GhostBlocks;
|
import nl.requios.effortlessbuilding.create.foundation.utility.ghost.GhostBlocks;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.outliner.Outliner;
|
|
||||||
|
|
||||||
public class CreateClient {
|
public class CreateClient {
|
||||||
public static final SuperByteBufferCache BUFFER_CACHE = new SuperByteBufferCache();
|
public static final SuperByteBufferCache BUFFER_CACHE = new SuperByteBufferCache();
|
||||||
public static final Outliner OUTLINER = new Outliner();
|
|
||||||
public static final GhostBlocks GHOST_BLOCKS = new GhostBlocks();
|
public static final GhostBlocks GHOST_BLOCKS = new GhostBlocks();
|
||||||
|
|
||||||
public static void invalidateRenderers() {
|
public static void invalidateRenderers() {
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create;
|
|
||||||
|
|
||||||
import net.minecraft.world.level.block.Blocks;
|
|
||||||
import net.minecraft.world.phys.AABB;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.event.TickEvent;
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(Dist.CLIENT)
|
|
||||||
public class CreateClientTest {
|
|
||||||
|
|
||||||
// @SubscribeEvent
|
|
||||||
// public static void onTick(TickEvent.ClientTickEvent event) {
|
|
||||||
// CreateClient.GHOST_BLOCKS.showGhostState(1, Blocks.SPRUCE_LOG.defaultBlockState())
|
|
||||||
// .at(0, 120, 0)
|
|
||||||
// .breathingAlpha();
|
|
||||||
// CreateClient.GHOST_BLOCKS.showGhostState(2, Blocks.SPRUCE_LOG.defaultBlockState())
|
|
||||||
// .at(1, 120, 0)
|
|
||||||
// .breathingAlpha();
|
|
||||||
//
|
|
||||||
// CreateClient.OUTLINER.showAABB(1, new AABB(0, 0, 0, 10, 2, 6)
|
|
||||||
// .move(10, 120, 0))
|
|
||||||
// .withFaceTexture(AllSpecialTextures.CHECKERED)
|
|
||||||
// .colored(new Color(0.11f, 0.49f, 0.7f, 1f))
|
|
||||||
//// .colored(0xbfbfbf)
|
|
||||||
// .disableNormals()
|
|
||||||
// .lineWidth(1 / 32f);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
@@ -1,29 +1,25 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.events;
|
package nl.requios.effortlessbuilding.create.events;
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import net.createmod.catnip.animation.AnimationTickHolder;
|
||||||
|
import net.createmod.catnip.levelWrappers.WrappedClientLevel;
|
||||||
|
import net.createmod.catnip.render.DefaultSuperRenderTypeBuffer;
|
||||||
|
import net.createmod.catnip.render.SuperRenderTypeBuffer;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.minecraftforge.client.event.RenderLevelStageEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.client.event.ViewportEvent;
|
import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.neoforged.neoforge.client.event.ClientTickEvent;
|
||||||
import net.minecraftforge.event.TickEvent.ClientTickEvent;
|
import net.neoforged.neoforge.client.event.RenderLevelStageEvent;
|
||||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
import net.neoforged.neoforge.client.event.ViewportEvent;
|
||||||
import net.minecraftforge.event.level.LevelEvent;
|
import net.neoforged.neoforge.event.level.LevelEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
|
||||||
import nl.requios.effortlessbuilding.create.Create;
|
import nl.requios.effortlessbuilding.create.Create;
|
||||||
import nl.requios.effortlessbuilding.create.CreateClient;
|
import nl.requios.effortlessbuilding.create.CreateClient;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.item.TooltipModifier;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.render.SuperRenderTypeBuffer;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.AnimationTickHolder;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.CameraAngleAnimationService;
|
import nl.requios.effortlessbuilding.create.foundation.utility.CameraAngleAnimationService;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.worldWrappers.WrappedClientWorld;
|
|
||||||
|
|
||||||
@EventBusSubscriber(Dist.CLIENT)
|
@EventBusSubscriber(Dist.CLIENT)
|
||||||
public class ClientEvents {
|
public class ClientEvents {
|
||||||
@@ -32,20 +28,20 @@ public class ClientEvents {
|
|||||||
private static final String BLOCK_PREFIX = "block." + Create.ID;
|
private static final String BLOCK_PREFIX = "block." + Create.ID;
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onTick(ClientTickEvent event) {
|
public static void onTick(ClientTickEvent.Post event) {
|
||||||
if (!isGameActive() || event.phase != TickEvent.Phase.END) return;
|
if (!isGameActive()) return;
|
||||||
|
|
||||||
AnimationTickHolder.tick();
|
AnimationTickHolder.tick();
|
||||||
|
|
||||||
CreateClient.GHOST_BLOCKS.tickGhosts();
|
CreateClient.GHOST_BLOCKS.tickGhosts();
|
||||||
CreateClient.OUTLINER.tickOutlines();
|
// CreateClient.OUTLINER.tickOutlines();
|
||||||
CameraAngleAnimationService.tick();
|
CameraAngleAnimationService.tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onLoadWorld(LevelEvent.Load event) {
|
public static void onLoadWorld(LevelEvent.Load event) {
|
||||||
LevelAccessor world = event.getLevel();
|
LevelAccessor world = event.getLevel();
|
||||||
if (world.isClientSide() && world instanceof ClientLevel && !(world instanceof WrappedClientWorld)) {
|
if (world.isClientSide() && world instanceof ClientLevel && !(world instanceof WrappedClientLevel)) {
|
||||||
CreateClient.invalidateRenderers();
|
CreateClient.invalidateRenderers();
|
||||||
AnimationTickHolder.reset();
|
AnimationTickHolder.reset();
|
||||||
}
|
}
|
||||||
@@ -62,21 +58,23 @@ public class ClientEvents {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onRenderWorld(RenderLevelStageEvent event) {
|
public static void onRenderWorld(RenderLevelStageEvent event) {
|
||||||
if (event.getStage() != RenderLevelStageEvent.Stage.AFTER_PARTICLES)
|
if(event.getStage() != RenderLevelStageEvent.Stage.AFTER_CUTOUT_BLOCKS) return;
|
||||||
return;
|
|
||||||
|
Vec3 cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera()
|
||||||
|
.getPosition();
|
||||||
|
float pt = AnimationTickHolder.getPartialTicks();
|
||||||
|
|
||||||
PoseStack ms = event.getPoseStack();
|
PoseStack ms = event.getPoseStack();
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
SuperRenderTypeBuffer buffer = SuperRenderTypeBuffer.getInstance();
|
ms.translate(-cameraPos.x(), -cameraPos.y(), -cameraPos.z());
|
||||||
float partialTicks = AnimationTickHolder.getPartialTicks();
|
SuperRenderTypeBuffer buffer = DefaultSuperRenderTypeBuffer.getInstance();
|
||||||
Vec3 camera = Minecraft.getInstance().gameRenderer.getMainCamera()
|
|
||||||
.getPosition();
|
|
||||||
|
|
||||||
CreateClient.GHOST_BLOCKS.renderAll(ms, buffer, camera);
|
CreateClient.GHOST_BLOCKS.renderAll(ms, buffer);
|
||||||
CreateClient.OUTLINER.renderOutlines(ms, buffer, camera, partialTicks);
|
|
||||||
|
|
||||||
|
// CreateClient.OUTLINER.renderOutlines(ms, buffer, pt);
|
||||||
buffer.draw();
|
buffer.draw();
|
||||||
RenderSystem.enableCull();
|
RenderSystem.enableCull();
|
||||||
|
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,20 +89,6 @@ public class ClientEvents {
|
|||||||
event.setPitch(CameraAngleAnimationService.getPitch(partialTicks));
|
event.setPitch(CameraAngleAnimationService.getPitch(partialTicks));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void addToItemTooltip(ItemTooltipEvent event) {
|
|
||||||
// if (!AllConfigs.client().tooltips.get())
|
|
||||||
// return;
|
|
||||||
if (event.getEntity() == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Item item = event.getItemStack().getItem();
|
|
||||||
TooltipModifier modifier = TooltipModifier.REGISTRY.get(item);
|
|
||||||
if (modifier != null && modifier != TooltipModifier.EMPTY) {
|
|
||||||
modifier.modify(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isGameActive() {
|
public static boolean isGameActive() {
|
||||||
return !(Minecraft.getInstance().level == null || Minecraft.getInstance().player == null);
|
return !(Minecraft.getInstance().level == null || Minecraft.getInstance().player == null);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package nl.requios.effortlessbuilding.create.events;
|
||||||
|
|
||||||
|
import net.createmod.catnip.data.WorldAttached;
|
||||||
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
|
import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
|
import net.neoforged.neoforge.event.level.LevelEvent;
|
||||||
|
|
||||||
|
@EventBusSubscriber
|
||||||
|
public class CommonEvents {
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onUnloadWorld(LevelEvent.Unload event) {
|
||||||
|
LevelAccessor world = event.getLevel();
|
||||||
|
WorldAttached.invalidateWorld(world);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
|
public static class ModBusEvents {
|
||||||
|
|
||||||
|
// @SubscribeEvent
|
||||||
|
// public static void addPackFinders(AddPackFindersEvent event) {
|
||||||
|
// if (event.getPackType() == PackType.CLIENT_RESOURCES) {
|
||||||
|
// IModFileInfo modFileInfo = ModList.get().getModFileById(Create.ID);
|
||||||
|
// if (modFileInfo == null) {
|
||||||
|
// Create.LOGGER.error("Could not find Create mod file info; built-in resource packs will be missing!");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// IModFile modFile = modFileInfo.getFile();
|
||||||
|
// event.addRepositorySource((consumer, constructor) -> {
|
||||||
|
// consumer.accept(Pack.create(Create.asResource("legacy_copper").toString(), false, () -> new ModFilePackResources("Create Legacy Copper", modFile, "resourcepacks/legacy_copper"), constructor, Pack.Position.TOP, PackSource.DEFAULT));
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation;
|
package nl.requios.effortlessbuilding.create.foundation;
|
||||||
|
|
||||||
import nl.requios.effortlessbuilding.create.CreateClient;
|
import net.createmod.catnip.lang.LangNumberFormat;
|
||||||
//import nl.requios.effortlessbuilding.create.foundation.sound.SoundScapes;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.LangNumberFormat;
|
|
||||||
|
|
||||||
import net.minecraft.server.packs.resources.ResourceManager;
|
import net.minecraft.server.packs.resources.ResourceManager;
|
||||||
import net.minecraft.server.packs.resources.ResourceManagerReloadListener;
|
import net.minecraft.server.packs.resources.ResourceManagerReloadListener;
|
||||||
|
|
||||||
@@ -11,7 +8,7 @@ public class ClientResourceReloadListener implements ResourceManagerReloadListen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResourceManagerReload(ResourceManager resourceManager) {
|
public void onResourceManagerReload(ResourceManager resourceManager) {
|
||||||
CreateClient.invalidateRenderers();
|
// CreateClient.invalidateRenderers();
|
||||||
// SoundScapes.invalidateAll();
|
// SoundScapes.invalidateAll();
|
||||||
LangNumberFormat.numberFormat.update();
|
LangNumberFormat.numberFormat.update();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import net.minecraftforge.forgespi.locating.IModFile;
|
|
||||||
import net.minecraftforge.resource.PathPackResources;
|
|
||||||
|
|
||||||
public class ModFilePackResources extends PathPackResources {
|
|
||||||
protected final IModFile modFile;
|
|
||||||
protected final String sourcePath;
|
|
||||||
|
|
||||||
public ModFilePackResources(String name, IModFile modFile, String sourcePath) {
|
|
||||||
super(name, true, modFile.findResource(sourcePath));
|
|
||||||
this.modFile = modFile;
|
|
||||||
this.sourcePath = sourcePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Path resolve(String... paths) {
|
|
||||||
String[] allPaths = new String[paths.length + 1];
|
|
||||||
allPaths[0] = sourcePath;
|
|
||||||
System.arraycopy(paths, 0, allPaths, 1, paths.length);
|
|
||||||
return modFile.findResource(allPaths);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package nl.requios.effortlessbuilding.create.foundation.block.render;
|
||||||
|
|
||||||
|
import net.createmod.catnip.render.SpriteShiftEntry;
|
||||||
|
|
||||||
|
public class CTSpriteShiftEntry extends SpriteShiftEntry {
|
||||||
|
|
||||||
|
protected final CTType type;
|
||||||
|
|
||||||
|
public CTSpriteShiftEntry(CTType type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CTType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getTargetU(float localU, int index) {
|
||||||
|
float uOffset = (index % type.getSheetSize());
|
||||||
|
return getTarget().getU(
|
||||||
|
(getUnInterpolatedU(getOriginal(), localU) + uOffset) / ((float) type.getSheetSize()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getTargetV(float localV, int index) {
|
||||||
|
float vOffset = (index / type.getSheetSize());
|
||||||
|
return getTarget().getV(
|
||||||
|
(getUnInterpolatedV(getOriginal(), localV) + vOffset) / ((float) type.getSheetSize()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package nl.requios.effortlessbuilding.create.foundation.block.render;
|
||||||
|
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.block.render.ConnectedTextureBehaviour.CTContext;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.block.render.ConnectedTextureBehaviour.ContextRequirement;
|
||||||
|
|
||||||
|
public interface CTType {
|
||||||
|
ResourceLocation getId();
|
||||||
|
|
||||||
|
int getSheetSize();
|
||||||
|
|
||||||
|
ContextRequirement getContextRequirement();
|
||||||
|
|
||||||
|
int getTextureIndex(CTContext context);
|
||||||
|
}
|
||||||
@@ -0,0 +1,283 @@
|
|||||||
|
package nl.requios.effortlessbuilding.create.foundation.block.render;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.core.Direction.Axis;
|
||||||
|
import net.minecraft.core.Direction.AxisDirection;
|
||||||
|
import net.minecraft.util.RandomSource;
|
||||||
|
import net.minecraft.world.level.BlockAndTintGetter;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public abstract class ConnectedTextureBehaviour {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public CTSpriteShiftEntry getShift(BlockState state, RandomSource rand, Direction direction,
|
||||||
|
@NotNull TextureAtlasSprite sprite) {
|
||||||
|
return getShift(state, direction, sprite);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract CTSpriteShiftEntry getShift(BlockState state, Direction direction,
|
||||||
|
@NotNull TextureAtlasSprite sprite);
|
||||||
|
|
||||||
|
// TODO: allow more than one data type per state/face?
|
||||||
|
@Nullable
|
||||||
|
public abstract CTType getDataType(BlockAndTintGetter world, BlockPos pos, BlockState state, Direction direction);
|
||||||
|
|
||||||
|
public boolean buildContextForOccludedDirections() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isBeingBlocked(BlockState state, BlockAndTintGetter reader, BlockPos pos, BlockPos otherPos,
|
||||||
|
Direction face) {
|
||||||
|
BlockPos blockingPos = otherPos.relative(face);
|
||||||
|
BlockState blockState = reader.getBlockState(pos);
|
||||||
|
BlockState blockingState = reader.getBlockState(blockingPos);
|
||||||
|
|
||||||
|
if (!Block.isFaceFull(blockingState.getShape(reader, blockingPos), face.getOpposite()))
|
||||||
|
return false;
|
||||||
|
if (face.getAxis()
|
||||||
|
.choose(pos.getX(), pos.getY(), pos.getZ()) != face.getAxis()
|
||||||
|
.choose(otherPos.getX(), otherPos.getY(), otherPos.getZ()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return connectsTo(state,
|
||||||
|
getCTBlockState(reader, blockState, face.getOpposite(), pos.relative(face), blockingPos), reader, pos,
|
||||||
|
blockingPos, face);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean connectsTo(BlockState state, BlockState other, BlockAndTintGetter reader, BlockPos pos,
|
||||||
|
BlockPos otherPos, Direction face, Direction primaryOffset, Direction secondaryOffset) {
|
||||||
|
return connectsTo(state, other, reader, pos, otherPos, face);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean connectsTo(BlockState state, BlockState other, BlockAndTintGetter reader, BlockPos pos,
|
||||||
|
BlockPos otherPos, Direction face) {
|
||||||
|
return !isBeingBlocked(state, reader, pos, otherPos, face) && state.getBlock() == other.getBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean testConnection(BlockAndTintGetter reader, BlockPos currentPos, BlockState connectiveCurrentState,
|
||||||
|
Direction textureSide, final Direction horizontal, final Direction vertical, int sh, int sv) {
|
||||||
|
BlockState trueCurrentState = reader.getBlockState(currentPos);
|
||||||
|
BlockPos targetPos = currentPos.relative(horizontal, sh)
|
||||||
|
.relative(vertical, sv);
|
||||||
|
BlockState connectiveTargetState =
|
||||||
|
getCTBlockState(reader, trueCurrentState, textureSide, currentPos, targetPos);
|
||||||
|
return connectsTo(connectiveCurrentState, connectiveTargetState, reader, currentPos, targetPos, textureSide,
|
||||||
|
sh == 0 ? null : sh == -1 ? horizontal.getOpposite() : horizontal,
|
||||||
|
sv == 0 ? null : sv == -1 ? vertical.getOpposite() : vertical);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getCTBlockState(BlockAndTintGetter reader, BlockState reference, Direction face, BlockPos fromPos,
|
||||||
|
BlockPos toPos) {
|
||||||
|
BlockState blockState = reader.getBlockState(toPos);
|
||||||
|
return blockState.getAppearance(reader, toPos, face, reference, fromPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean reverseUVs(BlockState state, Direction face) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean reverseUVsHorizontally(BlockState state, Direction face) {
|
||||||
|
return reverseUVs(state, face);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean reverseUVsVertically(BlockState state, Direction face) {
|
||||||
|
return reverseUVs(state, face);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Direction getUpDirection(BlockAndTintGetter reader, BlockPos pos, BlockState state, Direction face) {
|
||||||
|
Axis axis = face.getAxis();
|
||||||
|
return axis.isHorizontal() ? Direction.UP : Direction.NORTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Direction getRightDirection(BlockAndTintGetter reader, BlockPos pos, BlockState state, Direction face) {
|
||||||
|
Axis axis = face.getAxis();
|
||||||
|
return axis == Axis.X ? Direction.SOUTH : Direction.WEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CTContext buildContext(BlockAndTintGetter reader, BlockPos pos, BlockState state, Direction face,
|
||||||
|
ContextRequirement requirement) {
|
||||||
|
boolean positive = face.getAxisDirection() == AxisDirection.POSITIVE;
|
||||||
|
Direction h = getRightDirection(reader, pos, state, face);
|
||||||
|
Direction v = getUpDirection(reader, pos, state, face);
|
||||||
|
h = positive ? h.getOpposite() : h;
|
||||||
|
if (face == Direction.DOWN) {
|
||||||
|
v = v.getOpposite();
|
||||||
|
h = h.getOpposite();
|
||||||
|
}
|
||||||
|
|
||||||
|
final Direction horizontal = h;
|
||||||
|
final Direction vertical = v;
|
||||||
|
|
||||||
|
boolean flipH = reverseUVsHorizontally(state, face);
|
||||||
|
boolean flipV = reverseUVsVertically(state, face);
|
||||||
|
int sh = flipH ? -1 : 1;
|
||||||
|
int sv = flipV ? -1 : 1;
|
||||||
|
|
||||||
|
CTContext context = new CTContext();
|
||||||
|
|
||||||
|
if (requirement.up) {
|
||||||
|
context.up = testConnection(reader, pos, state, face, horizontal, vertical, 0, sv);
|
||||||
|
}
|
||||||
|
if (requirement.down) {
|
||||||
|
context.down = testConnection(reader, pos, state, face, horizontal, vertical, 0, -sv);
|
||||||
|
}
|
||||||
|
if (requirement.left) {
|
||||||
|
context.left = testConnection(reader, pos, state, face, horizontal, vertical, -sh, 0);
|
||||||
|
}
|
||||||
|
if (requirement.right) {
|
||||||
|
context.right = testConnection(reader, pos, state, face, horizontal, vertical, sh, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requirement.topLeft) {
|
||||||
|
context.topLeft =
|
||||||
|
context.up && context.left && testConnection(reader, pos, state, face, horizontal, vertical, -sh, sv);
|
||||||
|
}
|
||||||
|
if (requirement.topRight) {
|
||||||
|
context.topRight =
|
||||||
|
context.up && context.right && testConnection(reader, pos, state, face, horizontal, vertical, sh, sv);
|
||||||
|
}
|
||||||
|
if (requirement.bottomLeft) {
|
||||||
|
context.bottomLeft = context.down && context.left
|
||||||
|
&& testConnection(reader, pos, state, face, horizontal, vertical, -sh, -sv);
|
||||||
|
}
|
||||||
|
if (requirement.bottomRight) {
|
||||||
|
context.bottomRight = context.down && context.right
|
||||||
|
&& testConnection(reader, pos, state, face, horizontal, vertical, sh, -sv);
|
||||||
|
}
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CTContext {
|
||||||
|
public static final CTContext EMPTY = new CTContext();
|
||||||
|
|
||||||
|
public boolean up, down, left, right;
|
||||||
|
public boolean topLeft, topRight, bottomLeft, bottomRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ContextRequirement {
|
||||||
|
public final boolean up, down, left, right;
|
||||||
|
public final boolean topLeft, topRight, bottomLeft, bottomRight;
|
||||||
|
|
||||||
|
public ContextRequirement(boolean up, boolean down, boolean left, boolean right, boolean topLeft,
|
||||||
|
boolean topRight, boolean bottomLeft, boolean bottomRight) {
|
||||||
|
this.up = up;
|
||||||
|
this.down = down;
|
||||||
|
this.left = left;
|
||||||
|
this.right = right;
|
||||||
|
this.topLeft = topLeft;
|
||||||
|
this.topRight = topRight;
|
||||||
|
this.bottomLeft = bottomLeft;
|
||||||
|
this.bottomRight = bottomRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
private boolean up, down, left, right;
|
||||||
|
private boolean topLeft, topRight, bottomLeft, bottomRight;
|
||||||
|
|
||||||
|
public Builder up() {
|
||||||
|
up = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder down() {
|
||||||
|
down = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder left() {
|
||||||
|
left = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder right() {
|
||||||
|
right = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder topLeft() {
|
||||||
|
topLeft = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder topRight() {
|
||||||
|
topRight = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder bottomLeft() {
|
||||||
|
bottomLeft = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder bottomRight() {
|
||||||
|
bottomRight = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder horizontal() {
|
||||||
|
left();
|
||||||
|
right();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder vertical() {
|
||||||
|
up();
|
||||||
|
down();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder axisAligned() {
|
||||||
|
horizontal();
|
||||||
|
vertical();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder corners() {
|
||||||
|
topLeft();
|
||||||
|
topRight();
|
||||||
|
bottomLeft();
|
||||||
|
bottomRight();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder all() {
|
||||||
|
axisAligned();
|
||||||
|
corners();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContextRequirement build() {
|
||||||
|
return new ContextRequirement(up, down, left, right, topLeft, topRight, bottomLeft, bottomRight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static abstract class Base extends ConnectedTextureBehaviour {
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public abstract CTSpriteShiftEntry getShift(BlockState state, Direction direction,
|
||||||
|
@Nullable TextureAtlasSprite sprite);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public CTType getDataType(BlockAndTintGetter world, BlockPos pos, BlockState state, Direction direction) {
|
||||||
|
CTSpriteShiftEntry shift = getShift(state, direction, null);
|
||||||
|
if (shift == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return shift.getType();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.block.render;
|
|
||||||
|
|
||||||
import com.jozufozu.flywheel.core.StitchedSprite;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
|
|
||||||
public class SpriteShiftEntry {
|
|
||||||
protected StitchedSprite original;
|
|
||||||
protected StitchedSprite target;
|
|
||||||
|
|
||||||
public void set(ResourceLocation originalTextureLocation, ResourceLocation targetTextureLocation) {
|
|
||||||
original = new StitchedSprite(originalTextureLocation);
|
|
||||||
target = new StitchedSprite(targetTextureLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResourceLocation getOriginalResourceLocation() {
|
|
||||||
return original.getLocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResourceLocation getTargetResourceLocation() {
|
|
||||||
return target.getLocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
public TextureAtlasSprite getOriginal() {
|
|
||||||
return original.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public TextureAtlasSprite getTarget() {
|
|
||||||
return target.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getTargetU(float localU) {
|
|
||||||
return getTarget().getU(getUnInterpolatedU(getOriginal(), localU));
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getTargetV(float localV) {
|
|
||||||
return getTarget().getV(getUnInterpolatedV(getOriginal(), localV));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getUnInterpolatedU(TextureAtlasSprite sprite, float u) {
|
|
||||||
float f = sprite.getU1() - sprite.getU0();
|
|
||||||
return (u - sprite.getU0()) / f * 16.0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getUnInterpolatedV(TextureAtlasSprite sprite, float v) {
|
|
||||||
float f = sprite.getV1() - sprite.getV0();
|
|
||||||
return (v - sprite.getV0()) / f * 16.0F;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.events;
|
|
||||||
|
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
|
||||||
import net.minecraftforge.event.level.LevelEvent;
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.WorldAttached;
|
|
||||||
|
|
||||||
@EventBusSubscriber
|
|
||||||
public class CommonEvents {
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void onUnloadWorld(LevelEvent.Unload event) {
|
|
||||||
LevelAccessor world = event.getLevel();
|
|
||||||
WorldAttached.invalidateWorld(world);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,13 +1,9 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
package nl.requios.effortlessbuilding.create.foundation.gui;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.InputConstants;
|
import com.mojang.blaze3d.platform.InputConstants;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.AbstractSimiWidget;
|
import net.createmod.catnip.animation.AnimationTickHolder;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
import net.createmod.catnip.gui.TickableGuiEventListener;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.components.AbstractWidget;
|
import net.minecraft.client.gui.components.AbstractWidget;
|
||||||
import net.minecraft.client.gui.components.EditBox;
|
import net.minecraft.client.gui.components.EditBox;
|
||||||
@@ -16,8 +12,14 @@ import net.minecraft.client.gui.components.events.GuiEventListener;
|
|||||||
import net.minecraft.client.gui.narration.NarratableEntry;
|
import net.minecraft.client.gui.narration.NarratableEntry;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.gui.widget.AbstractSimiWidget;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||||
|
import nl.requios.effortlessbuilding.gui.buildmodifier.ModifiersScreenList;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public abstract class AbstractSimiScreen extends Screen {
|
public abstract class AbstractSimiScreen extends Screen {
|
||||||
@@ -106,7 +108,7 @@ public abstract class AbstractSimiScreen extends Screen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||||
partialTicks = minecraft.getFrameTime();
|
partialTicks = AnimationTickHolder.getPartialTicksUI();
|
||||||
PoseStack ms = graphics.pose();
|
PoseStack ms = graphics.pose();
|
||||||
|
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
@@ -114,8 +116,8 @@ public abstract class AbstractSimiScreen extends Screen {
|
|||||||
prepareFrame();
|
prepareFrame();
|
||||||
|
|
||||||
renderWindowBackground(graphics, mouseX, mouseY, partialTicks);
|
renderWindowBackground(graphics, mouseX, mouseY, partialTicks);
|
||||||
renderWindow(graphics, mouseX, mouseY, partialTicks);
|
|
||||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||||
|
renderWindow(graphics, mouseX, mouseY, partialTicks);
|
||||||
renderWindowForeground(graphics, mouseX, mouseY, partialTicks);
|
renderWindowForeground(graphics, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
endFrame();
|
endFrame();
|
||||||
@@ -123,6 +125,11 @@ public abstract class AbstractSimiScreen extends Screen {
|
|||||||
ms.popPose();
|
ms.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderBackground(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) {
|
||||||
|
// super.renderBackground(pGuiGraphics, pMouseX, pMouseY, pPartialTick);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||||
boolean keyPressed = super.keyPressed(keyCode, scanCode, modifiers);
|
boolean keyPressed = super.keyPressed(keyCode, scanCode, modifiers);
|
||||||
@@ -141,7 +148,7 @@ public abstract class AbstractSimiScreen extends Screen {
|
|||||||
protected void prepareFrame() {}
|
protected void prepareFrame() {}
|
||||||
|
|
||||||
protected void renderWindowBackground(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
protected void renderWindowBackground(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||||
renderBackground(graphics);
|
this.renderTransparentBackground(graphics); //Manually draw background
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void renderWindow(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks);
|
protected abstract void renderWindow(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks);
|
||||||
@@ -157,6 +164,11 @@ public abstract class AbstractSimiScreen extends Screen {
|
|||||||
int tty = simiWidget.lockedTooltipY == -1 ? mouseY : simiWidget.lockedTooltipY + simiWidget.getY();
|
int tty = simiWidget.lockedTooltipY == -1 ? mouseY : simiWidget.lockedTooltipY + simiWidget.getY();
|
||||||
graphics.renderComponentTooltip(font, tooltip, ttx, tty);
|
graphics.renderComponentTooltip(font, tooltip, ttx, tty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Added
|
||||||
|
if (widget instanceof ModifiersScreenList list) {
|
||||||
|
list.renderWindowForeground(graphics, mouseX, mouseY, partialTicks);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,164 +1,17 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
package nl.requios.effortlessbuilding.create.foundation.gui;
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import nl.requios.effortlessbuilding.create.Create;
|
import net.createmod.catnip.gui.UIRenderHelper;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.ScreenElement;
|
import net.createmod.catnip.gui.element.ScreenElement;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
import net.createmod.catnip.theme.Color;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
import nl.requios.effortlessbuilding.create.Create;
|
||||||
|
|
||||||
public enum AllGuiTextures implements ScreenElement {
|
public enum AllGuiTextures implements ScreenElement {
|
||||||
|
|
||||||
// Inventories
|
|
||||||
// PLAYER_INVENTORY("player_inventory", 176, 108),
|
|
||||||
// WAND_OF_SYMMETRY("curiosities", 0, 131, 188, 101),
|
|
||||||
// BLOCKZAPPER("curiosities", 0, 99, 214, 97),
|
|
||||||
// TERRAINZAPPER("curiosities", 234, 103),
|
|
||||||
// TERRAINZAPPER_INACTIVE_PARAM("curiosities", 238, 0, 18, 18),
|
|
||||||
//
|
|
||||||
// LOGO("logo", 256, 256),
|
|
||||||
// CURSEFORGE_LOGO("platform_icons/curseforge", 256, 256),
|
|
||||||
// MODRINTH_LOGO("platform_icons/modrinth", 256, 256),
|
|
||||||
//
|
|
||||||
// SCHEMATIC("schematics", 192, 121),
|
|
||||||
// SCHEMATIC_SLOT("widgets", 54, 0, 16, 16),
|
|
||||||
// SCHEMATIC_PROMPT("schematics_2", 213, 77),
|
|
||||||
// HUD_BACKGROUND("overlay", 0, 0, 16, 16),
|
|
||||||
//
|
|
||||||
// SCHEMATIC_TABLE("schematics", 0, 121, 214, 83),
|
|
||||||
// SCHEMATIC_TABLE_PROGRESS("schematics", 0, 204, 84, 16),
|
|
||||||
//
|
|
||||||
// SCHEMATICANNON_TOP("schematics_2", 0, 77, 213, 42),
|
|
||||||
// SCHEMATICANNON_BOTTOM("schematics_2", 0, 119, 213, 99),
|
|
||||||
// SCHEMATICANNON_PROGRESS("schematics_2", 76, 239, 114, 16),
|
|
||||||
// SCHEMATICANNON_CHECKLIST_PROGRESS("schematics_2", 191, 240, 16, 14),
|
|
||||||
// SCHEMATICANNON_HIGHLIGHT("schematics_2", 1, 229, 26, 26),
|
|
||||||
// SCHEMATICANNON_FUEL("schematics_2", 28, 222, 47, 16),
|
|
||||||
// SCHEMATICANNON_FUEL_CREATIVE("schematics_2", 28, 239, 47, 16),
|
|
||||||
//
|
|
||||||
// STOCKSWITCH("logistics", 182, 95),
|
|
||||||
// STOCKSWITCH_ARROW_UP("logistics", 191, 0, 7, 24),
|
|
||||||
// STOCKSWITCH_ARROW_DOWN("logistics", 198, 0, 7, 24),
|
|
||||||
// STOCKSWITCH_CURSOR("logistics", 206, 0, 7, 16),
|
|
||||||
// STOCKSWITCH_INTERVAL("logistics", 0, 95, 100, 18),
|
|
||||||
// STOCKSWITCH_UNPOWERED_LANE("logistics", 37, 20, 100, 18),
|
|
||||||
// STOCKSWITCH_POWERED_LANE("logistics", 37, 42, 100, 18),
|
|
||||||
//
|
|
||||||
// FILTER("filters", 214, 99),
|
|
||||||
// ATTRIBUTE_FILTER("filters", 0, 99, 241, 85),
|
|
||||||
//
|
|
||||||
// TOOLBOX("toolbox", 188, 171),
|
|
||||||
// TOOLBELT_SLOT("minecraft", "widgets", 24, 23, 22, 22),
|
|
||||||
// TOOLBELT_SLOT_HIGHLIGHT("minecraft", "widgets", 0, 22, 24, 24),
|
|
||||||
// TOOLBELT_MAIN_SLOT("widgets", 0, 97, 24, 24),
|
|
||||||
// TOOLBELT_EMPTY_SLOT("widgets", 27, 98, 22, 22),
|
|
||||||
// TOOLBELT_INACTIVE_SLOT("widgets", 52, 98, 22, 22),
|
|
||||||
//
|
|
||||||
// TOOLBELT_HOTBAR_OFF("widgets", 0, 130, 20, 24),
|
|
||||||
// TOOLBELT_HOTBAR_ON("widgets", 20, 130, 20, 24),
|
|
||||||
// TOOLBELT_SELECTED_OFF("widgets", 0, 155, 22, 22),
|
|
||||||
// TOOLBELT_SELECTED_ON("widgets", 22, 155, 22, 22),
|
|
||||||
//
|
|
||||||
// SEQUENCER("sequencer", 173, 161),
|
|
||||||
// SEQUENCER_INSTRUCTION("sequencer", 0, 16, 162, 22),
|
|
||||||
// SEQUENCER_DELAY("sequencer", 0, 60, 162, 22),
|
|
||||||
// SEQUENCER_END("sequencer", 0, 82, 162, 22),
|
|
||||||
// SEQUENCER_EMPTY("sequencer", 0, 104, 162, 22),
|
|
||||||
// SEQUENCER_AWAIT("sequencer", 0, 162, 162, 22),
|
|
||||||
//
|
|
||||||
// LINKED_CONTROLLER("curiosities_2", 179, 109),
|
|
||||||
// BLUEPRINT("curiosities_2", 0, 109, 179, 109),
|
|
||||||
//
|
|
||||||
// CLIPBOARD("clipboard", 0, 0, 256, 256),
|
|
||||||
//
|
|
||||||
// DATA_GATHERER("display_link", 235, 162),
|
|
||||||
// DATA_AREA_START("display_link", 0, 163, 2, 18),
|
|
||||||
// DATA_AREA_SPEECH("display_link", 8, 163, 5, 18),
|
|
||||||
// DATA_AREA("display_link", 3, 163, 1, 18),
|
|
||||||
// DATA_AREA_END("display_link", 5, 163, 2, 18),
|
|
||||||
//
|
|
||||||
// SCHEDULE("schedule", 256, 226),
|
|
||||||
// SCHEDULE_CARD_DARK("schedule", 5, 233, 1, 1),
|
|
||||||
// SCHEDULE_CARD_MEDIUM("schedule", 6, 233, 1, 1),
|
|
||||||
// SCHEDULE_CARD_LIGHT("schedule", 7, 233, 1, 1),
|
|
||||||
// SCHEDULE_CARD_MOVE_UP("schedule", 51, 230, 12, 12),
|
|
||||||
// SCHEDULE_CARD_MOVE_DOWN("schedule", 65, 230, 12, 12),
|
|
||||||
// SCHEDULE_CARD_REMOVE("schedule", 51, 243, 12, 12),
|
|
||||||
// SCHEDULE_CARD_DUPLICATE("schedule", 65, 243, 12, 12),
|
|
||||||
// SCHEDULE_CARD_NEW("schedule", 79, 239, 16, 16),
|
|
||||||
// SCHEDULE_CONDITION_NEW("schedule", 96, 239, 19, 16),
|
|
||||||
// SCHEDULE_CONDITION_LEFT("schedule", 116, 239, 6, 16),
|
|
||||||
// SCHEDULE_CONDITION_LEFT_CLEAN("schedule", 147, 239, 2, 16),
|
|
||||||
// SCHEDULE_CONDITION_MIDDLE("schedule", 123, 239, 1, 16),
|
|
||||||
// SCHEDULE_CONDITION_ITEM("schedule", 125, 239, 18, 16),
|
|
||||||
// SCHEDULE_CONDITION_RIGHT("schedule", 144, 239, 2, 16),
|
|
||||||
// SCHEDULE_CONDITION_APPEND("schedule", 150, 245, 10, 10),
|
|
||||||
// SCHEDULE_SCROLL_LEFT("schedule", 161, 247, 4, 8),
|
|
||||||
// SCHEDULE_SCROLL_RIGHT("schedule", 166, 247, 4, 8),
|
|
||||||
// SCHEDULE_STRIP_DARK("schedule", 5, 235, 3, 1),
|
|
||||||
// SCHEDULE_STRIP_LIGHT("schedule", 5, 237, 3, 1),
|
|
||||||
// SCHEDULE_STRIP_WAIT("schedule", 1, 239, 11, 16),
|
|
||||||
// SCHEDULE_STRIP_TRAVEL("schedule", 12, 239, 11, 16),
|
|
||||||
// SCHEDULE_STRIP_DOTTED("schedule", 23, 239, 11, 16),
|
|
||||||
// SCHEDULE_STRIP_END("schedule", 34, 239, 11, 16),
|
|
||||||
// SCHEDULE_STRIP_ACTION("schedule", 209, 239, 11, 16),
|
|
||||||
// SCHEDULE_EDITOR("schedule_2", 256, 89),
|
|
||||||
// SCHEDULE_EDITOR_ADDITIONAL_SLOT("schedule_2", 55, 47, 32, 18),
|
|
||||||
// SCHEDULE_EDITOR_INACTIVE_SLOT("schedule_2", 0, 91, 18, 18),
|
|
||||||
// SCHEDULE_POINTER("schedule", 185, 239, 21, 16),
|
|
||||||
// SCHEDULE_POINTER_OFFSCREEN("schedule", 171, 239, 13, 16),
|
|
||||||
//
|
|
||||||
// STATION("schedule_2", 0, 111, 200, 127),
|
|
||||||
// STATION_ASSEMBLING("assemble", 200, 178),
|
|
||||||
// STATION_TEXTBOX_TOP("assemble", 1, 179, 150, 18),
|
|
||||||
// STATION_TEXTBOX_MIDDLE("assemble", 1, 198, 150, 1),
|
|
||||||
// STATION_TEXTBOX_BOTTOM("assemble", 1, 200, 150, 4),
|
|
||||||
// STATION_TEXTBOX_SPEECH("assemble", 152, 179, 8, 6),
|
|
||||||
// STATION_EDIT_NAME("schedule_2", 0, 239, 13, 13),
|
|
||||||
// STATION_EDIT_TRAIN_NAME("schedule_2", 89, 239, 13, 13),
|
|
||||||
// I_NEW_TRAIN("schedule_2", 14, 239, 24, 16),
|
|
||||||
// I_DISASSEMBLE_TRAIN("schedule_2", 39, 239, 24, 16),
|
|
||||||
// I_ASSEMBLE_TRAIN("schedule_2", 64, 239, 24, 16),
|
|
||||||
//
|
|
||||||
// ELEVATOR_CONTACT("display_link", 20, 172, 233, 82),
|
|
||||||
//
|
|
||||||
// BRASS_FRAME_TL("value_settings", 65, 9, 4, 4),
|
|
||||||
// BRASS_FRAME_TR("value_settings", 70, 9, 4, 4),
|
|
||||||
// BRASS_FRAME_BL("value_settings", 65, 19, 4, 4),
|
|
||||||
// BRASS_FRAME_BR("value_settings", 70, 19, 4, 4),
|
|
||||||
// BRASS_FRAME_LEFT("value_settings", 65, 14, 3, 4),
|
|
||||||
// BRASS_FRAME_RIGHT("value_settings", 71, 14, 3, 4),
|
|
||||||
// BRASS_FRAME_TOP("value_settings", 0, 24, 256, 3),
|
|
||||||
// BRASS_FRAME_BOTTOM("value_settings", 0, 27, 256, 3),
|
|
||||||
//
|
|
||||||
// VALUE_SETTINGS_MILESTONE("value_settings", 0, 0, 7, 8),
|
|
||||||
// VALUE_SETTINGS_WIDE_MILESTONE("value_settings", 75, 14, 13, 8),
|
|
||||||
// VALUE_SETTINGS_BAR("value_settings", 7, 0, 249, 8),
|
|
||||||
// VALUE_SETTINGS_BAR_BG("value_settings", 75, 9, 1, 1),
|
|
||||||
// VALUE_SETTINGS_OUTER_BG("value_settings", 80, 9, 1, 1),
|
|
||||||
// VALUE_SETTINGS_CURSOR_LEFT("value_settings", 0, 9, 3, 14),
|
|
||||||
// VALUE_SETTINGS_CURSOR("value_settings", 4, 9, 56, 14),
|
|
||||||
// VALUE_SETTINGS_CURSOR_RIGHT("value_settings", 61, 9, 3, 14),
|
|
||||||
// VALUE_SETTINGS_CURSOR_ICON("value_settings", 0, 44, 22, 20),
|
|
||||||
// VALUE_SETTINGS_LABEL_BG("value_settings", 0, 31, 81, 11),
|
|
||||||
//
|
|
||||||
// // JEI
|
|
||||||
// JEI_SLOT("jei/widgets", 18, 18),
|
|
||||||
// JEI_CHANCE_SLOT("jei/widgets", 20, 156, 18, 18),
|
|
||||||
// JEI_CATALYST_SLOT("jei/widgets", 0, 156, 18, 18),
|
|
||||||
// JEI_ARROW("jei/widgets", 19, 10, 42, 10),
|
|
||||||
// JEI_LONG_ARROW("jei/widgets", 19, 0, 71, 10),
|
|
||||||
// JEI_DOWN_ARROW("jei/widgets", 0, 21, 18, 14),
|
|
||||||
// JEI_LIGHT("jei/widgets", 0, 42, 52, 11),
|
|
||||||
// JEI_QUESTION_MARK("jei/widgets", 0, 178, 12, 16),
|
|
||||||
// JEI_SHADOW("jei/widgets", 0, 56, 52, 11),
|
|
||||||
// BLOCKZAPPER_UPGRADE_RECIPE("jei/widgets", 0, 75, 144, 66),
|
|
||||||
// JEI_HEAT_BAR("jei/widgets", 0, 201, 169, 19),
|
|
||||||
// JEI_NO_HEAT_BAR("jei/widgets", 0, 221, 169, 19),
|
|
||||||
|
|
||||||
// Widgets
|
// Widgets
|
||||||
BUTTON("widgets", 18, 18),
|
BUTTON("widgets", 18, 18),
|
||||||
BUTTON_HOVER("widgets", 18, 0, 18, 18),
|
BUTTON_HOVER("widgets", 18, 0, 18, 18),
|
||||||
@@ -177,21 +30,15 @@ public enum AllGuiTextures implements ScreenElement {
|
|||||||
SPEECH_TOOLTIP_BACKGROUND("widgets", 0, 24, 8, 8),
|
SPEECH_TOOLTIP_BACKGROUND("widgets", 0, 24, 8, 8),
|
||||||
SPEECH_TOOLTIP_COLOR("widgets", 8, 24, 8, 8),
|
SPEECH_TOOLTIP_COLOR("widgets", 8, 24, 8, 8),
|
||||||
|
|
||||||
// TRAIN_HUD_SPEED_BG("widgets", 0, 190, 182, 5),
|
TRAIN_HUD_SPEED_BG("widgets", 0, 190, 182, 5),
|
||||||
// TRAIN_HUD_SPEED("widgets", 0, 185, 182, 5),
|
TRAIN_HUD_SPEED("widgets", 0, 185, 182, 5),
|
||||||
// TRAIN_HUD_THROTTLE("widgets", 0, 195, 182, 5),
|
TRAIN_HUD_THROTTLE("widgets", 0, 195, 182, 5),
|
||||||
// TRAIN_HUD_THROTTLE_POINTER("widgets", 0, 209, 6, 9),
|
TRAIN_HUD_THROTTLE_POINTER("widgets", 0, 209, 6, 9),
|
||||||
// TRAIN_HUD_FRAME("widgets", 0, 200, 186, 7),
|
TRAIN_HUD_FRAME("widgets", 0, 200, 186, 7),
|
||||||
// TRAIN_HUD_DIRECTION("widgets", 77, 165, 28, 20),
|
TRAIN_HUD_DIRECTION("widgets", 77, 165, 28, 20),
|
||||||
// TRAIN_PROMPT_L("widgets", 8, 209, 3, 16),
|
TRAIN_PROMPT_L("widgets", 8, 209, 3, 16),
|
||||||
// TRAIN_PROMPT_R("widgets", 11, 209, 3, 16),
|
TRAIN_PROMPT_R("widgets", 11, 209, 3, 16),
|
||||||
// TRAIN_PROMPT("widgets", 0, 230, 256, 16),
|
TRAIN_PROMPT("widgets", 0, 230, 256, 16),
|
||||||
|
|
||||||
// PlacementIndicator
|
|
||||||
// PLACEMENT_INDICATOR_SHEET("placement_indicator", 0, 0, 16, 256),
|
|
||||||
|
|
||||||
// ComputerCraft
|
|
||||||
// COMPUTER("computer", 200, 102);
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -214,7 +61,7 @@ public enum AllGuiTextures implements ScreenElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private AllGuiTextures(String namespace, String location, int startX, int startY, int width, int height) {
|
private AllGuiTextures(String namespace, String location, int startX, int startY, int width, int height) {
|
||||||
this.location = new ResourceLocation(namespace, "textures/gui/" + location + ".png");
|
this.location = ResourceLocation.fromNamespaceAndPath(namespace, "textures/gui/" + location + ".png");
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.startX = startX;
|
this.startX = startX;
|
||||||
|
|||||||
@@ -1,27 +1,25 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
package nl.requios.effortlessbuilding.create.foundation.gui;
|
||||||
|
|
||||||
import org.joml.Matrix4f;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
import nl.requios.effortlessbuilding.create.Create;
|
import net.createmod.catnip.gui.element.DelegatedStencilElement;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.DelegatedStencilElement;
|
import net.createmod.catnip.gui.element.ScreenElement;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.ScreenElement;
|
import net.createmod.catnip.theme.Color;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.renderer.LightTexture;
|
import net.minecraft.client.renderer.LightTexture;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
import nl.requios.effortlessbuilding.create.Create;
|
||||||
|
import org.joml.Matrix4f;
|
||||||
|
|
||||||
public class AllIcons implements ScreenElement {
|
public class AllIcons implements ScreenElement {
|
||||||
|
|
||||||
public static final ResourceLocation ICON_ATLAS = Create.asResource("textures/gui/icons.png");
|
public static final ResourceLocation ICON_ATLAS = Create.asResource("textures/gui/create_icons.png");
|
||||||
public static final int ICON_ATLAS_SIZE = 256;
|
public static final int ICON_ATLAS_SIZE = 256;
|
||||||
|
|
||||||
private static int x = 0, y = -1;
|
private static int x = 0, y = -1;
|
||||||
@@ -106,10 +104,6 @@ public class AllIcons implements ScreenElement {
|
|||||||
I_ADD_INVERTED_ATTRIBUTE = next(),
|
I_ADD_INVERTED_ATTRIBUTE = next(),
|
||||||
I_FLIP = next(),
|
I_FLIP = next(),
|
||||||
|
|
||||||
I_ROLLER_PAVE = next(),
|
|
||||||
I_ROLLER_FILL = next(),
|
|
||||||
I_ROLLER_WIDE_FILL = next(),
|
|
||||||
|
|
||||||
I_PLAY = newRow(),
|
I_PLAY = newRow(),
|
||||||
I_PAUSE = next(),
|
I_PAUSE = next(),
|
||||||
I_STOP = next(),
|
I_STOP = next(),
|
||||||
@@ -129,13 +123,8 @@ public class AllIcons implements ScreenElement {
|
|||||||
I_FOLLOW_DIAGONAL = next(),
|
I_FOLLOW_DIAGONAL = next(),
|
||||||
I_FOLLOW_MATERIAL = next(),
|
I_FOLLOW_MATERIAL = next(),
|
||||||
|
|
||||||
I_CLEAR_CHECKED = next(),
|
|
||||||
|
|
||||||
I_SCHEMATIC = newRow(),
|
I_SCHEMATIC = newRow(),
|
||||||
I_SEQ_REPEAT = next(),
|
I_SEQ_REPEAT = next(),
|
||||||
VALUE_BOX_HOVER_6PX = next(),
|
|
||||||
VALUE_BOX_HOVER_4PX = next(),
|
|
||||||
VALUE_BOX_HOVER_8PX = next(),
|
|
||||||
|
|
||||||
I_MTD_LEFT = newRow(),
|
I_MTD_LEFT = newRow(),
|
||||||
I_MTD_CLOSE = next(),
|
I_MTD_CLOSE = next(),
|
||||||
@@ -213,11 +202,10 @@ public class AllIcons implements ScreenElement {
|
|||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
private void vertex(VertexConsumer builder, Matrix4f matrix, Vec3 vec, Color rgb, float u, float v, int light) {
|
private void vertex(VertexConsumer builder, Matrix4f matrix, Vec3 vec, Color rgb, float u, float v, int light) {
|
||||||
builder.vertex(matrix, (float) vec.x, (float) vec.y, (float) vec.z)
|
builder.addVertex(matrix, (float) vec.x, (float) vec.y, (float) vec.z)
|
||||||
.color(rgb.getRed(), rgb.getGreen(), rgb.getBlue(), 255)
|
.setColor(rgb.getRed(), rgb.getGreen(), rgb.getBlue(), 255)
|
||||||
.uv(u, v)
|
.setUv(u, v)
|
||||||
.uv2(light)
|
.setLight(light);
|
||||||
.endVertex();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
|||||||
@@ -1,232 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL30;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.BoxElement;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.TextStencilElement;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.BoxWidget;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
|
||||||
import net.minecraft.network.chat.FormattedText;
|
|
||||||
import net.minecraft.network.chat.Style;
|
|
||||||
|
|
||||||
public class ConfirmationScreen extends AbstractSimiScreen {
|
|
||||||
|
|
||||||
private Screen source;
|
|
||||||
private Consumer<Response> action = _success -> {
|
|
||||||
};
|
|
||||||
private List<FormattedText> text = new ArrayList<>();
|
|
||||||
private boolean centered = false;
|
|
||||||
private int x;
|
|
||||||
private int y;
|
|
||||||
private int textWidth;
|
|
||||||
private int textHeight;
|
|
||||||
private boolean tristate;
|
|
||||||
|
|
||||||
private BoxWidget confirm;
|
|
||||||
private BoxWidget confirmDontSave;
|
|
||||||
private BoxWidget cancel;
|
|
||||||
private BoxElement textBackground;
|
|
||||||
|
|
||||||
public enum Response {
|
|
||||||
Confirm, ConfirmDontSave, Cancel
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Removes text lines from the back of the list
|
|
||||||
* */
|
|
||||||
public ConfirmationScreen removeTextLines(int amount) {
|
|
||||||
if (amount > text.size())
|
|
||||||
return clearText();
|
|
||||||
|
|
||||||
text.subList(text.size() - amount, text.size()).clear();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConfirmationScreen clearText() {
|
|
||||||
this.text.clear();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConfirmationScreen addText(FormattedText text) {
|
|
||||||
this.text.add(text);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConfirmationScreen withText(FormattedText text) {
|
|
||||||
return clearText().addText(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConfirmationScreen at(int x, int y) {
|
|
||||||
this.x = Math.max(x, 0);
|
|
||||||
this.y = Math.max(y, 0);
|
|
||||||
this.centered = false;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConfirmationScreen centered() {
|
|
||||||
this.centered = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConfirmationScreen withAction(Consumer<Boolean> action) {
|
|
||||||
this.action = r -> action.accept(r == Response.Confirm);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConfirmationScreen withThreeActions(Consumer<Response> action) {
|
|
||||||
this.action = action;
|
|
||||||
this.tristate = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void open(@Nonnull Screen source) {
|
|
||||||
this.source = source;
|
|
||||||
Minecraft client = source.getMinecraft();
|
|
||||||
this.init(client, client.getWindow().getGuiScaledWidth(), client.getWindow().getGuiScaledHeight());
|
|
||||||
this.minecraft.screen = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tick() {
|
|
||||||
super.tick();
|
|
||||||
source.tick();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void init() {
|
|
||||||
super.init();
|
|
||||||
|
|
||||||
ArrayList<FormattedText> copy = new ArrayList<>(text);
|
|
||||||
text.clear();
|
|
||||||
copy.forEach(t -> text.addAll(font.getSplitter().splitLines(t, 300, Style.EMPTY)));
|
|
||||||
|
|
||||||
textHeight = text.size() * (font.lineHeight + 1) + 4;
|
|
||||||
textWidth = 300;
|
|
||||||
|
|
||||||
if (centered) {
|
|
||||||
x = width/2 - textWidth/2 - 2;
|
|
||||||
y = height/2 - textHeight/2 - 16;
|
|
||||||
} else {
|
|
||||||
x = Math.max(0, x - textWidth / 2);
|
|
||||||
y = Math.max(0, y -= textHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x + textWidth > width) {
|
|
||||||
x = width - textWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (y + textHeight + 30 > height) {
|
|
||||||
y = height - textHeight - 30;
|
|
||||||
}
|
|
||||||
|
|
||||||
int buttonX = x + textWidth / 2 - 6 - (int) (70 * (tristate ? 1.5f : 1));
|
|
||||||
|
|
||||||
TextStencilElement confirmText =
|
|
||||||
new TextStencilElement(font, tristate ? "Save" : "Confirm").centered(true, true);
|
|
||||||
confirm = new BoxWidget(buttonX, y + textHeight + 6, 70, 16).withCallback(() -> accept(Response.Confirm));
|
|
||||||
confirm.showingElement(confirmText.withElementRenderer(BoxWidget.gradientFactory.apply(confirm)));
|
|
||||||
addRenderableWidget(confirm);
|
|
||||||
|
|
||||||
buttonX += 12 + 70;
|
|
||||||
|
|
||||||
if (tristate) {
|
|
||||||
TextStencilElement confirmDontSaveText =
|
|
||||||
new TextStencilElement(font, "Don't Save").centered(true, true);
|
|
||||||
confirmDontSave =
|
|
||||||
new BoxWidget(buttonX, y + textHeight + 6, 70, 16).withCallback(() -> accept(Response.ConfirmDontSave));
|
|
||||||
confirmDontSave.showingElement(
|
|
||||||
confirmDontSaveText.withElementRenderer(BoxWidget.gradientFactory.apply(confirmDontSave)));
|
|
||||||
addRenderableWidget(confirmDontSave);
|
|
||||||
buttonX += 12 + 70;
|
|
||||||
}
|
|
||||||
|
|
||||||
TextStencilElement cancelText = new TextStencilElement(font, "Cancel").centered(true, true);
|
|
||||||
cancel = new BoxWidget(buttonX, y + textHeight + 6, 70, 16)
|
|
||||||
.withCallback(() -> accept(Response.Cancel));
|
|
||||||
cancel.showingElement(cancelText.withElementRenderer(BoxWidget.gradientFactory.apply(cancel)));
|
|
||||||
addRenderableWidget(cancel);
|
|
||||||
|
|
||||||
textBackground = new BoxElement()
|
|
||||||
.gradientBorder(Theme.p(Theme.Key.BUTTON_DISABLE))
|
|
||||||
.withBounds(width + 10, textHeight + 35)
|
|
||||||
.at(-5, y - 5);
|
|
||||||
|
|
||||||
if (text.size() == 1)
|
|
||||||
x = (width - font.width(text.get(0))) / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClose() {
|
|
||||||
accept(Response.Cancel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void accept(Response success) {
|
|
||||||
minecraft.screen = source;
|
|
||||||
action.accept(success);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void renderWindow(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
|
||||||
textBackground.render(graphics);
|
|
||||||
int offset = font.lineHeight + 1;
|
|
||||||
int lineY = y - offset;
|
|
||||||
|
|
||||||
PoseStack ms = graphics.pose();
|
|
||||||
ms.pushPose();
|
|
||||||
ms.translate(0, 0, 200);
|
|
||||||
|
|
||||||
for (FormattedText line : text) {
|
|
||||||
lineY += offset;
|
|
||||||
if (line == null)
|
|
||||||
continue;
|
|
||||||
graphics.drawString(font, line.getString(), x, lineY, 0xeaeaea, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
ms.popPose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void renderWindowBackground(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
|
||||||
endFrame();
|
|
||||||
|
|
||||||
source.render(graphics, 0, 0, 10); // zero mouse coords to prevent further tooltips
|
|
||||||
|
|
||||||
prepareFrame();
|
|
||||||
|
|
||||||
graphics.fillGradient(0, 0, this.width, this.height, 0x70101010, 0x80101010);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void prepareFrame() {
|
|
||||||
UIRenderHelper.swapAndBlitColor(minecraft.getMainRenderTarget(), UIRenderHelper.framebuffer);
|
|
||||||
RenderSystem.clear(GL30.GL_STENCIL_BUFFER_BIT | GL30.GL_DEPTH_BUFFER_BIT, Minecraft.ON_OSX);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void endFrame() {
|
|
||||||
UIRenderHelper.swapAndBlitColor(UIRenderHelper.framebuffer, minecraft.getMainRenderTarget());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void resize(@Nonnull Minecraft client, int width, int height) {
|
|
||||||
super.resize(client, width, height);
|
|
||||||
source.resize(client, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPauseScreen() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
package nl.requios.effortlessbuilding.create.foundation.gui;
|
||||||
|
|
||||||
import org.joml.Matrix4f;
|
|
||||||
import org.joml.Vector3f;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.math.Axis;
|
import com.mojang.math.Axis;
|
||||||
|
import net.createmod.catnip.gui.ILightingSettings;
|
||||||
|
import org.joml.Matrix4f;
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
public class CustomLightingSettings implements ILightingSettings {
|
public class CustomLightingSettings implements ILightingSettings {
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ public class CustomLightingSettings implements ILightingSettings {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyLighting() {
|
public void applyLighting() {
|
||||||
RenderSystem.setupLevelDiffuseLighting(light1, light2, lightMatrix);
|
RenderSystem.setShaderLights(light1, light2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.Lighting;
|
|
||||||
|
|
||||||
public interface ILightingSettings {
|
|
||||||
|
|
||||||
void applyLighting();
|
|
||||||
|
|
||||||
static final ILightingSettings DEFAULT_3D = () -> Lighting.setupFor3DItems();
|
|
||||||
static final ILightingSettings DEFAULT_FLAT = () -> Lighting.setupForFlatItems();
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.ScrollInput;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.TooltipArea;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Couple;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Pair;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.client.gui.components.AbstractWidget;
|
|
||||||
import net.minecraft.client.gui.components.EditBox;
|
|
||||||
import net.minecraft.client.gui.components.Renderable;
|
|
||||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
|
||||||
import net.minecraft.client.gui.narration.NarratableEntry;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
|
|
||||||
public class ModularGuiLine {
|
|
||||||
|
|
||||||
List<Pair<AbstractWidget, String>> widgets;
|
|
||||||
List<Couple<Integer>> customBoxes;
|
|
||||||
boolean speechBubble;
|
|
||||||
|
|
||||||
public ModularGuiLine() {
|
|
||||||
widgets = new ArrayList<>();
|
|
||||||
customBoxes = new ArrayList<>();
|
|
||||||
speechBubble = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void renderWidgetBG(int guiLeft, GuiGraphics graphics) {
|
|
||||||
boolean first = true;
|
|
||||||
|
|
||||||
if (!customBoxes.isEmpty()) {
|
|
||||||
for (Couple<Integer> couple : customBoxes) {
|
|
||||||
int x = couple.getFirst() + guiLeft;
|
|
||||||
int width = couple.getSecond();
|
|
||||||
box(graphics, x, width, first & speechBubble);
|
|
||||||
first = false;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Pair<AbstractWidget, String> pair : widgets) {
|
|
||||||
if (pair.getSecond()
|
|
||||||
.equals("Dummy"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
AbstractWidget aw = pair.getFirst();
|
|
||||||
int x = aw.getX();
|
|
||||||
int width = aw.getWidth();
|
|
||||||
|
|
||||||
if (aw instanceof EditBox) {
|
|
||||||
x -= 5;
|
|
||||||
width += 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
box(graphics, x, width, first & speechBubble);
|
|
||||||
first = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void box(GuiGraphics graphics, int x, int width, boolean b) {
|
|
||||||
// UIRenderHelper.drawStretched(graphics, x, 0, width, 18, 0, AllGuiTextures.DATA_AREA);
|
|
||||||
// if (b)
|
|
||||||
// AllGuiTextures.DATA_AREA_SPEECH.render(graphics, x - 3, 0);
|
|
||||||
// else
|
|
||||||
// AllGuiTextures.DATA_AREA_START.render(graphics, x, 0);
|
|
||||||
// AllGuiTextures.DATA_AREA_END.render(graphics, x + width - 2, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveValues(CompoundTag data) {
|
|
||||||
for (Pair<AbstractWidget, String> pair : widgets) {
|
|
||||||
AbstractWidget w = pair.getFirst();
|
|
||||||
String key = pair.getSecond();
|
|
||||||
if (w instanceof EditBox eb)
|
|
||||||
data.putString(key, eb.getValue());
|
|
||||||
if (w instanceof ScrollInput si)
|
|
||||||
data.putInt(key, si.getState());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public <T extends GuiEventListener & Renderable & NarratableEntry> void loadValues(CompoundTag data,
|
|
||||||
Consumer<T> addRenderable, Consumer<T> addRenderableOnly) {
|
|
||||||
for (Pair<AbstractWidget, String> pair : widgets) {
|
|
||||||
AbstractWidget w = pair.getFirst();
|
|
||||||
String key = pair.getSecond();
|
|
||||||
if (w instanceof EditBox eb)
|
|
||||||
eb.setValue(data.getString(key));
|
|
||||||
if (w instanceof ScrollInput si)
|
|
||||||
si.setState(data.getInt(key));
|
|
||||||
|
|
||||||
if (w instanceof TooltipArea)
|
|
||||||
addRenderableOnly.accept((T) w);
|
|
||||||
else
|
|
||||||
addRenderable.accept((T) w);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void forEach(Consumer<GuiEventListener> callback) {
|
|
||||||
widgets.forEach(p -> callback.accept(p.getFirst()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear() {
|
|
||||||
widgets.clear();
|
|
||||||
customBoxes.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(Pair<AbstractWidget, String> pair) {
|
|
||||||
widgets.add(pair);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
|
||||||
|
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.Label;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.ScrollInput;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.SelectionScrollInput;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.TooltipArea;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Couple;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Pair;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.Font;
|
|
||||||
import net.minecraft.client.gui.components.EditBox;
|
|
||||||
|
|
||||||
public class ModularGuiLineBuilder {
|
|
||||||
|
|
||||||
private ModularGuiLine target;
|
|
||||||
private Font font;
|
|
||||||
private int x;
|
|
||||||
private int y;
|
|
||||||
|
|
||||||
public ModularGuiLineBuilder(Font font, ModularGuiLine target, int x, int y) {
|
|
||||||
this.font = font;
|
|
||||||
this.target = target;
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModularGuiLineBuilder addScrollInput(int x, int width, BiConsumer<ScrollInput, Label> inputTransform,
|
|
||||||
String dataKey) {
|
|
||||||
ScrollInput input = new ScrollInput(x + this.x, y - 4, width, 18);
|
|
||||||
addScrollInput(input, inputTransform, dataKey);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModularGuiLineBuilder addSelectionScrollInput(int x, int width,
|
|
||||||
BiConsumer<SelectionScrollInput, Label> inputTransform, String dataKey) {
|
|
||||||
SelectionScrollInput input = new SelectionScrollInput(x + this.x, y - 4, width, 18);
|
|
||||||
addScrollInput(input, inputTransform, dataKey);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModularGuiLineBuilder customArea(int x, int width) {
|
|
||||||
target.customBoxes.add(Couple.create(x, width));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModularGuiLineBuilder speechBubble() {
|
|
||||||
target.speechBubble = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T extends ScrollInput> void addScrollInput(T input, BiConsumer<T, Label> inputTransform, String dataKey) {
|
|
||||||
Label label = new Label(input.getX() + 5, y, Components.immutableEmpty());
|
|
||||||
label.withShadow();
|
|
||||||
inputTransform.accept(input, label);
|
|
||||||
input.writingTo(label);
|
|
||||||
target.add(Pair.of(label, "Dummy"));
|
|
||||||
target.add(Pair.of(input, dataKey));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModularGuiLineBuilder addIntegerTextInput(int x, int width, BiConsumer<EditBox, TooltipArea> inputTransform,
|
|
||||||
String dataKey) {
|
|
||||||
return addTextInput(x, width, inputTransform.andThen((editBox, $) -> editBox.setFilter(s -> {
|
|
||||||
if (s.isEmpty())
|
|
||||||
return true;
|
|
||||||
try {
|
|
||||||
Integer.parseInt(s);
|
|
||||||
return true;
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
})), dataKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModularGuiLineBuilder addTextInput(int x, int width, BiConsumer<EditBox, TooltipArea> inputTransform,
|
|
||||||
String dataKey) {
|
|
||||||
EditBox input = new EditBox(font, x + this.x + 5, y, width - 9, 8, Components.immutableEmpty());
|
|
||||||
input.setBordered(false);
|
|
||||||
input.setTextColor(0xffffff);
|
|
||||||
input.setFocused(false);
|
|
||||||
input.mouseClicked(0, 0, 0);
|
|
||||||
TooltipArea tooltipArea = new TooltipArea(this.x + x, y - 4, width, 18);
|
|
||||||
inputTransform.accept(input, tooltipArea);
|
|
||||||
target.add(Pair.of(input, dataKey));
|
|
||||||
target.add(Pair.of(tooltipArea, "Dummy"));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,16 +1,7 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
package nl.requios.effortlessbuilding.create.foundation.gui;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import org.joml.Matrix4f;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.mojang.blaze3d.vertex.Tesselator;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.Font;
|
import net.minecraft.client.gui.Font;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||||
@@ -18,10 +9,15 @@ import net.minecraft.client.renderer.MultiBufferSource;
|
|||||||
import net.minecraft.network.chat.FormattedText;
|
import net.minecraft.network.chat.FormattedText;
|
||||||
import net.minecraft.network.chat.Style;
|
import net.minecraft.network.chat.Style;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraftforge.client.ForgeHooksClient;
|
import net.neoforged.neoforge.client.ClientHooks;
|
||||||
import net.minecraftforge.client.event.RenderTooltipEvent;
|
import net.neoforged.neoforge.client.event.RenderTooltipEvent;
|
||||||
import net.minecraftforge.client.extensions.IForgeGuiGraphics;
|
import net.neoforged.neoforge.client.extensions.IGuiGraphicsExtension;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
|
import org.joml.Matrix4f;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class RemovedGuiUtils {
|
public class RemovedGuiUtils {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@@ -38,7 +34,7 @@ public class RemovedGuiUtils {
|
|||||||
public static void drawHoveringText(GuiGraphics graphics, List<? extends FormattedText> textLines, int mouseX,
|
public static void drawHoveringText(GuiGraphics graphics, List<? extends FormattedText> textLines, int mouseX,
|
||||||
int mouseY, int screenWidth, int screenHeight, int maxTextWidth, Font font) {
|
int mouseY, int screenWidth, int screenHeight, int maxTextWidth, Font font) {
|
||||||
drawHoveringText(graphics, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth,
|
drawHoveringText(graphics, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth,
|
||||||
IForgeGuiGraphics.DEFAULT_BACKGROUND_COLOR, IForgeGuiGraphics.DEFAULT_BORDER_COLOR_START, IForgeGuiGraphics.DEFAULT_BORDER_COLOR_END,
|
IGuiGraphicsExtension.DEFAULT_BACKGROUND_COLOR, IGuiGraphicsExtension.DEFAULT_BORDER_COLOR_START, IGuiGraphicsExtension.DEFAULT_BORDER_COLOR_END,
|
||||||
font);
|
font);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +49,7 @@ public class RemovedGuiUtils {
|
|||||||
List<? extends FormattedText> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight,
|
List<? extends FormattedText> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight,
|
||||||
int maxTextWidth, Font font) {
|
int maxTextWidth, Font font) {
|
||||||
drawHoveringText(stack, graphics, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth,
|
drawHoveringText(stack, graphics, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth,
|
||||||
IForgeGuiGraphics.DEFAULT_BACKGROUND_COLOR, IForgeGuiGraphics.DEFAULT_BORDER_COLOR_START, IForgeGuiGraphics.DEFAULT_BORDER_COLOR_END,
|
IGuiGraphicsExtension.DEFAULT_BACKGROUND_COLOR, IGuiGraphicsExtension.DEFAULT_BORDER_COLOR_START, IGuiGraphicsExtension.DEFAULT_BORDER_COLOR_END,
|
||||||
font);
|
font);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,11 +59,11 @@ public class RemovedGuiUtils {
|
|||||||
if (textLines.isEmpty())
|
if (textLines.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
List<ClientTooltipComponent> list = ForgeHooksClient.gatherTooltipComponents(stack, textLines,
|
List<ClientTooltipComponent> list = ClientHooks.gatherTooltipComponents(stack, textLines,
|
||||||
stack.getTooltipImage(), mouseX, screenWidth, screenHeight, font);
|
stack.getTooltipImage(), mouseX, screenWidth, screenHeight, font);
|
||||||
RenderTooltipEvent.Pre event =
|
RenderTooltipEvent.Pre event =
|
||||||
new RenderTooltipEvent.Pre(stack, graphics, mouseX, mouseY, screenWidth, screenHeight, font, list, null);
|
new RenderTooltipEvent.Pre(stack, graphics, mouseX, mouseY, screenWidth, screenHeight, font, list, null);
|
||||||
if (MinecraftForge.EVENT_BUS.post(event))
|
if (NeoForge.EVENT_BUS.post(event).isCanceled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PoseStack pStack = graphics.pose();
|
PoseStack pStack = graphics.pose();
|
||||||
@@ -152,7 +148,7 @@ public class RemovedGuiUtils {
|
|||||||
final int zLevel = 400;
|
final int zLevel = 400;
|
||||||
RenderTooltipEvent.Color colorEvent = new RenderTooltipEvent.Color(stack, graphics, tooltipX, tooltipY,
|
RenderTooltipEvent.Color colorEvent = new RenderTooltipEvent.Color(stack, graphics, tooltipX, tooltipY,
|
||||||
font, backgroundColor, borderColorStart, borderColorEnd, list);
|
font, backgroundColor, borderColorStart, borderColorEnd, list);
|
||||||
MinecraftForge.EVENT_BUS.post(colorEvent);
|
NeoForge.EVENT_BUS.post(colorEvent);
|
||||||
backgroundColor = colorEvent.getBackgroundStart();
|
backgroundColor = colorEvent.getBackgroundStart();
|
||||||
borderColorStart = colorEvent.getBorderStart();
|
borderColorStart = colorEvent.getBorderStart();
|
||||||
borderColorEnd = colorEvent.getBorderEnd();
|
borderColorEnd = colorEvent.getBorderEnd();
|
||||||
@@ -179,8 +175,7 @@ public class RemovedGuiUtils {
|
|||||||
graphics.fillGradient(tooltipX - 3, tooltipY + tooltipHeight + 2,
|
graphics.fillGradient(tooltipX - 3, tooltipY + tooltipHeight + 2,
|
||||||
tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, zLevel, borderColorEnd, borderColorEnd);
|
tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, zLevel, borderColorEnd, borderColorEnd);
|
||||||
|
|
||||||
MultiBufferSource.BufferSource renderType = MultiBufferSource.immediate(Tesselator.getInstance()
|
MultiBufferSource.BufferSource renderType = graphics.bufferSource();
|
||||||
.getBuilder());
|
|
||||||
pStack.translate(0.0D, 0.0D, zLevel);
|
pStack.translate(0.0D, 0.0D, zLevel);
|
||||||
|
|
||||||
for (int lineNumber = 0; lineNumber < list.size(); ++lineNumber) {
|
for (int lineNumber = 0; lineNumber < list.size(); ++lineNumber) {
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
package nl.requios.effortlessbuilding.create.foundation.gui;
|
||||||
|
|
||||||
|
import net.createmod.catnip.data.Couple;
|
||||||
|
import net.createmod.catnip.theme.Color;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -7,12 +12,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Couple;
|
|
||||||
|
|
||||||
public class Theme {
|
public class Theme {
|
||||||
|
|
||||||
private static final List<Theme> THEMES = new ArrayList<>();
|
private static final List<Theme> THEMES = new ArrayList<>();
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
|
||||||
|
|
||||||
public interface TickableGuiEventListener extends GuiEventListener {
|
|
||||||
void tick();
|
|
||||||
}
|
|
||||||
@@ -1,329 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
|
||||||
|
|
||||||
import org.joml.Matrix4f;
|
|
||||||
import org.lwjgl.opengl.GL20;
|
|
||||||
import org.lwjgl.opengl.GL30;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.pipeline.RenderTarget;
|
|
||||||
import com.mojang.blaze3d.platform.GlConst;
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
|
||||||
import com.mojang.blaze3d.platform.Window;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
|
||||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import com.mojang.blaze3d.vertex.Tesselator;
|
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
|
||||||
import com.mojang.math.Axis;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Couple;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
|
||||||
|
|
||||||
public class UIRenderHelper {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An FBO that has a stencil buffer for use wherever stencil are necessary. Forcing the main FBO to have a stencil
|
|
||||||
* buffer will cause GL error spam when using fabulous graphics.
|
|
||||||
*/
|
|
||||||
public static CustomRenderTarget framebuffer;
|
|
||||||
|
|
||||||
public static void init() {
|
|
||||||
RenderSystem.recordRenderCall(() -> {
|
|
||||||
Window mainWindow = Minecraft.getInstance().getWindow();
|
|
||||||
framebuffer = CustomRenderTarget.create(mainWindow);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateWindowSize(Window mainWindow) {
|
|
||||||
if (framebuffer != null)
|
|
||||||
framebuffer.resize(mainWindow.getWidth(), mainWindow.getHeight(), Minecraft.ON_OSX);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void drawFramebuffer(float alpha) {
|
|
||||||
framebuffer.renderWithAlpha(alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Switch from src to dst, after copying the contents of src to dst.
|
|
||||||
*/
|
|
||||||
public static void swapAndBlitColor(RenderTarget src, RenderTarget dst) {
|
|
||||||
GlStateManager._glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, src.frameBufferId);
|
|
||||||
GlStateManager._glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, dst.frameBufferId);
|
|
||||||
GlStateManager._glBlitFrameBuffer(0, 0, src.viewWidth, src.viewHeight, 0, 0, dst.viewWidth, dst.viewHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR);
|
|
||||||
|
|
||||||
GlStateManager._glBindFramebuffer(GlConst.GL_FRAMEBUFFER, dst.frameBufferId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void streak(GuiGraphics graphics, float angle, int x, int y, int breadth, int length) {
|
|
||||||
streak(graphics, angle, x, y, breadth, length, Theme.i(Theme.Key.STREAK));
|
|
||||||
}
|
|
||||||
// angle in degrees; 0° -> fading to the right
|
|
||||||
// x and y specify the middle point of the starting edge
|
|
||||||
// breadth is the total width of the streak
|
|
||||||
|
|
||||||
public static void streak(GuiGraphics graphics, float angle, int x, int y, int breadth, int length, int color) {
|
|
||||||
int a1 = 0xa0 << 24;
|
|
||||||
int a2 = 0x80 << 24;
|
|
||||||
int a3 = 0x10 << 24;
|
|
||||||
int a4 = 0x00 << 24;
|
|
||||||
|
|
||||||
color &= 0x00FFFFFF;
|
|
||||||
int c1 = a1 | color;
|
|
||||||
int c2 = a2 | color;
|
|
||||||
int c3 = a3 | color;
|
|
||||||
int c4 = a4 | color;
|
|
||||||
|
|
||||||
PoseStack ms = graphics.pose();
|
|
||||||
ms.pushPose();
|
|
||||||
ms.translate(x, y, 0);
|
|
||||||
ms.mulPose(Axis.ZP.rotationDegrees(angle - 90));
|
|
||||||
|
|
||||||
streak(graphics, breadth / 2, length, c1, c2, c3, c4);
|
|
||||||
|
|
||||||
ms.popPose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void streak(GuiGraphics graphics, float angle, int x, int y, int breadth, int length, Color c) {
|
|
||||||
Color color = c.copy().setImmutable();
|
|
||||||
int c1 = color.scaleAlpha(0.625f).getRGB();
|
|
||||||
int c2 = color.scaleAlpha(0.5f).getRGB();
|
|
||||||
int c3 = color.scaleAlpha(0.0625f).getRGB();
|
|
||||||
int c4 = color.scaleAlpha(0f).getRGB();
|
|
||||||
|
|
||||||
PoseStack ms = graphics.pose();
|
|
||||||
ms.pushPose();
|
|
||||||
ms.translate(x, y, 0);
|
|
||||||
ms.mulPose(Axis.ZP.rotationDegrees(angle - 90));
|
|
||||||
|
|
||||||
streak(graphics, breadth / 2, length, c1, c2, c3, c4);
|
|
||||||
|
|
||||||
ms.popPose();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void streak(GuiGraphics graphics, int width, int height, int c1, int c2, int c3, int c4) {
|
|
||||||
double split1 = .5;
|
|
||||||
double split2 = .75;
|
|
||||||
graphics.fillGradient(-width, 0, width, (int) (split1 * height), 0, c1, c2);
|
|
||||||
graphics.fillGradient(-width, (int) (split1 * height), width, (int) (split2 * height), 0, c2, c3);
|
|
||||||
graphics.fillGradient(-width, (int) (split2 * height), width, height, 0, c3, c4);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see #angledGradient(MatrixStack, float, int, int, int, int, int, Color, Color)
|
|
||||||
*/
|
|
||||||
public static void angledGradient(GuiGraphics graphics, float angle, int x, int y, int breadth, int length, Couple<Color> c) {
|
|
||||||
angledGradient(graphics, angle, x, y, 0, breadth, length, c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see #angledGradient(MatrixStack, float, int, int, int, int, int, Color, Color)
|
|
||||||
*/
|
|
||||||
public static void angledGradient(GuiGraphics graphics, float angle, int x, int y, int z, int breadth, int length, Couple<Color> c) {
|
|
||||||
angledGradient(graphics, angle, x, y, z, breadth, length, c.getFirst(), c.getSecond());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see #angledGradient(MatrixStack, float, int, int, int, int, int, Color, Color)
|
|
||||||
*/
|
|
||||||
public static void angledGradient(GuiGraphics graphics, float angle, int x, int y, int breadth, int length, Color color1, Color color2) {
|
|
||||||
angledGradient(graphics, angle, x, y, 0, breadth, length, color1, color2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* x and y specify the middle point of the starting edge
|
|
||||||
*
|
|
||||||
* @param angle the angle of the gradient in degrees; 0° means from left to right
|
|
||||||
* @param color1 the color at the starting edge
|
|
||||||
* @param color2 the color at the ending edge
|
|
||||||
* @param breadth the total width of the gradient
|
|
||||||
*/
|
|
||||||
public static void angledGradient(GuiGraphics graphics, float angle, int x, int y, int z, int breadth, int length, Color color1, Color color2) {
|
|
||||||
PoseStack ms = graphics.pose();
|
|
||||||
ms.pushPose();
|
|
||||||
ms.translate(x, y, z);
|
|
||||||
ms.mulPose(Axis.ZP.rotationDegrees(angle - 90));
|
|
||||||
|
|
||||||
int w = breadth / 2;
|
|
||||||
graphics.fillGradient(-w, 0, w, length, 0, color1.getRGB(), color2.getRGB());
|
|
||||||
|
|
||||||
ms.popPose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void breadcrumbArrow(GuiGraphics graphics, int x, int y, int z, int width, int height, int indent, Couple<Color> colors) {breadcrumbArrow(graphics, x, y, z, width, height, indent, colors.getFirst(), colors.getSecond());}
|
|
||||||
|
|
||||||
// draws a wide chevron-style breadcrumb arrow pointing left
|
|
||||||
public static void breadcrumbArrow(GuiGraphics graphics, int x, int y, int z, int width, int height, int indent, Color startColor, Color endColor) {
|
|
||||||
PoseStack matrixStack = graphics.pose();
|
|
||||||
matrixStack.pushPose();
|
|
||||||
matrixStack.translate(x - indent, y, z);
|
|
||||||
|
|
||||||
breadcrumbArrow(graphics, width, height, indent, startColor, endColor);
|
|
||||||
|
|
||||||
matrixStack.popPose();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void breadcrumbArrow(GuiGraphics graphics, int width, int height, int indent, Color c1, Color c2) {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 0,0 x1,y1 ********************* x4,y4 ***** x7,y7
|
|
||||||
* **** ****
|
|
||||||
* **** ****
|
|
||||||
* x0,y0 x2,y2 x5,y5
|
|
||||||
* **** ****
|
|
||||||
* **** ****
|
|
||||||
* x3,y3 ********************* x6,y6 ***** x8,y8
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
float x0 = 0, y0 = height / 2f;
|
|
||||||
float x1 = indent, y1 = 0;
|
|
||||||
float x2 = indent, y2 = height / 2f;
|
|
||||||
float x3 = indent, y3 = height;
|
|
||||||
float x4 = width, y4 = 0;
|
|
||||||
float x5 = width, y5 = height / 2f;
|
|
||||||
float x6 = width, y6 = height;
|
|
||||||
float x7 = indent + width, y7 = 0;
|
|
||||||
float x8 = indent + width, y8 = height;
|
|
||||||
|
|
||||||
indent = Math.abs(indent);
|
|
||||||
width = Math.abs(width);
|
|
||||||
Color fc1 = Color.mixColors(c1, c2, 0);
|
|
||||||
Color fc2 = Color.mixColors(c1, c2, (indent) / (width + 2f * indent));
|
|
||||||
Color fc3 = Color.mixColors(c1, c2, (indent + width) / (width + 2f * indent));
|
|
||||||
Color fc4 = Color.mixColors(c1, c2, 1);
|
|
||||||
|
|
||||||
// RenderSystem.disableTexture();
|
|
||||||
RenderSystem.enableBlend();
|
|
||||||
RenderSystem.disableCull();
|
|
||||||
RenderSystem.defaultBlendFunc();
|
|
||||||
RenderSystem.setShader(GameRenderer::getPositionColorShader);
|
|
||||||
|
|
||||||
Tesselator tessellator = Tesselator.getInstance();
|
|
||||||
BufferBuilder bufferbuilder = tessellator.getBuilder();
|
|
||||||
Matrix4f model = graphics.pose().last().pose();
|
|
||||||
bufferbuilder.begin(VertexFormat.Mode.TRIANGLES, DefaultVertexFormat.POSITION_COLOR);
|
|
||||||
|
|
||||||
bufferbuilder.vertex(model, x0, y0, 0).color(fc1.getRed(), fc1.getGreen(), fc1.getBlue(), fc1.getAlpha()).endVertex();
|
|
||||||
bufferbuilder.vertex(model, x1, y1, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex();
|
|
||||||
bufferbuilder.vertex(model, x2, y2, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex();
|
|
||||||
|
|
||||||
bufferbuilder.vertex(model, x0, y0, 0).color(fc1.getRed(), fc1.getGreen(), fc1.getBlue(), fc1.getAlpha()).endVertex();
|
|
||||||
bufferbuilder.vertex(model, x2, y2, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex();
|
|
||||||
bufferbuilder.vertex(model, x3, y3, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex();
|
|
||||||
|
|
||||||
bufferbuilder.vertex(model, x3, y3, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex();
|
|
||||||
bufferbuilder.vertex(model, x1, y1, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex();
|
|
||||||
bufferbuilder.vertex(model, x4, y4, 0).color(fc3.getRed(), fc3.getGreen(), fc3.getBlue(), fc3.getAlpha()).endVertex();
|
|
||||||
|
|
||||||
bufferbuilder.vertex(model, x3, y3, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex();
|
|
||||||
bufferbuilder.vertex(model, x4, y4, 0).color(fc3.getRed(), fc3.getGreen(), fc3.getBlue(), fc3.getAlpha()).endVertex();
|
|
||||||
bufferbuilder.vertex(model, x6, y6, 0).color(fc3.getRed(), fc3.getGreen(), fc3.getBlue(), fc3.getAlpha()).endVertex();
|
|
||||||
|
|
||||||
bufferbuilder.vertex(model, x5, y5, 0).color(fc3.getRed(), fc3.getGreen(), fc3.getBlue(), fc3.getAlpha()).endVertex();
|
|
||||||
bufferbuilder.vertex(model, x4, y4, 0).color(fc3.getRed(), fc3.getGreen(), fc3.getBlue(), fc3.getAlpha()).endVertex();
|
|
||||||
bufferbuilder.vertex(model, x7, y7, 0).color(fc4.getRed(), fc4.getGreen(), fc4.getBlue(), fc4.getAlpha()).endVertex();
|
|
||||||
|
|
||||||
bufferbuilder.vertex(model, x6, y6, 0).color(fc3.getRed(), fc3.getGreen(), fc3.getBlue(), fc3.getAlpha()).endVertex();
|
|
||||||
bufferbuilder.vertex(model, x5, y5, 0).color(fc3.getRed(), fc3.getGreen(), fc3.getBlue(), fc3.getAlpha()).endVertex();
|
|
||||||
bufferbuilder.vertex(model, x8, y8, 0).color(fc4.getRed(), fc4.getGreen(), fc4.getBlue(), fc4.getAlpha()).endVertex();
|
|
||||||
|
|
||||||
tessellator.end();
|
|
||||||
RenderSystem.enableCull();
|
|
||||||
RenderSystem.disableBlend();
|
|
||||||
// RenderSystem.enableTexture();
|
|
||||||
}
|
|
||||||
|
|
||||||
//just like AbstractGui#drawTexture, but with a color at every vertex
|
|
||||||
public static void drawColoredTexture(GuiGraphics graphics, Color c, int x, int y, int tex_left, int tex_top, int width, int height) {
|
|
||||||
drawColoredTexture(graphics, c, x, y, 0, (float) tex_left, (float) tex_top, width, height, 256, 256);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void drawColoredTexture(GuiGraphics graphics, Color c, int x, int y, int z, float tex_left, float tex_top, int width, int height, int sheet_width, int sheet_height) {
|
|
||||||
drawColoredTexture(graphics, c, x, x + width, y, y + height, z, width, height, tex_left, tex_top, sheet_width, sheet_height);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void drawStretched(GuiGraphics graphics, int left, int top, int w, int h, int z, AllGuiTextures tex) {
|
|
||||||
tex.bind();
|
|
||||||
drawTexturedQuad(graphics.pose().last()
|
|
||||||
.pose(), Color.WHITE, left, left + w, top, top + h, z, tex.startX / 256f, (tex.startX + tex.width) / 256f,
|
|
||||||
tex.startY / 256f, (tex.startY + tex.height) / 256f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void drawCropped(GuiGraphics graphics, int left, int top, int w, int h, int z, AllGuiTextures tex) {
|
|
||||||
tex.bind();
|
|
||||||
drawTexturedQuad(graphics.pose().last()
|
|
||||||
.pose(), Color.WHITE, left, left + w, top, top + h, z, tex.startX / 256f, (tex.startX + w) / 256f,
|
|
||||||
tex.startY / 256f, (tex.startY + h) / 256f);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void drawColoredTexture(GuiGraphics graphics, Color c, int left, int right, int top, int bot, int z, int tex_width, int tex_height, float tex_left, float tex_top, int sheet_width, int sheet_height) {
|
|
||||||
drawTexturedQuad(graphics.pose().last().pose(), c, left, right, top, bot, z, (tex_left + 0.0F) / (float) sheet_width, (tex_left + (float) tex_width) / (float) sheet_width, (tex_top + 0.0F) / (float) sheet_height, (tex_top + (float) tex_height) / (float) sheet_height);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void drawTexturedQuad(Matrix4f m, Color c, int left, int right, int top, int bot, int z, float u1, float u2, float v1, float v2) {
|
|
||||||
Tesselator tesselator = Tesselator.getInstance();
|
|
||||||
BufferBuilder bufferbuilder = tesselator.getBuilder();
|
|
||||||
RenderSystem.enableBlend();
|
|
||||||
RenderSystem.defaultBlendFunc();
|
|
||||||
RenderSystem.setShader(GameRenderer::getPositionColorTexShader);
|
|
||||||
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR_TEX);
|
|
||||||
bufferbuilder.vertex(m, (float) left , (float) bot, (float) z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).uv(u1, v2).endVertex();
|
|
||||||
bufferbuilder.vertex(m, (float) right, (float) bot, (float) z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).uv(u2, v2).endVertex();
|
|
||||||
bufferbuilder.vertex(m, (float) right, (float) top, (float) z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).uv(u2, v1).endVertex();
|
|
||||||
bufferbuilder.vertex(m, (float) left , (float) top, (float) z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).uv(u1, v1).endVertex();
|
|
||||||
tesselator.end();
|
|
||||||
RenderSystem.disableBlend();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void flipForGuiRender(PoseStack poseStack) {
|
|
||||||
poseStack.mulPoseMatrix(new Matrix4f().scaling(1, -1, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class CustomRenderTarget extends RenderTarget {
|
|
||||||
|
|
||||||
public CustomRenderTarget(boolean useDepth) {
|
|
||||||
super(useDepth);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CustomRenderTarget create(Window mainWindow) {
|
|
||||||
CustomRenderTarget framebuffer = new CustomRenderTarget(true);
|
|
||||||
framebuffer.resize(mainWindow.getWidth(), mainWindow.getHeight(), Minecraft.ON_OSX);
|
|
||||||
framebuffer.setClearColor(0, 0, 0, 0);
|
|
||||||
framebuffer.enableStencil();
|
|
||||||
return framebuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void renderWithAlpha(float alpha) {
|
|
||||||
Window window = Minecraft.getInstance().getWindow();
|
|
||||||
|
|
||||||
float vx = (float) window.getGuiScaledWidth();
|
|
||||||
float vy = (float) window.getGuiScaledHeight();
|
|
||||||
float tx = (float) viewWidth / (float) width;
|
|
||||||
float ty = (float) viewHeight / (float) height;
|
|
||||||
|
|
||||||
// RenderSystem.enableTexture();
|
|
||||||
RenderSystem.enableDepthTest();
|
|
||||||
RenderSystem.setShader(() -> Minecraft.getInstance().gameRenderer.blitShader);
|
|
||||||
RenderSystem.getShader().setSampler("DiffuseSampler", colorTextureId);
|
|
||||||
|
|
||||||
bindRead();
|
|
||||||
|
|
||||||
Tesselator tessellator = Tesselator.getInstance();
|
|
||||||
BufferBuilder bufferbuilder = tessellator.getBuilder();
|
|
||||||
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR_TEX);
|
|
||||||
|
|
||||||
bufferbuilder.vertex(0, vy, 0).color(1, 1, 1, alpha).uv(0, 0).endVertex();
|
|
||||||
bufferbuilder.vertex(vx, vy, 0).color(1, 1, 1, alpha).uv(tx, 0).endVertex();
|
|
||||||
bufferbuilder.vertex(vx, 0, 0).color(1, 1, 1, alpha).uv(tx, ty).endVertex();
|
|
||||||
bufferbuilder.vertex(0, 0, 0).color(1, 1, 1, alpha).uv(0, ty).endVertex();
|
|
||||||
|
|
||||||
tessellator.end();
|
|
||||||
unbindRead();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,16 +1,8 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.menu;
|
package nl.requios.effortlessbuilding.create.foundation.gui.container;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.InputConstants;
|
import com.mojang.blaze3d.platform.InputConstants;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.AllGuiTextures;
|
import net.createmod.catnip.animation.AnimationTickHolder;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.TickableGuiEventListener;
|
import net.createmod.catnip.gui.TickableGuiEventListener;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.AbstractSimiWidget;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.components.AbstractWidget;
|
import net.minecraft.client.gui.components.AbstractWidget;
|
||||||
import net.minecraft.client.gui.components.EditBox;
|
import net.minecraft.client.gui.components.EditBox;
|
||||||
@@ -23,8 +15,14 @@ import net.minecraft.client.renderer.Rect2i;
|
|||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.gui.widget.AbstractSimiWidget;
|
||||||
|
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
@@ -95,9 +93,7 @@ public abstract class AbstractSimiContainerScreen<T extends AbstractContainerMen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||||
partialTicks = minecraft.getFrameTime();
|
partialTicks = AnimationTickHolder.getPartialTicksUI();
|
||||||
|
|
||||||
renderBackground(graphics);
|
|
||||||
|
|
||||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
@@ -130,10 +126,10 @@ public abstract class AbstractSimiContainerScreen<T extends AbstractContainerMen
|
|||||||
return leftPos - windowXOffset + (imageWidth - textureWidth) / 2;
|
return leftPos - windowXOffset + (imageWidth - textureWidth) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderPlayerInventory(GuiGraphics graphics, int x, int y) {
|
// public void renderPlayerInventory(GuiGraphics graphics, int x, int y) {
|
||||||
// AllGuiTextures.PLAYER_INVENTORY.render(graphics, x, y);
|
// AllGuiTextures.PLAYER_INVENTORY.render(graphics, x, y);
|
||||||
graphics.drawString(font, playerInventoryTitle, x + 8, y + 6, 0x404040, false);
|
// graphics.drawString(font, playerInventoryTitle, x + 8, y + 6, 0x404040, false);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) {
|
public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.menu;
|
package nl.requios.effortlessbuilding.create.foundation.gui.container;
|
||||||
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
@@ -7,8 +7,7 @@ import net.minecraft.world.inventory.ClickType;
|
|||||||
import net.minecraft.world.inventory.MenuType;
|
import net.minecraft.world.inventory.MenuType;
|
||||||
import net.minecraft.world.inventory.Slot;
|
import net.minecraft.world.inventory.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.neoforged.neoforge.items.ItemStackHandler;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
|
||||||
|
|
||||||
public abstract class GhostItemMenu<T> extends MenuBase<T> implements IClearableMenu {
|
public abstract class GhostItemMenu<T> extends MenuBase<T> implements IClearableMenu {
|
||||||
|
|
||||||
@@ -88,7 +87,7 @@ public abstract class GhostItemMenu<T> extends MenuBase<T> implements IClearable
|
|||||||
ItemStack stackToInsert = playerInventory.getItem(index);
|
ItemStack stackToInsert = playerInventory.getItem(index);
|
||||||
for (int i = 0; i < ghostInventory.getSlots(); i++) {
|
for (int i = 0; i < ghostInventory.getSlots(); i++) {
|
||||||
ItemStack stack = ghostInventory.getStackInSlot(i);
|
ItemStack stack = ghostInventory.getStackInSlot(i);
|
||||||
if (!allowRepeats() && ItemHandlerHelper.canItemStacksStack(stack, stackToInsert))
|
if (!allowRepeats() && ItemStack.isSameItemSameComponents(stack, stackToInsert))
|
||||||
break;
|
break;
|
||||||
if (stack.isEmpty()) {
|
if (stack.isEmpty()) {
|
||||||
ItemStack copy = stackToInsert.copy();
|
ItemStack copy = stackToInsert.copy();
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package nl.requios.effortlessbuilding.create.foundation.gui.container;
|
||||||
|
|
||||||
|
public interface IClearableMenu {
|
||||||
|
|
||||||
|
default void sendClearPacket() {
|
||||||
|
// PacketDistributor.SERVER.noArg().send(new ClearMenuPacket());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearContents();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.menu;
|
package nl.requios.effortlessbuilding.create.foundation.gui.container;
|
||||||
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.IInteractionChecker;
|
|
||||||
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
@@ -8,8 +6,9 @@ import net.minecraft.world.entity.player.Player;
|
|||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.MenuType;
|
import net.minecraft.world.inventory.MenuType;
|
||||||
import net.minecraft.world.inventory.Slot;
|
import net.minecraft.world.inventory.Slot;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.IInteractionChecker;
|
||||||
|
|
||||||
public abstract class MenuBase<T> extends AbstractContainerMenu {
|
public abstract class MenuBase<T> extends AbstractContainerMenu {
|
||||||
|
|
||||||
@@ -1,160 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
|
||||||
|
|
||||||
import org.joml.Matrix4f;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
|
||||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import com.mojang.blaze3d.vertex.Tesselator;
|
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Couple;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
|
||||||
|
|
||||||
public class BoxElement extends RenderElement {
|
|
||||||
|
|
||||||
protected Color background = new Color(0xff000000, true);
|
|
||||||
protected Color borderTop = new Color(0x40ffeedd, true);
|
|
||||||
protected Color borderBot = new Color(0x20ffeedd, true);
|
|
||||||
protected int borderOffset = 2;
|
|
||||||
|
|
||||||
public <T extends BoxElement> T withBackground(Color color) {
|
|
||||||
this.background = color;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends BoxElement> T withBackground(int color) {
|
|
||||||
return withBackground(new Color(color, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends BoxElement> T flatBorder(Color color) {
|
|
||||||
this.borderTop = color;
|
|
||||||
this.borderBot = color;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends BoxElement> T flatBorder(int color) {
|
|
||||||
return flatBorder(new Color(color, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends BoxElement> T gradientBorder(Couple<Color> colors) {
|
|
||||||
this.borderTop = colors.getFirst();
|
|
||||||
this.borderBot = colors.getSecond();
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends BoxElement> T gradientBorder(Color top, Color bot) {
|
|
||||||
this.borderTop = top;
|
|
||||||
this.borderBot = bot;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends BoxElement> T gradientBorder(int top, int bot) {
|
|
||||||
return gradientBorder(new Color(top, true), new Color(bot, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends BoxElement> T withBorderOffset(int offset) {
|
|
||||||
this.borderOffset = offset;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(GuiGraphics graphics) {
|
|
||||||
renderBox(graphics.pose());
|
|
||||||
}
|
|
||||||
|
|
||||||
//total box width = 1 * 2 (outer border) + 1 * 2 (inner color border) + 2 * borderOffset + width
|
|
||||||
//defaults to 2 + 2 + 4 + 16 = 24px
|
|
||||||
//batch everything together to save a bunch of gl calls over ScreenUtils
|
|
||||||
protected void renderBox(PoseStack ms) {
|
|
||||||
/*
|
|
||||||
* _____________
|
|
||||||
* _|_____________|_
|
|
||||||
* | | ___________ | |
|
|
||||||
* | | | | | | |
|
|
||||||
* | | | | | | |
|
|
||||||
* | | |--* | | | |
|
|
||||||
* | | | h | | |
|
|
||||||
* | | | --w-+ | | |
|
|
||||||
* | | | | | |
|
|
||||||
* | | |_________| | |
|
|
||||||
* |_|_____________|_|
|
|
||||||
* |_____________|
|
|
||||||
*
|
|
||||||
* */
|
|
||||||
// RenderSystem.disableTexture();
|
|
||||||
RenderSystem.enableBlend();
|
|
||||||
RenderSystem.defaultBlendFunc();
|
|
||||||
RenderSystem.setShader(GameRenderer::getPositionColorShader);
|
|
||||||
|
|
||||||
Matrix4f model = ms.last().pose();
|
|
||||||
int f = borderOffset;
|
|
||||||
Color c1 = background.copy().scaleAlpha(alpha);
|
|
||||||
Color c2 = borderTop.copy().scaleAlpha(alpha);
|
|
||||||
Color c3 = borderBot.copy().scaleAlpha(alpha);
|
|
||||||
Tesselator tessellator = Tesselator.getInstance();
|
|
||||||
BufferBuilder b = tessellator.getBuilder();
|
|
||||||
|
|
||||||
b.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
|
|
||||||
//outer top
|
|
||||||
b.vertex(model, x - f - 1 , y - f - 2 , z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x - f - 1 , y - f - 1 , z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x + f + 1 + width, y - f - 1 , z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x + f + 1 + width, y - f - 2 , z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex();
|
|
||||||
//outer left
|
|
||||||
b.vertex(model, x - f - 2 , y - f - 1 , z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x - f - 2 , y + f + 1 + height, z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x - f - 1 , y + f + 1 + height, z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x - f - 1 , y - f - 1 , z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex();
|
|
||||||
//outer bottom
|
|
||||||
b.vertex(model, x - f - 1 , y + f + 1 + height, z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x - f - 1 , y + f + 2 + height, z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x + f + 1 + width, y + f + 2 + height, z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x + f + 1 + width, y + f + 1 + height, z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex();
|
|
||||||
//outer right
|
|
||||||
b.vertex(model, x + f + 1 + width, y - f - 1 , z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x + f + 1 + width, y + f + 1 + height, z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x + f + 2 + width, y + f + 1 + height, z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x + f + 2 + width, y - f - 1 , z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex();
|
|
||||||
//inner background - also render behind the inner edges
|
|
||||||
b.vertex(model, x - f - 1 , y - f - 1 , z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x - f - 1 , y + f + 1 + height, z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x + f + 1 + width, y + f + 1 + height, z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x + f + 1 + width, y - f - 1 , z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex();
|
|
||||||
tessellator.end();
|
|
||||||
b.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
|
|
||||||
//inner top - includes corners
|
|
||||||
b.vertex(model, x - f - 1 , y - f - 1 , z).color(c2.getRed(), c2.getGreen(), c2.getBlue(), c2.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x - f - 1 , y - f , z).color(c2.getRed(), c2.getGreen(), c2.getBlue(), c2.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x + f + 1 + width, y - f , z).color(c2.getRed(), c2.getGreen(), c2.getBlue(), c2.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x + f + 1 + width, y - f - 1 , z).color(c2.getRed(), c2.getGreen(), c2.getBlue(), c2.getAlpha()).endVertex();
|
|
||||||
//inner left - excludes corners
|
|
||||||
b.vertex(model, x - f - 1 , y - f , z).color(c2.getRed(), c2.getGreen(), c2.getBlue(), c2.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x - f - 1 , y + f + height, z).color(c3.getRed(), c3.getGreen(), c3.getBlue(), c3.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x - f , y + f + height, z).color(c3.getRed(), c3.getGreen(), c3.getBlue(), c3.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x - f , y - f , z).color(c2.getRed(), c2.getGreen(), c2.getBlue(), c2.getAlpha()).endVertex();
|
|
||||||
//inner bottom - includes corners
|
|
||||||
b.vertex(model, x - f - 1 , y + f + height, z).color(c3.getRed(), c3.getGreen(), c3.getBlue(), c3.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x - f - 1 , y + f + 1 + height, z).color(c3.getRed(), c3.getGreen(), c3.getBlue(), c3.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x + f + 1 + width, y + f + 1 + height, z).color(c3.getRed(), c3.getGreen(), c3.getBlue(), c3.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x + f + 1 + width, y + f + height, z).color(c3.getRed(), c3.getGreen(), c3.getBlue(), c3.getAlpha()).endVertex();
|
|
||||||
//inner right - excludes corners
|
|
||||||
b.vertex(model, x + f + width, y - f , z).color(c2.getRed(), c2.getGreen(), c2.getBlue(), c2.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x + f + width, y + f + height, z).color(c3.getRed(), c3.getGreen(), c3.getBlue(), c3.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x + f + 1 + width, y + f + height, z).color(c3.getRed(), c3.getGreen(), c3.getBlue(), c3.getAlpha()).endVertex();
|
|
||||||
b.vertex(model, x + f + 1 + width, y - f , z).color(c2.getRed(), c2.getGreen(), c2.getBlue(), c2.getAlpha()).endVertex();
|
|
||||||
|
|
||||||
tessellator.end();
|
|
||||||
|
|
||||||
RenderSystem.disableBlend();
|
|
||||||
// RenderSystem.enableTexture();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
|
|
||||||
public class CombinedStencilElement extends StencilElement {
|
|
||||||
|
|
||||||
private StencilElement element1;
|
|
||||||
private StencilElement element2;
|
|
||||||
private ElementMode mode;
|
|
||||||
|
|
||||||
private CombinedStencilElement() {}
|
|
||||||
|
|
||||||
public static CombinedStencilElement of(@Nonnull StencilElement element1, @Nonnull StencilElement element2) {
|
|
||||||
return of(element1, element2, ElementMode.FIRST);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CombinedStencilElement of(@Nonnull StencilElement element1, @Nonnull StencilElement element2, ElementMode mode) {
|
|
||||||
CombinedStencilElement e = new CombinedStencilElement();
|
|
||||||
e.element1 = element1;
|
|
||||||
e.element2 = element2;
|
|
||||||
e.mode = mode;
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends CombinedStencilElement> T withFirst(StencilElement element) {
|
|
||||||
this.element1 = element;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends CombinedStencilElement> T withSecond(StencilElement element) {
|
|
||||||
this.element2 = element;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends CombinedStencilElement> T withMode(ElementMode mode) {
|
|
||||||
this.mode = mode;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void renderStencil(GuiGraphics graphics) {
|
|
||||||
PoseStack ms = graphics.pose();
|
|
||||||
ms.pushPose();
|
|
||||||
element1.transform(ms);
|
|
||||||
element1.withBounds(width, height);
|
|
||||||
element1.renderStencil(graphics);
|
|
||||||
ms.popPose();
|
|
||||||
ms.pushPose();
|
|
||||||
element2.transform(ms);
|
|
||||||
element2.withBounds(width, height);
|
|
||||||
element2.renderStencil(graphics);
|
|
||||||
ms.popPose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void renderElement(GuiGraphics graphics) {
|
|
||||||
if (mode.rendersFirst())
|
|
||||||
element1.<StencilElement>withBounds(width, height).renderElement(graphics);
|
|
||||||
|
|
||||||
if (mode.rendersSecond())
|
|
||||||
element2.<StencilElement>withBounds(width, height).renderElement(graphics);
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ElementMode {
|
|
||||||
FIRST, SECOND, BOTH;
|
|
||||||
|
|
||||||
boolean rendersFirst() {
|
|
||||||
return this == FIRST || this == BOTH;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean rendersSecond() {
|
|
||||||
return this == SECOND || this == BOTH;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
|
||||||
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.UIRenderHelper;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
|
|
||||||
public class DelegatedStencilElement extends StencilElement {
|
|
||||||
|
|
||||||
protected static final ElementRenderer EMPTY_RENDERER = (graphics, width, height, alpha) -> {};
|
|
||||||
protected static final ElementRenderer DEFAULT_ELEMENT = (graphics, width, height, alpha) -> UIRenderHelper.angledGradient(graphics, 0, -3, 5, height+4, width+6, new Color(0xff_10dd10).scaleAlpha(alpha), new Color(0xff_1010dd).scaleAlpha(alpha));
|
|
||||||
|
|
||||||
protected ElementRenderer stencil;
|
|
||||||
protected ElementRenderer element;
|
|
||||||
|
|
||||||
public DelegatedStencilElement() {
|
|
||||||
stencil = EMPTY_RENDERER;
|
|
||||||
element = DEFAULT_ELEMENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DelegatedStencilElement(ElementRenderer stencil, ElementRenderer element) {
|
|
||||||
this.stencil = stencil;
|
|
||||||
this.element = element;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends DelegatedStencilElement> T withStencilRenderer(ElementRenderer renderer) {
|
|
||||||
stencil = renderer;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends DelegatedStencilElement> T withElementRenderer(ElementRenderer renderer) {
|
|
||||||
element = renderer;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void renderStencil(GuiGraphics graphics) {
|
|
||||||
stencil.render(graphics, width, height, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void renderElement(GuiGraphics graphics) {
|
|
||||||
element.render(graphics, width, height, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface ElementRenderer {
|
|
||||||
void render(GuiGraphics graphics, int width, int height, float alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,304 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.jozufozu.flywheel.core.PartialModel;
|
|
||||||
import com.jozufozu.flywheel.core.model.ModelUtil;
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager.DestFactor;
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager.SourceFactor;
|
|
||||||
import com.mojang.blaze3d.platform.Lighting;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import com.mojang.math.Axis;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.ILightingSettings;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.UIRenderHelper;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.VecHelper;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.client.renderer.LightTexture;
|
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
|
||||||
import net.minecraft.client.renderer.RenderType;
|
|
||||||
import net.minecraft.client.renderer.Sheets;
|
|
||||||
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
|
|
||||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
|
||||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
|
||||||
import net.minecraft.client.resources.model.BakedModel;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.util.RandomSource;
|
|
||||||
import net.minecraft.world.inventory.InventoryMenu;
|
|
||||||
import net.minecraft.world.item.ItemDisplayContext;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.ItemLike;
|
|
||||||
import net.minecraft.world.level.block.BaseFireBlock;
|
|
||||||
import net.minecraft.world.level.block.Blocks;
|
|
||||||
import net.minecraft.world.level.block.LiquidBlock;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.level.material.Fluid;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
import net.minecraftforge.client.RenderTypeHelper;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
|
|
||||||
public class GuiGameElement {
|
|
||||||
|
|
||||||
public static GuiRenderBuilder of(ItemStack stack) {
|
|
||||||
return new GuiItemRenderBuilder(stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GuiRenderBuilder of(ItemLike itemProvider) {
|
|
||||||
return new GuiItemRenderBuilder(itemProvider);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GuiRenderBuilder of(BlockState state) {
|
|
||||||
return new GuiBlockStateRenderBuilder(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GuiRenderBuilder of(PartialModel partial) {
|
|
||||||
return new GuiBlockPartialRenderBuilder(partial);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GuiRenderBuilder of(Fluid fluid) {
|
|
||||||
return new GuiBlockStateRenderBuilder(fluid.defaultFluidState()
|
|
||||||
.createLegacyBlock()
|
|
||||||
.setValue(LiquidBlock.LEVEL, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static abstract class GuiRenderBuilder extends RenderElement {
|
|
||||||
protected double xLocal, yLocal, zLocal;
|
|
||||||
protected double xRot, yRot, zRot;
|
|
||||||
protected double scale = 1;
|
|
||||||
protected int color = 0xFFFFFF;
|
|
||||||
protected Vec3 rotationOffset = Vec3.ZERO;
|
|
||||||
protected ILightingSettings customLighting = null;
|
|
||||||
|
|
||||||
public GuiRenderBuilder atLocal(double x, double y, double z) {
|
|
||||||
this.xLocal = x;
|
|
||||||
this.yLocal = y;
|
|
||||||
this.zLocal = z;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuiRenderBuilder rotate(double xRot, double yRot, double zRot) {
|
|
||||||
this.xRot = xRot;
|
|
||||||
this.yRot = yRot;
|
|
||||||
this.zRot = zRot;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuiRenderBuilder rotateBlock(double xRot, double yRot, double zRot) {
|
|
||||||
return this.rotate(xRot, yRot, zRot)
|
|
||||||
.withRotationOffset(VecHelper.getCenterOf(BlockPos.ZERO));
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuiRenderBuilder scale(double scale) {
|
|
||||||
this.scale = scale;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuiRenderBuilder color(int color) {
|
|
||||||
this.color = color;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuiRenderBuilder withRotationOffset(Vec3 offset) {
|
|
||||||
this.rotationOffset = offset;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuiRenderBuilder lighting(ILightingSettings lighting) {
|
|
||||||
customLighting = lighting;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void prepareMatrix(PoseStack matrixStack) {
|
|
||||||
matrixStack.pushPose();
|
|
||||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
RenderSystem.enableDepthTest();
|
|
||||||
RenderSystem.enableBlend();
|
|
||||||
RenderSystem.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
|
|
||||||
prepareLighting(matrixStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void transformMatrix(PoseStack matrixStack) {
|
|
||||||
matrixStack.translate(x, y, z);
|
|
||||||
matrixStack.scale((float) scale, (float) scale, (float) scale);
|
|
||||||
matrixStack.translate(xLocal, yLocal, zLocal);
|
|
||||||
UIRenderHelper.flipForGuiRender(matrixStack);
|
|
||||||
matrixStack.translate(rotationOffset.x, rotationOffset.y, rotationOffset.z);
|
|
||||||
matrixStack.mulPose(Axis.ZP.rotationDegrees((float) zRot));
|
|
||||||
matrixStack.mulPose(Axis.XP.rotationDegrees((float) xRot));
|
|
||||||
matrixStack.mulPose(Axis.YP.rotationDegrees((float) yRot));
|
|
||||||
matrixStack.translate(-rotationOffset.x, -rotationOffset.y, -rotationOffset.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void cleanUpMatrix(PoseStack matrixStack) {
|
|
||||||
matrixStack.popPose();
|
|
||||||
cleanUpLighting(matrixStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void prepareLighting(PoseStack matrixStack) {
|
|
||||||
if (customLighting != null) {
|
|
||||||
customLighting.applyLighting();
|
|
||||||
} else {
|
|
||||||
Lighting.setupFor3DItems();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void cleanUpLighting(PoseStack matrixStack) {
|
|
||||||
if (customLighting != null) {
|
|
||||||
Lighting.setupFor3DItems();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class GuiBlockModelRenderBuilder extends GuiRenderBuilder {
|
|
||||||
|
|
||||||
protected BakedModel blockModel;
|
|
||||||
protected BlockState blockState;
|
|
||||||
|
|
||||||
public GuiBlockModelRenderBuilder(BakedModel blockmodel, @Nullable BlockState blockState) {
|
|
||||||
this.blockState = blockState == null ? Blocks.AIR.defaultBlockState() : blockState;
|
|
||||||
this.blockModel = blockmodel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(GuiGraphics graphics) {
|
|
||||||
PoseStack matrixStack = graphics.pose();
|
|
||||||
prepareMatrix(matrixStack);
|
|
||||||
|
|
||||||
Minecraft mc = Minecraft.getInstance();
|
|
||||||
BlockRenderDispatcher blockRenderer = mc.getBlockRenderer();
|
|
||||||
MultiBufferSource.BufferSource buffer = mc.renderBuffers()
|
|
||||||
.bufferSource();
|
|
||||||
|
|
||||||
transformMatrix(matrixStack);
|
|
||||||
|
|
||||||
RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS);
|
|
||||||
renderModel(blockRenderer, buffer, matrixStack);
|
|
||||||
|
|
||||||
cleanUpMatrix(matrixStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void renderModel(BlockRenderDispatcher blockRenderer, MultiBufferSource.BufferSource buffer,
|
|
||||||
PoseStack ms) {
|
|
||||||
if (blockState.getBlock() == Blocks.AIR) {
|
|
||||||
RenderType renderType = Sheets.translucentCullBlockSheet();
|
|
||||||
blockRenderer.getModelRenderer()
|
|
||||||
.renderModel(ms.last(), buffer.getBuffer(renderType), blockState, blockModel, 1, 1, 1,
|
|
||||||
LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, ModelUtil.VIRTUAL_DATA, null);
|
|
||||||
} else {
|
|
||||||
int color = Minecraft.getInstance()
|
|
||||||
.getBlockColors()
|
|
||||||
.getColor(blockState, null, null, 0);
|
|
||||||
Color rgb = new Color(color == -1 ? this.color : color);
|
|
||||||
|
|
||||||
for (RenderType chunkType : blockModel.getRenderTypes(blockState, RandomSource.create(42L), ModelUtil.VIRTUAL_DATA)) {
|
|
||||||
RenderType renderType = RenderTypeHelper.getEntityRenderType(chunkType, true);
|
|
||||||
blockRenderer.getModelRenderer()
|
|
||||||
.renderModel(ms.last(), buffer.getBuffer(renderType), blockState, blockModel,
|
|
||||||
rgb.getRedAsFloat(), rgb.getGreenAsFloat(), rgb.getBlueAsFloat(),
|
|
||||||
LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, ModelUtil.VIRTUAL_DATA, chunkType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer.endBatch();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class GuiBlockStateRenderBuilder extends GuiBlockModelRenderBuilder {
|
|
||||||
|
|
||||||
public GuiBlockStateRenderBuilder(BlockState blockstate) {
|
|
||||||
super(Minecraft.getInstance()
|
|
||||||
.getBlockRenderer()
|
|
||||||
.getBlockModel(blockstate), blockstate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void renderModel(BlockRenderDispatcher blockRenderer, MultiBufferSource.BufferSource buffer,
|
|
||||||
PoseStack ms) {
|
|
||||||
if (blockState.getBlock() instanceof BaseFireBlock) {
|
|
||||||
Lighting.setupForFlatItems();
|
|
||||||
super.renderModel(blockRenderer, buffer, ms);
|
|
||||||
Lighting.setupFor3DItems();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
super.renderModel(blockRenderer, buffer, ms);
|
|
||||||
|
|
||||||
if (blockState.getFluidState()
|
|
||||||
.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// FluidRenderer.renderFluidBox(new FluidStack(blockState.getFluidState()
|
|
||||||
// .getType(), 1000), 0, 0, 0, 1, 1, 1, buffer, ms, LightTexture.FULL_BRIGHT, false);
|
|
||||||
buffer.endBatch();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class GuiBlockPartialRenderBuilder extends GuiBlockModelRenderBuilder {
|
|
||||||
|
|
||||||
public GuiBlockPartialRenderBuilder(PartialModel partial) {
|
|
||||||
super(partial.get(), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class GuiItemRenderBuilder extends GuiRenderBuilder {
|
|
||||||
|
|
||||||
private final ItemStack stack;
|
|
||||||
|
|
||||||
public GuiItemRenderBuilder(ItemStack stack) {
|
|
||||||
this.stack = stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuiItemRenderBuilder(ItemLike provider) {
|
|
||||||
this(new ItemStack(provider));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(GuiGraphics graphics) {
|
|
||||||
PoseStack matrixStack = graphics.pose();
|
|
||||||
prepareMatrix(matrixStack);
|
|
||||||
transformMatrix(matrixStack);
|
|
||||||
renderItemIntoGUI(matrixStack, stack, customLighting == null);
|
|
||||||
cleanUpMatrix(matrixStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void renderItemIntoGUI(PoseStack matrixStack, ItemStack stack, boolean useDefaultLighting) {
|
|
||||||
ItemRenderer renderer = Minecraft.getInstance().getItemRenderer();
|
|
||||||
BakedModel bakedModel = renderer.getModel(stack, null, null, 0);
|
|
||||||
|
|
||||||
renderer.textureManager.getTexture(InventoryMenu.BLOCK_ATLAS).setFilter(false, false);
|
|
||||||
RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS);
|
|
||||||
RenderSystem.enableBlend();
|
|
||||||
RenderSystem.enableCull();
|
|
||||||
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
|
||||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
matrixStack.pushPose();
|
|
||||||
matrixStack.translate(0, 0, 100.0F);
|
|
||||||
matrixStack.translate(8.0F, -8.0F, 0.0F);
|
|
||||||
matrixStack.scale(16.0F, 16.0F, 16.0F);
|
|
||||||
MultiBufferSource.BufferSource buffer = Minecraft.getInstance().renderBuffers().bufferSource();
|
|
||||||
boolean flatLighting = !bakedModel.usesBlockLight();
|
|
||||||
if (useDefaultLighting && flatLighting) {
|
|
||||||
Lighting.setupForFlatItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
renderer.render(stack, ItemDisplayContext.GUI, false, matrixStack, buffer, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, bakedModel);
|
|
||||||
RenderSystem.disableDepthTest();
|
|
||||||
buffer.endBatch();
|
|
||||||
|
|
||||||
RenderSystem.enableDepthTest();
|
|
||||||
if (useDefaultLighting && flatLighting) {
|
|
||||||
Lighting.setupFor3DItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
matrixStack.popPose();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
|
|
||||||
public abstract class RenderElement implements ScreenElement {
|
|
||||||
|
|
||||||
public static final RenderElement EMPTY = new RenderElement() {
|
|
||||||
@Override
|
|
||||||
public void render(GuiGraphics graphics) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public static RenderElement of(ScreenElement renderable) {
|
|
||||||
return new SimpleRenderElement(renderable);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int width = 16, height = 16;
|
|
||||||
protected float x = 0, y = 0, z = 0;
|
|
||||||
protected float alpha = 1f;
|
|
||||||
|
|
||||||
public <T extends RenderElement> T at(float x, float y) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends RenderElement> T at(float x, float y, float z) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends RenderElement> T withBounds(int width, int height) {
|
|
||||||
this.width = width;
|
|
||||||
this.height = height;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends RenderElement> T withAlpha(float alpha) {
|
|
||||||
this.alpha = alpha;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWidth() {
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHeight() {
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getX() {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getY() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getZ() {
|
|
||||||
return z;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void render(GuiGraphics graphics);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(GuiGraphics graphics, int x, int y) {
|
|
||||||
this.at(x, y).render(graphics);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class SimpleRenderElement extends RenderElement {
|
|
||||||
|
|
||||||
private ScreenElement renderable;
|
|
||||||
|
|
||||||
public SimpleRenderElement(ScreenElement renderable) {
|
|
||||||
this.renderable = renderable;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(GuiGraphics graphics) {
|
|
||||||
renderable.render(graphics, (int) x, (int) y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
|
|
||||||
public interface ScreenElement {
|
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
void render(GuiGraphics graphics, int x, int y);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
|
|
||||||
public abstract class StencilElement extends RenderElement {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(GuiGraphics graphics) {
|
|
||||||
PoseStack ms = graphics.pose();
|
|
||||||
ms.pushPose();
|
|
||||||
transform(ms);
|
|
||||||
prepareStencil(ms);
|
|
||||||
renderStencil(graphics);
|
|
||||||
prepareElement(ms);
|
|
||||||
renderElement(graphics);
|
|
||||||
cleanUp(ms);
|
|
||||||
ms.popPose();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void renderStencil(GuiGraphics graphics);
|
|
||||||
|
|
||||||
protected abstract void renderElement(GuiGraphics graphics);
|
|
||||||
|
|
||||||
protected void transform(PoseStack ms) {
|
|
||||||
ms.translate(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void prepareStencil(PoseStack ms) {
|
|
||||||
GL11.glDisable(GL11.GL_STENCIL_TEST);
|
|
||||||
RenderSystem.stencilMask(~0);
|
|
||||||
RenderSystem.clear(GL11.GL_STENCIL_BUFFER_BIT, Minecraft.ON_OSX);
|
|
||||||
GL11.glEnable(GL11.GL_STENCIL_TEST);
|
|
||||||
RenderSystem.stencilOp(GL11.GL_REPLACE, GL11.GL_KEEP, GL11.GL_KEEP);
|
|
||||||
RenderSystem.stencilMask(0xFF);
|
|
||||||
RenderSystem.stencilFunc(GL11.GL_NEVER, 1, 0xFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void prepareElement(PoseStack ms) {
|
|
||||||
GL11.glEnable(GL11.GL_STENCIL_TEST);
|
|
||||||
RenderSystem.stencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP);
|
|
||||||
RenderSystem.stencilFunc(GL11.GL_EQUAL, 1, 0xFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void cleanUp(PoseStack ms) {
|
|
||||||
GL11.glDisable(GL11.GL_STENCIL_TEST);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.Font;
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
|
||||||
|
|
||||||
public class TextStencilElement extends DelegatedStencilElement {
|
|
||||||
|
|
||||||
protected Font font;
|
|
||||||
protected MutableComponent component;
|
|
||||||
protected boolean centerVertically = false;
|
|
||||||
protected boolean centerHorizontally = false;
|
|
||||||
|
|
||||||
public TextStencilElement(Font font) {
|
|
||||||
super();
|
|
||||||
this.font = font;
|
|
||||||
height = 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TextStencilElement(Font font, String text) {
|
|
||||||
this(font);
|
|
||||||
component = Components.literal(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TextStencilElement(Font font, MutableComponent component) {
|
|
||||||
this(font);
|
|
||||||
this.component = component;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TextStencilElement withText(String text) {
|
|
||||||
component = Components.literal(text);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TextStencilElement withText(MutableComponent component) {
|
|
||||||
this.component = component;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TextStencilElement centered(boolean vertical, boolean horizontal) {
|
|
||||||
this.centerVertically = vertical;
|
|
||||||
this.centerHorizontally = horizontal;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void renderStencil(GuiGraphics graphics) {
|
|
||||||
float x = 0, y = 0;
|
|
||||||
if (centerHorizontally)
|
|
||||||
x = width / 2f - font.width(component) / 2f;
|
|
||||||
|
|
||||||
if (centerVertically)
|
|
||||||
y = height / 2f - (font.lineHeight - 1) / 2f;
|
|
||||||
|
|
||||||
graphics.drawString(font, component, Math.round(x), Math.round(y), 0xff_000000, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void renderElement(GuiGraphics graphics) {
|
|
||||||
float x = 0, y = 0;
|
|
||||||
if (centerHorizontally)
|
|
||||||
x = width / 2f - font.width(component) / 2f;
|
|
||||||
|
|
||||||
if (centerVertically)
|
|
||||||
y = height / 2f - (font.lineHeight - 1) / 2f;
|
|
||||||
|
|
||||||
PoseStack ms = graphics.pose();
|
|
||||||
ms.pushPose();
|
|
||||||
ms.translate(x, y, 0);
|
|
||||||
element.render(graphics, font.width(component), font.lineHeight + 2, alpha);
|
|
||||||
ms.popPose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public MutableComponent getComponent() {
|
|
||||||
return component;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.menu;
|
|
||||||
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.networking.SimplePacketBase;
|
|
||||||
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraftforge.network.NetworkEvent.Context;
|
|
||||||
|
|
||||||
public class ClearMenuPacket extends SimplePacketBase {
|
|
||||||
|
|
||||||
public ClearMenuPacket() {}
|
|
||||||
|
|
||||||
public ClearMenuPacket(FriendlyByteBuf buffer) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(FriendlyByteBuf buffer) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handle(Context context) {
|
|
||||||
context.enqueueWork(() -> {
|
|
||||||
ServerPlayer player = context.getSender();
|
|
||||||
if (player == null)
|
|
||||||
return;
|
|
||||||
if (!(player.containerMenu instanceof IClearableMenu))
|
|
||||||
return;
|
|
||||||
((IClearableMenu) player.containerMenu).clearContents();
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.menu;
|
|
||||||
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.networking.SimplePacketBase;
|
|
||||||
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraftforge.network.NetworkEvent.Context;
|
|
||||||
|
|
||||||
public class GhostItemSubmitPacket extends SimplePacketBase {
|
|
||||||
|
|
||||||
private final ItemStack item;
|
|
||||||
private final int slot;
|
|
||||||
|
|
||||||
public GhostItemSubmitPacket(ItemStack item, int slot) {
|
|
||||||
this.item = item;
|
|
||||||
this.slot = slot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GhostItemSubmitPacket(FriendlyByteBuf buffer) {
|
|
||||||
item = buffer.readItem();
|
|
||||||
slot = buffer.readInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(FriendlyByteBuf buffer) {
|
|
||||||
buffer.writeItem(item);
|
|
||||||
buffer.writeInt(slot);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handle(Context context) {
|
|
||||||
context.enqueueWork(() -> {
|
|
||||||
ServerPlayer player = context.getSender();
|
|
||||||
if (player == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (player.containerMenu instanceof GhostItemMenu<?> menu) {
|
|
||||||
menu.ghostInventory.setStackInSlot(slot, item);
|
|
||||||
menu.getSlot(36 + slot).setChanged();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.menu;
|
|
||||||
|
|
||||||
//import nl.requios.effortlessbuilding.create.AllPackets;
|
|
||||||
|
|
||||||
public interface IClearableMenu {
|
|
||||||
|
|
||||||
default void sendClearPacket() {
|
|
||||||
// AllPackets.getChannel().sendToServer(new ClearMenuPacket());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearContents();
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +1,16 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import net.createmod.catnip.gui.TickableGuiEventListener;
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.TickableGuiEventListener;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.components.AbstractWidget;
|
import net.minecraft.client.gui.components.AbstractWidget;
|
||||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner;
|
|
||||||
import net.minecraft.client.gui.screens.inventory.tooltip.DefaultTooltipPositioner;
|
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
public abstract class AbstractSimiWidget extends AbstractWidget implements TickableGuiEventListener {
|
public abstract class AbstractSimiWidget extends AbstractWidget implements TickableGuiEventListener {
|
||||||
|
|
||||||
@@ -41,10 +37,10 @@ public abstract class AbstractSimiWidget extends AbstractWidget implements Ticka
|
|||||||
super(x, y, width, height, message);
|
super(x, y, width, height, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
protected ClientTooltipPositioner createTooltipPositioner() {
|
// protected ClientTooltipPositioner createTooltipPositioner() {
|
||||||
return DefaultTooltipPositioner.INSTANCE;
|
// return DefaultTooltipPositioner.INSTANCE;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public <T extends AbstractSimiWidget> T withCallback(BiConsumer<Integer, Integer> cb) {
|
public <T extends AbstractSimiWidget> T withCallback(BiConsumer<Integer, Integer> cb) {
|
||||||
this.onClick = cb;
|
this.onClick = cb;
|
||||||
@@ -72,7 +68,7 @@ public abstract class AbstractSimiWidget extends AbstractWidget implements Ticka
|
|||||||
@Override
|
@Override
|
||||||
public void renderWidget(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
public void renderWidget(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||||
beforeRender(graphics, mouseX, mouseY, partialTicks);
|
beforeRender(graphics, mouseX, mouseY, partialTicks);
|
||||||
renderButton(graphics, mouseX, mouseY, partialTicks);
|
doRender(graphics, mouseX, mouseY, partialTicks);
|
||||||
afterRender(graphics, mouseX, mouseY, partialTicks);
|
afterRender(graphics, mouseX, mouseY, partialTicks);
|
||||||
wasHovered = isHoveredOrFocused();
|
wasHovered = isHoveredOrFocused();
|
||||||
}
|
}
|
||||||
@@ -81,7 +77,7 @@ public abstract class AbstractSimiWidget extends AbstractWidget implements Ticka
|
|||||||
graphics.pose().pushPose();
|
graphics.pose().pushPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderButton(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
protected void doRender(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void afterRender(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
protected void afterRender(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||||
|
|||||||
@@ -1,228 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
|
||||||
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.Theme;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.Theme.Key;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.UIRenderHelper;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.BoxElement;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.DelegatedStencilElement;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Couple;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.animation.LerpedFloat;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
|
|
||||||
public class BoxWidget extends ElementWidget {
|
|
||||||
|
|
||||||
public static final Function<BoxWidget, DelegatedStencilElement.ElementRenderer> gradientFactory = (box) -> (ms, w, h, alpha) -> UIRenderHelper.angledGradient(ms, 90, w/2, -2, w + 4, h + 4, box.gradientColor1, box.gradientColor2);
|
|
||||||
|
|
||||||
protected BoxElement box;
|
|
||||||
|
|
||||||
protected Color customBorderTop;
|
|
||||||
protected Color customBorderBot;
|
|
||||||
protected Color customBackground;
|
|
||||||
protected boolean animateColors = true;
|
|
||||||
protected LerpedFloat colorAnimation = LerpedFloat.linear();
|
|
||||||
|
|
||||||
protected Color gradientColor1, gradientColor2;
|
|
||||||
private Color previousColor1, previousColor2;
|
|
||||||
private Color colorTarget1 = Theme.c(getIdleTheme(), true).copy();
|
|
||||||
private Color colorTarget2 = Theme.c(getIdleTheme(), false).copy();
|
|
||||||
|
|
||||||
public BoxWidget() {
|
|
||||||
this(0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BoxWidget(int x, int y) {
|
|
||||||
this(x, y, 16, 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BoxWidget(int x, int y, int width, int height) {
|
|
||||||
super(x, y, width, height);
|
|
||||||
box = new BoxElement()
|
|
||||||
.at(x, y)
|
|
||||||
.withBounds(width, height);
|
|
||||||
gradientColor1 = colorTarget1;
|
|
||||||
gradientColor2 = colorTarget2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends BoxWidget> T withBounds(int width, int height) {
|
|
||||||
this.width = width;
|
|
||||||
this.height = height;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends BoxWidget> T withBorderColors(Couple<Color> colors) {
|
|
||||||
this.customBorderTop = colors.getFirst();
|
|
||||||
this.customBorderBot = colors.getSecond();
|
|
||||||
updateColorsFromState();
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends BoxWidget> T withBorderColors(Color top, Color bot) {
|
|
||||||
this.customBorderTop = top;
|
|
||||||
this.customBorderBot = bot;
|
|
||||||
updateColorsFromState();
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends BoxWidget> T withCustomBackground(Color color) {
|
|
||||||
this.customBackground = color;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends BoxWidget> T animateColors(boolean b) {
|
|
||||||
this.animateColors = b;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tick() {
|
|
||||||
super.tick();
|
|
||||||
colorAnimation.tickChaser();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(double x, double y) {
|
|
||||||
super.onClick(x, y);
|
|
||||||
|
|
||||||
gradientColor1 = Theme.c(getClickTheme(), true);
|
|
||||||
gradientColor2 = Theme.c(getClickTheme(), false);
|
|
||||||
startGradientAnimation(getColorForState(true), getColorForState(false), true, 0.15);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void beforeRender(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
|
||||||
super.beforeRender(graphics, mouseX, mouseY, partialTicks);
|
|
||||||
|
|
||||||
if (isHovered != wasHovered) {
|
|
||||||
startGradientAnimation(
|
|
||||||
getColorForState(true),
|
|
||||||
getColorForState(false),
|
|
||||||
isHovered
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (colorAnimation.settled()) {
|
|
||||||
gradientColor1 = colorTarget1;
|
|
||||||
gradientColor2 = colorTarget2;
|
|
||||||
} else {
|
|
||||||
float animationValue = 1 - Math.abs(colorAnimation.getValue(partialTicks));
|
|
||||||
gradientColor1 = Color.mixColors(previousColor1, colorTarget1, animationValue);
|
|
||||||
gradientColor2 = Color.mixColors(previousColor2, colorTarget2, animationValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderButton(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
|
||||||
float fadeValue = fade.getValue(partialTicks);
|
|
||||||
if (fadeValue < .1f)
|
|
||||||
return;
|
|
||||||
|
|
||||||
box.withAlpha(fadeValue);
|
|
||||||
box.withBackground(customBackground != null ? customBackground : Theme.c(Theme.Key.PONDER_BACKGROUND_TRANSPARENT))
|
|
||||||
.gradientBorder(gradientColor1, gradientColor2)
|
|
||||||
.at(getX(), getY(), z)
|
|
||||||
.withBounds(width, height)
|
|
||||||
.render(graphics);
|
|
||||||
|
|
||||||
super.renderButton(graphics, mouseX, mouseY, partialTicks);
|
|
||||||
|
|
||||||
wasHovered = isHovered;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isMouseOver(double mX, double mY) {
|
|
||||||
if (!active || !visible)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
float padX = 2 + paddingX;
|
|
||||||
float padY = 2 + paddingY;
|
|
||||||
|
|
||||||
return getX() - padX <= mX && getY() - padY <= mY && mX < getX() + padX + width && mY < getY() + padY + height;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean clicked(double pMouseX, double pMouseY) {
|
|
||||||
if (!active || !visible)
|
|
||||||
return false;
|
|
||||||
return isMouseOver(pMouseX, pMouseY);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BoxElement getBox() {
|
|
||||||
return box;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateColorsFromState() {
|
|
||||||
colorTarget1 = getColorForState(true);
|
|
||||||
colorTarget2 = getColorForState(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void animateGradientFromState() {
|
|
||||||
startGradientAnimation(
|
|
||||||
getColorForState(true),
|
|
||||||
getColorForState(false),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startGradientAnimation(Color c1, Color c2, boolean positive, double expSpeed) {
|
|
||||||
if (!animateColors)
|
|
||||||
return;
|
|
||||||
|
|
||||||
colorAnimation.startWithValue(positive ? 1 : -1);
|
|
||||||
colorAnimation.chase(0, expSpeed, LerpedFloat.Chaser.EXP);
|
|
||||||
colorAnimation.tickChaser();
|
|
||||||
|
|
||||||
previousColor1 = gradientColor1;
|
|
||||||
previousColor2 = gradientColor2;
|
|
||||||
|
|
||||||
colorTarget1 = c1;
|
|
||||||
colorTarget2 = c2;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startGradientAnimation(Color c1, Color c2, boolean positive) {
|
|
||||||
startGradientAnimation(c1, c2, positive, 0.6);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Color getColorForState(boolean first) {
|
|
||||||
if (!active)
|
|
||||||
return Theme.p(getDisabledTheme()).get(first);
|
|
||||||
|
|
||||||
if (isHovered) {
|
|
||||||
if (first)
|
|
||||||
return customBorderTop != null ? customBorderTop.darker() : Theme.c(getHoverTheme(), true);
|
|
||||||
else
|
|
||||||
return customBorderBot != null ? customBorderBot.darker() : Theme.c(getHoverTheme(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (first)
|
|
||||||
return customBorderTop != null ? customBorderTop : Theme.c(getIdleTheme(), true);
|
|
||||||
else
|
|
||||||
return customBorderBot != null ? customBorderBot : Theme.c(getIdleTheme(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Key getDisabledTheme() {
|
|
||||||
return Theme.Key.BUTTON_DISABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Key getIdleTheme() {
|
|
||||||
return Theme.Key.BUTTON_IDLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Key getHoverTheme() {
|
|
||||||
return Theme.Key.BUTTON_HOVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Key getClickTheme() {
|
|
||||||
return Theme.Key.BUTTON_CLICK;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,158 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.UnaryOperator;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.RenderElement;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.ScreenElement;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.animation.LerpedFloat;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
|
|
||||||
public class ElementWidget extends AbstractSimiWidget {
|
|
||||||
|
|
||||||
protected RenderElement element = RenderElement.EMPTY;
|
|
||||||
|
|
||||||
protected boolean usesFade = false;
|
|
||||||
protected int fadeModX;
|
|
||||||
protected int fadeModY;
|
|
||||||
protected LerpedFloat fade = LerpedFloat.linear().startWithValue(1);
|
|
||||||
|
|
||||||
protected boolean rescaleElement = false;
|
|
||||||
protected float rescaleSizeX;
|
|
||||||
protected float rescaleSizeY;
|
|
||||||
|
|
||||||
protected float paddingX = 0;
|
|
||||||
protected float paddingY = 0;
|
|
||||||
|
|
||||||
public ElementWidget(int x, int y) {
|
|
||||||
super(x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElementWidget(int x, int y, int width, int height) {
|
|
||||||
super(x, y, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends ElementWidget> T showingElement(RenderElement element) {
|
|
||||||
this.element = element;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends ElementWidget> T showing(ScreenElement renderable) {
|
|
||||||
return this.showingElement(RenderElement.of(renderable));
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends ElementWidget> T modifyElement(Consumer<RenderElement> consumer) {
|
|
||||||
if (element != null)
|
|
||||||
consumer.accept(element);
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends ElementWidget> T mapElement(UnaryOperator<RenderElement> function) {
|
|
||||||
if (element != null)
|
|
||||||
element = function.apply(element);
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends ElementWidget> T withPadding(float paddingX, float paddingY) {
|
|
||||||
this.paddingX = paddingX;
|
|
||||||
this.paddingY = paddingY;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends ElementWidget> T enableFade(int fadeModifierX, int fadeModifierY) {
|
|
||||||
this.fade.startWithValue(0);
|
|
||||||
this.usesFade = true;
|
|
||||||
this.fadeModX = fadeModifierX;
|
|
||||||
this.fadeModY = fadeModifierY;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends ElementWidget> T disableFade() {
|
|
||||||
this.fade.startWithValue(1);
|
|
||||||
this.usesFade = false;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LerpedFloat fade() {
|
|
||||||
return fade;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends ElementWidget> T fade(float target) {
|
|
||||||
fade.chase(target, 0.1, LerpedFloat.Chaser.EXP);
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rescaling and its effects aren't properly tested with most elements.
|
|
||||||
* Thought it should work fine when using a TextStencilElement.
|
|
||||||
* Check BaseConfigScreen's title for such an example.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public <T extends ElementWidget> T rescaleElement(float rescaleSizeX, float rescaleSizeY) {
|
|
||||||
this.rescaleElement = true;
|
|
||||||
this.rescaleSizeX = rescaleSizeX;
|
|
||||||
this.rescaleSizeY = rescaleSizeY;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends ElementWidget> T disableRescale() {
|
|
||||||
this.rescaleElement = false;
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tick() {
|
|
||||||
super.tick();
|
|
||||||
fade.tickChaser();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void beforeRender(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
|
||||||
super.beforeRender(graphics, mouseX, mouseY, partialTicks);
|
|
||||||
isHovered = isMouseOver(mouseX, mouseY);
|
|
||||||
|
|
||||||
float fadeValue = fade.getValue(partialTicks);
|
|
||||||
element.withAlpha(fadeValue);
|
|
||||||
if (fadeValue < 1) {
|
|
||||||
graphics.pose().translate((1 - fadeValue) * fadeModX, (1 - fadeValue) * fadeModY, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderButton(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
|
||||||
PoseStack ms = graphics.pose();
|
|
||||||
ms.pushPose();
|
|
||||||
ms.translate(getX() + paddingX, getY() + paddingY, z);
|
|
||||||
float innerWidth = width - 2 * paddingX;
|
|
||||||
float innerHeight = height - 2 * paddingY;
|
|
||||||
float eX = element.getX(), eY = element.getY();
|
|
||||||
if (rescaleElement) {
|
|
||||||
float xScale = innerWidth / rescaleSizeX;
|
|
||||||
float yScale = innerHeight / rescaleSizeY;
|
|
||||||
ms.scale(xScale, yScale, 1);
|
|
||||||
element.at(eX / xScale, eY / yScale);
|
|
||||||
innerWidth /= xScale;
|
|
||||||
innerHeight /= yScale;
|
|
||||||
}
|
|
||||||
element.withBounds((int) innerWidth, (int) innerHeight).render(graphics);
|
|
||||||
ms.popPose();
|
|
||||||
if (rescaleElement) {
|
|
||||||
element.at(eX, eY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public RenderElement getRenderElement() {
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.AllGuiTextures;
|
import net.createmod.catnip.gui.element.ScreenElement;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.ScreenElement;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.gui.AllGuiTextures;
|
||||||
|
|
||||||
public class IconButton extends AbstractSimiWidget {
|
public class IconButton extends AbstractSimiWidget {
|
||||||
|
|
||||||
@@ -21,7 +20,7 @@ public class IconButton extends AbstractSimiWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderButton(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
public void doRender(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
isHovered = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + width && mouseY < getY() + height;
|
isHovered = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + width && mouseY < getY() + height;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.AllGuiTextures;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.gui.AllGuiTextures;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class Indicator extends AbstractSimiWidget {
|
public class Indicator extends AbstractSimiWidget {
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ public class Indicator extends AbstractSimiWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks ) {
|
public void renderWidget(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||||
if (!visible)
|
if (!visible)
|
||||||
return;
|
return;
|
||||||
AllGuiTextures toDraw;
|
AllGuiTextures toDraw;
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Font;
|
import net.minecraft.client.gui.Font;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class Label extends AbstractSimiWidget {
|
public class Label extends AbstractSimiWidget {
|
||||||
|
|
||||||
@@ -71,7 +70,7 @@ public class Label extends AbstractSimiWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderButton(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
protected void doRender(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||||
if (text == null || text.getString().isEmpty())
|
if (text == null || text.getString().isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,14 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import net.minecraft.ChatFormatting;
|
||||||
import java.util.function.Function;
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
import nl.requios.effortlessbuilding.create.AllKeys;
|
import nl.requios.effortlessbuilding.create.AllKeys;
|
||||||
//import nl.requios.effortlessbuilding.create.AllSoundEvents;
|
|
||||||
//import nl.requios.effortlessbuilding.create.foundation.blockEntity.behaviour.scrollValue.ScrollValueBehaviour.StepContext;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Lang;
|
import nl.requios.effortlessbuilding.create.foundation.utility.Lang;
|
||||||
|
|
||||||
import net.minecraft.ChatFormatting;
|
import java.util.function.Consumer;
|
||||||
import net.minecraft.client.Minecraft;
|
import java.util.function.Function;
|
||||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
|
||||||
|
|
||||||
public class ScrollInput extends AbstractSimiWidget {
|
public class ScrollInput extends AbstractSimiWidget {
|
||||||
|
|
||||||
@@ -122,19 +117,21 @@ public class ScrollInput extends AbstractSimiWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseScrolled(double mouseX, double mouseY, double delta) {
|
public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) {
|
||||||
|
if (!this.visible || !this.isHovered) return false; //Added
|
||||||
|
|
||||||
if (inverted)
|
if (inverted)
|
||||||
delta *= -1;
|
scrollX *= -1;
|
||||||
|
|
||||||
StepContext context = new StepContext();
|
StepContext context = new StepContext();
|
||||||
context.control = AllKeys.ctrlDown();
|
context.control = AllKeys.ctrlDown();
|
||||||
context.shift = AllKeys.shiftDown();
|
context.shift = AllKeys.shiftDown();
|
||||||
context.currentValue = state;
|
context.currentValue = state;
|
||||||
context.forward = delta > 0;
|
context.forward = scrollX > 0;
|
||||||
|
|
||||||
int priorState = state;
|
int priorState = state;
|
||||||
boolean shifted = AllKeys.shiftDown();
|
boolean shifted = AllKeys.shiftDown();
|
||||||
int step = (int) Math.signum(delta) * this.step.apply(context);
|
int step = (int) Math.signum(scrollX) * this.step.apply(context);
|
||||||
|
|
||||||
state += step;
|
state += step;
|
||||||
if (shifted)
|
if (shifted)
|
||||||
@@ -152,7 +149,8 @@ public class ScrollInput extends AbstractSimiWidget {
|
|||||||
onChanged();
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
return priorState != state;
|
// return priorState != state;
|
||||||
|
return true; //Changed
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void clampState() {
|
protected void clampState() {
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Lang;
|
|
||||||
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.Lang;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class SelectionScrollInput extends ScrollInput {
|
public class SelectionScrollInput extends ScrollInput {
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class TooltipArea extends AbstractSimiWidget {
|
public class TooltipArea extends AbstractSimiWidget {
|
||||||
|
|
||||||
public TooltipArea(int x, int y, int width, int height) {
|
public TooltipArea(int x, int y, int width, int height) {
|
||||||
|
|||||||
@@ -1,165 +1,98 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.item;
|
package nl.requios.effortlessbuilding.create.foundation.item;
|
||||||
|
|
||||||
import static net.minecraft.ChatFormatting.DARK_GRAY;
|
import net.minecraft.ChatFormatting;
|
||||||
import static net.minecraft.ChatFormatting.GRAY;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import static net.minecraft.ChatFormatting.WHITE;
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.IdentityHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.item.TooltipHelper.Palette;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Lang;
|
import nl.requios.effortlessbuilding.create.foundation.utility.Lang;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import java.util.ArrayList;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import java.util.Arrays;
|
||||||
import net.minecraft.client.resources.language.I18n;
|
import java.util.List;
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.level.ItemLike;
|
|
||||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
|
||||||
|
|
||||||
public record ItemDescription(ImmutableList<Component> lines, ImmutableList<Component> linesOnShift, ImmutableList<Component> linesOnCtrl) {
|
import static net.minecraft.ChatFormatting.AQUA;
|
||||||
private static final Map<Item, Supplier<String>> CUSTOM_TOOLTIP_KEYS = new IdentityHashMap<>();
|
import static net.minecraft.ChatFormatting.BLUE;
|
||||||
|
import static net.minecraft.ChatFormatting.DARK_GRAY;
|
||||||
|
import static net.minecraft.ChatFormatting.DARK_GREEN;
|
||||||
|
import static net.minecraft.ChatFormatting.DARK_PURPLE;
|
||||||
|
import static net.minecraft.ChatFormatting.DARK_RED;
|
||||||
|
import static net.minecraft.ChatFormatting.GOLD;
|
||||||
|
import static net.minecraft.ChatFormatting.GRAY;
|
||||||
|
import static net.minecraft.ChatFormatting.GREEN;
|
||||||
|
import static net.minecraft.ChatFormatting.LIGHT_PURPLE;
|
||||||
|
import static net.minecraft.ChatFormatting.RED;
|
||||||
|
import static net.minecraft.ChatFormatting.STRIKETHROUGH;
|
||||||
|
import static net.minecraft.ChatFormatting.WHITE;
|
||||||
|
import static net.minecraft.ChatFormatting.YELLOW;
|
||||||
|
import static nl.requios.effortlessbuilding.create.foundation.item.TooltipHelper.cutStringTextComponent;
|
||||||
|
import static nl.requios.effortlessbuilding.create.foundation.item.TooltipHelper.cutTextComponent;
|
||||||
|
|
||||||
@Nullable
|
public class ItemDescription {
|
||||||
public static ItemDescription create(Item item, Palette palette) {
|
|
||||||
return create(getTooltipTranslationKey(item), palette);
|
public static final ItemDescription MISSING = new ItemDescription(null);
|
||||||
|
public static Component trim = Components.literal(" ").withStyle(WHITE, STRIKETHROUGH);
|
||||||
|
|
||||||
|
public enum Palette {
|
||||||
|
|
||||||
|
Blue(BLUE, AQUA),
|
||||||
|
Green(DARK_GREEN, GREEN),
|
||||||
|
Yellow(GOLD, YELLOW),
|
||||||
|
Red(DARK_RED, RED),
|
||||||
|
Purple(DARK_PURPLE, LIGHT_PURPLE),
|
||||||
|
Gray(DARK_GRAY, GRAY),
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
private Palette(ChatFormatting primary, ChatFormatting highlight) {
|
||||||
|
color = primary;
|
||||||
|
hColor = highlight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public ChatFormatting color;
|
||||||
public static ItemDescription create(String translationKey, Palette palette) {
|
public ChatFormatting hColor;
|
||||||
if (!canFillBuilder(translationKey)) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Builder builder = new Builder(palette);
|
private List<Component> lines;
|
||||||
fillBuilder(builder, translationKey);
|
private List<Component> linesOnShift;
|
||||||
return builder.build();
|
private List<Component> linesOnCtrl;
|
||||||
}
|
private Palette palette;
|
||||||
|
|
||||||
public static boolean canFillBuilder(String translationKey) {
|
public ItemDescription(Palette palette) {
|
||||||
return I18n.exists(translationKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void fillBuilder(Builder builder, String translationKey) {
|
|
||||||
// Summary
|
|
||||||
String summaryKey = translationKey + ".summary";
|
|
||||||
if (I18n.exists(summaryKey)) {
|
|
||||||
builder.addSummary(I18n.get(summaryKey));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Behaviours
|
|
||||||
for (int i = 1; i < 100; i++) {
|
|
||||||
String conditionKey = translationKey + ".condition" + i;
|
|
||||||
String behaviourKey = translationKey + ".behaviour" + i;
|
|
||||||
if (!I18n.exists(conditionKey))
|
|
||||||
break;
|
|
||||||
builder.addBehaviour(I18n.get(conditionKey), I18n.get(behaviourKey));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actions
|
|
||||||
for (int i = 1; i < 100; i++) {
|
|
||||||
String controlKey = translationKey + ".control" + i;
|
|
||||||
String actionKey = translationKey + ".action" + i;
|
|
||||||
if (!I18n.exists(controlKey))
|
|
||||||
break;
|
|
||||||
builder.addAction(I18n.get(controlKey), I18n.get(actionKey));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void useKey(Item item, Supplier<String> supplier) {
|
|
||||||
CUSTOM_TOOLTIP_KEYS.put(item, supplier);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void useKey(ItemLike item, String string) {
|
|
||||||
useKey(item.asItem(), () -> string);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void referKey(ItemLike item, Supplier<? extends ItemLike> otherItem) {
|
|
||||||
useKey(item.asItem(), () -> otherItem.get()
|
|
||||||
.asItem()
|
|
||||||
.getDescriptionId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getTooltipTranslationKey(Item item) {
|
|
||||||
if (CUSTOM_TOOLTIP_KEYS.containsKey(item)) {
|
|
||||||
return CUSTOM_TOOLTIP_KEYS.get(item).get() + ".tooltip";
|
|
||||||
}
|
|
||||||
return item.getDescriptionId() + ".tooltip";
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImmutableList<Component> getCurrentLines() {
|
|
||||||
if (Screen.hasShiftDown()) {
|
|
||||||
return linesOnShift;
|
|
||||||
} else if (Screen.hasControlDown()) {
|
|
||||||
return linesOnCtrl;
|
|
||||||
} else {
|
|
||||||
return lines;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder {
|
|
||||||
protected final Palette palette;
|
|
||||||
protected final List<String> summary = new ArrayList<>();
|
|
||||||
protected final List<Pair<String, String>> behaviours = new ArrayList<>();
|
|
||||||
protected final List<Pair<String, String>> actions = new ArrayList<>();
|
|
||||||
|
|
||||||
public Builder(Palette palette) {
|
|
||||||
this.palette = palette;
|
this.palette = palette;
|
||||||
|
lines = new ArrayList<>();
|
||||||
|
linesOnShift = new ArrayList<>();
|
||||||
|
linesOnCtrl = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder addSummary(String summaryLine) {
|
public ItemDescription withSummary(Component summary) {
|
||||||
summary.add(summaryLine);
|
addStrings(linesOnShift, cutTextComponent(summary, palette.color, palette.hColor));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder addBehaviour(String condition, String behaviour) {
|
public static String makeProgressBar(int length, int filledLength) {
|
||||||
behaviours.add(Pair.of(condition, behaviour));
|
String bar = " ";
|
||||||
|
int emptySpaces = length - filledLength;
|
||||||
|
for (int i = 0; i < filledLength; i++)
|
||||||
|
bar += "\u2588";
|
||||||
|
for (int i = 0; i < emptySpaces; i++)
|
||||||
|
bar += "\u2592";
|
||||||
|
return bar + " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemDescription withBehaviour(String condition, String behaviour) {
|
||||||
|
add(linesOnShift, Components.literal(condition).withStyle(GRAY));
|
||||||
|
addStrings(linesOnShift, cutStringTextComponent(behaviour, palette.color, palette.hColor, 1));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder addAction(String condition, String action) {
|
public ItemDescription withControl(String condition, String action) {
|
||||||
actions.add(Pair.of(condition, action));
|
add(linesOnCtrl, Components.literal(condition).withStyle(GRAY));
|
||||||
|
addStrings(linesOnCtrl, cutStringTextComponent(action, palette.color, palette.hColor, 1));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemDescription build() {
|
public ItemDescription createTabs() {
|
||||||
List<Component> lines = new ArrayList<>();
|
|
||||||
List<Component> linesOnShift = new ArrayList<>();
|
|
||||||
List<Component> linesOnCtrl = new ArrayList<>();
|
|
||||||
|
|
||||||
for (String summaryLine : summary) {
|
|
||||||
linesOnShift.addAll(TooltipHelper.cutStringTextComponent(summaryLine, palette));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!behaviours.isEmpty()) {
|
|
||||||
linesOnShift.add(Components.immutableEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Pair<String, String> behaviourPair : behaviours) {
|
|
||||||
String condition = behaviourPair.getLeft();
|
|
||||||
String behaviour = behaviourPair.getRight();
|
|
||||||
linesOnShift.add(Components.literal(condition).withStyle(GRAY));
|
|
||||||
linesOnShift.addAll(TooltipHelper.cutStringTextComponent(behaviour, palette.primary(), palette.highlight(), 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Pair<String, String> actionPair : actions) {
|
|
||||||
String condition = actionPair.getLeft();
|
|
||||||
String action = actionPair.getRight();
|
|
||||||
linesOnCtrl.add(Components.literal(condition).withStyle(GRAY));
|
|
||||||
linesOnCtrl.addAll(TooltipHelper.cutStringTextComponent(action, palette.primary(), palette.highlight(), 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean hasDescription = !linesOnShift.isEmpty();
|
boolean hasDescription = !linesOnShift.isEmpty();
|
||||||
boolean hasControls = !linesOnCtrl.isEmpty();
|
boolean hasControls = !linesOnCtrl.isEmpty();
|
||||||
|
|
||||||
@@ -204,50 +137,59 @@ public record ItemDescription(ImmutableList<Component> lines, ImmutableList<Comp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasDescription) {
|
if (!hasDescription)
|
||||||
linesOnCtrl.clear();
|
linesOnShift = lines;
|
||||||
linesOnShift.addAll(lines);
|
if (!hasControls)
|
||||||
}
|
linesOnCtrl = lines;
|
||||||
if (!hasControls) {
|
|
||||||
linesOnCtrl.clear();
|
return this;
|
||||||
linesOnCtrl.addAll(lines);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ItemDescription(ImmutableList.copyOf(lines), ImmutableList.copyOf(linesOnShift), ImmutableList.copyOf(linesOnCtrl));
|
public static String hightlight(String s, Palette palette) {
|
||||||
}
|
return palette.hColor + s + palette.color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Modifier implements TooltipModifier {
|
public static void addStrings(List<Component> infoList, List<Component> textLines) {
|
||||||
protected final Item item;
|
textLines.forEach(s -> add(infoList, s));
|
||||||
protected final Palette palette;
|
|
||||||
protected String cachedLanguage;
|
|
||||||
protected ItemDescription description;
|
|
||||||
|
|
||||||
public Modifier(Item item, Palette palette) {
|
|
||||||
this.item = item;
|
|
||||||
this.palette = palette;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public static void add(List<Component> infoList, List<Component> textLines) {
|
||||||
public void modify(ItemTooltipEvent context) {
|
infoList.addAll(textLines);
|
||||||
if (checkLocale()) {
|
|
||||||
description = create(item, palette);
|
|
||||||
}
|
|
||||||
if (description == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
context.getToolTip().addAll(1, description.getCurrentLines());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean checkLocale() {
|
public static void add(List<Component> infoList, Component line) {
|
||||||
String currentLanguage = Minecraft.getInstance()
|
infoList.add(line);
|
||||||
.getLanguageManager()
|
|
||||||
.getSelected();
|
|
||||||
if (!currentLanguage.equals(cachedLanguage)) {
|
|
||||||
cachedLanguage = currentLanguage;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
public Palette getPalette() {
|
||||||
|
return palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Component> addInformation(List<Component> tooltip) {
|
||||||
|
if (Screen.hasShiftDown()) {
|
||||||
|
tooltip.addAll(linesOnShift);
|
||||||
|
return tooltip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Screen.hasControlDown()) {
|
||||||
|
tooltip.addAll(linesOnCtrl);
|
||||||
|
return tooltip;
|
||||||
|
}
|
||||||
|
|
||||||
|
tooltip.addAll(lines);
|
||||||
|
return tooltip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Component> getLines() {
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Component> getLinesOnCtrl() {
|
||||||
|
return linesOnCtrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Component> getLinesOnShift() {
|
||||||
|
return linesOnShift;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.item;
|
package nl.requios.effortlessbuilding.create.foundation.item;
|
||||||
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.neoforged.neoforge.items.IItemHandlerModifiable;
|
||||||
|
|
||||||
public class ItemHandlerWrapper implements IItemHandlerModifiable {
|
public class ItemHandlerWrapper implements IItemHandlerModifiable {
|
||||||
|
|
||||||
|
|||||||
@@ -1,36 +1,25 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.item;
|
package nl.requios.effortlessbuilding.create.foundation.item;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import net.createmod.catnip.data.Pair;
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.mutable.MutableInt;
|
|
||||||
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Pair;
|
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.NonNullList;
|
import net.minecraft.core.NonNullList;
|
||||||
|
import net.minecraft.core.component.DataComponents;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.Containers;
|
import net.minecraft.world.Containers;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.crafting.Ingredient;
|
import net.minecraft.world.item.crafting.Ingredient;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.neoforged.neoforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import org.apache.commons.lang3.mutable.MutableInt;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class ItemHelper {
|
public class ItemHelper {
|
||||||
|
|
||||||
public static boolean sameItem(ItemStack stack, ItemStack otherStack) {
|
|
||||||
return !otherStack.isEmpty() && stack.is(otherStack.getItem());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Predicate<ItemStack> sameItemPredicate(ItemStack stack) {
|
|
||||||
return s -> sameItem(stack, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void dropContents(Level world, BlockPos pos, IItemHandler inv) {
|
public static void dropContents(Level world, BlockPos pos, IItemHandler inv) {
|
||||||
for (int slot = 0; slot < inv.getSlots(); slot++)
|
for (int slot = 0; slot < inv.getSlots(); slot++)
|
||||||
Containers.dropItemStack(world, pos.getX(), pos.getY(), pos.getZ(), inv.getStackInSlot(slot));
|
Containers.dropItemStack(world, pos.getX(), pos.getY(), pos.getZ(), inv.getStackInSlot(slot));
|
||||||
@@ -51,9 +40,9 @@ public class ItemHelper {
|
|||||||
|
|
||||||
public static void addToList(ItemStack stack, List<ItemStack> stacks) {
|
public static void addToList(ItemStack stack, List<ItemStack> stacks) {
|
||||||
for (ItemStack s : stacks) {
|
for (ItemStack s : stacks) {
|
||||||
if (!ItemHandlerHelper.canItemStacksStack(stack, s))
|
if (!ItemStack.isSameItemSameComponents(stack, s))
|
||||||
continue;
|
continue;
|
||||||
int transferred = Math.min(s.getMaxStackSize() - s.getCount(), stack.getCount());
|
int transferred = Math.min(s.getOrDefault(DataComponents.MAX_STACK_SIZE, 64) - s.getCount(), stack.getCount());
|
||||||
s.grow(transferred);
|
s.grow(transferred);
|
||||||
stack.shrink(transferred);
|
stack.shrink(transferred);
|
||||||
}
|
}
|
||||||
@@ -210,7 +199,7 @@ public class ItemHelper {
|
|||||||
|
|
||||||
if (!extracting.isEmpty() && !hasEnoughItems && potentialOtherMatch) {
|
if (!extracting.isEmpty() && !hasEnoughItems && potentialOtherMatch) {
|
||||||
ItemStack blackListed = extracting.copy();
|
ItemStack blackListed = extracting.copy();
|
||||||
test = test.and(i -> !ItemHandlerHelper.canItemStacksStack(i, blackListed));
|
test = test.and(i -> !ItemStack.isSameItemSameComponents(i, blackListed));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,7 +254,7 @@ public class ItemHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canItemStackAmountsStack(ItemStack a, ItemStack b) {
|
public static boolean canItemStackAmountsStack(ItemStack a, ItemStack b) {
|
||||||
return ItemHandlerHelper.canItemStacksStack(a, b) && a.getCount() + b.getCount() <= a.getMaxStackSize();
|
return ItemStack.isSameItemSameComponents(a, b) && a.getCount() + b.getCount() <= a.getOrDefault(DataComponents.MAX_STACK_SIZE, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack findFirstMatch(IItemHandler inv, Predicate<ItemStack> test) {
|
public static ItemStack findFirstMatch(IItemHandler inv, Predicate<ItemStack> test) {
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.item;
|
package nl.requios.effortlessbuilding.create.foundation.item;
|
||||||
|
|
||||||
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.tags.TagKey;
|
import net.minecraft.tags.TagKey;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
|
||||||
import net.minecraftforge.registries.tags.ITagManager;
|
|
||||||
|
|
||||||
public class TagDependentIngredientItem extends Item {
|
public class TagDependentIngredientItem extends Item {
|
||||||
|
|
||||||
@@ -15,8 +14,7 @@ public class TagDependentIngredientItem extends Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldHide() {
|
public boolean shouldHide() {
|
||||||
ITagManager<Item> tagManager = ForgeRegistries.ITEMS.tags();
|
return BuiltInRegistries.ITEM.getTag(tag).isEmpty() || BuiltInRegistries.ITEM.getTag(tag).get().size() == 0;
|
||||||
return !tagManager.isKnownTagName(tag) || tagManager.getTag(tag).isEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,37 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.item;
|
package nl.requios.effortlessbuilding.create.foundation.item;
|
||||||
|
|
||||||
import java.text.BreakIterator;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
//import nl.requios.effortlessbuilding.create.content.equipment.goggles.IHaveGoggleInformation;
|
import net.createmod.catnip.data.Couple;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
import net.createmod.catnip.lang.ClientFontHelper;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Couple;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Lang;
|
|
||||||
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Font;
|
import net.minecraft.client.gui.Font;
|
||||||
|
import net.minecraft.client.resources.language.I18n;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
import net.minecraft.network.chat.Style;
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.level.ItemLike;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.item.ItemDescription.Palette;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.Lang;
|
||||||
|
|
||||||
|
import java.text.BreakIterator;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class TooltipHelper {
|
public class TooltipHelper {
|
||||||
|
|
||||||
public static final int MAX_WIDTH_PER_LINE = 200;
|
public static final int maxWidthPerLine = 200;
|
||||||
|
public static final Map<String, ItemDescription> cachedTooltips = new HashMap<>();
|
||||||
|
private static boolean gogglesMode;
|
||||||
|
private static final Map<Item, Supplier<String>> tooltipReferrals = new HashMap<>();
|
||||||
|
|
||||||
public static MutableComponent holdShift(Palette palette, boolean highlighted) {
|
public static MutableComponent holdShift(Palette color, boolean highlighted) {
|
||||||
return Lang.translateDirect("tooltip.holdForDescription", Lang.translateDirect("tooltip.keyShift")
|
return Lang.translateDirect("tooltip.holdForDescription", Lang.translateDirect("tooltip.keyShift")
|
||||||
.withStyle(ChatFormatting.GRAY))
|
.withStyle(ChatFormatting.GRAY))
|
||||||
.withStyle(ChatFormatting.DARK_GRAY);
|
.withStyle(ChatFormatting.DARK_GRAY);
|
||||||
@@ -34,64 +43,87 @@ public class TooltipHelper {
|
|||||||
.append(Lang.translateDirect(hintKey + ".title"))
|
.append(Lang.translateDirect(hintKey + ".title"))
|
||||||
.withStyle(ChatFormatting.GOLD));
|
.withStyle(ChatFormatting.GOLD));
|
||||||
Component hint = Lang.translateDirect(hintKey);
|
Component hint = Lang.translateDirect(hintKey);
|
||||||
List<Component> cutComponent = cutTextComponent(hint, Palette.GRAY_AND_WHITE);
|
List<Component> cutComponent = TooltipHelper.cutTextComponent(hint, ChatFormatting.GRAY, ChatFormatting.WHITE);
|
||||||
for (Component component : cutComponent)
|
for (Component component : cutComponent)
|
||||||
tooltip.add(spacing.plainCopy()
|
tooltip.add(spacing.plainCopy()
|
||||||
.append(component));
|
.append(component));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String makeProgressBar(int length, int filledLength) {
|
public static void referTo(ItemLike item, Supplier<? extends ItemLike> itemWithTooltip) {
|
||||||
String bar = " ";
|
tooltipReferrals.put(item.asItem(), () -> itemWithTooltip.get()
|
||||||
int emptySpaces = length - filledLength;
|
.asItem()
|
||||||
for (int i = 0; i < filledLength; i++)
|
.getDescriptionId());
|
||||||
bar += "\u2588";
|
|
||||||
for (int i = 0; i < emptySpaces; i++)
|
|
||||||
bar += "\u2592";
|
|
||||||
return bar + " ";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Style styleFromColor(ChatFormatting color) {
|
public static void referTo(ItemLike item, String string) {
|
||||||
return Style.EMPTY.applyFormat(color);
|
tooltipReferrals.put(item.asItem(), () -> string);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Style styleFromColor(int hex) {
|
@Deprecated
|
||||||
return Style.EMPTY.withColor(hex);
|
public static List<String> cutString(Component s, ChatFormatting defaultColor, ChatFormatting highlightColor) {
|
||||||
|
return cutString(s.getString(), defaultColor, highlightColor, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Component> cutStringTextComponent(String s, Palette palette) {
|
@Deprecated
|
||||||
return cutTextComponent(Components.literal(s), palette);
|
public static List<String> cutString(String s, ChatFormatting defaultColor, ChatFormatting highlightColor,
|
||||||
}
|
int indent) {
|
||||||
|
// Apply markup
|
||||||
public static List<Component> cutTextComponent(Component c, Palette palette) {
|
String markedUp = s.replaceAll("_([^_]+)_", highlightColor + "$1" + defaultColor);
|
||||||
return cutTextComponent(c, palette.primary(), palette.highlight());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Component> cutStringTextComponent(String s, Style primaryStyle,
|
|
||||||
Style highlightStyle) {
|
|
||||||
return cutTextComponent(Components.literal(s), primaryStyle, highlightStyle);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Component> cutTextComponent(Component c, Style primaryStyle,
|
|
||||||
Style highlightStyle) {
|
|
||||||
return cutTextComponent(c, primaryStyle, highlightStyle, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Component> cutStringTextComponent(String c, Style primaryStyle,
|
|
||||||
Style highlightStyle, int indent) {
|
|
||||||
return cutTextComponent(Components.literal(c), primaryStyle, highlightStyle, indent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Component> cutTextComponent(Component c, Style primaryStyle,
|
|
||||||
Style highlightStyle, int indent) {
|
|
||||||
String s = c.getString();
|
|
||||||
|
|
||||||
// Split words
|
// Split words
|
||||||
List<String> words = new LinkedList<>();
|
List<String> words = new LinkedList<>();
|
||||||
BreakIterator iterator = BreakIterator.getLineInstance(Minecraft.getInstance().getLocale());
|
BreakIterator iterator = BreakIterator.getLineInstance(Minecraft.getInstance().getLocale());
|
||||||
iterator.setText(s);
|
iterator.setText(markedUp);
|
||||||
int start = iterator.first();
|
int start = iterator.first();
|
||||||
for (int end = iterator.next(); end != BreakIterator.DONE; start = end, end = iterator.next()) {
|
for (int end = iterator.next(); end != BreakIterator.DONE; start = end, end = iterator.next()) {
|
||||||
String word = s.substring(start, end);
|
String word = markedUp.substring(start, end);
|
||||||
|
words.add(word);
|
||||||
|
}
|
||||||
|
|
||||||
|
Font font = Minecraft.getInstance().font;
|
||||||
|
List<String> lines = ClientFontHelper.cutString(font, markedUp, maxWidthPerLine);
|
||||||
|
|
||||||
|
// Format
|
||||||
|
String lineStart = Strings.repeat(" ", indent);
|
||||||
|
List<String> formattedLines = new ArrayList<>(lines.size());
|
||||||
|
String format = defaultColor.toString();
|
||||||
|
for (String line : lines) {
|
||||||
|
String formattedLine = format + lineStart + line;
|
||||||
|
formattedLines.add(formattedLine);
|
||||||
|
// format = TextFormatting.getFormatString(formattedLine);
|
||||||
|
}
|
||||||
|
return formattedLines;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Component> cutStringTextComponent(String c, ChatFormatting defaultColor,
|
||||||
|
ChatFormatting highlightColor) {
|
||||||
|
return cutTextComponent(Components.literal(c), defaultColor, highlightColor, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Component> cutTextComponent(Component c, ChatFormatting defaultColor,
|
||||||
|
ChatFormatting highlightColor) {
|
||||||
|
return cutTextComponent(c, defaultColor, highlightColor, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Component> cutStringTextComponent(String c, ChatFormatting defaultColor,
|
||||||
|
ChatFormatting highlightColor, int indent) {
|
||||||
|
return cutTextComponent(Components.literal(c), defaultColor, highlightColor, indent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Component> cutTextComponent(Component c, ChatFormatting defaultColor,
|
||||||
|
ChatFormatting highlightColor, int indent) {
|
||||||
|
String s = c.getString();
|
||||||
|
|
||||||
|
// Apply markup
|
||||||
|
String markedUp = s;// .replaceAll("_([^_]+)_", highlightColor + "$1" + defaultColor);
|
||||||
|
|
||||||
|
// Split words
|
||||||
|
List<String> words = new LinkedList<>();
|
||||||
|
BreakIterator iterator = BreakIterator.getLineInstance(Minecraft.getInstance().getLocale());
|
||||||
|
iterator.setText(markedUp);
|
||||||
|
int start = iterator.first();
|
||||||
|
for (int end = iterator.next(); end != BreakIterator.DONE; start = end, end = iterator.next()) {
|
||||||
|
String word = markedUp.substring(start, end);
|
||||||
words.add(word);
|
words.add(word);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +134,7 @@ public class TooltipHelper {
|
|||||||
int width = 0;
|
int width = 0;
|
||||||
for (String word : words) {
|
for (String word : words) {
|
||||||
int newWidth = font.width(word.replaceAll("_", ""));
|
int newWidth = font.width(word.replaceAll("_", ""));
|
||||||
if (width + newWidth > MAX_WIDTH_PER_LINE) {
|
if (width + newWidth > maxWidthPerLine) {
|
||||||
if (width > 0) {
|
if (width > 0) {
|
||||||
String line = currentLine.toString();
|
String line = currentLine.toString();
|
||||||
lines.add(line);
|
lines.add(line);
|
||||||
@@ -122,16 +154,16 @@ public class TooltipHelper {
|
|||||||
|
|
||||||
// Format
|
// Format
|
||||||
MutableComponent lineStart = Components.literal(Strings.repeat(" ", indent));
|
MutableComponent lineStart = Components.literal(Strings.repeat(" ", indent));
|
||||||
lineStart.withStyle(primaryStyle);
|
lineStart.withStyle(defaultColor);
|
||||||
List<Component> formattedLines = new ArrayList<>(lines.size());
|
List<Component> formattedLines = new ArrayList<>(lines.size());
|
||||||
Couple<Style> styles = Couple.create(highlightStyle, primaryStyle);
|
Couple<ChatFormatting> f = Couple.create(highlightColor, defaultColor);
|
||||||
|
|
||||||
boolean currentlyHighlighted = false;
|
boolean currentlyHighlighted = false;
|
||||||
for (String string : lines) {
|
for (String string : lines) {
|
||||||
MutableComponent currentComponent = lineStart.plainCopy();
|
MutableComponent currentComponent = lineStart.plainCopy();
|
||||||
String[] split = string.split("_");
|
String[] split = string.split("_");
|
||||||
for (String part : split) {
|
for (String part : split) {
|
||||||
currentComponent.append(Components.literal(part).withStyle(styles.get(currentlyHighlighted)));
|
currentComponent.append(Components.literal(part).withStyle(f.get(currentlyHighlighted)));
|
||||||
currentlyHighlighted = !currentlyHighlighted;
|
currentlyHighlighted = !currentlyHighlighted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,25 +174,110 @@ public class TooltipHelper {
|
|||||||
return formattedLines;
|
return formattedLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
public record Palette(Style primary, Style highlight) {
|
// public static List<ITextComponent> cutTextComponentOld(ITextComponent c, TextFormatting defaultColor,
|
||||||
public static final Palette STANDARD_CREATE = new Palette(styleFromColor(0xC9974C), styleFromColor(0xF1DD79));
|
// TextFormatting highlightColor, int indent) {
|
||||||
|
// IFormattableTextComponent lineStart = StringTextComponent.EMPTY.copy();
|
||||||
|
// for (int i = 0; i < indent; i++)
|
||||||
|
// lineStart.append(" ");
|
||||||
|
// lineStart.formatted(defaultColor);
|
||||||
|
//
|
||||||
|
// List<ITextComponent> lines = new ArrayList<>();
|
||||||
|
// String rawText = getUnformattedDeepText(c);
|
||||||
|
// String[] words = rawText.split(" ");
|
||||||
|
// String word;
|
||||||
|
// IFormattableTextComponent currentLine = lineStart.copy();
|
||||||
|
//
|
||||||
|
// boolean firstWord = true;
|
||||||
|
// boolean lastWord;
|
||||||
|
//
|
||||||
|
// // Apply hard wrap
|
||||||
|
// for (int i = 0; i < words.length; i++) {
|
||||||
|
// word = words[i];
|
||||||
|
// lastWord = i == words.length - 1;
|
||||||
|
//
|
||||||
|
// if (!lastWord && !firstWord && getComponentLength(currentLine) + word.length() > maxCharsPerLine) {
|
||||||
|
// lines.add(currentLine);
|
||||||
|
// currentLine = lineStart.copy();
|
||||||
|
// firstWord = true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// currentLine.append(new StringTextComponent((firstWord ? "" : " ") + word.replace("_", ""))
|
||||||
|
// .formatted(word.matches("_([^_]+)_") ? highlightColor : defaultColor));
|
||||||
|
// firstWord = false;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (!firstWord) {
|
||||||
|
// lines.add(currentLine);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return lines;
|
||||||
|
// }
|
||||||
|
|
||||||
public static final Palette BLUE = ofColors(ChatFormatting.BLUE, ChatFormatting.AQUA);
|
private static boolean findTooltip(ItemStack stack) {
|
||||||
public static final Palette GREEN = ofColors(ChatFormatting.DARK_GREEN, ChatFormatting.GREEN);
|
String key = getTooltipTranslationKey(stack);
|
||||||
public static final Palette YELLOW = ofColors(ChatFormatting.GOLD, ChatFormatting.YELLOW);
|
if (I18n.exists(key)) {
|
||||||
public static final Palette RED = ofColors(ChatFormatting.DARK_RED, ChatFormatting.RED);
|
cachedTooltips.put(key, buildToolTip(key, stack));
|
||||||
public static final Palette PURPLE = ofColors(ChatFormatting.DARK_PURPLE, ChatFormatting.LIGHT_PURPLE);
|
return true;
|
||||||
public static final Palette GRAY = ofColors(ChatFormatting.DARK_GRAY, ChatFormatting.GRAY);
|
|
||||||
|
|
||||||
public static final Palette ALL_GRAY = ofColors(ChatFormatting.GRAY, ChatFormatting.GRAY);
|
|
||||||
public static final Palette GRAY_AND_BLUE = ofColors(ChatFormatting.GRAY, ChatFormatting.BLUE);
|
|
||||||
public static final Palette GRAY_AND_WHITE = ofColors(ChatFormatting.GRAY, ChatFormatting.WHITE);
|
|
||||||
public static final Palette GRAY_AND_GOLD = ofColors(ChatFormatting.GRAY, ChatFormatting.GOLD);
|
|
||||||
public static final Palette GRAY_AND_RED = ofColors(ChatFormatting.GRAY, ChatFormatting.RED);
|
|
||||||
|
|
||||||
public static Palette ofColors(ChatFormatting primary, ChatFormatting highlight) {
|
|
||||||
return new Palette(styleFromColor(primary), styleFromColor(highlight));
|
|
||||||
}
|
}
|
||||||
|
cachedTooltips.put(key, ItemDescription.MISSING);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ItemDescription buildToolTip(String translationKey, ItemStack stack) {
|
||||||
|
ItemDescription tooltip = new ItemDescription(Palette.Blue);
|
||||||
|
String summaryKey = translationKey + ".summary";
|
||||||
|
|
||||||
|
// Summary
|
||||||
|
if (I18n.exists(summaryKey))
|
||||||
|
tooltip = tooltip.withSummary(Components.literal(I18n.get(summaryKey)));
|
||||||
|
|
||||||
|
// Requirements
|
||||||
|
// if (stack.getItem() instanceof BlockItem) {
|
||||||
|
// BlockItem item = (BlockItem) stack.getItem();
|
||||||
|
// if (item.getBlock() instanceof IRotate || item.getBlock() instanceof EngineBlock) {
|
||||||
|
// tooltip = tooltip.withKineticStats(item.getBlock());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Behaviours
|
||||||
|
for (int i = 1; i < 100; i++) {
|
||||||
|
String conditionKey = translationKey + ".condition" + i;
|
||||||
|
String behaviourKey = translationKey + ".behaviour" + i;
|
||||||
|
if (!I18n.exists(conditionKey))
|
||||||
|
break;
|
||||||
|
if (i == 1)
|
||||||
|
tooltip.getLinesOnShift()
|
||||||
|
.add(Components.immutableEmpty());
|
||||||
|
tooltip.withBehaviour(I18n.get(conditionKey), I18n.get(behaviourKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Controls
|
||||||
|
for (int i = 1; i < 100; i++) {
|
||||||
|
String controlKey = translationKey + ".control" + i;
|
||||||
|
String actionKey = translationKey + ".action" + i;
|
||||||
|
if (!I18n.exists(controlKey))
|
||||||
|
break;
|
||||||
|
tooltip.withControl(I18n.get(controlKey), I18n.get(actionKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
return tooltip.createTabs();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getTooltipTranslationKey(ItemStack stack) {
|
||||||
|
Item item = stack.getItem();
|
||||||
|
if (tooltipReferrals.containsKey(item))
|
||||||
|
return tooltipReferrals.get(item)
|
||||||
|
.get() + ".tooltip";
|
||||||
|
return item.getDescriptionId(stack) + ".tooltip";
|
||||||
|
}
|
||||||
|
|
||||||
|
// private static int getComponentLength(ITextComponent component) {
|
||||||
|
// AtomicInteger l = new AtomicInteger();
|
||||||
|
// TextProcessing.visitFormatted(component, Style.EMPTY, (s, style, charConsumer) -> {
|
||||||
|
// l.getAndIncrement();
|
||||||
|
// return true;
|
||||||
|
// });
|
||||||
|
// return l.get();
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.item;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.AttachedRegistry;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
|
||||||
|
|
||||||
public interface TooltipModifier {
|
|
||||||
AttachedRegistry<Item, TooltipModifier> REGISTRY = new AttachedRegistry<>(ForgeRegistries.ITEMS);
|
|
||||||
|
|
||||||
TooltipModifier EMPTY = new TooltipModifier() {
|
|
||||||
@Override
|
|
||||||
public void modify(ItemTooltipEvent context) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TooltipModifier andThen(TooltipModifier after) {
|
|
||||||
return after;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void modify(ItemTooltipEvent context);
|
|
||||||
|
|
||||||
default TooltipModifier andThen(TooltipModifier after) {
|
|
||||||
if (after == EMPTY) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
return tooltip -> {
|
|
||||||
modify(tooltip);
|
|
||||||
after.modify(tooltip);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static TooltipModifier mapNull(@Nullable TooltipModifier modifier) {
|
|
||||||
if (modifier == null) {
|
|
||||||
return EMPTY;
|
|
||||||
}
|
|
||||||
return modifier;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.item.render;
|
package nl.requios.effortlessbuilding.create.foundation.item.render;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
|
||||||
import net.minecraft.client.resources.model.BakedModel;
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.world.item.ItemDisplayContext;
|
import net.minecraft.world.item.ItemDisplayContext;
|
||||||
import net.minecraftforge.client.model.BakedModelWrapper;
|
import net.neoforged.neoforge.client.model.BakedModelWrapper;
|
||||||
|
|
||||||
public class CustomRenderedItemModel extends BakedModelWrapper<BakedModel> {
|
public class CustomRenderedItemModel extends BakedModelWrapper<BakedModel> {
|
||||||
|
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.item.render;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
|
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
|
||||||
import net.minecraft.world.item.ItemDisplayContext;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
|
|
||||||
public abstract class CustomRenderedItemModelRenderer extends BlockEntityWithoutLevelRenderer {
|
|
||||||
|
|
||||||
public CustomRenderedItemModelRenderer() {
|
|
||||||
super(null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderByItem(ItemStack stack, ItemDisplayContext transformType, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
|
|
||||||
CustomRenderedItemModel mainModel = (CustomRenderedItemModel) Minecraft.getInstance()
|
|
||||||
.getItemRenderer()
|
|
||||||
.getModel(stack, null, null, 0);
|
|
||||||
PartialItemModelRenderer renderer = PartialItemModelRenderer.of(stack, transformType, ms, buffer, overlay);
|
|
||||||
|
|
||||||
ms.pushPose();
|
|
||||||
ms.translate(0.5F, 0.5F, 0.5F);
|
|
||||||
render(stack, mainModel, renderer, transformType, ms, buffer, light, overlay);
|
|
||||||
ms.popPose();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void render(ItemStack stack, CustomRenderedItemModel model, PartialItemModelRenderer renderer, ItemDisplayContext transformType,
|
|
||||||
PoseStack ms, MultiBufferSource buffer, int light, int overlay);
|
|
||||||
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user