Compare commits
2 Commits
1.20-alter
...
1.19.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2bec37ce0a | ||
|
|
5fce26a796 |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -20,7 +20,7 @@ build
|
|||||||
# other
|
# other
|
||||||
eclipse
|
eclipse
|
||||||
run
|
run
|
||||||
runs
|
logs/*
|
||||||
run-data
|
|
||||||
|
|
||||||
repo
|
# Files from Forge MDK
|
||||||
|
forge*changelog.txt
|
||||||
|
|||||||
193
build.gradle
193
build.gradle
@@ -1,94 +1,102 @@
|
|||||||
plugins {
|
buildscript {
|
||||||
id "idea"
|
repositories {
|
||||||
id "eclipse"
|
maven { url = 'https://maven.minecraftforge.net' }
|
||||||
id "maven-publish"
|
mavenCentral()
|
||||||
id 'net.neoforged.moddev.legacyforge' version '2.0.78'
|
maven { url = 'https://repo.spongepowered.org/repository/maven-public' }
|
||||||
id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.8" // https://github.com/JetBrains/gradle-idea-ext-plugin
|
maven { url = 'https://maven.parchmentmc.org' }
|
||||||
id "net.darkhax.curseforgegradle" version "1.1.26"
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath "net.minecraftforge.gradle:ForgeGradle:${forgegradle_version}"
|
||||||
|
classpath "org.spongepowered:mixingradle:${mixingradle_version}"
|
||||||
|
classpath "org.parchmentmc:librarian:${librarian_version}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "./gradle/java.gradle"
|
plugins {
|
||||||
apply from: "gradle/property_loader.gradle"
|
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 flywheelInWorkspace = findProject(':Flywheel') != null
|
||||||
|
|
||||||
ext.buildNumber = System.getenv('BUILD_NUMBER')
|
ext.buildNumber = System.getenv('BUILD_NUMBER')
|
||||||
|
|
||||||
|
version = mod_version
|
||||||
group = 'nl.requios.effortlessbuilding'
|
group = 'nl.requios.effortlessbuilding'
|
||||||
base {
|
base {
|
||||||
archivesName = "effortlessbuilding-${artifact_minecraft_version}"
|
archivesName = "effortlessbuilding-${artifact_minecraft_version}"
|
||||||
version = mod_version
|
|
||||||
}
|
}
|
||||||
|
|
||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||||
|
|
||||||
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'))
|
||||||
|
|
||||||
legacyForge {
|
minecraft {
|
||||||
version = "$minecraft_version-$forge_version"
|
mappings channel: 'parchment', version: "${parchment_version}-${minecraft_version}"
|
||||||
|
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||||
if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) {
|
|
||||||
accessTransformers.from "src/main/resources/META-INF/accesstransformer.cfg"
|
|
||||||
}
|
|
||||||
|
|
||||||
parchment {
|
|
||||||
minecraftVersion = minecraft_version
|
|
||||||
mappingsVersion = parchment_version
|
|
||||||
}
|
|
||||||
|
|
||||||
runs {
|
runs {
|
||||||
// applies to all the run configs below
|
|
||||||
configureEach {
|
|
||||||
systemProperty 'forge.logging.markers', ''
|
|
||||||
systemProperty 'forge.logging.console.level', 'info'
|
|
||||||
jvmArguments = ["-XX:+IgnoreUnrecognizedVMOptions", "-XX:+AllowEnhancedClassRedefinition"]
|
|
||||||
//jvmArgs("-XX:-OmitStackTraceInFastThrow") // uncomment when you get exceptions with null messages etc
|
|
||||||
//jvmArgs '-XX:+UnlockCommercialFeatures' // uncomment for profiling
|
|
||||||
|
|
||||||
systemProperty 'mixin.debug.export', 'true'
|
|
||||||
systemProperty 'mixin.debug.verbose', 'true'
|
|
||||||
}
|
|
||||||
|
|
||||||
client {
|
client {
|
||||||
client()
|
workingDirectory project.file('run')
|
||||||
|
arg '-mixin.config=flywheel.mixins.json'
|
||||||
|
//jvmArgs '-XX:+UnlockCommercialFeatures' // uncomment for profiling
|
||||||
|
property 'forge.logging.console.level', 'info'
|
||||||
|
|
||||||
gameDirectory = project.file('run')
|
mods {
|
||||||
|
effortlessbuilding {
|
||||||
|
source sourceSets.main
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flywheelInWorkspace) {
|
||||||
|
flywheel {
|
||||||
|
source project(":Flywheel").sourceSets.main
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
server()
|
workingDirectory project.file('run/server')
|
||||||
|
property 'forge.logging.console.level', 'info'
|
||||||
gameDirectory = project.file('run/server')
|
mods {
|
||||||
|
effortlessbuilding {
|
||||||
|
source sourceSets.main
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data {
|
data {
|
||||||
data()
|
workingDirectory project.file('run')
|
||||||
|
property 'forge.logging.markers', 'REGISTRIES,REGISTRYDUMP'
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
gameDirectory = project.file('run')
|
if (flywheelInWorkspace) {
|
||||||
systemProperty 'forge.logging.markers', 'REGISTRIES,REGISTRYDUMP'
|
flywheel {
|
||||||
systemProperty 'forge.logging.console.level', 'debug'
|
source project(":Flywheel").sourceSets.main
|
||||||
programArguments.addAll("--mod", mod_id as String, "--all", "--output", file("src/generated/resources/").getAbsolutePath(), "--existing", file("src/main/resources").getAbsolutePath())
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
gameTestServer {
|
|
||||||
type = "gameTestServer"
|
|
||||||
|
|
||||||
gameDirectory = project.file('run/gametest')
|
|
||||||
// setForceExit false <- FIXME 1.20
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mods {
|
|
||||||
effortlessbuilding {
|
|
||||||
sourceSet sourceSets.main
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Include resources generated by data generators.
|
|
||||||
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven { url = "https://maven.createmod.net" } // Ponder, Flywheel
|
maven {
|
||||||
maven { url = "https://maven.tterrag.com" } // Registrate
|
// location of the maven for Registrate and Flywheel
|
||||||
|
name = 'tterrag maven'
|
||||||
|
url = 'https://maven.tterrag.com'
|
||||||
|
}
|
||||||
|
|
||||||
maven {
|
maven {
|
||||||
url = 'https://www.cursemaven.com'
|
url = 'https://www.cursemaven.com'
|
||||||
@@ -111,26 +119,23 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
jarJar("net.createmod.ponder:Ponder-Forge-${minecraft_version}:${ponder_version}")
|
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||||
|
|
||||||
modCompileOnly("dev.engine-room.flywheel:flywheel-forge-api-${flywheel_minecraft_version}:${flywheel_version}")
|
jarJar("com.jozufozu.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}") {
|
||||||
modRuntimeOnly(jarJar("dev.engine-room.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}") {
|
jarJar.ranged(it, '[0.6.9,0.7)')
|
||||||
version {
|
}
|
||||||
strictly "[1.0,2.0)"
|
|
||||||
prefer flywheel_version
|
|
||||||
}
|
|
||||||
})
|
|
||||||
modRuntimeOnly("dev.engine-room.vanillin:vanillin-forge-${flywheel_minecraft_version}:${vanillin_version}")
|
|
||||||
|
|
||||||
modImplementation("net.createmod.ponder:Ponder-Forge-${minecraft_version}:${ponder_version}")
|
if (flywheelInWorkspace) {
|
||||||
|
implementation project(':Flywheel')
|
||||||
|
} else {
|
||||||
|
implementation fg.deobf("com.jozufozu.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}")
|
||||||
|
}
|
||||||
|
|
||||||
// Prevent Mixin annotation processor from getting into IntelliJ's annotation processor settings
|
// 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
|
// 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')) {
|
if (!Boolean.getBoolean('idea.sync.active')) {
|
||||||
annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor"
|
annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor"
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOnly('org.jetbrains:annotations:24.0.1')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets.main.resources {
|
sourceSets.main.resources {
|
||||||
@@ -141,13 +146,6 @@ 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 {
|
|
||||||
module {
|
|
||||||
downloadJavadoc = true
|
|
||||||
downloadSources = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
compileJava {
|
compileJava {
|
||||||
options.compilerArgs = ['-Xdiags:verbose']
|
options.compilerArgs = ['-Xdiags:verbose']
|
||||||
}
|
}
|
||||||
@@ -155,13 +153,13 @@ compileJava {
|
|||||||
jar {
|
jar {
|
||||||
manifest {
|
manifest {
|
||||||
attributes([
|
attributes([
|
||||||
"Specification-Title" : mod_id,
|
"Specification-Title": "effortlessbuilding",
|
||||||
"Specification-Vendor" : mod_author,
|
"Specification-Vendor": "requios",
|
||||||
"Specification-Version" : "1",
|
"Specification-Version": "1",
|
||||||
"Implementation-Title" : project.name,
|
"Implementation-Title": project.name,
|
||||||
"Implementation-Version" : project.jar.archiveVersion,
|
"Implementation-Version": project.jar.archiveVersion,
|
||||||
"Implementation-Vendor" : mod_author,
|
"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")
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,17 +179,24 @@ java {
|
|||||||
withJavadocJar()
|
withJavadocJar()
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.build.dependsOn tasks.jarJar
|
jar.finalizedBy('reobfJar')
|
||||||
|
tasks.jarJar.finalizedBy('reobfJarJar')
|
||||||
|
|
||||||
project.publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
mavenJava(MavenPublication) {
|
mavenJava(MavenPublication) {
|
||||||
artifactId base.archivesName.get()
|
artifactId = base.archivesName.get()
|
||||||
from components.java
|
|
||||||
|
|
||||||
artifact(tasks.jar) {
|
from components.java
|
||||||
classifier = "all"
|
fg.component(it)
|
||||||
}
|
jarJar.component(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
if (project.hasProperty('mavendir')) {
|
||||||
|
maven { url mavendir }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,27 +3,18 @@
|
|||||||
org.gradle.jvmargs=-Xmx3G
|
org.gradle.jvmargs=-Xmx3G
|
||||||
org.gradle.daemon=false
|
org.gradle.daemon=false
|
||||||
|
|
||||||
mod_version = 3.10
|
mod_version = 3.7
|
||||||
artifact_minecraft_version = 1.20.1
|
artifact_minecraft_version = 1.19.4
|
||||||
|
|
||||||
minecraft_version = 1.20.1
|
minecraft_version = 1.19.4
|
||||||
forge_version = 47.1.3
|
forge_version = 45.2.6
|
||||||
|
|
||||||
forgegradle_version = 6.0.7
|
forgegradle_version = 6.0.7
|
||||||
mixingradle_version = 0.7-SNAPSHOT
|
mixingradle_version = 0.7-SNAPSHOT
|
||||||
mixin_version = 0.8.5
|
mixin_version = 0.8.5
|
||||||
librarian_version = 1.+
|
librarian_version = 1.+
|
||||||
cursegradle_version = 1.4.0
|
cursegradle_version = 1.4.0
|
||||||
parchment_version = 2023.09.03
|
parchment_version = 2023.06.26
|
||||||
|
|
||||||
flywheel_minecraft_version = 1.20.1
|
flywheel_minecraft_version = 1.19.3
|
||||||
flywheel_version = 1.0.1
|
flywheel_version = 0.6.9-2
|
||||||
vanillin_version = 1.0.0-beta-217
|
|
||||||
ponder_version = 1.0.51
|
|
||||||
|
|
||||||
# mod options
|
|
||||||
mod_id = effortlessbuilding
|
|
||||||
mod_name = Effortless Building
|
|
||||||
mod_author = Requios
|
|
||||||
mod_description = Makes building easier by providing tools like mirrors, arrays, build modes and a block randomizer. For survival and creative mode.
|
|
||||||
mod_license = GNU LGPLv3
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
apply plugin: 'java'
|
|
||||||
|
|
||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
|
||||||
java.withSourcesJar()
|
|
||||||
java.withJavadocJar()
|
|
||||||
|
|
||||||
jar {
|
|
||||||
manifest {
|
|
||||||
attributes([
|
|
||||||
'Specification-Title' : mod_name,
|
|
||||||
'Specification-Vendor' : mod_author,
|
|
||||||
'Specification-Version' : project.jar.archiveVersion,
|
|
||||||
'Implementation-Title' : project.name,
|
|
||||||
'Implementation-Version' : project.jar.archiveVersion,
|
|
||||||
'Implementation-Vendor' : mod_author,
|
|
||||||
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
|
||||||
'Timestampe' : System.currentTimeMillis(),
|
|
||||||
'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
|
|
||||||
'Built-On-Minecraft' : minecraft_version
|
|
||||||
])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile).configureEach {
|
|
||||||
it.options.encoding = 'UTF-8'
|
|
||||||
it.options.release = 17
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disables Gradle's custom module metadata from being published to maven. The
|
|
||||||
// metadata includes mapped dependencies which are not reasonably consumable by
|
|
||||||
// other mod developers.
|
|
||||||
tasks.withType(GenerateModuleMetadata) {
|
|
||||||
enabled = false
|
|
||||||
}
|
|
||||||
|
|
||||||
javadoc {
|
|
||||||
// Suppress annoying warnings when generating JavaDoc files.
|
|
||||||
options.addStringOption('Xdoclint:none', '-quiet')
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
This module can inject build properties from a JSON file. Each property in the
|
|
||||||
JSON file will be mapped to a build property using the key of that property.
|
|
||||||
Property keys ending with _comment will be skipped.
|
|
||||||
|
|
||||||
If a secretFile property exists and points to a valid JSON file that file will
|
|
||||||
be automatically loaded. You can manually load a file using the loadProperties
|
|
||||||
method.
|
|
||||||
*/
|
|
||||||
import groovy.json.JsonSlurper
|
|
||||||
|
|
||||||
// Auto detects a secret file and injects it.
|
|
||||||
if (project.rootProject.hasProperty("secretFile")) {
|
|
||||||
project.logger.lifecycle("Automatically loading properties from the secretFile")
|
|
||||||
final def secretsFile = project.rootProject.file(project.rootProject.getProperty("secretFile"))
|
|
||||||
|
|
||||||
if (secretsFile.exists() && secretsFile.name.endsWith(".json")) {
|
|
||||||
loadProperties(secretsFile)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loads properties using a specified json file.
|
|
||||||
def loadProperties(propertyFile) {
|
|
||||||
if (propertyFile.exists()) {
|
|
||||||
propertyFile.withReader {
|
|
||||||
Map propMap = new JsonSlurper().parse it
|
|
||||||
|
|
||||||
for (entry in propMap) {
|
|
||||||
|
|
||||||
// Filter entries that use _comment in the key.
|
|
||||||
if (!entry.key.endsWith("_comment")) {
|
|
||||||
|
|
||||||
project.ext.set(entry.key, entry.value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
project.logger.lifecycle("Successfully loaded " + propMap.size() + " properties")
|
|
||||||
propMap.clear()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
project.logger.warn("The property file " + propertyFile.getName() + " could not be loaded. It does not exist.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allows other scripts to use these methods.
|
|
||||||
ext {
|
|
||||||
loadProperties = this.&loadProperties
|
|
||||||
}
|
|
||||||
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,7 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@@ -1,15 +1,10 @@
|
|||||||
pluginManagement {
|
pluginManagement {
|
||||||
repositories {
|
repositories {
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
mavenCentral()
|
|
||||||
maven { url = 'https://maven.minecraftforge.net/' }
|
maven { url = 'https://maven.minecraftforge.net/' }
|
||||||
maven { url = 'https://repo.spongepowered.org/repository/maven-public' }
|
|
||||||
maven { url = 'https://maven.parchmentmc.org' }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
|
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
rootProject.name = 'Effortless Building'
|
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
package nl.requios.effortlessbuilding;
|
package nl.requios.effortlessbuilding;
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import net.minecraft.client.gui.GuiComponent;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
@@ -46,16 +47,23 @@ public enum AllGuiTextures implements ScreenElement {
|
|||||||
public void bind() {
|
public void bind() {
|
||||||
RenderSystem.setShaderTexture(0, location);
|
RenderSystem.setShaderTexture(0, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics ms, int x, int y) {
|
public void render(PoseStack poseStack, int x, int y) {
|
||||||
ms.blit(location, x, y, 0, startX, startY, width, height, 256, 256);
|
bind();
|
||||||
|
GuiComponent.blit(poseStack, x, y, 0, startX, startY, width, height, 256, 256);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public void render(PoseStack poseStack, int x, int y, GuiComponent component) {
|
||||||
|
bind();
|
||||||
|
component.blit(poseStack, x, y, 0, startX, startY, width, height, 256, 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void render(GuiGraphics ms, int x, int y, Color c) {
|
public void render(PoseStack poseStack, int x, int y, Color c, GuiComponent component) {
|
||||||
bind();
|
bind();
|
||||||
UIRenderHelper.drawColoredTexture(ms, c, x, y, startX, startY, width, height);
|
UIRenderHelper.drawColoredTexture(poseStack, c, x, y, startX, startY, width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
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.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiComponent;
|
||||||
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;
|
||||||
@@ -100,10 +101,15 @@ public class AllIcons implements ScreenElement {
|
|||||||
return new AllIcons(x = 0, ++y);
|
return new AllIcons(x = 0, ++y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void bind() {
|
||||||
|
RenderSystem.setShaderTexture(0, ICON_ATLAS);
|
||||||
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, int x, int y) {
|
public void render(PoseStack ms, int x, int y) {
|
||||||
guiGraphics.blit(ICON_ATLAS, x, y, 0, iconX, iconY, 16, 16, 256, 256);
|
bind();
|
||||||
|
GuiComponent.blit(ms, x, y, 0, iconX, iconY, 16, 16, 256, 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
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.capability.CapabilityHandler;
|
|
||||||
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;
|
||||||
@@ -134,7 +133,7 @@ public class ClientEvents {
|
|||||||
|
|
||||||
//Radial menu
|
//Radial menu
|
||||||
if (keyBindings[0].isDown()) {
|
if (keyBindings[0].isDown()) {
|
||||||
if (!CapabilityHandler.isDisabled(player)) {
|
if (!EffortlessBuildingClient.POWER_LEVEL.isDisabled(player)) {
|
||||||
if (!RadialMenu.instance.isVisible()) {
|
if (!RadialMenu.instance.isVisible()) {
|
||||||
Minecraft.getInstance().setScreen(RadialMenu.instance);
|
Minecraft.getInstance().setScreen(RadialMenu.instance);
|
||||||
}
|
}
|
||||||
@@ -175,7 +174,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 (CapabilityHandler.isDisabled(player)) {
|
if (EffortlessBuildingClient.POWER_LEVEL.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());
|
||||||
|
|||||||
@@ -2,12 +2,10 @@ package nl.requios.effortlessbuilding;
|
|||||||
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
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.util.FakePlayer;
|
import net.minecraftforge.common.util.FakePlayer;
|
||||||
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
|
||||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.minecraftforge.event.TickEvent;
|
||||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||||
@@ -16,13 +14,9 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|||||||
import net.minecraftforge.fml.LogicalSide;
|
import net.minecraftforge.fml.LogicalSide;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
import net.minecraftforge.network.PacketDistributor;
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
import nl.requios.effortlessbuilding.capability.CapabilityHandler;
|
|
||||||
import nl.requios.effortlessbuilding.capability.IPowerLevel;
|
|
||||||
import nl.requios.effortlessbuilding.capability.PowerLevelCapability;
|
|
||||||
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
||||||
import nl.requios.effortlessbuilding.network.ModifierSettingsPacket;
|
import nl.requios.effortlessbuilding.network.ModifierSettingsPacket;
|
||||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
import nl.requios.effortlessbuilding.network.PacketHandler;
|
||||||
import nl.requios.effortlessbuilding.network.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;
|
||||||
|
|
||||||
@@ -80,10 +74,7 @@ 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;
|
||||||
|
|
||||||
IPowerLevel powerLevel = player.getCapability(CapabilityHandler.POWER_LEVEL_CAPABILITY).orElse(null);
|
if (!ServerBuildState.isLikeVanilla(player) && EffortlessBuilding.SERVER_POWER_LEVEL.canBreakFar(player)) {
|
||||||
if (powerLevel == null) return; //Should never be null but just to be sure
|
|
||||||
|
|
||||||
if (!ServerBuildState.isLikeVanilla(player) && powerLevel.canBreakFar(player)) {
|
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,34 +94,7 @@ public class CommonEvents {
|
|||||||
ServerBuildState.handleNewPlayer(player);
|
ServerBuildState.handleNewPlayer(player);
|
||||||
|
|
||||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new ModifierSettingsPacket(player));
|
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new ModifierSettingsPacket(player));
|
||||||
|
EffortlessBuilding.SERVER_POWER_LEVEL.sendToClient(player);
|
||||||
IPowerLevel powerLevel = player.getCapability(CapabilityHandler.POWER_LEVEL_CAPABILITY).orElse(null);
|
|
||||||
if (powerLevel == null) return; //Should never be null but just to be sure
|
|
||||||
|
|
||||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new PowerLevelPacket(powerLevel.getPowerLevel()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void registerCaps(AttachCapabilitiesEvent<Entity> event) {
|
|
||||||
if (event.getObject() instanceof Player) {
|
|
||||||
event.addCapability(CapabilityHandler.POWER_LEVEL_CAP, new PowerLevelCapability());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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
|
|
||||||
original.getCapability(CapabilityHandler.POWER_LEVEL_CAPABILITY).ifPresent(dataOriginal ->
|
|
||||||
clone.getCapability(CapabilityHandler.POWER_LEVEL_CAPABILITY).ifPresent(dataClone -> {
|
|
||||||
dataClone.setPowerLevel(dataOriginal.getPowerLevel());
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import net.minecraft.world.item.ItemStack;
|
|||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.loot.IGlobalLootModifier;
|
import net.minecraftforge.common.loot.IGlobalLootModifier;
|
||||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
import net.minecraftforge.fml.ModLoadingContext;
|
import net.minecraftforge.fml.ModLoadingContext;
|
||||||
@@ -35,6 +35,7 @@ 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;
|
||||||
@@ -53,6 +54,7 @@ public class EffortlessBuilding {
|
|||||||
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<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||||
@@ -104,8 +106,8 @@ public class EffortlessBuilding {
|
|||||||
CompatHelper.setup();
|
CompatHelper.setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addTabContents(final BuildCreativeModeTabContentsEvent event) {
|
public static void addTabContents(final CreativeModeTabEvent.BuildContents event) {
|
||||||
if (event.getTabKey() == CreativeModeTabs.TOOLS_AND_UTILITIES) {
|
if (event.getTab() == CreativeModeTabs.TOOLS_AND_UTILITIES) {
|
||||||
List<ItemStack> stacks = ITEMS.getEntries().stream().map(reg -> new ItemStack(reg.get())).toList();
|
List<ItemStack> stacks = ITEMS.getEntries().stream().map(reg -> new ItemStack(reg.get())).toList();
|
||||||
event.acceptAll(stacks);
|
event.acceptAll(stacks);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ 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::clientSetup);
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public class BuildModes {
|
|||||||
if (!skipRaytrace) {
|
if (!skipRaytrace) {
|
||||||
//collision within a 1 block radius to selected is fine
|
//collision within a 1 block radius to selected is fine
|
||||||
ClipContext rayTraceContext = new ClipContext(start, lineBound, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, player);
|
ClipContext rayTraceContext = new ClipContext(start, lineBound, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, player);
|
||||||
HitResult rayTraceResult = player.level().clip(rayTraceContext);
|
HitResult rayTraceResult = player.level.clip(rayTraceContext);
|
||||||
intersects = rayTraceResult != null && rayTraceResult.getType() == HitResult.Type.BLOCK &&
|
intersects = rayTraceResult != null && rayTraceResult.getType() == HitResult.Type.BLOCK &&
|
||||||
planeBound.subtract(rayTraceResult.getLocation()).lengthSqr() > 4;
|
planeBound.subtract(rayTraceResult.getLocation()).lengthSqr() > 4;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public class ModeOptions {
|
|||||||
case CIRCLE_START_CORNER -> circleStart = ActionEnum.CIRCLE_START_CORNER;
|
case CIRCLE_START_CORNER -> circleStart = ActionEnum.CIRCLE_START_CORNER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.level().isClientSide &&
|
if (player.level.isClientSide &&
|
||||||
action != ActionEnum.OPEN_MODIFIER_SETTINGS &&
|
action != ActionEnum.OPEN_MODIFIER_SETTINGS &&
|
||||||
action != ActionEnum.OPEN_PLAYER_SETTINGS &&
|
action != ActionEnum.OPEN_PLAYER_SETTINGS &&
|
||||||
action != ActionEnum.PREVIOUS_BUILD_MODE &&
|
action != ActionEnum.PREVIOUS_BUILD_MODE &&
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ 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.capability.CapabilityHandler;
|
|
||||||
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
||||||
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
||||||
|
|
||||||
@@ -65,7 +64,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 = CapabilityHandler.getMaxBlocksPerAxis(player, false);
|
int axisLimit = EffortlessBuildingClient.POWER_LEVEL.getMaxBlocksPerAxis(player);
|
||||||
|
|
||||||
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();
|
||||||
@@ -94,7 +93,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 = CapabilityHandler.getMaxBlocksPerAxis(player, false);
|
int axisLimit = EffortlessBuildingClient.POWER_LEVEL.getMaxBlocksPerAxis(player);
|
||||||
|
|
||||||
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();
|
||||||
@@ -140,7 +139,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 = CapabilityHandler.getBuildModeReach(player);
|
int reach = EffortlessBuildingClient.POWER_LEVEL.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,7 +4,6 @@ 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.capability.CapabilityHandler;
|
|
||||||
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
||||||
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
||||||
|
|
||||||
@@ -49,7 +48,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 = CapabilityHandler.getMaxBlocksPerAxis(player, false);
|
int axisLimit = EffortlessBuildingClient.POWER_LEVEL.getMaxBlocksPerAxis(player);
|
||||||
|
|
||||||
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();
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
|||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||||
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.capability.CapabilityHandler;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -24,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 = CapabilityHandler.getBuildModeReach(player);
|
int reach = EffortlessBuildingClient.POWER_LEVEL.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
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
|||||||
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 net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||||
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.capability.CapabilityHandler;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -31,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 = CapabilityHandler.getBuildModeReach(player);
|
int reach = EffortlessBuildingClient.POWER_LEVEL.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
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
|||||||
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||||
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.capability.CapabilityHandler;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -15,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 = CapabilityHandler.getMaxBlocksPerAxis(player, false);
|
int axisLimit = EffortlessBuildingClient.POWER_LEVEL.getMaxBlocksPerAxis(player);
|
||||||
|
|
||||||
//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;
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
|||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||||
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.capability.CapabilityHandler;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -28,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 = CapabilityHandler.getBuildModeReach(player);
|
int reach = EffortlessBuildingClient.POWER_LEVEL.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
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import net.minecraft.world.entity.player.Player;
|
|||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
import nl.requios.effortlessbuilding.capability.CapabilityHandler;
|
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;
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ public class Mirror extends BaseModifier {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPowerLevelChanged(int powerLevel) {
|
public void onPowerLevelChanged(int powerLevel) {
|
||||||
radius = CapabilityHandler.getMaxMirrorRadius(Minecraft.getInstance().player, false);
|
radius = EffortlessBuildingClient.POWER_LEVEL.getMaxMirrorRadius(Minecraft.getInstance().player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void performMirrorX(BlockSet blocks, BlockEntry blockEntry) {
|
private void performMirrorX(BlockSet blocks, BlockEntry blockEntry) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import net.minecraft.world.level.block.Rotation;
|
|||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import nl.requios.effortlessbuilding.capability.CapabilityHandler;
|
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;
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ public class RadialMirror extends BaseModifier {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPowerLevelChanged(int powerLevel) {
|
public void onPowerLevelChanged(int powerLevel) {
|
||||||
radius = CapabilityHandler.getMaxMirrorRadius(Minecraft.getInstance().player, false);
|
radius = EffortlessBuildingClient.POWER_LEVEL.getMaxMirrorRadius(Minecraft.getInstance().player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void performRadialMirror(BlockSet blocks, BlockEntry blockEntry) {
|
public void performRadialMirror(BlockSet blocks, BlockEntry blockEntry) {
|
||||||
@@ -112,11 +112,11 @@ public class RadialMirror extends BaseModifier {
|
|||||||
BlockState newBlockState = blockState;
|
BlockState newBlockState = blockState;
|
||||||
|
|
||||||
if (startAngleToCenter < -0.751 * Math.PI || startAngleToCenter > 0.749 * Math.PI) {
|
if (startAngleToCenter < -0.751 * Math.PI || startAngleToCenter > 0.749 * Math.PI) {
|
||||||
newBlockState = blockState.rotate(player.level(), startPos, Rotation.CLOCKWISE_180);
|
newBlockState = blockState.rotate(player.level, startPos, Rotation.CLOCKWISE_180);
|
||||||
} else if (startAngleToCenter < -0.251 * Math.PI) {
|
} else if (startAngleToCenter < -0.251 * Math.PI) {
|
||||||
newBlockState = blockState.rotate(player.level(), startPos, Rotation.COUNTERCLOCKWISE_90);
|
newBlockState = blockState.rotate(player.level, startPos, Rotation.COUNTERCLOCKWISE_90);
|
||||||
} else if (startAngleToCenter > 0.249 * Math.PI) {
|
} else if (startAngleToCenter > 0.249 * Math.PI) {
|
||||||
newBlockState = blockState.rotate(player.level(), startPos, Rotation.CLOCKWISE_90);
|
newBlockState = blockState.rotate(player.level, startPos, Rotation.CLOCKWISE_90);
|
||||||
}
|
}
|
||||||
|
|
||||||
return newBlockState;
|
return newBlockState;
|
||||||
@@ -127,17 +127,17 @@ public class RadialMirror extends BaseModifier {
|
|||||||
double angleToCenter = Mth.atan2(relVec.x, relVec.z); //between -PI and PI
|
double angleToCenter = Mth.atan2(relVec.x, relVec.z); //between -PI and PI
|
||||||
|
|
||||||
if (angleToCenter < -0.751 * Math.PI || angleToCenter > 0.749 * Math.PI) {
|
if (angleToCenter < -0.751 * Math.PI || angleToCenter > 0.749 * Math.PI) {
|
||||||
newBlockState = blockState.rotate(player.level(), startPos, Rotation.CLOCKWISE_180);
|
newBlockState = blockState.rotate(player.level, startPos, Rotation.CLOCKWISE_180);
|
||||||
if (alternate) {
|
if (alternate) {
|
||||||
newBlockState = newBlockState.mirror(Mirror.FRONT_BACK);
|
newBlockState = newBlockState.mirror(Mirror.FRONT_BACK);
|
||||||
}
|
}
|
||||||
} else if (angleToCenter < -0.251 * Math.PI) {
|
} else if (angleToCenter < -0.251 * Math.PI) {
|
||||||
newBlockState = blockState.rotate(player.level(), startPos, Rotation.CLOCKWISE_90);
|
newBlockState = blockState.rotate(player.level, startPos, Rotation.CLOCKWISE_90);
|
||||||
if (alternate) {
|
if (alternate) {
|
||||||
newBlockState = newBlockState.mirror(Mirror.LEFT_RIGHT);
|
newBlockState = newBlockState.mirror(Mirror.LEFT_RIGHT);
|
||||||
}
|
}
|
||||||
} else if (angleToCenter > 0.249 * Math.PI) {
|
} else if (angleToCenter > 0.249 * Math.PI) {
|
||||||
newBlockState = blockState.rotate(player.level(), startPos, Rotation.COUNTERCLOCKWISE_90);
|
newBlockState = blockState.rotate(player.level, startPos, Rotation.COUNTERCLOCKWISE_90);
|
||||||
if (alternate) {
|
if (alternate) {
|
||||||
newBlockState = newBlockState.mirror(Mirror.LEFT_RIGHT);
|
newBlockState = newBlockState.mirror(Mirror.LEFT_RIGHT);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,137 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.capability;
|
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
|
||||||
import net.minecraftforge.common.capabilities.CapabilityToken;
|
|
||||||
import net.minecraftforge.network.PacketDistributor;
|
|
||||||
import nl.requios.effortlessbuilding.CommonConfig;
|
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
|
||||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
|
||||||
import nl.requios.effortlessbuilding.network.PowerLevelPacket;
|
|
||||||
|
|
||||||
public class CapabilityHandler {
|
|
||||||
public static final ResourceLocation POWER_LEVEL_CAP = new ResourceLocation(EffortlessBuilding.MODID, "power_level");
|
|
||||||
public static final Capability<IPowerLevel> POWER_LEVEL_CAPABILITY = CapabilityManager.get(new CapabilityToken<>() {
|
|
||||||
});
|
|
||||||
|
|
||||||
public static void syncToClient(Player player) {
|
|
||||||
IPowerLevel powerLevel = player.getCapability(CapabilityHandler.POWER_LEVEL_CAPABILITY).orElse(null);
|
|
||||||
if (powerLevel == null) return; //Should never be null but just to be sure
|
|
||||||
|
|
||||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new PowerLevelPacket(powerLevel.getPowerLevel()));
|
|
||||||
}
|
|
||||||
|
|
||||||
//Helper methods to reduce boilerplate code
|
|
||||||
public static boolean canReplaceBlocks(Player player) {
|
|
||||||
if (player != null) {
|
|
||||||
IPowerLevel powerLevel = player.getCapability(CapabilityHandler.POWER_LEVEL_CAPABILITY).orElse(null);
|
|
||||||
if (powerLevel != null) {
|
|
||||||
return powerLevel.canReplaceBlocks(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getMaxBlocksPerAxis(Player player, boolean nextPowerLevel) {
|
|
||||||
if (player != null) {
|
|
||||||
IPowerLevel powerLevel = player.getCapability(CapabilityHandler.POWER_LEVEL_CAPABILITY).orElse(null);
|
|
||||||
if (powerLevel != null) {
|
|
||||||
return powerLevel.getMaxBlocksPerAxis(player, nextPowerLevel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return CommonConfig.maxBlocksPerAxis.level0.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getMaxBlocksPlacedAtOnce(Player player, boolean nextPowerLevel) {
|
|
||||||
if (player != null) {
|
|
||||||
IPowerLevel powerLevel = player.getCapability(CapabilityHandler.POWER_LEVEL_CAPABILITY).orElse(null);
|
|
||||||
if (powerLevel != null) {
|
|
||||||
return powerLevel.getMaxBlocksPlacedAtOnce(player, nextPowerLevel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return CommonConfig.maxBlocksPlacedAtOnce.level0.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getMaxMirrorRadius(Player player, boolean nextPowerLevel) {
|
|
||||||
if (player != null) {
|
|
||||||
IPowerLevel powerLevel = player.getCapability(CapabilityHandler.POWER_LEVEL_CAPABILITY).orElse(null);
|
|
||||||
if (powerLevel != null) {
|
|
||||||
return powerLevel.getMaxMirrorRadius(player, nextPowerLevel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return CommonConfig.maxMirrorRadius.level0.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getBuildModeReach(Player player) {
|
|
||||||
if (player != null) {
|
|
||||||
IPowerLevel powerLevel = player.getCapability(CapabilityHandler.POWER_LEVEL_CAPABILITY).orElse(null);
|
|
||||||
if (powerLevel != null) {
|
|
||||||
return powerLevel.getBuildModeReach(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return CommonConfig.maxMirrorRadius.level0.get() + 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getPlacementReach(Player player, boolean nextPowerLevel) {
|
|
||||||
if (player != null) {
|
|
||||||
IPowerLevel powerLevel = player.getCapability(CapabilityHandler.POWER_LEVEL_CAPABILITY).orElse(null);
|
|
||||||
if (powerLevel != null) {
|
|
||||||
return powerLevel.getPlacementReach(player, nextPowerLevel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return CommonConfig.reach.level0.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getPowerLevel(Player player) {
|
|
||||||
if (player != null) {
|
|
||||||
IPowerLevel powerLevel = player.getCapability(CapabilityHandler.POWER_LEVEL_CAPABILITY).orElse(null);
|
|
||||||
if (powerLevel != null) {
|
|
||||||
return powerLevel.getPowerLevel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getNextPowerLevel(Player player) {
|
|
||||||
if (player != null) {
|
|
||||||
IPowerLevel powerLevel = player.getCapability(CapabilityHandler.POWER_LEVEL_CAPABILITY).orElse(null);
|
|
||||||
if (powerLevel != null) {
|
|
||||||
return powerLevel.getNextPowerLevel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canIncreasePowerLevel(Player player) {
|
|
||||||
if (player != null) {
|
|
||||||
IPowerLevel powerLevel = player.getCapability(CapabilityHandler.POWER_LEVEL_CAPABILITY).orElse(null);
|
|
||||||
if (powerLevel != null) {
|
|
||||||
return powerLevel.canIncreasePowerLevel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isDisabled(Player player) {
|
|
||||||
if (player != null) {
|
|
||||||
IPowerLevel powerLevel = player.getCapability(CapabilityHandler.POWER_LEVEL_CAPABILITY).orElse(null);
|
|
||||||
if (powerLevel != null) {
|
|
||||||
return powerLevel.isDisabled(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canBreakFar(Player player) {
|
|
||||||
if (player != null) {
|
|
||||||
IPowerLevel powerLevel = player.getCapability(CapabilityHandler.POWER_LEVEL_CAPABILITY).orElse(null);
|
|
||||||
if (powerLevel != null) {
|
|
||||||
return powerLevel.canBreakFar(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.capability;
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraftforge.common.capabilities.AutoRegisterCapability;
|
|
||||||
|
|
||||||
@AutoRegisterCapability
|
|
||||||
public interface IPowerLevel {
|
|
||||||
|
|
||||||
int getPowerLevel();
|
|
||||||
|
|
||||||
int getNextPowerLevel();
|
|
||||||
|
|
||||||
void setPowerLevel(int powerLevel);
|
|
||||||
|
|
||||||
boolean canIncreasePowerLevel();
|
|
||||||
|
|
||||||
void increasePowerLevel();
|
|
||||||
|
|
||||||
|
|
||||||
int getPlacementReach(Player player, boolean nextPowerLevel);
|
|
||||||
|
|
||||||
int getBuildModeReach(Player player);
|
|
||||||
|
|
||||||
|
|
||||||
int getMaxBlocksPlacedAtOnce(Player player, boolean nextPowerLevel);
|
|
||||||
|
|
||||||
|
|
||||||
int getMaxBlocksPerAxis(Player player, boolean nextPowerLevel);
|
|
||||||
|
|
||||||
|
|
||||||
int getMaxMirrorRadius(Player player, boolean nextPowerLevel);
|
|
||||||
|
|
||||||
boolean isDisabled(Player player);
|
|
||||||
|
|
||||||
boolean canBreakFar(Player player);
|
|
||||||
|
|
||||||
boolean canReplaceBlocks(Player player);
|
|
||||||
}
|
|
||||||
@@ -1,127 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.capability;
|
|
||||||
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
|
||||||
import nl.requios.effortlessbuilding.CommonConfig;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
public class PowerLevelCapability implements IPowerLevel, ICapabilitySerializable<CompoundTag> {
|
|
||||||
public static final int MAX_POWER_LEVEL = 3; //Common access
|
|
||||||
|
|
||||||
private int powerLevel = 0;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getPowerLevel() {
|
|
||||||
return this.powerLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getNextPowerLevel() {
|
|
||||||
return Math.min(getPowerLevel() + 1, MAX_POWER_LEVEL);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPowerLevel(int powerLevel) {
|
|
||||||
this.powerLevel = powerLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canIncreasePowerLevel() {
|
|
||||||
return getPowerLevel() < MAX_POWER_LEVEL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void increasePowerLevel() {
|
|
||||||
if (canIncreasePowerLevel()) {
|
|
||||||
setPowerLevel(getPowerLevel() + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getPlacementReach(Player player, boolean nextPowerLevel) {
|
|
||||||
if (player.isCreative()) return CommonConfig.reach.creative.get();
|
|
||||||
return switch (nextPowerLevel ? getNextPowerLevel() : getPowerLevel()) {
|
|
||||||
case 1 -> CommonConfig.reach.level1.get();
|
|
||||||
case 2 -> CommonConfig.reach.level2.get();
|
|
||||||
case 3 -> CommonConfig.reach.level3.get();
|
|
||||||
default -> CommonConfig.reach.level0.get();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
//How far away we can detect the second and third click of build modes (distance to player)
|
|
||||||
@Override
|
|
||||||
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.
|
|
||||||
return getPlacementReach(player, false) + 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMaxBlocksPlacedAtOnce(Player player, boolean nextPowerLevel) {
|
|
||||||
if (player.isCreative()) return CommonConfig.maxBlocksPlacedAtOnce.creative.get();
|
|
||||||
return switch (nextPowerLevel ? getNextPowerLevel() : getPowerLevel()) {
|
|
||||||
case 1 -> CommonConfig.maxBlocksPlacedAtOnce.level1.get();
|
|
||||||
case 2 -> CommonConfig.maxBlocksPlacedAtOnce.level2.get();
|
|
||||||
case 3 -> CommonConfig.maxBlocksPlacedAtOnce.level3.get();
|
|
||||||
default -> CommonConfig.maxBlocksPlacedAtOnce.level0.get();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMaxBlocksPerAxis(Player player, boolean nextPowerLevel) {
|
|
||||||
if (player.isCreative()) return CommonConfig.maxBlocksPerAxis.creative.get();
|
|
||||||
return switch (nextPowerLevel ? getNextPowerLevel() : getPowerLevel()) {
|
|
||||||
case 1 -> CommonConfig.maxBlocksPerAxis.level1.get();
|
|
||||||
case 2 -> CommonConfig.maxBlocksPerAxis.level2.get();
|
|
||||||
case 3 -> CommonConfig.maxBlocksPerAxis.level3.get();
|
|
||||||
default -> CommonConfig.maxBlocksPerAxis.level0.get();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMaxMirrorRadius(Player player, boolean nextPowerLevel) {
|
|
||||||
if (player.isCreative()) return CommonConfig.maxMirrorRadius.creative.get();
|
|
||||||
return switch (getPowerLevel() + (nextPowerLevel ? 1 : 0)) {
|
|
||||||
case 1 -> CommonConfig.maxMirrorRadius.level1.get();
|
|
||||||
case 2 -> CommonConfig.maxMirrorRadius.level2.get();
|
|
||||||
case 3 -> CommonConfig.maxMirrorRadius.level3.get();
|
|
||||||
default -> CommonConfig.maxMirrorRadius.level0.get();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isDisabled(Player player) {
|
|
||||||
return getMaxBlocksPlacedAtOnce(player, false) <= 0 || getMaxBlocksPerAxis(player, false) <= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canBreakFar(Player player) {
|
|
||||||
return player.getAbilities().instabuild;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canReplaceBlocks(Player player) {
|
|
||||||
return player.getAbilities().instabuild;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side) {
|
|
||||||
return CapabilityHandler.POWER_LEVEL_CAPABILITY.orEmpty(cap, LazyOptional.of(() -> this));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundTag serializeNBT() {
|
|
||||||
CompoundTag tag = new CompoundTag();
|
|
||||||
tag.putInt("powerLevel", getPowerLevel());
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deserializeNBT(CompoundTag nbt) {
|
|
||||||
setPowerLevel(nbt.getInt("powerLevel"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
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 implements BindableTexture {
|
public enum AllSpecialTextures {
|
||||||
|
|
||||||
BLANK("blank.png"),
|
BLANK("blank.png"),
|
||||||
CHECKERED("checkerboard.png"),
|
CHECKERED("checkerboard.png"),
|
||||||
@@ -19,7 +18,7 @@ public enum AllSpecialTextures implements BindableTexture {
|
|||||||
public static final String ASSET_PATH = "textures/special/";
|
public static final String ASSET_PATH = "textures/special/";
|
||||||
private ResourceLocation location;
|
private ResourceLocation location;
|
||||||
|
|
||||||
AllSpecialTextures(String filename) {
|
private AllSpecialTextures(String filename) {
|
||||||
location = Create.asResource(ASSET_PATH + filename);
|
location = Create.asResource(ASSET_PATH + filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package nl.requios.effortlessbuilding.create;
|
package nl.requios.effortlessbuilding.create;
|
||||||
|
|
||||||
import net.createmod.catnip.render.SuperByteBufferCache;
|
import nl.requios.effortlessbuilding.create.foundation.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.utility.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() {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ 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.outliner.Outliner;
|
|
||||||
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.level.LevelAccessor;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
@@ -17,11 +16,10 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
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.render.SuperRenderTypeBuffer;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.AnimationTickHolder;
|
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;
|
import nl.requios.effortlessbuilding.create.foundation.utility.worldWrappers.WrappedClientWorld;
|
||||||
import net.createmod.catnip.render.DefaultSuperRenderTypeBuffer;
|
|
||||||
import net.createmod.catnip.render.SuperRenderTypeBuffer;
|
|
||||||
|
|
||||||
@EventBusSubscriber(Dist.CLIENT)
|
@EventBusSubscriber(Dist.CLIENT)
|
||||||
public class ClientEvents {
|
public class ClientEvents {
|
||||||
@@ -36,7 +34,7 @@ public class ClientEvents {
|
|||||||
AnimationTickHolder.tick();
|
AnimationTickHolder.tick();
|
||||||
|
|
||||||
CreateClient.GHOST_BLOCKS.tickGhosts();
|
CreateClient.GHOST_BLOCKS.tickGhosts();
|
||||||
// Outliner.getInstance().tickOutlines();
|
CreateClient.OUTLINER.tickOutlines();
|
||||||
CameraAngleAnimationService.tick();
|
CameraAngleAnimationService.tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,11 +67,11 @@ public class ClientEvents {
|
|||||||
PoseStack ms = event.getPoseStack();
|
PoseStack ms = event.getPoseStack();
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
ms.translate(-cameraPos.x(), -cameraPos.y(), -cameraPos.z());
|
ms.translate(-cameraPos.x(), -cameraPos.y(), -cameraPos.z());
|
||||||
SuperRenderTypeBuffer buffer = DefaultSuperRenderTypeBuffer.getInstance();
|
SuperRenderTypeBuffer buffer = SuperRenderTypeBuffer.getInstance();
|
||||||
|
|
||||||
CreateClient.GHOST_BLOCKS.renderAll(ms, buffer);
|
CreateClient.GHOST_BLOCKS.renderAll(ms, buffer);
|
||||||
|
|
||||||
// Outliner.getInstance().renderOutlines(ms, buffer, pt);
|
CreateClient.OUTLINER.renderOutlines(ms, buffer, pt);
|
||||||
buffer.draw();
|
buffer.draw();
|
||||||
RenderSystem.enableCull();
|
RenderSystem.enableCull();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.block.render;
|
package nl.requios.effortlessbuilding.create.foundation.block.render;
|
||||||
|
|
||||||
import net.createmod.catnip.render.StitchedSprite;
|
import com.jozufozu.flywheel.core.StitchedSprite;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package nl.requios.effortlessbuilding.create.foundation.gui;
|
|||||||
|
|
||||||
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 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;
|
||||||
import net.minecraft.client.gui.components.Renderable;
|
import net.minecraft.client.gui.components.Renderable;
|
||||||
@@ -105,18 +104,16 @@ public abstract class AbstractSimiScreen extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
partialTicks = minecraft.getFrameTime();
|
partialTicks = minecraft.getFrameTime();
|
||||||
PoseStack ms = graphics.pose();
|
|
||||||
|
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
|
|
||||||
prepareFrame();
|
prepareFrame();
|
||||||
|
|
||||||
renderWindowBackground(graphics, mouseX, mouseY, partialTicks);
|
renderWindowBackground(ms, mouseX, mouseY, partialTicks);
|
||||||
renderWindow(graphics, mouseX, mouseY, partialTicks);
|
renderWindow(ms, mouseX, mouseY, partialTicks);
|
||||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
super.render(ms, mouseX, mouseY, partialTicks);
|
||||||
renderWindowForeground(graphics, mouseX, mouseY, partialTicks);
|
renderWindowForeground(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
endFrame();
|
endFrame();
|
||||||
|
|
||||||
@@ -140,13 +137,13 @@ 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(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
renderBackground(graphics);
|
renderBackground(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void renderWindow(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks);
|
protected abstract void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks);
|
||||||
|
|
||||||
protected void renderWindowForeground(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
protected void renderWindowForeground(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
for (Renderable widget : renderables) {
|
for (Renderable widget : renderables) {
|
||||||
if (widget instanceof AbstractSimiWidget simiWidget && simiWidget.isMouseOver(mouseX, mouseY)
|
if (widget instanceof AbstractSimiWidget simiWidget && simiWidget.isMouseOver(mouseX, mouseY)
|
||||||
&& simiWidget.visible) {
|
&& simiWidget.visible) {
|
||||||
@@ -155,12 +152,12 @@ public abstract class AbstractSimiScreen extends Screen {
|
|||||||
continue;
|
continue;
|
||||||
int ttx = simiWidget.lockedTooltipX == -1 ? mouseX : simiWidget.lockedTooltipX + simiWidget.getX();
|
int ttx = simiWidget.lockedTooltipX == -1 ? mouseX : simiWidget.lockedTooltipX + simiWidget.getX();
|
||||||
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);
|
renderComponentTooltip(ms, tooltip, ttx, tty);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Added
|
//Added
|
||||||
if (widget instanceof ModifiersScreenList list) {
|
if (widget instanceof ModifiersScreenList list) {
|
||||||
list.renderWindowForeground(graphics, mouseX, mouseY, partialTicks);
|
list.renderWindowForeground(ms, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,8 +165,8 @@ public abstract class AbstractSimiScreen extends Screen {
|
|||||||
protected void endFrame() {}
|
protected void endFrame() {}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
protected void debugWindowArea(GuiGraphics graphics) {
|
protected void debugWindowArea(PoseStack graphics) {
|
||||||
graphics.fill(guiLeft + windowWidth, guiTop + windowHeight, guiLeft, guiTop, 0xD3D3D3D3);
|
fill(graphics, guiLeft + windowWidth, guiTop + windowHeight, guiLeft, guiTop, 0xD3D3D3D3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
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 net.minecraft.client.gui.GuiGraphics;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import net.minecraft.client.gui.GuiComponent;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
@@ -72,15 +73,21 @@ public enum AllGuiTextures implements ScreenElement {
|
|||||||
RenderSystem.setShaderTexture(0, location);
|
RenderSystem.setShaderTexture(0, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
public void render(PoseStack ms, int x, int y) {
|
||||||
public void render(GuiGraphics graphics, int x, int y) {
|
bind();
|
||||||
graphics.blit(location, x, y, startX, startY, width, height);
|
GuiComponent.blit(ms, x, y, startX, startY, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void render(GuiGraphics graphics, int x, int y, Color c) {
|
public void render(PoseStack ms, int x, int y, GuiComponent component) {
|
||||||
bind();
|
bind();
|
||||||
UIRenderHelper.drawColoredTexture(graphics, c, x, y, startX, startY, width, height);
|
component.blit(ms, x, y, startX, startY, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public void render(PoseStack ms, int x, int y, Color c) {
|
||||||
|
bind();
|
||||||
|
UIRenderHelper.drawColoredTexture(ms, c, x, y, startX, startY, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package nl.requios.effortlessbuilding.create.foundation.gui;
|
|||||||
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 net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiComponent;
|
||||||
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;
|
||||||
@@ -173,8 +173,9 @@ public class AllIcons implements ScreenElement {
|
|||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics graphics, int x, int y) {
|
public void render(PoseStack ms, int x, int y) {
|
||||||
graphics.blit(ICON_ATLAS, x, y, 0, iconX, iconY, 16, 16, 256, 256);
|
bind();
|
||||||
|
GuiComponent.blit(ms, x, y, 0, iconX, iconY, 16, 16, 256, 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package nl.requios.effortlessbuilding.create.foundation.gui;
|
|||||||
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.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.network.chat.FormattedText;
|
import net.minecraft.network.chat.FormattedText;
|
||||||
import net.minecraft.network.chat.Style;
|
import net.minecraft.network.chat.Style;
|
||||||
@@ -174,12 +173,11 @@ public class ConfirmationScreen extends AbstractSimiScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderWindow(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
textBackground.render(graphics);
|
textBackground.render(ms);
|
||||||
int offset = font.lineHeight + 1;
|
int offset = font.lineHeight + 1;
|
||||||
int lineY = y - offset;
|
int lineY = y - offset;
|
||||||
|
|
||||||
PoseStack ms = graphics.pose();
|
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
ms.translate(0, 0, 200);
|
ms.translate(0, 0, 200);
|
||||||
|
|
||||||
@@ -187,21 +185,21 @@ public class ConfirmationScreen extends AbstractSimiScreen {
|
|||||||
lineY += offset;
|
lineY += offset;
|
||||||
if (line == null)
|
if (line == null)
|
||||||
continue;
|
continue;
|
||||||
graphics.drawString(font, line.getString(), x, lineY, 0xeaeaea, false);
|
font.draw(ms, line.getString(), x, lineY, 0xeaeaea);
|
||||||
}
|
}
|
||||||
|
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderWindowBackground(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
protected void renderWindowBackground(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
endFrame();
|
endFrame();
|
||||||
|
|
||||||
source.render(graphics, 0, 0, 10); // zero mouse coords to prevent further tooltips
|
source.render(ms, 0, 0, 10); // zero mouse coords to prevent further tooltips
|
||||||
|
|
||||||
prepareFrame();
|
prepareFrame();
|
||||||
|
|
||||||
graphics.fillGradient(0, 0, this.width, this.height, 0x70101010, 0x80101010);
|
fillGradient(ms, 0, 0, this.width, this.height, 0x70101010, 0x80101010);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,203 +1,202 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
//package nl.requios.effortlessbuilding.create.foundation.gui;
|
||||||
|
//
|
||||||
import java.util.ArrayList;
|
//import java.util.ArrayList;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
|
//
|
||||||
import javax.annotation.Nonnull;
|
//import javax.annotation.Nonnull;
|
||||||
|
//
|
||||||
import org.joml.Matrix4f;
|
//import net.minecraft.client.gui.GuiComponent;
|
||||||
|
//import org.joml.Matrix4f;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
//
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
//import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.Tesselator;
|
//import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
//import com.mojang.blaze3d.vertex.Tesselator;
|
||||||
import net.minecraft.client.gui.Font;
|
//
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
//import net.minecraft.client.gui.Font;
|
||||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
//import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
//import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||||
import net.minecraft.network.chat.FormattedText;
|
//import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.network.chat.Style;
|
//import net.minecraft.network.chat.FormattedText;
|
||||||
import net.minecraft.world.item.ItemStack;
|
//import net.minecraft.network.chat.Style;
|
||||||
import net.minecraftforge.client.ForgeHooksClient;
|
//import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraftforge.client.event.RenderTooltipEvent;
|
//import net.minecraftforge.client.ForgeHooksClient;
|
||||||
import net.minecraftforge.client.extensions.IForgeGuiGraphics;
|
//import net.minecraftforge.client.event.RenderTooltipEvent;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
//import net.minecraftforge.client.extensions.IForgeGuiGraphics;
|
||||||
|
//import net.minecraftforge.common.MinecraftForge;
|
||||||
public class RemovedGuiUtils {
|
//
|
||||||
@Nonnull
|
//public class RemovedGuiUtils {
|
||||||
private static ItemStack cachedTooltipStack = ItemStack.EMPTY;
|
// @Nonnull
|
||||||
|
// private static ItemStack cachedTooltipStack = ItemStack.EMPTY;
|
||||||
public static void preItemToolTip(@Nonnull ItemStack stack) {
|
//
|
||||||
cachedTooltipStack = stack;
|
// public static void preItemToolTip(@Nonnull ItemStack stack) {
|
||||||
}
|
// cachedTooltipStack = stack;
|
||||||
|
// }
|
||||||
public static void postItemToolTip() {
|
//
|
||||||
cachedTooltipStack = ItemStack.EMPTY;
|
// public static void postItemToolTip() {
|
||||||
}
|
// cachedTooltipStack = ItemStack.EMPTY;
|
||||||
|
// }
|
||||||
public static void drawHoveringText(GuiGraphics graphics, List<? extends FormattedText> textLines, int mouseX,
|
//
|
||||||
int mouseY, int screenWidth, int screenHeight, int maxTextWidth, Font font) {
|
// public static void drawHoveringText(PoseStack graphics, List<? extends FormattedText> textLines, int mouseX,
|
||||||
drawHoveringText(graphics, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth,
|
// int mouseY, int screenWidth, int screenHeight, int maxTextWidth, Font font) {
|
||||||
IForgeGuiGraphics.DEFAULT_BACKGROUND_COLOR, IForgeGuiGraphics.DEFAULT_BORDER_COLOR_START, IForgeGuiGraphics.DEFAULT_BORDER_COLOR_END,
|
// drawHoveringText(graphics, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth,
|
||||||
font);
|
// IForgeGuiGraphics.DEFAULT_BACKGROUND_COLOR, IForgeGuiGraphics.DEFAULT_BORDER_COLOR_START, IForgeGuiGraphics.DEFAULT_BORDER_COLOR_END,
|
||||||
}
|
// font);
|
||||||
|
// }
|
||||||
public static void drawHoveringText(GuiGraphics graphics, List<? extends FormattedText> textLines, int mouseX,
|
//
|
||||||
int mouseY, int screenWidth, int screenHeight, int maxTextWidth, int backgroundColor, int borderColorStart,
|
// public static void drawHoveringText(PoseStack graphics, List<? extends FormattedText> textLines, int mouseX,
|
||||||
int borderColorEnd, Font font) {
|
// int mouseY, int screenWidth, int screenHeight, int maxTextWidth, int backgroundColor, int borderColorStart,
|
||||||
drawHoveringText(cachedTooltipStack, graphics, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth,
|
// int borderColorEnd, Font font) {
|
||||||
backgroundColor, borderColorStart, borderColorEnd, font);
|
// drawHoveringText(cachedTooltipStack, graphics, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth,
|
||||||
}
|
// backgroundColor, borderColorStart, borderColorEnd, font);
|
||||||
|
// }
|
||||||
public static void drawHoveringText(@Nonnull final ItemStack stack, GuiGraphics graphics,
|
//
|
||||||
List<? extends FormattedText> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight,
|
// public static void drawHoveringText(@Nonnull final ItemStack stack, PoseStack graphics,
|
||||||
int maxTextWidth, Font font) {
|
// List<? extends FormattedText> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight,
|
||||||
drawHoveringText(stack, graphics, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth,
|
// int maxTextWidth, Font font) {
|
||||||
IForgeGuiGraphics.DEFAULT_BACKGROUND_COLOR, IForgeGuiGraphics.DEFAULT_BORDER_COLOR_START, IForgeGuiGraphics.DEFAULT_BORDER_COLOR_END,
|
// drawHoveringText(stack, graphics, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth,
|
||||||
font);
|
// IForgeGuiGraphics.DEFAULT_BACKGROUND_COLOR, IForgeGuiGraphics.DEFAULT_BORDER_COLOR_START, IForgeGuiGraphics.DEFAULT_BORDER_COLOR_END,
|
||||||
}
|
// font);
|
||||||
|
// }
|
||||||
public static void drawHoveringText(@Nonnull final ItemStack stack, GuiGraphics graphics,
|
//
|
||||||
List<? extends FormattedText> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight,
|
// public static void drawHoveringText(@Nonnull final ItemStack stack, PoseStack pStack,
|
||||||
int maxTextWidth, int backgroundColor, int borderColorStart, int borderColorEnd, Font font) {
|
// List<? extends FormattedText> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight,
|
||||||
if (textLines.isEmpty())
|
// int maxTextWidth, int backgroundColor, int borderColorStart, int borderColorEnd, Font font) {
|
||||||
return;
|
// if (textLines.isEmpty())
|
||||||
|
// return;
|
||||||
List<ClientTooltipComponent> list = ForgeHooksClient.gatherTooltipComponents(stack, textLines,
|
//
|
||||||
stack.getTooltipImage(), mouseX, screenWidth, screenHeight, font);
|
// List<ClientTooltipComponent> list = ForgeHooksClient.gatherTooltipComponents(stack, textLines,
|
||||||
RenderTooltipEvent.Pre event =
|
// stack.getTooltipImage(), mouseX, screenWidth, screenHeight, font);
|
||||||
new RenderTooltipEvent.Pre(stack, graphics, mouseX, mouseY, screenWidth, screenHeight, font, list, null);
|
// RenderTooltipEvent.Pre event =
|
||||||
if (MinecraftForge.EVENT_BUS.post(event))
|
// new RenderTooltipEvent.Pre(stack, pStack, mouseX, mouseY, screenWidth, screenHeight, font, list, null);
|
||||||
return;
|
// if (MinecraftForge.EVENT_BUS.post(event))
|
||||||
|
// return;
|
||||||
PoseStack pStack = graphics.pose();
|
//
|
||||||
|
// mouseX = event.getX();
|
||||||
mouseX = event.getX();
|
// mouseY = event.getY();
|
||||||
mouseY = event.getY();
|
// screenWidth = event.getScreenWidth();
|
||||||
screenWidth = event.getScreenWidth();
|
// screenHeight = event.getScreenHeight();
|
||||||
screenHeight = event.getScreenHeight();
|
// font = event.getFont();
|
||||||
font = event.getFont();
|
//
|
||||||
|
// // RenderSystem.disableRescaleNormal();
|
||||||
// RenderSystem.disableRescaleNormal();
|
// RenderSystem.disableDepthTest();
|
||||||
RenderSystem.disableDepthTest();
|
// int tooltipTextWidth = 0;
|
||||||
int tooltipTextWidth = 0;
|
//
|
||||||
|
// for (FormattedText textLine : textLines) {
|
||||||
for (FormattedText textLine : textLines) {
|
// int textLineWidth = font.width(textLine);
|
||||||
int textLineWidth = font.width(textLine);
|
// if (textLineWidth > tooltipTextWidth)
|
||||||
if (textLineWidth > tooltipTextWidth)
|
// tooltipTextWidth = textLineWidth;
|
||||||
tooltipTextWidth = textLineWidth;
|
// }
|
||||||
}
|
//
|
||||||
|
// boolean needsWrap = false;
|
||||||
boolean needsWrap = false;
|
//
|
||||||
|
// int titleLinesCount = 1;
|
||||||
int titleLinesCount = 1;
|
// int tooltipX = mouseX + 12;
|
||||||
int tooltipX = mouseX + 12;
|
// if (tooltipX + tooltipTextWidth + 4 > screenWidth) {
|
||||||
if (tooltipX + tooltipTextWidth + 4 > screenWidth) {
|
// tooltipX = mouseX - 16 - tooltipTextWidth;
|
||||||
tooltipX = mouseX - 16 - tooltipTextWidth;
|
// if (tooltipX < 4) // if the tooltip doesn't fit on the screen
|
||||||
if (tooltipX < 4) // if the tooltip doesn't fit on the screen
|
// {
|
||||||
{
|
// if (mouseX > screenWidth / 2)
|
||||||
if (mouseX > screenWidth / 2)
|
// tooltipTextWidth = mouseX - 12 - 8;
|
||||||
tooltipTextWidth = mouseX - 12 - 8;
|
// else
|
||||||
else
|
// tooltipTextWidth = screenWidth - 16 - mouseX;
|
||||||
tooltipTextWidth = screenWidth - 16 - mouseX;
|
// needsWrap = true;
|
||||||
needsWrap = true;
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//
|
||||||
|
// if (maxTextWidth > 0 && tooltipTextWidth > maxTextWidth) {
|
||||||
if (maxTextWidth > 0 && tooltipTextWidth > maxTextWidth) {
|
// tooltipTextWidth = maxTextWidth;
|
||||||
tooltipTextWidth = maxTextWidth;
|
// needsWrap = true;
|
||||||
needsWrap = true;
|
// }
|
||||||
}
|
//
|
||||||
|
// if (needsWrap) {
|
||||||
if (needsWrap) {
|
// int wrappedTooltipWidth = 0;
|
||||||
int wrappedTooltipWidth = 0;
|
// List<FormattedText> wrappedTextLines = new ArrayList<>();
|
||||||
List<FormattedText> wrappedTextLines = new ArrayList<>();
|
// for (int i = 0; i < textLines.size(); i++) {
|
||||||
for (int i = 0; i < textLines.size(); i++) {
|
// FormattedText textLine = textLines.get(i);
|
||||||
FormattedText textLine = textLines.get(i);
|
// List<FormattedText> wrappedLine = font.getSplitter()
|
||||||
List<FormattedText> wrappedLine = font.getSplitter()
|
// .splitLines(textLine, tooltipTextWidth, Style.EMPTY);
|
||||||
.splitLines(textLine, tooltipTextWidth, Style.EMPTY);
|
// if (i == 0)
|
||||||
if (i == 0)
|
// titleLinesCount = wrappedLine.size();
|
||||||
titleLinesCount = wrappedLine.size();
|
//
|
||||||
|
// for (FormattedText line : wrappedLine) {
|
||||||
for (FormattedText line : wrappedLine) {
|
// int lineWidth = font.width(line);
|
||||||
int lineWidth = font.width(line);
|
// if (lineWidth > wrappedTooltipWidth)
|
||||||
if (lineWidth > wrappedTooltipWidth)
|
// wrappedTooltipWidth = lineWidth;
|
||||||
wrappedTooltipWidth = lineWidth;
|
// wrappedTextLines.add(line);
|
||||||
wrappedTextLines.add(line);
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// tooltipTextWidth = wrappedTooltipWidth;
|
||||||
tooltipTextWidth = wrappedTooltipWidth;
|
// textLines = wrappedTextLines;
|
||||||
textLines = wrappedTextLines;
|
//
|
||||||
|
// if (mouseX > screenWidth / 2)
|
||||||
if (mouseX > screenWidth / 2)
|
// tooltipX = mouseX - 16 - tooltipTextWidth;
|
||||||
tooltipX = mouseX - 16 - tooltipTextWidth;
|
// else
|
||||||
else
|
// tooltipX = mouseX + 12;
|
||||||
tooltipX = mouseX + 12;
|
// }
|
||||||
}
|
//
|
||||||
|
// int tooltipY = mouseY - 12;
|
||||||
int tooltipY = mouseY - 12;
|
// int tooltipHeight = 8;
|
||||||
int tooltipHeight = 8;
|
//
|
||||||
|
// if (textLines.size() > 1) {
|
||||||
if (textLines.size() > 1) {
|
// tooltipHeight += (textLines.size() - 1) * 10;
|
||||||
tooltipHeight += (textLines.size() - 1) * 10;
|
// if (textLines.size() > titleLinesCount)
|
||||||
if (textLines.size() > titleLinesCount)
|
// tooltipHeight += 2; // gap between title lines and next lines
|
||||||
tooltipHeight += 2; // gap between title lines and next lines
|
// }
|
||||||
}
|
//
|
||||||
|
// if (tooltipY < 4)
|
||||||
if (tooltipY < 4)
|
// tooltipY = 4;
|
||||||
tooltipY = 4;
|
// else if (tooltipY + tooltipHeight + 4 > screenHeight)
|
||||||
else if (tooltipY + tooltipHeight + 4 > screenHeight)
|
// tooltipY = screenHeight - tooltipHeight - 4;
|
||||||
tooltipY = screenHeight - tooltipHeight - 4;
|
//
|
||||||
|
// final int zLevel = 400;
|
||||||
final int zLevel = 400;
|
// RenderTooltipEvent.Color colorEvent = new RenderTooltipEvent.Color(stack, pStack, 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);
|
||||||
MinecraftForge.EVENT_BUS.post(colorEvent);
|
// backgroundColor = colorEvent.getBackgroundStart();
|
||||||
backgroundColor = colorEvent.getBackgroundStart();
|
// borderColorStart = colorEvent.getBorderStart();
|
||||||
borderColorStart = colorEvent.getBorderStart();
|
// borderColorEnd = colorEvent.getBorderEnd();
|
||||||
borderColorEnd = colorEvent.getBorderEnd();
|
//
|
||||||
|
// pStack.pushPose();
|
||||||
pStack.pushPose();
|
// Matrix4f mat = pStack.last()
|
||||||
Matrix4f mat = pStack.last()
|
// .pose();
|
||||||
.pose();
|
// GuiComponent.fillGradient(pStack, tooltipX - 3, tooltipY - 4, tooltipX + tooltipTextWidth + 3,
|
||||||
graphics.fillGradient(tooltipX - 3, tooltipY - 4, tooltipX + tooltipTextWidth + 3,
|
// tooltipY - 3, zLevel, backgroundColor, backgroundColor);
|
||||||
tooltipY - 3, zLevel, backgroundColor, backgroundColor);
|
// GuiComponent.fillGradient(pStack, tooltipX - 3, tooltipY + tooltipHeight + 3,
|
||||||
graphics.fillGradient(tooltipX - 3, tooltipY + tooltipHeight + 3,
|
// tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 4, zLevel, backgroundColor, backgroundColor);
|
||||||
tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 4, zLevel, backgroundColor, backgroundColor);
|
// GuiComponent.fillGradient(pStack, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3,
|
||||||
graphics.fillGradient(tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3,
|
// tooltipY + tooltipHeight + 3, zLevel, backgroundColor, backgroundColor);
|
||||||
tooltipY + tooltipHeight + 3, zLevel, backgroundColor, backgroundColor);
|
// GuiComponent.fillGradient(pStack, tooltipX - 4, tooltipY - 3, tooltipX - 3, tooltipY + tooltipHeight + 3,
|
||||||
graphics.fillGradient(tooltipX - 4, tooltipY - 3, tooltipX - 3, tooltipY + tooltipHeight + 3,
|
// zLevel, backgroundColor, backgroundColor);
|
||||||
zLevel, backgroundColor, backgroundColor);
|
// GuiComponent.fillGradient(pStack, tooltipX + tooltipTextWidth + 3, tooltipY - 3,
|
||||||
graphics.fillGradient(tooltipX + tooltipTextWidth + 3, tooltipY - 3,
|
// tooltipX + tooltipTextWidth + 4, tooltipY + tooltipHeight + 3, zLevel, backgroundColor, backgroundColor);
|
||||||
tooltipX + tooltipTextWidth + 4, tooltipY + tooltipHeight + 3, zLevel, backgroundColor, backgroundColor);
|
// GuiComponent.fillGradient(pStack, tooltipX - 3, tooltipY - 3 + 1, tooltipX - 3 + 1,
|
||||||
graphics.fillGradient(tooltipX - 3, tooltipY - 3 + 1, tooltipX - 3 + 1,
|
// tooltipY + tooltipHeight + 3 - 1, zLevel, borderColorStart, borderColorEnd);
|
||||||
tooltipY + tooltipHeight + 3 - 1, zLevel, borderColorStart, borderColorEnd);
|
// GuiComponent.fillGradient(pStack, tooltipX + tooltipTextWidth + 2, tooltipY - 3 + 1,
|
||||||
graphics.fillGradient(tooltipX + tooltipTextWidth + 2, tooltipY - 3 + 1,
|
// tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3 - 1, zLevel, borderColorStart, borderColorEnd);
|
||||||
tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3 - 1, zLevel, borderColorStart, borderColorEnd);
|
// GuiComponent.fillGradient(pStack, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3,
|
||||||
graphics.fillGradient(tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3,
|
// tooltipY - 3 + 1, zLevel, borderColorStart, borderColorStart);
|
||||||
tooltipY - 3 + 1, zLevel, borderColorStart, borderColorStart);
|
// GuiComponent.fillGradient(pStack, 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 = MultiBufferSource.immediate(Tesselator.getInstance()
|
// .getBuilder());
|
||||||
.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) {
|
// ClientTooltipComponent line = list.get(lineNumber);
|
||||||
ClientTooltipComponent line = list.get(lineNumber);
|
//
|
||||||
|
// if (line != null)
|
||||||
if (line != null)
|
// line.renderText(font, tooltipX, tooltipY, mat, renderType);
|
||||||
line.renderText(font, tooltipX, tooltipY, mat, renderType);
|
//
|
||||||
|
// if (lineNumber + 1 == titleLinesCount)
|
||||||
if (lineNumber + 1 == titleLinesCount)
|
// tooltipY += 2;
|
||||||
tooltipY += 2;
|
//
|
||||||
|
// tooltipY += 10;
|
||||||
tooltipY += 10;
|
// }
|
||||||
}
|
//
|
||||||
|
// renderType.endBatch();
|
||||||
renderType.endBatch();
|
// pStack.popPose();
|
||||||
pStack.popPose();
|
//
|
||||||
|
// RenderSystem.enableDepthTest();
|
||||||
RenderSystem.enableDepthTest();
|
// }
|
||||||
}
|
//}
|
||||||
}
|
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import com.mojang.blaze3d.vertex.Tesselator;
|
|||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
import com.mojang.math.Axis;
|
import com.mojang.math.Axis;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
|
import net.minecraftforge.client.gui.ScreenUtils;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Couple;
|
import nl.requios.effortlessbuilding.create.foundation.utility.Couple;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
@@ -55,14 +55,14 @@ public class UIRenderHelper {
|
|||||||
GlStateManager._glBindFramebuffer(GlConst.GL_FRAMEBUFFER, dst.frameBufferId);
|
GlStateManager._glBindFramebuffer(GlConst.GL_FRAMEBUFFER, dst.frameBufferId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void streak(GuiGraphics graphics, float angle, int x, int y, int breadth, int length) {
|
public static void streak(PoseStack ms, float angle, int x, int y, int breadth, int length) {
|
||||||
streak(graphics, angle, x, y, breadth, length, Theme.i(Theme.Key.STREAK));
|
streak(ms, angle, x, y, breadth, length, Theme.i(Theme.Key.STREAK));
|
||||||
}
|
}
|
||||||
// angle in degrees; 0° -> fading to the right
|
// angle in degrees; 0° -> fading to the right
|
||||||
// x and y specify the middle point of the starting edge
|
// x and y specify the middle point of the starting edge
|
||||||
// breadth is the total width of the streak
|
// 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) {
|
public static void streak(PoseStack ms, float angle, int x, int y, int breadth, int length, int color) {
|
||||||
int a1 = 0xa0 << 24;
|
int a1 = 0xa0 << 24;
|
||||||
int a2 = 0x80 << 24;
|
int a2 = 0x80 << 24;
|
||||||
int a3 = 0x10 << 24;
|
int a3 = 0x10 << 24;
|
||||||
@@ -74,60 +74,59 @@ public class UIRenderHelper {
|
|||||||
int c3 = a3 | color;
|
int c3 = a3 | color;
|
||||||
int c4 = a4 | color;
|
int c4 = a4 | color;
|
||||||
|
|
||||||
PoseStack ms = graphics.pose();
|
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
ms.translate(x, y, 0);
|
ms.translate(x, y, 0);
|
||||||
ms.mulPose(Axis.ZP.rotationDegrees(angle - 90));
|
ms.mulPose(Axis.ZP.rotationDegrees(angle - 90));
|
||||||
|
|
||||||
streak(graphics, breadth / 2, length, c1, c2, c3, c4);
|
streak(ms, breadth / 2, length, c1, c2, c3, c4);
|
||||||
|
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void streak(GuiGraphics graphics, float angle, int x, int y, int breadth, int length, Color c) {
|
public static void streak(PoseStack ms, float angle, int x, int y, int breadth, int length, Color c) {
|
||||||
Color color = c.copy().setImmutable();
|
Color color = c.copy().setImmutable();
|
||||||
int c1 = color.scaleAlpha(0.625f).getRGB();
|
int c1 = color.scaleAlpha(0.625f).getRGB();
|
||||||
int c2 = color.scaleAlpha(0.5f).getRGB();
|
int c2 = color.scaleAlpha(0.5f).getRGB();
|
||||||
int c3 = color.scaleAlpha(0.0625f).getRGB();
|
int c3 = color.scaleAlpha(0.0625f).getRGB();
|
||||||
int c4 = color.scaleAlpha(0f).getRGB();
|
int c4 = color.scaleAlpha(0f).getRGB();
|
||||||
|
|
||||||
PoseStack ms = graphics.pose();
|
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
ms.translate(x, y, 0);
|
ms.translate(x, y, 0);
|
||||||
ms.mulPose(Axis.ZP.rotationDegrees(angle - 90));
|
ms.mulPose(Axis.ZP.rotationDegrees(angle - 90));
|
||||||
|
|
||||||
streak(graphics, breadth / 2, length, c1, c2, c3, c4);
|
streak(ms, breadth / 2, length, c1, c2, c3, c4);
|
||||||
|
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void streak(GuiGraphics graphics, int width, int height, int c1, int c2, int c3, int c4) {
|
private static void streak(PoseStack ms, int width, int height, int c1, int c2, int c3, int c4) {
|
||||||
double split1 = .5;
|
double split1 = .5;
|
||||||
double split2 = .75;
|
double split2 = .75;
|
||||||
graphics.fillGradient(-width, 0, width, (int) (split1 * height), 0, c1, c2);
|
Matrix4f model = ms.last().pose();
|
||||||
graphics.fillGradient(-width, (int) (split1 * height), width, (int) (split2 * height), 0, c2, c3);
|
ScreenUtils.drawGradientRect(model, -width, 0, width, (int) (split1 * height), 0, c1, c2);
|
||||||
graphics.fillGradient(-width, (int) (split2 * height), width, height, 0, c3, c4);
|
ScreenUtils.drawGradientRect(model, -width, (int) (split1 * height), width, (int) (split2 * height), 0, c2, c3);
|
||||||
|
ScreenUtils.drawGradientRect(model, -width, (int) (split2 * height), width, height, 0, c3, c4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see #angledGradient(GuiGraphics, float, int, int, int, int, int, Color, Color)
|
* @see #angledGradient(PoseStack, 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) {
|
public static void angledGradient(PoseStack ms, float angle, int x, int y, int breadth, int length, Couple<Color> c) {
|
||||||
angledGradient(graphics, angle, x, y, 0, breadth, length, c);
|
angledGradient(ms, angle, x, y, 0, breadth, length, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see #angledGradient(GuiGraphics, float, int, int, int, int, int, Color, Color)
|
* @see #angledGradient(PoseStack, 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) {
|
public static void angledGradient(PoseStack ms, 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());
|
angledGradient(ms, angle, x, y, z, breadth, length, c.getFirst(), c.getSecond());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see #angledGradient(GuiGraphics, float, int, int, int, int, int, Color, Color)
|
* @see #angledGradient(PoseStack, 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) {
|
public static void angledGradient(PoseStack ms, float angle, int x, int y, int breadth, int length, Color color1, Color color2) {
|
||||||
angledGradient(graphics, angle, x, y, 0, breadth, length, color1, color2);
|
angledGradient(ms, angle, x, y, 0, breadth, length, color1, color2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,32 +137,31 @@ public class UIRenderHelper {
|
|||||||
* @param color2 the color at the ending edge
|
* @param color2 the color at the ending edge
|
||||||
* @param breadth the total width of the gradient
|
* @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) {
|
public static void angledGradient(PoseStack ms, float angle, int x, int y, int z, int breadth, int length, Color color1, Color color2) {
|
||||||
PoseStack ms = graphics.pose();
|
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
ms.translate(x, y, z);
|
ms.translate(x, y, z);
|
||||||
ms.mulPose(Axis.ZP.rotationDegrees(angle - 90));
|
ms.mulPose(Axis.ZP.rotationDegrees(angle - 90));
|
||||||
|
|
||||||
int w = breadth / 2;
|
int w = breadth / 2;
|
||||||
graphics.fillGradient(-w, 0, w, length, 0, color1.getRGB(), color2.getRGB());
|
Matrix4f model = ms.last().pose();
|
||||||
|
ScreenUtils.drawGradientRect(model, -w, 0, w, length, 0, color1.getRGB(), color2.getRGB());
|
||||||
|
|
||||||
ms.popPose();
|
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());}
|
public static void breadcrumbArrow(PoseStack ms, int x, int y, int z, int width, int height, int indent, Couple<Color> colors) {breadcrumbArrow(ms, x, y, z, width, height, indent, colors.getFirst(), colors.getSecond());}
|
||||||
|
|
||||||
// draws a wide chevron-style breadcrumb arrow pointing left
|
// 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) {
|
public static void breadcrumbArrow(PoseStack ms, int x, int y, int z, int width, int height, int indent, Color startColor, Color endColor) {
|
||||||
PoseStack matrixStack = graphics.pose();
|
ms.pushPose();
|
||||||
matrixStack.pushPose();
|
ms.translate(x - indent, y, z);
|
||||||
matrixStack.translate(x - indent, y, z);
|
|
||||||
|
|
||||||
breadcrumbArrow(graphics, width, height, indent, startColor, endColor);
|
breadcrumbArrow(ms, width, height, indent, startColor, endColor);
|
||||||
|
|
||||||
matrixStack.popPose();
|
ms.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void breadcrumbArrow(GuiGraphics graphics, int width, int height, int indent, Color c1, Color c2) {
|
private static void breadcrumbArrow(PoseStack ms, int width, int height, int indent, Color c1, Color c2) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 0,0 x1,y1 ********************* x4,y4 ***** x7,y7
|
* 0,0 x1,y1 ********************* x4,y4 ***** x7,y7
|
||||||
@@ -201,7 +199,7 @@ public class UIRenderHelper {
|
|||||||
|
|
||||||
Tesselator tessellator = Tesselator.getInstance();
|
Tesselator tessellator = Tesselator.getInstance();
|
||||||
BufferBuilder bufferbuilder = tessellator.getBuilder();
|
BufferBuilder bufferbuilder = tessellator.getBuilder();
|
||||||
Matrix4f model = graphics.pose().last().pose();
|
Matrix4f model = ms.last().pose();
|
||||||
bufferbuilder.begin(VertexFormat.Mode.TRIANGLES, DefaultVertexFormat.POSITION_COLOR);
|
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, x0, y0, 0).color(fc1.getRed(), fc1.getGreen(), fc1.getBlue(), fc1.getAlpha()).endVertex();
|
||||||
@@ -235,30 +233,30 @@ public class UIRenderHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//just like AbstractGui#drawTexture, but with a color at every vertex
|
//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) {
|
public static void drawColoredTexture(PoseStack ms, 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);
|
drawColoredTexture(ms, 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) {
|
public static void drawColoredTexture(PoseStack ms, 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);
|
drawColoredTexture(ms, 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) {
|
public static void drawStretched(PoseStack ms, int left, int top, int w, int h, int z, AllGuiTextures tex) {
|
||||||
tex.bind();
|
tex.bind();
|
||||||
drawTexturedQuad(graphics.pose().last()
|
drawTexturedQuad(ms.last()
|
||||||
.pose(), Color.WHITE, left, left + w, top, top + h, z, tex.startX / 256f, (tex.startX + tex.width) / 256f,
|
.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);
|
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) {
|
public static void drawCropped(PoseStack ms, int left, int top, int w, int h, int z, AllGuiTextures tex) {
|
||||||
tex.bind();
|
tex.bind();
|
||||||
drawTexturedQuad(graphics.pose().last()
|
drawTexturedQuad(ms.last()
|
||||||
.pose(), Color.WHITE, left, left + w, top, top + h, z, tex.startX / 256f, (tex.startX + w) / 256f,
|
.pose(), Color.WHITE, left, left + w, top, top + h, z, tex.startX / 256f, (tex.startX + w) / 256f,
|
||||||
tex.startY / 256f, (tex.startY + h) / 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) {
|
private static void drawColoredTexture(PoseStack ms, 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);
|
drawTexturedQuad(ms.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) {
|
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) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.container;
|
package nl.requios.effortlessbuilding.create.foundation.gui.container;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.InputConstants;
|
import com.mojang.blaze3d.platform.InputConstants;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
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;
|
||||||
import net.minecraft.client.gui.components.Renderable;
|
import net.minecraft.client.gui.components.Renderable;
|
||||||
@@ -91,26 +91,26 @@ public abstract class AbstractSimiContainerScreen<T extends AbstractContainerMen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
partialTicks = minecraft.getFrameTime();
|
partialTicks = minecraft.getFrameTime();
|
||||||
|
|
||||||
renderBackground(graphics);
|
renderBackground(ms);
|
||||||
|
|
||||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
super.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
renderForeground(graphics, mouseX, mouseY, partialTicks);
|
renderForeground(ms, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) {
|
protected void renderLabels(PoseStack ms, int mouseX, int mouseY) {
|
||||||
// no-op to prevent screen- and inventory-title from being rendered at incorrect
|
// no-op to prevent screen- and inventory-title from being rendered at incorrect
|
||||||
// location
|
// location
|
||||||
// could also set this.titleX/Y and this.playerInventoryTitleX/Y to the proper
|
// could also set this.titleX/Y and this.playerInventoryTitleX/Y to the proper
|
||||||
// values instead
|
// values instead
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderForeground(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
protected void renderForeground(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
renderTooltip(graphics, mouseX, mouseY);
|
renderTooltip(ms, mouseX, mouseY);
|
||||||
for (Renderable widget : renderables) {
|
for (Renderable widget : renderables) {
|
||||||
if (widget instanceof AbstractSimiWidget simiWidget && simiWidget.isMouseOver(mouseX, mouseY)) {
|
if (widget instanceof AbstractSimiWidget simiWidget && simiWidget.isMouseOver(mouseX, mouseY)) {
|
||||||
List<Component> tooltip = simiWidget.getToolTip();
|
List<Component> tooltip = simiWidget.getToolTip();
|
||||||
@@ -118,7 +118,7 @@ public abstract class AbstractSimiContainerScreen<T extends AbstractContainerMen
|
|||||||
continue;
|
continue;
|
||||||
int ttx = simiWidget.lockedTooltipX == -1 ? mouseX : simiWidget.lockedTooltipX + simiWidget.getX();
|
int ttx = simiWidget.lockedTooltipX == -1 ? mouseX : simiWidget.lockedTooltipX + simiWidget.getX();
|
||||||
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);
|
renderComponentTooltip(ms, tooltip, ttx, tty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -127,7 +127,7 @@ 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(PoseStack 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);
|
||||||
// }
|
// }
|
||||||
@@ -167,14 +167,14 @@ public abstract class AbstractSimiContainerScreen<T extends AbstractContainerMen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
protected void debugWindowArea(GuiGraphics graphics) {
|
protected void debugWindowArea(PoseStack ms) {
|
||||||
graphics.fill(leftPos + imageWidth, topPos + imageHeight, leftPos, topPos, 0xD3D3D3D3);
|
fill(ms, leftPos + imageWidth, topPos + imageHeight, leftPos, topPos, 0xD3D3D3D3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
protected void debugExtraAreas(GuiGraphics graphics) {
|
protected void debugExtraAreas(PoseStack ms) {
|
||||||
for (Rect2i area : getExtraAreas()) {
|
for (Rect2i area : getExtraAreas()) {
|
||||||
graphics.fill(area.getX() + area.getWidth(), area.getY() + area.getHeight(), area.getX(), area.getY(),
|
fill(ms, area.getX() + area.getWidth(), area.getY() + area.getHeight(), area.getX(), area.getY(),
|
||||||
0xD3D3D3D3);
|
0xD3D3D3D3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
|||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.mojang.blaze3d.vertex.Tesselator;
|
import com.mojang.blaze3d.vertex.Tesselator;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Couple;
|
import nl.requios.effortlessbuilding.create.foundation.utility.Couple;
|
||||||
@@ -65,8 +64,8 @@ public class BoxElement extends RenderElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics graphics) {
|
public void render(PoseStack ms) {
|
||||||
renderBox(graphics.pose());
|
renderBox(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
//total box width = 1 * 2 (outer border) + 1 * 2 (inner color border) + 2 * borderOffset + width
|
//total box width = 1 * 2 (outer border) + 1 * 2 (inner color border) + 2 * borderOffset + width
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import javax.annotation.Nonnull;
|
|||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
|
|
||||||
public class CombinedStencilElement extends StencilElement {
|
public class CombinedStencilElement extends StencilElement {
|
||||||
|
|
||||||
private StencilElement element1;
|
private StencilElement element1;
|
||||||
@@ -45,22 +43,21 @@ public class CombinedStencilElement extends StencilElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderStencil(GuiGraphics graphics) {
|
protected void renderStencil(PoseStack ms) {
|
||||||
PoseStack ms = graphics.pose();
|
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
element1.transform(ms);
|
element1.transform(ms);
|
||||||
element1.withBounds(width, height);
|
element1.withBounds(width, height);
|
||||||
element1.renderStencil(graphics);
|
element1.renderStencil(ms);
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
element2.transform(ms);
|
element2.transform(ms);
|
||||||
element2.withBounds(width, height);
|
element2.withBounds(width, height);
|
||||||
element2.renderStencil(graphics);
|
element2.renderStencil(ms);
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderElement(GuiGraphics graphics) {
|
protected void renderElement(PoseStack graphics) {
|
||||||
if (mode.rendersFirst())
|
if (mode.rendersFirst())
|
||||||
element1.<StencilElement>withBounds(width, height).renderElement(graphics);
|
element1.<StencilElement>withBounds(width, height).renderElement(graphics);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.UIRenderHelper;
|
import nl.requios.effortlessbuilding.create.foundation.gui.UIRenderHelper;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||||
|
|
||||||
@@ -35,18 +35,18 @@ public class DelegatedStencilElement extends StencilElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderStencil(GuiGraphics graphics) {
|
protected void renderStencil(PoseStack ms) {
|
||||||
stencil.render(graphics, width, height, 1);
|
stencil.render(ms, width, height, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderElement(GuiGraphics graphics) {
|
protected void renderElement(PoseStack ms) {
|
||||||
element.render(graphics, width, height, alpha);
|
element.render(ms, width, height, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface ElementRenderer {
|
public interface ElementRenderer {
|
||||||
void render(GuiGraphics graphics, int width, int height, float alpha);
|
void render(PoseStack ms, int width, int height, float alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.core.PartialModel;
|
||||||
|
import com.jozufozu.flywheel.core.model.ModelUtil;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager.DestFactor;
|
import com.mojang.blaze3d.platform.GlStateManager.DestFactor;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager.SourceFactor;
|
import com.mojang.blaze3d.platform.GlStateManager.SourceFactor;
|
||||||
import com.mojang.blaze3d.platform.Lighting;
|
import com.mojang.blaze3d.platform.Lighting;
|
||||||
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.math.Axis;
|
import com.mojang.math.Axis;
|
||||||
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
|
|
||||||
import net.createmod.ponder.render.VirtualRenderHelper;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
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;
|
||||||
@@ -161,8 +160,7 @@ public class GuiGameElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics graphics) {
|
public void render(PoseStack matrixStack) {
|
||||||
PoseStack matrixStack = graphics.pose();
|
|
||||||
prepareMatrix(matrixStack);
|
prepareMatrix(matrixStack);
|
||||||
|
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
@@ -184,19 +182,19 @@ public class GuiGameElement {
|
|||||||
RenderType renderType = Sheets.translucentCullBlockSheet();
|
RenderType renderType = Sheets.translucentCullBlockSheet();
|
||||||
blockRenderer.getModelRenderer()
|
blockRenderer.getModelRenderer()
|
||||||
.renderModel(ms.last(), buffer.getBuffer(renderType), blockState, blockModel, 1, 1, 1,
|
.renderModel(ms.last(), buffer.getBuffer(renderType), blockState, blockModel, 1, 1, 1,
|
||||||
LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, VirtualRenderHelper.VIRTUAL_DATA, null);
|
LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, ModelUtil.VIRTUAL_DATA, null);
|
||||||
} else {
|
} else {
|
||||||
int color = Minecraft.getInstance()
|
int color = Minecraft.getInstance()
|
||||||
.getBlockColors()
|
.getBlockColors()
|
||||||
.getColor(blockState, null, null, 0);
|
.getColor(blockState, null, null, 0);
|
||||||
Color rgb = new Color(color == -1 ? this.color : color);
|
Color rgb = new Color(color == -1 ? this.color : color);
|
||||||
|
|
||||||
for (RenderType chunkType : blockModel.getRenderTypes(blockState, RandomSource.create(42L), VirtualRenderHelper.VIRTUAL_DATA)) {
|
for (RenderType chunkType : blockModel.getRenderTypes(blockState, RandomSource.create(42L), ModelUtil.VIRTUAL_DATA)) {
|
||||||
RenderType renderType = RenderTypeHelper.getEntityRenderType(chunkType, true);
|
RenderType renderType = RenderTypeHelper.getEntityRenderType(chunkType, true);
|
||||||
blockRenderer.getModelRenderer()
|
blockRenderer.getModelRenderer()
|
||||||
.renderModel(ms.last(), buffer.getBuffer(renderType), blockState, blockModel,
|
.renderModel(ms.last(), buffer.getBuffer(renderType), blockState, blockModel,
|
||||||
rgb.getRedAsFloat(), rgb.getGreenAsFloat(), rgb.getBlueAsFloat(),
|
rgb.getRedAsFloat(), rgb.getGreenAsFloat(), rgb.getBlueAsFloat(),
|
||||||
LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, VirtualRenderHelper.VIRTUAL_DATA, chunkType);
|
LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, ModelUtil.VIRTUAL_DATA, chunkType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,8 +254,7 @@ public class GuiGameElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics graphics) {
|
public void render(PoseStack matrixStack) {
|
||||||
PoseStack matrixStack = graphics.pose();
|
|
||||||
prepareMatrix(matrixStack);
|
prepareMatrix(matrixStack);
|
||||||
transformMatrix(matrixStack);
|
transformMatrix(matrixStack);
|
||||||
renderItemIntoGUI(matrixStack, stack, customLighting == null);
|
renderItemIntoGUI(matrixStack, stack, customLighting == null);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
|
||||||
public abstract class RenderElement implements ScreenElement {
|
public abstract class RenderElement implements ScreenElement {
|
||||||
|
|
||||||
public static final RenderElement EMPTY = new RenderElement() {
|
public static final RenderElement EMPTY = new RenderElement() {
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics graphics) {
|
public void render(PoseStack ms) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -66,11 +66,11 @@ public abstract class RenderElement implements ScreenElement {
|
|||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void render(GuiGraphics graphics);
|
public abstract void render(PoseStack ms);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics graphics, int x, int y) {
|
public void render(PoseStack ms, int x, int y) {
|
||||||
this.at(x, y).render(graphics);
|
this.at(x, y).render(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SimpleRenderElement extends RenderElement {
|
public static class SimpleRenderElement extends RenderElement {
|
||||||
@@ -82,8 +82,8 @@ public abstract class RenderElement implements ScreenElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics graphics) {
|
public void render(PoseStack ms) {
|
||||||
renderable.render(graphics, (int) x, (int) y);
|
renderable.render(ms, (int) x, (int) y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
public interface ScreenElement {
|
public interface ScreenElement {
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
void render(GuiGraphics graphics, int x, int y);
|
void render(PoseStack poseStack, int x, int y);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,26 +6,24 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
|||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
|
|
||||||
public abstract class StencilElement extends RenderElement {
|
public abstract class StencilElement extends RenderElement {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics graphics) {
|
public void render(PoseStack ms) {
|
||||||
PoseStack ms = graphics.pose();
|
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
transform(ms);
|
transform(ms);
|
||||||
prepareStencil(ms);
|
prepareStencil(ms);
|
||||||
renderStencil(graphics);
|
renderStencil(ms);
|
||||||
prepareElement(ms);
|
prepareElement(ms);
|
||||||
renderElement(graphics);
|
renderElement(ms);
|
||||||
cleanUp(ms);
|
cleanUp(ms);
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void renderStencil(GuiGraphics graphics);
|
protected abstract void renderStencil(PoseStack graphics);
|
||||||
|
|
||||||
protected abstract void renderElement(GuiGraphics graphics);
|
protected abstract void renderElement(PoseStack graphics);
|
||||||
|
|
||||||
protected void transform(PoseStack ms) {
|
protected void transform(PoseStack ms) {
|
||||||
ms.translate(x, y, z);
|
ms.translate(x, y, z);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
|||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.gui.Font;
|
import net.minecraft.client.gui.Font;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
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.Components;
|
||||||
|
|
||||||
@@ -46,7 +45,7 @@ public class TextStencilElement extends DelegatedStencilElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderStencil(GuiGraphics graphics) {
|
protected void renderStencil(PoseStack ms) {
|
||||||
float x = 0, y = 0;
|
float x = 0, y = 0;
|
||||||
if (centerHorizontally)
|
if (centerHorizontally)
|
||||||
x = width / 2f - font.width(component) / 2f;
|
x = width / 2f - font.width(component) / 2f;
|
||||||
@@ -54,11 +53,11 @@ public class TextStencilElement extends DelegatedStencilElement {
|
|||||||
if (centerVertically)
|
if (centerVertically)
|
||||||
y = height / 2f - (font.lineHeight - 1) / 2f;
|
y = height / 2f - (font.lineHeight - 1) / 2f;
|
||||||
|
|
||||||
graphics.drawString(font, component, Math.round(x), Math.round(y), 0xff_000000, false);
|
font.draw(ms, component, Math.round(x), Math.round(y), 0xff_000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderElement(GuiGraphics graphics) {
|
protected void renderElement(PoseStack ms) {
|
||||||
float x = 0, y = 0;
|
float x = 0, y = 0;
|
||||||
if (centerHorizontally)
|
if (centerHorizontally)
|
||||||
x = width / 2f - font.width(component) / 2f;
|
x = width / 2f - font.width(component) / 2f;
|
||||||
@@ -66,10 +65,9 @@ public class TextStencilElement extends DelegatedStencilElement {
|
|||||||
if (centerVertically)
|
if (centerVertically)
|
||||||
y = height / 2f - (font.lineHeight - 1) / 2f;
|
y = height / 2f - (font.lineHeight - 1) / 2f;
|
||||||
|
|
||||||
PoseStack ms = graphics.pose();
|
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
ms.translate(x, y, 0);
|
ms.translate(x, y, 0);
|
||||||
element.render(graphics, font.width(component), font.lineHeight + 2, alpha);
|
element.render(ms, font.width(component), font.lineHeight + 2, alpha);
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
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.ClientTooltipPositioner;
|
||||||
@@ -68,22 +68,22 @@ public abstract class AbstractSimiWidget extends AbstractWidget implements Ticka
|
|||||||
public void tick() {}
|
public void tick() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderWidget(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
public void renderWidget(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
beforeRender(graphics, mouseX, mouseY, partialTicks);
|
beforeRender(ms, mouseX, mouseY, partialTicks);
|
||||||
doRender(graphics, mouseX, mouseY, partialTicks);
|
doRender(ms, mouseX, mouseY, partialTicks);
|
||||||
afterRender(graphics, mouseX, mouseY, partialTicks);
|
afterRender(ms, mouseX, mouseY, partialTicks);
|
||||||
wasHovered = isHoveredOrFocused();
|
wasHovered = isHoveredOrFocused();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void beforeRender(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
protected void beforeRender(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
graphics.pose().pushPose();
|
ms.pushPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doRender(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
protected void doRender(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void afterRender(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
protected void afterRender(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
graphics.pose().popPose();
|
ms.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runCallback(double mouseX, double mouseY) {
|
public void runCallback(double mouseX, double mouseY) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.Theme;
|
import nl.requios.effortlessbuilding.create.foundation.gui.Theme;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.UIRenderHelper;
|
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.BoxElement;
|
||||||
@@ -96,8 +96,8 @@ public class BoxWidget extends ElementWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void beforeRender(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
protected void beforeRender(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
super.beforeRender(graphics, mouseX, mouseY, partialTicks);
|
super.beforeRender(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
if (isHovered != wasHovered) {
|
if (isHovered != wasHovered) {
|
||||||
startGradientAnimation(
|
startGradientAnimation(
|
||||||
@@ -119,7 +119,7 @@ public class BoxWidget extends ElementWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doRender(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
public void doRender(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
float fadeValue = fade.getValue(partialTicks);
|
float fadeValue = fade.getValue(partialTicks);
|
||||||
if (fadeValue < .1f)
|
if (fadeValue < .1f)
|
||||||
return;
|
return;
|
||||||
@@ -129,9 +129,9 @@ public class BoxWidget extends ElementWidget {
|
|||||||
.gradientBorder(gradientColor1, gradientColor2)
|
.gradientBorder(gradientColor1, gradientColor2)
|
||||||
.at(getX(), getY(), z)
|
.at(getX(), getY(), z)
|
||||||
.withBounds(width, height)
|
.withBounds(width, height)
|
||||||
.render(graphics);
|
.render(ms);
|
||||||
|
|
||||||
super.doRender(graphics, mouseX, mouseY, partialTicks);
|
super.doRender(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
wasHovered = isHovered;
|
wasHovered = isHovered;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.RenderElement;
|
import nl.requios.effortlessbuilding.create.foundation.gui.element.RenderElement;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.ScreenElement;
|
import nl.requios.effortlessbuilding.create.foundation.gui.element.ScreenElement;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.animation.LerpedFloat;
|
import nl.requios.effortlessbuilding.create.foundation.utility.animation.LerpedFloat;
|
||||||
@@ -117,20 +116,19 @@ public class ElementWidget extends AbstractSimiWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void beforeRender(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
protected void beforeRender(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
super.beforeRender(graphics, mouseX, mouseY, partialTicks);
|
super.beforeRender(ms, mouseX, mouseY, partialTicks);
|
||||||
isHovered = isMouseOver(mouseX, mouseY);
|
isHovered = isMouseOver(mouseX, mouseY);
|
||||||
|
|
||||||
float fadeValue = fade.getValue(partialTicks);
|
float fadeValue = fade.getValue(partialTicks);
|
||||||
element.withAlpha(fadeValue);
|
element.withAlpha(fadeValue);
|
||||||
if (fadeValue < 1) {
|
if (fadeValue < 1) {
|
||||||
graphics.pose().translate((1 - fadeValue) * fadeModX, (1 - fadeValue) * fadeModY, 0);
|
ms.translate((1 - fadeValue) * fadeModX, (1 - fadeValue) * fadeModY, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doRender(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
public void doRender(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
PoseStack ms = graphics.pose();
|
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
ms.translate(getX() + paddingX, getY() + paddingY, z);
|
ms.translate(getX() + paddingX, getY() + paddingY, z);
|
||||||
float innerWidth = width - 2 * paddingX;
|
float innerWidth = width - 2 * paddingX;
|
||||||
@@ -144,7 +142,7 @@ public class ElementWidget extends AbstractSimiWidget {
|
|||||||
innerWidth /= xScale;
|
innerWidth /= xScale;
|
||||||
innerHeight /= yScale;
|
innerHeight /= yScale;
|
||||||
}
|
}
|
||||||
element.withBounds((int) innerWidth, (int) innerHeight).render(graphics);
|
element.withBounds((int) innerWidth, (int) innerHeight).render(ms);
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
if (rescaleElement) {
|
if (rescaleElement) {
|
||||||
element.at(eX, eY);
|
element.at(eX, eY);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
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 net.minecraft.client.gui.GuiGraphics;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.AllGuiTextures;
|
import nl.requios.effortlessbuilding.create.foundation.gui.AllGuiTextures;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.ScreenElement;
|
import nl.requios.effortlessbuilding.create.foundation.gui.element.ScreenElement;
|
||||||
@@ -20,7 +20,7 @@ public class IconButton extends AbstractSimiWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doRender(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
public void doRender(PoseStack ms, 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;
|
||||||
|
|
||||||
@@ -28,13 +28,14 @@ public class IconButton extends AbstractSimiWidget {
|
|||||||
: isMouseOver(mouseX, mouseY) ? AllGuiTextures.BUTTON_HOVER : AllGuiTextures.BUTTON;
|
: isMouseOver(mouseX, mouseY) ? AllGuiTextures.BUTTON_HOVER : AllGuiTextures.BUTTON;
|
||||||
|
|
||||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
drawBg(graphics, button);
|
drawBg(ms, button);
|
||||||
icon.render(graphics, getX() + 1, getY() + 1);
|
icon.render(ms, getX() + 1, getY() + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawBg(GuiGraphics graphics, AllGuiTextures button) {
|
protected void drawBg(PoseStack ms, AllGuiTextures button) {
|
||||||
graphics.blit(button.location, getX(), getY(), button.startX, button.startY, button.width, button.height);
|
AllGuiTextures.BUTTON.bind();
|
||||||
|
blit(ms, getX(), getY(), button.startX, button.startY, button.width, button.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setToolTip(Component text) {
|
public void setToolTip(Component text) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
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 net.minecraft.client.gui.GuiGraphics;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.AllGuiTextures;
|
import nl.requios.effortlessbuilding.create.foundation.gui.AllGuiTextures;
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ public class Indicator extends AbstractSimiWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks ) {
|
public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks ) {
|
||||||
if (!visible)
|
if (!visible)
|
||||||
return;
|
return;
|
||||||
AllGuiTextures toDraw;
|
AllGuiTextures toDraw;
|
||||||
@@ -28,7 +28,7 @@ public class Indicator extends AbstractSimiWidget {
|
|||||||
case GREEN: toDraw = AllGuiTextures.INDICATOR_GREEN; break;
|
case GREEN: toDraw = AllGuiTextures.INDICATOR_GREEN; break;
|
||||||
default: toDraw = AllGuiTextures.INDICATOR; break;
|
default: toDraw = AllGuiTextures.INDICATOR; break;
|
||||||
}
|
}
|
||||||
toDraw.render(graphics, getX(), getY());
|
toDraw.render(ms, getX(), getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum State {
|
public enum State {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
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 com.mojang.blaze3d.vertex.PoseStack;
|
||||||
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.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.Components;
|
||||||
@@ -70,7 +70,7 @@ public class Label extends AbstractSimiWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doRender(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
protected void doRender(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
if (text == null || text.getString().isEmpty())
|
if (text == null || text.getString().isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -79,7 +79,10 @@ public class Label extends AbstractSimiWidget {
|
|||||||
if (suffix != null && !suffix.isEmpty())
|
if (suffix != null && !suffix.isEmpty())
|
||||||
copy.append(suffix);
|
copy.append(suffix);
|
||||||
|
|
||||||
graphics.drawString(font, copy, getX(), getY(), color, hasShadow);
|
if (hasShadow)
|
||||||
|
font.drawShadow(ms, copy, getX(), getY(), color);
|
||||||
|
else
|
||||||
|
font.draw(ms, copy, getX(), getY(), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
public class TooltipArea extends AbstractSimiWidget {
|
public class TooltipArea extends AbstractSimiWidget {
|
||||||
@@ -12,7 +12,7 @@ public class TooltipArea extends AbstractSimiWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
public void renderWidget(PoseStack 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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ public class ItemHelper {
|
|||||||
return true;
|
return true;
|
||||||
if (stacks1.length == stacks2.length) {
|
if (stacks1.length == stacks2.length) {
|
||||||
for (int i = 0; i < stacks1.length; i++)
|
for (int i = 0; i < stacks1.length; i++)
|
||||||
if (!ItemStack.isSameItem(stacks1[i], stacks2[i]))
|
if (!ItemStack.isSame(stacks1[i], stacks2[i]))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package nl.requios.effortlessbuilding.create.foundation.render;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.core.model.ModelUtil;
|
||||||
|
import com.jozufozu.flywheel.util.Pair;
|
||||||
|
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
|
||||||
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
|
public class BakedModelRenderHelper {
|
||||||
|
|
||||||
|
public static SuperByteBuffer standardBlockRender(BlockState renderedState) {
|
||||||
|
BlockRenderDispatcher dispatcher = Minecraft.getInstance()
|
||||||
|
.getBlockRenderer();
|
||||||
|
return standardModelRender(dispatcher.getBlockModel(renderedState), renderedState);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SuperByteBuffer standardModelRender(BakedModel model, BlockState referenceState) {
|
||||||
|
return standardModelRender(model, referenceState, new PoseStack());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SuperByteBuffer standardModelRender(BakedModel model, BlockState referenceState, PoseStack ms) {
|
||||||
|
Pair<BufferBuilder.RenderedBuffer, Integer> pair = ModelUtil.getBufferBuilder(model, referenceState, ms);
|
||||||
|
return new SuperByteBuffer(pair.first(), pair.second());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
package nl.requios.effortlessbuilding.create.foundation.render;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.core.PartialModel;
|
||||||
|
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import nl.requios.effortlessbuilding.create.CreateClient;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.render.SuperByteBufferCache.Compartment;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.AngleHelper;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import static net.minecraft.world.level.block.state.properties.BlockStateProperties.FACING;
|
||||||
|
|
||||||
|
public class CachedBufferer {
|
||||||
|
|
||||||
|
public static final Compartment<BlockState> GENERIC_TILE = new Compartment<>();
|
||||||
|
public static final Compartment<PartialModel> PARTIAL = new Compartment<>();
|
||||||
|
public static final Compartment<Pair<Direction, PartialModel>> DIRECTIONAL_PARTIAL = new Compartment<>();
|
||||||
|
|
||||||
|
public static SuperByteBuffer block(BlockState toRender) {
|
||||||
|
return block(GENERIC_TILE, toRender);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SuperByteBuffer block(Compartment<BlockState> compartment, BlockState toRender) {
|
||||||
|
return CreateClient.BUFFER_CACHE.get(compartment, toRender, () -> BakedModelRenderHelper.standardBlockRender(toRender));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SuperByteBuffer partial(PartialModel partial, BlockState referenceState) {
|
||||||
|
return CreateClient.BUFFER_CACHE.get(PARTIAL, partial,
|
||||||
|
() -> BakedModelRenderHelper.standardModelRender(partial.get(), referenceState));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SuperByteBuffer partial(PartialModel partial, BlockState referenceState,
|
||||||
|
Supplier<PoseStack> modelTransform) {
|
||||||
|
return CreateClient.BUFFER_CACHE.get(PARTIAL, partial,
|
||||||
|
() -> BakedModelRenderHelper.standardModelRender(partial.get(), referenceState, modelTransform.get()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SuperByteBuffer partialFacing(PartialModel partial, BlockState referenceState) {
|
||||||
|
Direction facing = referenceState.getValue(FACING);
|
||||||
|
return partialFacing(partial, referenceState, facing);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SuperByteBuffer partialFacing(PartialModel partial, BlockState referenceState, Direction facing) {
|
||||||
|
return partialDirectional(partial, referenceState, facing,
|
||||||
|
rotateToFace(facing));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SuperByteBuffer partialFacingVertical(PartialModel partial, BlockState referenceState, Direction facing) {
|
||||||
|
return partialDirectional(partial, referenceState, facing,
|
||||||
|
rotateToFaceVertical(facing));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SuperByteBuffer partialDirectional(PartialModel partial, BlockState referenceState, Direction dir,
|
||||||
|
Supplier<PoseStack> modelTransform) {
|
||||||
|
return CreateClient.BUFFER_CACHE.get(DIRECTIONAL_PARTIAL, Pair.of(dir, partial),
|
||||||
|
() -> BakedModelRenderHelper.standardModelRender(partial.get(), referenceState, modelTransform.get()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Supplier<PoseStack> rotateToFace(Direction facing) {
|
||||||
|
return () -> {
|
||||||
|
PoseStack stack = new PoseStack();
|
||||||
|
TransformStack.cast(stack)
|
||||||
|
.centre()
|
||||||
|
.rotateY(AngleHelper.horizontalAngle(facing))
|
||||||
|
.rotateX(AngleHelper.verticalAngle(facing))
|
||||||
|
.unCentre();
|
||||||
|
return stack;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Supplier<PoseStack> rotateToFaceVertical(Direction facing) {
|
||||||
|
return () -> {
|
||||||
|
PoseStack stack = new PoseStack();
|
||||||
|
TransformStack.cast(stack)
|
||||||
|
.centre()
|
||||||
|
.rotateY(AngleHelper.horizontalAngle(facing))
|
||||||
|
.rotateX(AngleHelper.verticalAngle(facing) + 90)
|
||||||
|
.unCentre();
|
||||||
|
return stack;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package nl.requios.effortlessbuilding.create.foundation.render;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.util.DiffuseLightCalculator;
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public final class ForcedDiffuseState {
|
||||||
|
private static final ThreadLocal<ObjectArrayList<DiffuseLightCalculator>> FORCED_DIFFUSE = ThreadLocal.withInitial(ObjectArrayList::new);
|
||||||
|
|
||||||
|
private ForcedDiffuseState() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void pushCalculator(DiffuseLightCalculator calculator) {
|
||||||
|
FORCED_DIFFUSE.get().push(calculator);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void popCalculator() {
|
||||||
|
FORCED_DIFFUSE.get().pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static DiffuseLightCalculator getForcedCalculator() {
|
||||||
|
ObjectArrayList<DiffuseLightCalculator> stack = FORCED_DIFFUSE.get();
|
||||||
|
if (stack.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return stack.top();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,467 @@
|
|||||||
|
package nl.requios.effortlessbuilding.create.foundation.render;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.util.Color;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.block.render.SpriteShiftEntry;
|
||||||
|
import org.joml.Matrix3f;
|
||||||
|
import org.joml.Matrix4f;
|
||||||
|
import org.joml.Quaternionf;
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
import org.joml.Vector4f;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.api.vertex.ShadedVertexList;
|
||||||
|
import com.jozufozu.flywheel.backend.ShadersModHandler;
|
||||||
|
import com.jozufozu.flywheel.core.vertex.BlockVertexList;
|
||||||
|
import com.jozufozu.flywheel.util.DiffuseLightCalculator;
|
||||||
|
import com.jozufozu.flywheel.util.transform.TStack;
|
||||||
|
import com.jozufozu.flywheel.util.transform.Transform;
|
||||||
|
import com.mojang.blaze3d.vertex.BufferBuilder.DrawState;
|
||||||
|
import com.mojang.blaze3d.vertex.BufferBuilder.RenderedBuffer;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.longs.Long2IntMap;
|
||||||
|
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.LevelRenderer;
|
||||||
|
import net.minecraft.client.renderer.LightTexture;
|
||||||
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
|
public class SuperByteBuffer implements Transform<SuperByteBuffer>, TStack<SuperByteBuffer> {
|
||||||
|
|
||||||
|
private final ShadedVertexList template;
|
||||||
|
|
||||||
|
// Vertex Position
|
||||||
|
private final PoseStack transforms;
|
||||||
|
|
||||||
|
// Vertex Coloring
|
||||||
|
private boolean shouldColor;
|
||||||
|
private int r, g, b, a;
|
||||||
|
private boolean disableDiffuseMult;
|
||||||
|
private DiffuseLightCalculator diffuseCalculator;
|
||||||
|
|
||||||
|
// Vertex Texture Coords
|
||||||
|
private SpriteShiftFunc spriteShiftFunc;
|
||||||
|
|
||||||
|
// Vertex Overlay Color
|
||||||
|
private boolean hasOverlay;
|
||||||
|
private int overlay = OverlayTexture.NO_OVERLAY;
|
||||||
|
|
||||||
|
// Vertex Lighting
|
||||||
|
private boolean useWorldLight;
|
||||||
|
private Matrix4f lightTransform;
|
||||||
|
private boolean hasCustomLight;
|
||||||
|
private int packedLightCoords;
|
||||||
|
private boolean hybridLight;
|
||||||
|
|
||||||
|
// Vertex Normals
|
||||||
|
private boolean fullNormalTransform;
|
||||||
|
|
||||||
|
// Temporary
|
||||||
|
private static final Long2IntMap WORLD_LIGHT_CACHE = new Long2IntOpenHashMap();
|
||||||
|
|
||||||
|
public SuperByteBuffer(RenderedBuffer buf, int unshadedStartVertex) {
|
||||||
|
DrawState drawState = buf.drawState();
|
||||||
|
template = new BlockVertexList.Shaded(buf.vertexBuffer(), drawState.vertexCount(), drawState.format().getVertexSize(), unshadedStartVertex);
|
||||||
|
|
||||||
|
transforms = new PoseStack();
|
||||||
|
transforms.pushPose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void renderInto(PoseStack input, VertexConsumer builder) {
|
||||||
|
if (isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Matrix4f modelMat = new Matrix4f(input.last()
|
||||||
|
.pose());
|
||||||
|
Matrix4f localTransforms = transforms.last()
|
||||||
|
.pose();
|
||||||
|
modelMat.mul(localTransforms);
|
||||||
|
|
||||||
|
Matrix3f normalMat;
|
||||||
|
if (fullNormalTransform) {
|
||||||
|
normalMat = new Matrix3f(input.last()
|
||||||
|
.normal());
|
||||||
|
Matrix3f localNormalTransforms = transforms.last()
|
||||||
|
.normal();
|
||||||
|
normalMat.mul(localNormalTransforms);
|
||||||
|
} else {
|
||||||
|
normalMat = new Matrix3f(transforms.last()
|
||||||
|
.normal());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useWorldLight) {
|
||||||
|
WORLD_LIGHT_CACHE.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
final Vector4f pos = new Vector4f();
|
||||||
|
final Vector3f normal = new Vector3f();
|
||||||
|
final Vector4f lightPos = new Vector4f();
|
||||||
|
|
||||||
|
DiffuseLightCalculator diffuseCalculator = ForcedDiffuseState.getForcedCalculator();
|
||||||
|
final boolean disableDiffuseMult =
|
||||||
|
this.disableDiffuseMult || (ShadersModHandler.isShaderPackInUse() && diffuseCalculator == null);
|
||||||
|
if (diffuseCalculator == null) {
|
||||||
|
diffuseCalculator = this.diffuseCalculator;
|
||||||
|
if (diffuseCalculator == null) {
|
||||||
|
diffuseCalculator = DiffuseLightCalculator.forCurrentLevel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final int vertexCount = template.getVertexCount();
|
||||||
|
for (int i = 0; i < vertexCount; i++) {
|
||||||
|
float x = template.getX(i);
|
||||||
|
float y = template.getY(i);
|
||||||
|
float z = template.getZ(i);
|
||||||
|
|
||||||
|
pos.set(x, y, z, 1F);
|
||||||
|
pos.mul(modelMat);
|
||||||
|
builder.vertex(pos.x(), pos.y(), pos.z());
|
||||||
|
|
||||||
|
float normalX = template.getNX(i);
|
||||||
|
float normalY = template.getNY(i);
|
||||||
|
float normalZ = template.getNZ(i);
|
||||||
|
|
||||||
|
normal.set(normalX, normalY, normalZ);
|
||||||
|
normal.mul(normalMat);
|
||||||
|
float nx = normal.x();
|
||||||
|
float ny = normal.y();
|
||||||
|
float nz = normal.z();
|
||||||
|
|
||||||
|
byte r, g, b, a;
|
||||||
|
if (shouldColor) {
|
||||||
|
r = (byte) this.r;
|
||||||
|
g = (byte) this.g;
|
||||||
|
b = (byte) this.b;
|
||||||
|
a = (byte) this.a;
|
||||||
|
} else {
|
||||||
|
r = template.getR(i);
|
||||||
|
g = template.getG(i);
|
||||||
|
b = template.getB(i);
|
||||||
|
a = template.getA(i);
|
||||||
|
}
|
||||||
|
if (disableDiffuseMult) {
|
||||||
|
builder.color(r, g, b, a);
|
||||||
|
} else {
|
||||||
|
float instanceDiffuse = diffuseCalculator.getDiffuse(nx, ny, nz, template.isShaded(i));
|
||||||
|
int colorR = transformColor(r, instanceDiffuse);
|
||||||
|
int colorG = transformColor(g, instanceDiffuse);
|
||||||
|
int colorB = transformColor(b, instanceDiffuse);
|
||||||
|
builder.color(colorR, colorG, colorB, a);
|
||||||
|
}
|
||||||
|
|
||||||
|
float u = template.getU(i);
|
||||||
|
float v = template.getV(i);
|
||||||
|
if (spriteShiftFunc != null) {
|
||||||
|
spriteShiftFunc.shift(builder, u, v);
|
||||||
|
} else {
|
||||||
|
builder.uv(u, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasOverlay) {
|
||||||
|
builder.overlayCoords(overlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
int light;
|
||||||
|
if (useWorldLight) {
|
||||||
|
lightPos.set(((x - .5f) * 15 / 16f) + .5f, (y - .5f) * 15 / 16f + .5f, (z - .5f) * 15 / 16f + .5f, 1f);
|
||||||
|
lightPos.mul(localTransforms);
|
||||||
|
if (lightTransform != null) {
|
||||||
|
lightPos.mul(lightTransform);
|
||||||
|
}
|
||||||
|
|
||||||
|
light = getLight(Minecraft.getInstance().level, lightPos);
|
||||||
|
if (hasCustomLight) {
|
||||||
|
light = maxLight(light, packedLightCoords);
|
||||||
|
}
|
||||||
|
} else if (hasCustomLight) {
|
||||||
|
light = packedLightCoords;
|
||||||
|
} else {
|
||||||
|
light = template.getLight(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hybridLight) {
|
||||||
|
builder.uv2(maxLight(light, template.getLight(i)));
|
||||||
|
} else {
|
||||||
|
builder.uv2(light);
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.normal(nx, ny, nz);
|
||||||
|
|
||||||
|
builder.endVertex();
|
||||||
|
}
|
||||||
|
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer reset() {
|
||||||
|
while (!transforms.clear())
|
||||||
|
transforms.popPose();
|
||||||
|
transforms.pushPose();
|
||||||
|
|
||||||
|
shouldColor = false;
|
||||||
|
r = 0;
|
||||||
|
g = 0;
|
||||||
|
b = 0;
|
||||||
|
a = 0;
|
||||||
|
disableDiffuseMult = false;
|
||||||
|
diffuseCalculator = null;
|
||||||
|
spriteShiftFunc = null;
|
||||||
|
hasOverlay = false;
|
||||||
|
overlay = OverlayTexture.NO_OVERLAY;
|
||||||
|
useWorldLight = false;
|
||||||
|
lightTransform = null;
|
||||||
|
hasCustomLight = false;
|
||||||
|
packedLightCoords = 0;
|
||||||
|
hybridLight = false;
|
||||||
|
fullNormalTransform = false;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return template.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PoseStack getTransforms() {
|
||||||
|
return transforms;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuperByteBuffer translate(double x, double y, double z) {
|
||||||
|
transforms.translate(x, y, z);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuperByteBuffer multiply(Quaternionf quaternion) {
|
||||||
|
transforms.mulPose(quaternion);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuperByteBuffer scale(float factorX, float factorY, float factorZ) {
|
||||||
|
transforms.scale(factorX, factorY, factorZ);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuperByteBuffer pushPose() {
|
||||||
|
transforms.pushPose();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuperByteBuffer popPose() {
|
||||||
|
transforms.popPose();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuperByteBuffer mulPose(Matrix4f pose) {
|
||||||
|
transforms.last()
|
||||||
|
.pose()
|
||||||
|
.mul(pose);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuperByteBuffer mulNormal(Matrix3f normal) {
|
||||||
|
transforms.last()
|
||||||
|
.normal()
|
||||||
|
.mul(normal);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer transform(PoseStack stack) {
|
||||||
|
transforms.last()
|
||||||
|
.pose()
|
||||||
|
.mul(stack.last()
|
||||||
|
.pose());
|
||||||
|
transforms.last()
|
||||||
|
.normal()
|
||||||
|
.mul(stack.last()
|
||||||
|
.normal());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer rotateCentered(Direction axis, float radians) {
|
||||||
|
translate(.5f, .5f, .5f).rotate(axis, radians)
|
||||||
|
.translate(-.5f, -.5f, -.5f);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer rotateCentered(Quaternionf q) {
|
||||||
|
translate(.5f, .5f, .5f).multiply(q)
|
||||||
|
.translate(-.5f, -.5f, -.5f);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer color(int r, int g, int b, int a) {
|
||||||
|
shouldColor = true;
|
||||||
|
this.r = r;
|
||||||
|
this.g = g;
|
||||||
|
this.b = b;
|
||||||
|
this.a = a;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer color(int color) {
|
||||||
|
shouldColor = true;
|
||||||
|
r = ((color >> 16) & 0xFF);
|
||||||
|
g = ((color >> 8) & 0xFF);
|
||||||
|
b = (color & 0xFF);
|
||||||
|
a = 255;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer color(Color c) {
|
||||||
|
return color(c.getRGB());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prevents vertex colors from being multiplied by the diffuse value calculated
|
||||||
|
* from the final transformed normal vector. Useful for entity rendering, when
|
||||||
|
* diffuse is applied automatically later.
|
||||||
|
*/
|
||||||
|
public SuperByteBuffer disableDiffuse() {
|
||||||
|
disableDiffuseMult = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer diffuseCalculator(DiffuseLightCalculator diffuseCalculator) {
|
||||||
|
this.diffuseCalculator = diffuseCalculator;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer shiftUV(SpriteShiftEntry entry) {
|
||||||
|
this.spriteShiftFunc = (builder, u, v) -> {
|
||||||
|
builder.uv(entry.getTargetU(u), entry.getTargetV(v));
|
||||||
|
};
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer shiftUVScrolling(SpriteShiftEntry entry, float scrollV) {
|
||||||
|
return this.shiftUVScrolling(entry, 0, scrollV);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer shiftUVScrolling(SpriteShiftEntry entry, float scrollU, float scrollV) {
|
||||||
|
this.spriteShiftFunc = (builder, u, v) -> {
|
||||||
|
float targetU = u - entry.getOriginal()
|
||||||
|
.getU0() + entry.getTarget()
|
||||||
|
.getU0()
|
||||||
|
+ scrollU;
|
||||||
|
float targetV = v - entry.getOriginal()
|
||||||
|
.getV0() + entry.getTarget()
|
||||||
|
.getV0()
|
||||||
|
+ scrollV;
|
||||||
|
builder.uv(targetU, targetV);
|
||||||
|
};
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer shiftUVtoSheet(SpriteShiftEntry entry, float uTarget, float vTarget, int sheetSize) {
|
||||||
|
this.spriteShiftFunc = (builder, u, v) -> {
|
||||||
|
float targetU = entry.getTarget()
|
||||||
|
.getU((SpriteShiftEntry.getUnInterpolatedU(entry.getOriginal(), u) / sheetSize) + uTarget * 16);
|
||||||
|
float targetV = entry.getTarget()
|
||||||
|
.getV((SpriteShiftEntry.getUnInterpolatedV(entry.getOriginal(), v) / sheetSize) + vTarget * 16);
|
||||||
|
builder.uv(targetU, targetV);
|
||||||
|
};
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer overlay() {
|
||||||
|
hasOverlay = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer overlay(int overlay) {
|
||||||
|
hasOverlay = true;
|
||||||
|
this.overlay = overlay;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer light() {
|
||||||
|
useWorldLight = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer light(Matrix4f lightTransform) {
|
||||||
|
useWorldLight = true;
|
||||||
|
this.lightTransform = lightTransform;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer light(int packedLightCoords) {
|
||||||
|
hasCustomLight = true;
|
||||||
|
this.packedLightCoords = packedLightCoords;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer light(Matrix4f lightTransform, int packedLightCoords) {
|
||||||
|
light(lightTransform);
|
||||||
|
light(packedLightCoords);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uses max light from calculated light (world light or custom light) and vertex
|
||||||
|
* light for the final light value. Ineffective if any other light method was
|
||||||
|
* not called.
|
||||||
|
*/
|
||||||
|
public SuperByteBuffer hybridLight() {
|
||||||
|
hybridLight = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transforms normals not only by the local matrix stack, but also by the passed
|
||||||
|
* matrix stack.
|
||||||
|
*/
|
||||||
|
public SuperByteBuffer fullNormalTransform() {
|
||||||
|
fullNormalTransform = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer forEntityRender() {
|
||||||
|
disableDiffuse();
|
||||||
|
overlay();
|
||||||
|
fullNormalTransform();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int transformColor(byte component, float scale) {
|
||||||
|
return Mth.clamp((int) (Byte.toUnsignedInt(component) * scale), 0, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int transformColor(int component, float scale) {
|
||||||
|
return Mth.clamp((int) (component * scale), 0, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int maxLight(int packedLight1, int packedLight2) {
|
||||||
|
int blockLight1 = LightTexture.block(packedLight1);
|
||||||
|
int skyLight1 = LightTexture.sky(packedLight1);
|
||||||
|
int blockLight2 = LightTexture.block(packedLight2);
|
||||||
|
int skyLight2 = LightTexture.sky(packedLight2);
|
||||||
|
return LightTexture.pack(Math.max(blockLight1, blockLight2), Math.max(skyLight1, skyLight2));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getLight(Level world, Vector4f lightPos) {
|
||||||
|
BlockPos pos = BlockPos.containing(lightPos.x(), lightPos.y(), lightPos.z());
|
||||||
|
return WORLD_LIGHT_CACHE.computeIfAbsent(pos.asLong(), $ -> LevelRenderer.getLightColor(world, pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface SpriteShiftFunc {
|
||||||
|
void shift(VertexConsumer builder, float u, float v);
|
||||||
|
}
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface VertexLighter {
|
||||||
|
int getPackedLight(float x, float y, float z);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package nl.requios.effortlessbuilding.create.foundation.render;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import com.google.common.cache.Cache;
|
||||||
|
import com.google.common.cache.CacheBuilder;
|
||||||
|
|
||||||
|
public class SuperByteBufferCache {
|
||||||
|
|
||||||
|
protected final Map<Compartment<?>, Cache<Object, SuperByteBuffer>> caches = new HashMap<>();
|
||||||
|
|
||||||
|
public synchronized void registerCompartment(Compartment<?> compartment) {
|
||||||
|
caches.put(compartment, CacheBuilder.newBuilder()
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void registerCompartment(Compartment<?> compartment, long ticksUntilExpired) {
|
||||||
|
caches.put(compartment, CacheBuilder.newBuilder()
|
||||||
|
.expireAfterAccess(ticksUntilExpired * 50, TimeUnit.MILLISECONDS)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> SuperByteBuffer get(Compartment<T> compartment, T key, Callable<SuperByteBuffer> callable) {
|
||||||
|
Cache<Object, SuperByteBuffer> cache = caches.get(compartment);
|
||||||
|
if (cache != null) {
|
||||||
|
try {
|
||||||
|
return cache.get(key, callable);
|
||||||
|
} catch (ExecutionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void invalidate(Compartment<T> compartment, T key) {
|
||||||
|
caches.get(compartment).invalidate(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void invalidate(Compartment<?> compartment) {
|
||||||
|
caches.get(compartment).invalidateAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void invalidate() {
|
||||||
|
caches.forEach((compartment, cache) -> cache.invalidateAll());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Compartment<T> {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package nl.requios.effortlessbuilding.create.foundation.render;
|
||||||
|
|
||||||
|
import java.util.SortedMap;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
|
||||||
|
import net.minecraft.Util;
|
||||||
|
import net.minecraft.client.renderer.ChunkBufferBuilderPack;
|
||||||
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
|
import net.minecraft.client.renderer.RenderType;
|
||||||
|
import net.minecraft.client.renderer.Sheets;
|
||||||
|
import net.minecraft.client.resources.model.ModelBakery;
|
||||||
|
|
||||||
|
public class SuperRenderTypeBuffer implements MultiBufferSource {
|
||||||
|
|
||||||
|
private static final SuperRenderTypeBuffer INSTANCE = new SuperRenderTypeBuffer();
|
||||||
|
|
||||||
|
public static SuperRenderTypeBuffer getInstance() {
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SuperRenderTypeBufferPhase earlyBuffer;
|
||||||
|
private SuperRenderTypeBufferPhase defaultBuffer;
|
||||||
|
private SuperRenderTypeBufferPhase lateBuffer;
|
||||||
|
|
||||||
|
public SuperRenderTypeBuffer() {
|
||||||
|
earlyBuffer = new SuperRenderTypeBufferPhase();
|
||||||
|
defaultBuffer = new SuperRenderTypeBufferPhase();
|
||||||
|
lateBuffer = new SuperRenderTypeBufferPhase();
|
||||||
|
}
|
||||||
|
|
||||||
|
public VertexConsumer getEarlyBuffer(RenderType type) {
|
||||||
|
return earlyBuffer.bufferSource.getBuffer(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VertexConsumer getBuffer(RenderType type) {
|
||||||
|
return defaultBuffer.bufferSource.getBuffer(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public VertexConsumer getLateBuffer(RenderType type) {
|
||||||
|
return lateBuffer.bufferSource.getBuffer(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void draw() {
|
||||||
|
earlyBuffer.bufferSource.endBatch();
|
||||||
|
defaultBuffer.bufferSource.endBatch();
|
||||||
|
lateBuffer.bufferSource.endBatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void draw(RenderType type) {
|
||||||
|
earlyBuffer.bufferSource.endBatch(type);
|
||||||
|
defaultBuffer.bufferSource.endBatch(type);
|
||||||
|
lateBuffer.bufferSource.endBatch(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class SuperRenderTypeBufferPhase {
|
||||||
|
|
||||||
|
// Visible clones from RenderBuffers
|
||||||
|
private final ChunkBufferBuilderPack fixedBufferPack = new ChunkBufferBuilderPack();
|
||||||
|
private final SortedMap<RenderType, BufferBuilder> fixedBuffers = Util.make(new Object2ObjectLinkedOpenHashMap<>(), map -> {
|
||||||
|
map.put(Sheets.solidBlockSheet(), fixedBufferPack.builder(RenderType.solid()));
|
||||||
|
map.put(Sheets.cutoutBlockSheet(), fixedBufferPack.builder(RenderType.cutout()));
|
||||||
|
map.put(Sheets.bannerSheet(), fixedBufferPack.builder(RenderType.cutoutMipped()));
|
||||||
|
map.put(Sheets.translucentCullBlockSheet(), fixedBufferPack.builder(RenderType.translucent()));
|
||||||
|
put(map, Sheets.shieldSheet());
|
||||||
|
put(map, Sheets.bedSheet());
|
||||||
|
put(map, Sheets.shulkerBoxSheet());
|
||||||
|
put(map, Sheets.signSheet());
|
||||||
|
put(map, Sheets.chestSheet());
|
||||||
|
put(map, RenderType.translucentNoCrumbling());
|
||||||
|
put(map, RenderType.armorGlint());
|
||||||
|
put(map, RenderType.armorEntityGlint());
|
||||||
|
put(map, RenderType.glint());
|
||||||
|
put(map, RenderType.glintDirect());
|
||||||
|
put(map, RenderType.glintTranslucent());
|
||||||
|
put(map, RenderType.entityGlint());
|
||||||
|
put(map, RenderType.entityGlintDirect());
|
||||||
|
put(map, RenderType.waterMask());
|
||||||
|
put(map, RenderTypes.getOutlineSolid());
|
||||||
|
ModelBakery.DESTROY_TYPES.forEach((p_173062_) -> {
|
||||||
|
put(map, p_173062_);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
private final BufferSource bufferSource = MultiBufferSource.immediateWithBuffers(fixedBuffers, new BufferBuilder(256));
|
||||||
|
|
||||||
|
private static void put(Object2ObjectLinkedOpenHashMap<RenderType, BufferBuilder> map, RenderType type) {
|
||||||
|
map.put(type, new BufferBuilder(type.bufferSize()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
package nl.requios.effortlessbuilding.create.foundation.render;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
|
||||||
|
import com.jozufozu.flywheel.config.BackendType;
|
||||||
|
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
|
||||||
|
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.LevelRenderer;
|
||||||
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||||
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import nl.requios.effortlessbuilding.create.Create;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.AnimationTickHolder;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.RegisteredObjects;
|
||||||
|
import org.joml.Matrix4f;
|
||||||
|
import org.joml.Vector4f;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
public class TileEntityRenderHelper {
|
||||||
|
|
||||||
|
public static void renderTileEntities(Level world, Iterable<BlockEntity> customRenderTEs, PoseStack ms,
|
||||||
|
MultiBufferSource buffer) {
|
||||||
|
renderTileEntities(world, null, customRenderTEs, ms, null, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void renderTileEntities(Level world, Iterable<BlockEntity> customRenderTEs, PoseStack ms,
|
||||||
|
MultiBufferSource buffer, float pt) {
|
||||||
|
renderTileEntities(world, null, customRenderTEs, ms, null, buffer, pt);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void renderTileEntities(Level world, @Nullable VirtualRenderWorld renderWorld,
|
||||||
|
Iterable<BlockEntity> customRenderTEs, PoseStack ms, @Nullable Matrix4f lightTransform, MultiBufferSource buffer) {
|
||||||
|
renderTileEntities(world, renderWorld, customRenderTEs, ms, lightTransform, buffer,
|
||||||
|
AnimationTickHolder.getPartialTicks());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void renderTileEntities(Level world, @Nullable VirtualRenderWorld renderWorld,
|
||||||
|
Iterable<BlockEntity> customRenderTEs, PoseStack ms, @Nullable Matrix4f lightTransform, MultiBufferSource buffer,
|
||||||
|
float pt) {
|
||||||
|
Iterator<BlockEntity> iterator = customRenderTEs.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
BlockEntity tileEntity = iterator.next();
|
||||||
|
if (Backend.getBackendType() == BackendType.INSTANCING && Backend.isFlywheelWorld(renderWorld) && InstancedRenderRegistry.shouldSkipRender(tileEntity))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
BlockEntityRenderer<BlockEntity> renderer = Minecraft.getInstance().getBlockEntityRenderDispatcher().getRenderer(tileEntity);
|
||||||
|
if (renderer == null) {
|
||||||
|
iterator.remove();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockPos pos = tileEntity.getBlockPos();
|
||||||
|
ms.pushPose();
|
||||||
|
TransformStack.cast(ms)
|
||||||
|
.translate(pos);
|
||||||
|
|
||||||
|
try {
|
||||||
|
int worldLight = getCombinedLight(world, getLightPos(lightTransform, pos), renderWorld, pos);
|
||||||
|
|
||||||
|
if (renderWorld != null) {
|
||||||
|
// Swap the real world for the render world so that the renderer gets contraption-local information
|
||||||
|
tileEntity.setLevel(renderWorld);
|
||||||
|
renderer.render(tileEntity, pt, ms, buffer, worldLight, OverlayTexture.NO_OVERLAY);
|
||||||
|
tileEntity.setLevel(world);
|
||||||
|
} else {
|
||||||
|
renderer.render(tileEntity, pt, ms, buffer, worldLight, OverlayTexture.NO_OVERLAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
iterator.remove();
|
||||||
|
|
||||||
|
String message = "BlockEntity " + RegisteredObjects.getKeyOrThrow(tileEntity.getType())
|
||||||
|
.toString() + " could not be rendered virtually.";
|
||||||
|
// if (AllConfigs.CLIENT.explainRenderErrors.get())
|
||||||
|
Create.LOGGER.error(message, e);
|
||||||
|
// else
|
||||||
|
// Create.LOGGER.error(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
ms.popPose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BlockPos getLightPos(@Nullable Matrix4f lightTransform, BlockPos contraptionPos) {
|
||||||
|
if (lightTransform != null) {
|
||||||
|
Vector4f lightVec = new Vector4f(contraptionPos.getX() + .5f, contraptionPos.getY() + .5f, contraptionPos.getZ() + .5f, 1);
|
||||||
|
lightVec.mul(lightTransform);
|
||||||
|
return BlockPos.containing(lightVec.x(), lightVec.y(), lightVec.z());
|
||||||
|
} else {
|
||||||
|
return contraptionPos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getCombinedLight(Level world, BlockPos worldPos, @Nullable VirtualRenderWorld renderWorld,
|
||||||
|
BlockPos renderWorldPos) {
|
||||||
|
int worldLight = LevelRenderer.getLightColor(world, worldPos);
|
||||||
|
|
||||||
|
if (renderWorld != null) {
|
||||||
|
int renderWorldLight = LevelRenderer.getLightColor(renderWorld, renderWorldPos);
|
||||||
|
return SuperByteBuffer.maxLight(worldLight, renderWorldLight);
|
||||||
|
}
|
||||||
|
|
||||||
|
return worldLight;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -185,7 +185,7 @@ public class BlockHelper {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
BlockState belowState = world.getBlockState(pos.below());
|
BlockState belowState = world.getBlockState(pos.below());
|
||||||
if (belowState.blocksMotion() || belowState.liquid())
|
if (belowState.getMaterial().blocksMotion() || belowState.getMaterial().isLiquid())
|
||||||
world.setBlockAndUpdate(pos, Blocks.WATER.defaultBlockState());
|
world.setBlockAndUpdate(pos, Blocks.WATER.defaultBlockState());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -213,7 +213,7 @@ public class BlockHelper {
|
|||||||
int idx = chunk.getSectionIndex(target.getY());
|
int idx = chunk.getSectionIndex(target.getY());
|
||||||
LevelChunkSection chunksection = chunk.getSection(idx);
|
LevelChunkSection chunksection = chunk.getSection(idx);
|
||||||
if (chunksection == null) {
|
if (chunksection == null) {
|
||||||
chunksection = new LevelChunkSection(world.registryAccess()
|
chunksection = new LevelChunkSection(chunk.getSectionYFromSectionIndex(idx), world.registryAccess()
|
||||||
.registryOrThrow(Registries.BIOME));
|
.registryOrThrow(Registries.BIOME));
|
||||||
chunk.getSections()[idx] = chunksection;
|
chunk.getSections()[idx] = chunksection;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.utility.ghost;
|
package nl.requios.effortlessbuilding.create.foundation.utility.ghost;
|
||||||
|
|
||||||
import net.createmod.catnip.theme.Color;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.utility.ghost;
|
package nl.requios.effortlessbuilding.create.foundation.utility.ghost;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.core.model.ModelUtil;
|
||||||
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.render.SuperRenderTypeBuffer;
|
import nl.requios.effortlessbuilding.create.foundation.render.SuperRenderTypeBuffer;
|
||||||
import net.createmod.catnip.theme.Color;
|
|
||||||
import net.createmod.ponder.render.VirtualRenderHelper;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.LevelRenderer;
|
import net.minecraft.client.renderer.LevelRenderer;
|
||||||
import net.minecraft.client.renderer.LightTexture;
|
import net.minecraft.client.renderer.LightTexture;
|
||||||
@@ -20,6 +19,7 @@ import net.minecraft.util.Mth;
|
|||||||
import net.minecraft.util.RandomSource;
|
import net.minecraft.util.RandomSource;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraftforge.client.model.data.ModelData;
|
import net.minecraftforge.client.model.data.ModelData;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -56,10 +56,10 @@ public abstract class GhostBlockRenderer {
|
|||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
ms.translate(pos.getX(), pos.getY(), pos.getZ());
|
ms.translate(pos.getX(), pos.getY(), pos.getZ());
|
||||||
|
|
||||||
for (RenderType layer : model.getRenderTypes(state, RandomSource.create(42L), VirtualRenderHelper.VIRTUAL_DATA)) {
|
for (RenderType layer : model.getRenderTypes(state, RandomSource.create(42L), ModelUtil.VIRTUAL_DATA)) {
|
||||||
VertexConsumer vb = buffer.getEarlyBuffer(layer);
|
VertexConsumer vb = buffer.getEarlyBuffer(layer);
|
||||||
renderer.renderModel(ms.last(), vb, state, model, 1f, 1f, 1f, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY,
|
renderer.renderModel(ms.last(), vb, state, model, 1f, 1f, 1f, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY,
|
||||||
VirtualRenderHelper.VIRTUAL_DATA, layer);
|
ModelUtil.VIRTUAL_DATA, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
@@ -92,7 +92,8 @@ public abstract class GhostBlockRenderer {
|
|||||||
ms.translate(-.5, -.5, -.5);
|
ms.translate(-.5, -.5, -.5);
|
||||||
|
|
||||||
renderModel(ms.last(), vb, state, model, color.getRedAsFloat(), color.getGreenAsFloat(), color.getBlueAsFloat(), alpha,
|
renderModel(ms.last(), vb, state, model, color.getRedAsFloat(), color.getGreenAsFloat(), color.getBlueAsFloat(), alpha,
|
||||||
LevelRenderer.getLightColor(mc.level, pos), OverlayTexture.NO_OVERLAY, VirtualRenderHelper.VIRTUAL_DATA, layer);
|
LevelRenderer.getLightColor(mc.level, pos), OverlayTexture.NO_OVERLAY,
|
||||||
|
ModelUtil.VIRTUAL_DATA, layer);
|
||||||
|
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package nl.requios.effortlessbuilding.create.foundation.utility.ghost;
|
package nl.requios.effortlessbuilding.create.foundation.utility.ghost;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.createmod.catnip.render.SuperRenderTypeBuffer;
|
import nl.requios.effortlessbuilding.create.foundation.render.SuperRenderTypeBuffer;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
package nl.requios.effortlessbuilding.create.foundation.utility.outliner;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.render.RenderTypes;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.render.SuperRenderTypeBuffer;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.RenderType;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.core.Direction.Axis;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.phys.AABB;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
|
public class AABBOutline extends Outline {
|
||||||
|
|
||||||
|
protected AABB bb;
|
||||||
|
|
||||||
|
public AABBOutline(AABB bb) {
|
||||||
|
this.setBounds(bb);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) {
|
||||||
|
renderBB(ms, buffer, bb);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void renderBB(PoseStack ms, SuperRenderTypeBuffer buffer, AABB bb) {
|
||||||
|
Vec3 projectedView = Minecraft.getInstance().gameRenderer.getMainCamera()
|
||||||
|
.getPosition();
|
||||||
|
boolean noCull = bb.contains(projectedView);
|
||||||
|
bb = bb.inflate(noCull ? -1 / 128d : 1 / 128d);
|
||||||
|
noCull |= params.disableCull;
|
||||||
|
|
||||||
|
Vec3 xyz = new Vec3(bb.minX, bb.minY, bb.minZ);
|
||||||
|
Vec3 Xyz = new Vec3(bb.maxX, bb.minY, bb.minZ);
|
||||||
|
Vec3 xYz = new Vec3(bb.minX, bb.maxY, bb.minZ);
|
||||||
|
Vec3 XYz = new Vec3(bb.maxX, bb.maxY, bb.minZ);
|
||||||
|
Vec3 xyZ = new Vec3(bb.minX, bb.minY, bb.maxZ);
|
||||||
|
Vec3 XyZ = new Vec3(bb.maxX, bb.minY, bb.maxZ);
|
||||||
|
Vec3 xYZ = new Vec3(bb.minX, bb.maxY, bb.maxZ);
|
||||||
|
Vec3 XYZ = new Vec3(bb.maxX, bb.maxY, bb.maxZ);
|
||||||
|
|
||||||
|
Vec3 start = xyz;
|
||||||
|
renderAACuboidLine(ms, buffer, start, Xyz);
|
||||||
|
renderAACuboidLine(ms, buffer, start, xYz);
|
||||||
|
renderAACuboidLine(ms, buffer, start, xyZ);
|
||||||
|
|
||||||
|
start = XyZ;
|
||||||
|
renderAACuboidLine(ms, buffer, start, xyZ);
|
||||||
|
renderAACuboidLine(ms, buffer, start, XYZ);
|
||||||
|
renderAACuboidLine(ms, buffer, start, Xyz);
|
||||||
|
|
||||||
|
start = XYz;
|
||||||
|
renderAACuboidLine(ms, buffer, start, xYz);
|
||||||
|
renderAACuboidLine(ms, buffer, start, Xyz);
|
||||||
|
renderAACuboidLine(ms, buffer, start, XYZ);
|
||||||
|
|
||||||
|
start = xYZ;
|
||||||
|
renderAACuboidLine(ms, buffer, start, XYZ);
|
||||||
|
renderAACuboidLine(ms, buffer, start, xyZ);
|
||||||
|
renderAACuboidLine(ms, buffer, start, xYz);
|
||||||
|
|
||||||
|
renderFace(ms, buffer, Direction.NORTH, xYz, XYz, Xyz, xyz, noCull);
|
||||||
|
renderFace(ms, buffer, Direction.SOUTH, XYZ, xYZ, xyZ, XyZ, noCull);
|
||||||
|
renderFace(ms, buffer, Direction.EAST, XYz, XYZ, XyZ, Xyz, noCull);
|
||||||
|
renderFace(ms, buffer, Direction.WEST, xYZ, xYz, xyz, xyZ, noCull);
|
||||||
|
renderFace(ms, buffer, Direction.UP, xYZ, XYZ, XYz, xYz, noCull);
|
||||||
|
renderFace(ms, buffer, Direction.DOWN, xyz, Xyz, XyZ, xyZ, noCull);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void renderFace(PoseStack ms, SuperRenderTypeBuffer buffer, Direction direction, Vec3 p1, Vec3 p2,
|
||||||
|
Vec3 p3, Vec3 p4, boolean noCull) {
|
||||||
|
if (!params.faceTexture.isPresent())
|
||||||
|
return;
|
||||||
|
|
||||||
|
ResourceLocation faceTexture = params.faceTexture.get()
|
||||||
|
.getLocation();
|
||||||
|
float alphaBefore = params.alpha;
|
||||||
|
params.alpha =
|
||||||
|
(direction == params.getHighlightedFace() && params.hightlightedFaceTexture.isPresent()) ? 1 : 0.5f;
|
||||||
|
|
||||||
|
RenderType translucentType = RenderTypes.getOutlineTranslucent(faceTexture, !noCull);
|
||||||
|
VertexConsumer builder = buffer.getLateBuffer(translucentType);
|
||||||
|
|
||||||
|
Axis axis = direction.getAxis();
|
||||||
|
Vec3 uDiff = p2.subtract(p1);
|
||||||
|
Vec3 vDiff = p4.subtract(p1);
|
||||||
|
float maxU = (float) Math.abs(axis == Axis.X ? uDiff.z : uDiff.x);
|
||||||
|
float maxV = (float) Math.abs(axis == Axis.Y ? vDiff.z : vDiff.y);
|
||||||
|
putQuadUV(ms, builder, p1, p2, p3, p4, 0, 0, maxU, maxV, Direction.UP);
|
||||||
|
params.alpha = alphaBefore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBounds(AABB bb) {
|
||||||
|
this.bb = bb;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,178 @@
|
|||||||
|
package nl.requios.effortlessbuilding.create.foundation.utility.outliner;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
|
import nl.requios.effortlessbuilding.create.AllSpecialTextures;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.render.RenderTypes;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.render.SuperRenderTypeBuffer;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.Iterate;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.VecHelper;
|
||||||
|
import net.minecraft.client.renderer.RenderType;
|
||||||
|
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.world.phys.Vec3;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class BlockClusterOutline extends Outline {
|
||||||
|
|
||||||
|
private Cluster cluster;
|
||||||
|
|
||||||
|
public BlockClusterOutline(Iterable<BlockPos> selection) {
|
||||||
|
cluster = new Cluster();
|
||||||
|
selection.forEach(cluster::include);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) {
|
||||||
|
cluster.visibleEdges.forEach(edge -> {
|
||||||
|
Vec3 start = Vec3.atLowerCornerOf(edge.pos);
|
||||||
|
Direction direction = Direction.get(AxisDirection.POSITIVE, edge.axis);
|
||||||
|
renderAACuboidLine(ms, buffer, start, Vec3.atLowerCornerOf(edge.pos.relative(direction)));
|
||||||
|
});
|
||||||
|
|
||||||
|
Optional<AllSpecialTextures> faceTexture = params.faceTexture;
|
||||||
|
if (!faceTexture.isPresent())
|
||||||
|
return;
|
||||||
|
|
||||||
|
RenderType translucentType = RenderTypes.getOutlineTranslucent(faceTexture.get()
|
||||||
|
.getLocation(), true);
|
||||||
|
VertexConsumer builder = buffer.getLateBuffer(translucentType);
|
||||||
|
|
||||||
|
cluster.visibleFaces.forEach((face, axisDirection) -> {
|
||||||
|
Direction direction = Direction.get(axisDirection, face.axis);
|
||||||
|
BlockPos pos = face.pos;
|
||||||
|
if (axisDirection == AxisDirection.POSITIVE)
|
||||||
|
pos = pos.relative(direction.getOpposite());
|
||||||
|
renderBlockFace(ms, builder, pos, direction);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static Vec3 xyz = new Vec3(-.5, -.5, -.5);
|
||||||
|
static Vec3 Xyz = new Vec3(.5, -.5, -.5);
|
||||||
|
static Vec3 xYz = new Vec3(-.5, .5, -.5);
|
||||||
|
static Vec3 XYz = new Vec3(.5, .5, -.5);
|
||||||
|
static Vec3 xyZ = new Vec3(-.5, -.5, .5);
|
||||||
|
static Vec3 XyZ = new Vec3(.5, -.5, .5);
|
||||||
|
static Vec3 xYZ = new Vec3(-.5, .5, .5);
|
||||||
|
static Vec3 XYZ = new Vec3(.5, .5, .5);
|
||||||
|
|
||||||
|
protected void renderBlockFace(PoseStack ms, VertexConsumer builder, BlockPos pos, Direction face) {
|
||||||
|
Vec3 center = VecHelper.getCenterOf(pos);
|
||||||
|
Vec3 offset = Vec3.atLowerCornerOf(face.getNormal());
|
||||||
|
offset = offset.scale(1 / 128d);
|
||||||
|
center = center.add(offset);
|
||||||
|
|
||||||
|
ms.pushPose();
|
||||||
|
ms.translate(center.x, center.y, center.z);
|
||||||
|
|
||||||
|
switch (face) {
|
||||||
|
case DOWN:
|
||||||
|
putQuad(ms, builder, xyz, Xyz, XyZ, xyZ, face);
|
||||||
|
break;
|
||||||
|
case EAST:
|
||||||
|
putQuad(ms, builder, XYz, XYZ, XyZ, Xyz, face);
|
||||||
|
break;
|
||||||
|
case NORTH:
|
||||||
|
putQuad(ms, builder, xYz, XYz, Xyz, xyz, face);
|
||||||
|
break;
|
||||||
|
case SOUTH:
|
||||||
|
putQuad(ms, builder, XYZ, xYZ, xyZ, XyZ, face);
|
||||||
|
break;
|
||||||
|
case UP:
|
||||||
|
putQuad(ms, builder, xYZ, XYZ, XYz, xYz, face);
|
||||||
|
break;
|
||||||
|
case WEST:
|
||||||
|
putQuad(ms, builder, xYZ, xYz, xyz, xyZ, face);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ms.popPose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Cluster {
|
||||||
|
|
||||||
|
private Map<MergeEntry, AxisDirection> visibleFaces;
|
||||||
|
private Set<MergeEntry> visibleEdges;
|
||||||
|
|
||||||
|
public Cluster() {
|
||||||
|
visibleEdges = new HashSet<>();
|
||||||
|
visibleFaces = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void include(BlockPos pos) {
|
||||||
|
|
||||||
|
// 6 FACES
|
||||||
|
for (Axis axis : Iterate.axes) {
|
||||||
|
Direction direction = Direction.get(AxisDirection.POSITIVE, axis);
|
||||||
|
for (int offset : Iterate.zeroAndOne) {
|
||||||
|
MergeEntry entry = new MergeEntry(axis, pos.relative(direction, offset));
|
||||||
|
if (visibleFaces.remove(entry) == null)
|
||||||
|
visibleFaces.put(entry, offset == 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 12 EDGES
|
||||||
|
for (Axis axis : Iterate.axes) {
|
||||||
|
for (Axis axis2 : Iterate.axes) {
|
||||||
|
if (axis == axis2)
|
||||||
|
continue;
|
||||||
|
for (Axis axis3 : Iterate.axes) {
|
||||||
|
if (axis == axis3)
|
||||||
|
continue;
|
||||||
|
if (axis2 == axis3)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Direction direction = Direction.get(AxisDirection.POSITIVE, axis2);
|
||||||
|
Direction direction2 = Direction.get(AxisDirection.POSITIVE, axis3);
|
||||||
|
|
||||||
|
for (int offset : Iterate.zeroAndOne) {
|
||||||
|
BlockPos entryPos = pos.relative(direction, offset);
|
||||||
|
for (int offset2 : Iterate.zeroAndOne) {
|
||||||
|
entryPos = entryPos.relative(direction2, offset2);
|
||||||
|
MergeEntry entry = new MergeEntry(axis, entryPos);
|
||||||
|
if (!visibleEdges.remove(entry))
|
||||||
|
visibleEdges.add(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class MergeEntry {
|
||||||
|
|
||||||
|
private Axis axis;
|
||||||
|
private BlockPos pos;
|
||||||
|
|
||||||
|
public MergeEntry(Axis axis, BlockPos pos) {
|
||||||
|
this.axis = axis;
|
||||||
|
this.pos = pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (!(o instanceof MergeEntry))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
MergeEntry other = (MergeEntry) o;
|
||||||
|
return this.axis == other.axis && this.pos.equals(other.pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return this.pos.hashCode() * 31 + axis.ordinal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package nl.requios.effortlessbuilding.create.foundation.utility.outliner;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.render.SuperRenderTypeBuffer;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
|
import net.minecraft.world.phys.AABB;
|
||||||
|
|
||||||
|
public class ChasingAABBOutline extends AABBOutline {
|
||||||
|
|
||||||
|
AABB targetBB;
|
||||||
|
AABB prevBB;
|
||||||
|
|
||||||
|
public ChasingAABBOutline(AABB bb) {
|
||||||
|
super(bb);
|
||||||
|
prevBB = bb.inflate(0);
|
||||||
|
targetBB = bb.inflate(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void target(AABB target) {
|
||||||
|
targetBB = target;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick() {
|
||||||
|
prevBB = bb;
|
||||||
|
setBounds(interpolateBBs(bb, targetBB, .5f));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) {
|
||||||
|
renderBB(ms, buffer, interpolateBBs(prevBB, bb, pt));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static AABB interpolateBBs(AABB current, AABB target, float pt) {
|
||||||
|
return new AABB(Mth.lerp(pt, current.minX, target.minX),
|
||||||
|
Mth.lerp(pt, current.minY, target.minY), Mth.lerp(pt, current.minZ, target.minZ),
|
||||||
|
Mth.lerp(pt, current.maxX, target.maxX), Mth.lerp(pt, current.maxY, target.maxY),
|
||||||
|
Mth.lerp(pt, current.maxZ, target.maxZ));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package nl.requios.effortlessbuilding.create.foundation.utility.outliner;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.render.SuperRenderTypeBuffer;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
|
public class LineOutline extends Outline {
|
||||||
|
|
||||||
|
protected Vec3 start = Vec3.ZERO;
|
||||||
|
protected Vec3 end = Vec3.ZERO;
|
||||||
|
|
||||||
|
public LineOutline set(Vec3 start, Vec3 end) {
|
||||||
|
this.start = start;
|
||||||
|
this.end = end;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) {
|
||||||
|
renderCuboidLine(ms, buffer, start, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class EndChasingLineOutline extends LineOutline {
|
||||||
|
|
||||||
|
float prevProgress = 0;
|
||||||
|
float progress = 0;
|
||||||
|
private boolean lockStart;
|
||||||
|
|
||||||
|
public EndChasingLineOutline(boolean lockStart) {
|
||||||
|
this.lockStart = lockStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick() {}
|
||||||
|
|
||||||
|
public EndChasingLineOutline setProgress(float progress) {
|
||||||
|
prevProgress = this.progress;
|
||||||
|
this.progress = progress;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LineOutline set(Vec3 start, Vec3 end) {
|
||||||
|
if (!end.equals(this.end))
|
||||||
|
super.set(start, end);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) {
|
||||||
|
float distanceToTarget = Mth.lerp(pt, prevProgress, progress);
|
||||||
|
if (!lockStart)
|
||||||
|
distanceToTarget = 1 - distanceToTarget;
|
||||||
|
Vec3 start = lockStart ? this.end : this.start;
|
||||||
|
Vec3 end = lockStart ? this.start : this.end;
|
||||||
|
|
||||||
|
start = end.add(this.start.subtract(end)
|
||||||
|
.scale(distanceToTarget));
|
||||||
|
renderCuboidLine(ms, buffer, start, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,246 @@
|
|||||||
|
package nl.requios.effortlessbuilding.create.foundation.utility.outliner;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
|
import nl.requios.effortlessbuilding.create.AllSpecialTextures;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.render.RenderTypes;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.render.SuperRenderTypeBuffer;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.AngleHelper;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.VecHelper;
|
||||||
|
import net.minecraft.client.renderer.LightTexture;
|
||||||
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.core.Direction.Axis;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import org.joml.Matrix3f;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public abstract class Outline {
|
||||||
|
|
||||||
|
protected OutlineParams params;
|
||||||
|
protected Matrix3f transformNormals; // TODO: not used?
|
||||||
|
|
||||||
|
public Outline() {
|
||||||
|
params = new OutlineParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt);
|
||||||
|
|
||||||
|
public void tick() {}
|
||||||
|
|
||||||
|
public OutlineParams getParams() {
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void renderCuboidLine(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 start, Vec3 end) {
|
||||||
|
Vec3 diff = end.subtract(start);
|
||||||
|
float hAngle = AngleHelper.deg(Mth.atan2(diff.x, diff.z));
|
||||||
|
float hDistance = (float) diff.multiply(1, 0, 1)
|
||||||
|
.length();
|
||||||
|
float vAngle = AngleHelper.deg(Mth.atan2(hDistance, diff.y)) - 90;
|
||||||
|
ms.pushPose();
|
||||||
|
TransformStack.cast(ms)
|
||||||
|
.translate(start)
|
||||||
|
.rotateY(hAngle).rotateX(vAngle);
|
||||||
|
renderAACuboidLine(ms, buffer, Vec3.ZERO, new Vec3(0, 0, diff.length()));
|
||||||
|
ms.popPose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void renderAACuboidLine(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 start, Vec3 end) {
|
||||||
|
float lineWidth = params.getLineWidth();
|
||||||
|
if (lineWidth == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
VertexConsumer builder = buffer.getBuffer(RenderTypes.getOutlineSolid());
|
||||||
|
|
||||||
|
Vec3 diff = end.subtract(start);
|
||||||
|
if (diff.x + diff.y + diff.z < 0) {
|
||||||
|
Vec3 temp = start;
|
||||||
|
start = end;
|
||||||
|
end = temp;
|
||||||
|
diff = diff.scale(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec3 extension = diff.normalize()
|
||||||
|
.scale(lineWidth / 2);
|
||||||
|
Vec3 plane = VecHelper.axisAlingedPlaneOf(diff);
|
||||||
|
Direction face = Direction.getNearest(diff.x, diff.y, diff.z);
|
||||||
|
Axis axis = face.getAxis();
|
||||||
|
|
||||||
|
start = start.subtract(extension);
|
||||||
|
end = end.add(extension);
|
||||||
|
plane = plane.scale(lineWidth / 2);
|
||||||
|
|
||||||
|
Vec3 a1 = plane.add(start);
|
||||||
|
Vec3 b1 = plane.add(end);
|
||||||
|
plane = VecHelper.rotate(plane, -90, axis);
|
||||||
|
Vec3 a2 = plane.add(start);
|
||||||
|
Vec3 b2 = plane.add(end);
|
||||||
|
plane = VecHelper.rotate(plane, -90, axis);
|
||||||
|
Vec3 a3 = plane.add(start);
|
||||||
|
Vec3 b3 = plane.add(end);
|
||||||
|
plane = VecHelper.rotate(plane, -90, axis);
|
||||||
|
Vec3 a4 = plane.add(start);
|
||||||
|
Vec3 b4 = plane.add(end);
|
||||||
|
|
||||||
|
if (params.disableNormals) {
|
||||||
|
face = Direction.UP;
|
||||||
|
putQuad(ms, builder, b4, b3, b2, b1, face);
|
||||||
|
putQuad(ms, builder, a1, a2, a3, a4, face);
|
||||||
|
putQuad(ms, builder, a1, b1, b2, a2, face);
|
||||||
|
putQuad(ms, builder, a2, b2, b3, a3, face);
|
||||||
|
putQuad(ms, builder, a3, b3, b4, a4, face);
|
||||||
|
putQuad(ms, builder, a4, b4, b1, a1, face);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
putQuad(ms, builder, b4, b3, b2, b1, face);
|
||||||
|
putQuad(ms, builder, a1, a2, a3, a4, face.getOpposite());
|
||||||
|
Vec3 vec = a1.subtract(a4);
|
||||||
|
face = Direction.getNearest(vec.x, vec.y, vec.z);
|
||||||
|
putQuad(ms, builder, a1, b1, b2, a2, face);
|
||||||
|
vec = VecHelper.rotate(vec, -90, axis);
|
||||||
|
face = Direction.getNearest(vec.x, vec.y, vec.z);
|
||||||
|
putQuad(ms, builder, a2, b2, b3, a3, face);
|
||||||
|
vec = VecHelper.rotate(vec, -90, axis);
|
||||||
|
face = Direction.getNearest(vec.x, vec.y, vec.z);
|
||||||
|
putQuad(ms, builder, a3, b3, b4, a4, face);
|
||||||
|
vec = VecHelper.rotate(vec, -90, axis);
|
||||||
|
face = Direction.getNearest(vec.x, vec.y, vec.z);
|
||||||
|
putQuad(ms, builder, a4, b4, b1, a1, face);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void putQuad(PoseStack ms, VertexConsumer builder, Vec3 v1, Vec3 v2, Vec3 v3, Vec3 v4,
|
||||||
|
Direction normal) {
|
||||||
|
putQuadUV(ms, builder, v1, v2, v3, v4, 0, 0, 1, 1, normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void putQuadUV(PoseStack ms, VertexConsumer builder, Vec3 v1, Vec3 v2, Vec3 v3, Vec3 v4, float minU,
|
||||||
|
float minV, float maxU, float maxV, Direction normal) {
|
||||||
|
putVertex(ms, builder, v1, minU, minV, normal);
|
||||||
|
putVertex(ms, builder, v2, maxU, minV, normal);
|
||||||
|
putVertex(ms, builder, v3, maxU, maxV, normal);
|
||||||
|
putVertex(ms, builder, v4, minU, maxV, normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void putVertex(PoseStack ms, VertexConsumer builder, Vec3 pos, float u, float v, Direction normal) {
|
||||||
|
putVertex(ms.last(), builder, (float) pos.x, (float) pos.y, (float) pos.z, u, v, normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void putVertex(PoseStack.Pose pose, VertexConsumer builder, float x, float y, float z, float u, float v, Direction normal) {
|
||||||
|
Color rgb = params.rgb;
|
||||||
|
if (transformNormals == null)
|
||||||
|
transformNormals = pose.normal();
|
||||||
|
|
||||||
|
int xOffset = 0;
|
||||||
|
int yOffset = 0;
|
||||||
|
int zOffset = 0;
|
||||||
|
|
||||||
|
if (normal != null) {
|
||||||
|
xOffset = normal.getStepX();
|
||||||
|
yOffset = normal.getStepY();
|
||||||
|
zOffset = normal.getStepZ();
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.vertex(pose.pose(), x, y, z)
|
||||||
|
.color(rgb.getRedAsFloat(), rgb.getGreenAsFloat(), rgb.getBlueAsFloat(), rgb.getAlphaAsFloat() * params.alpha)
|
||||||
|
.uv(u, v)
|
||||||
|
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||||
|
.uv2(params.lightMap)
|
||||||
|
.normal(pose.normal(), xOffset, yOffset, zOffset)
|
||||||
|
.endVertex();
|
||||||
|
|
||||||
|
transformNormals = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class OutlineParams {
|
||||||
|
protected Optional<AllSpecialTextures> faceTexture;
|
||||||
|
protected Optional<AllSpecialTextures> hightlightedFaceTexture;
|
||||||
|
protected Direction highlightedFace;
|
||||||
|
protected boolean fadeLineWidth;
|
||||||
|
protected boolean disableCull;
|
||||||
|
protected boolean disableNormals;
|
||||||
|
protected float alpha;
|
||||||
|
protected int lightMap;
|
||||||
|
protected Color rgb;
|
||||||
|
private float lineWidth;
|
||||||
|
|
||||||
|
public OutlineParams() {
|
||||||
|
faceTexture = hightlightedFaceTexture = Optional.empty();
|
||||||
|
alpha = 1;
|
||||||
|
lineWidth = 1 / 32f;
|
||||||
|
fadeLineWidth = true;
|
||||||
|
rgb = Color.WHITE;
|
||||||
|
lightMap = LightTexture.FULL_BRIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
|
// builder
|
||||||
|
|
||||||
|
public OutlineParams colored(int color) {
|
||||||
|
rgb = new Color(color, false);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OutlineParams colored(Color c) {
|
||||||
|
rgb = c.copy();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OutlineParams lightMap(int light) {
|
||||||
|
lightMap = light;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OutlineParams lineWidth(float width) {
|
||||||
|
this.lineWidth = width;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OutlineParams withFaceTexture(AllSpecialTextures texture) {
|
||||||
|
this.faceTexture = Optional.ofNullable(texture);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OutlineParams clearTextures() {
|
||||||
|
return this.withFaceTextures(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OutlineParams withFaceTextures(AllSpecialTextures texture, AllSpecialTextures highlightTexture) {
|
||||||
|
this.faceTexture = Optional.ofNullable(texture);
|
||||||
|
this.hightlightedFaceTexture = Optional.ofNullable(highlightTexture);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OutlineParams highlightFace(@Nullable Direction face) {
|
||||||
|
highlightedFace = face;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OutlineParams disableNormals() {
|
||||||
|
disableNormals = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OutlineParams disableCull() {
|
||||||
|
disableCull = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// getter
|
||||||
|
|
||||||
|
public float getLineWidth() {
|
||||||
|
return fadeLineWidth ? alpha * lineWidth : lineWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Direction getHighlightedFace() {
|
||||||
|
return highlightedFace;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,185 @@
|
|||||||
|
package nl.requios.effortlessbuilding.create.foundation.utility.outliner;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.render.SuperRenderTypeBuffer;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.outliner.LineOutline.EndChasingLineOutline;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.outliner.Outline.OutlineParams;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
|
import net.minecraft.world.phys.AABB;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class Outliner {
|
||||||
|
|
||||||
|
private final Map<Object, OutlineEntry> outlines = Collections.synchronizedMap(new HashMap<>());
|
||||||
|
private final Map<Object, OutlineEntry> outlinesView = Collections.unmodifiableMap(outlines);
|
||||||
|
|
||||||
|
// Facade
|
||||||
|
|
||||||
|
public OutlineParams showLine(Object slot, Vec3 start, Vec3 end) {
|
||||||
|
if (!outlines.containsKey(slot)) {
|
||||||
|
LineOutline outline = new LineOutline();
|
||||||
|
outlines.put(slot, new OutlineEntry(outline));
|
||||||
|
}
|
||||||
|
OutlineEntry entry = outlines.get(slot);
|
||||||
|
entry.ticksTillRemoval = 1;
|
||||||
|
((LineOutline) entry.outline).set(start, end);
|
||||||
|
return entry.outline.getParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
public OutlineParams endChasingLine(Object slot, Vec3 start, Vec3 end, float chasingProgress, boolean lockStart) {
|
||||||
|
if (!outlines.containsKey(slot)) {
|
||||||
|
EndChasingLineOutline outline = new EndChasingLineOutline(lockStart);
|
||||||
|
outlines.put(slot, new OutlineEntry(outline));
|
||||||
|
}
|
||||||
|
OutlineEntry entry = outlines.get(slot);
|
||||||
|
entry.ticksTillRemoval = 1;
|
||||||
|
((EndChasingLineOutline) entry.outline).setProgress(chasingProgress)
|
||||||
|
.set(start, end);
|
||||||
|
return entry.outline.getParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
public OutlineParams showAABB(Object slot, AABB bb, int ttl) {
|
||||||
|
createAABBOutlineIfMissing(slot, bb);
|
||||||
|
ChasingAABBOutline outline = getAndRefreshAABB(slot, ttl);
|
||||||
|
outline.prevBB = outline.targetBB = outline.bb = bb;
|
||||||
|
return outline.getParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
public OutlineParams showAABB(Object slot, AABB bb) {
|
||||||
|
createAABBOutlineIfMissing(slot, bb);
|
||||||
|
ChasingAABBOutline outline = getAndRefreshAABB(slot);
|
||||||
|
outline.prevBB = outline.targetBB = outline.bb = bb;
|
||||||
|
return outline.getParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
public OutlineParams chaseAABB(Object slot, AABB bb) {
|
||||||
|
createAABBOutlineIfMissing(slot, bb);
|
||||||
|
ChasingAABBOutline outline = getAndRefreshAABB(slot);
|
||||||
|
outline.targetBB = bb;
|
||||||
|
return outline.getParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
public OutlineParams showCluster(Object slot, Iterable<BlockPos> selection) {
|
||||||
|
BlockClusterOutline outline = new BlockClusterOutline(selection);
|
||||||
|
OutlineEntry entry = new OutlineEntry(outline);
|
||||||
|
outlines.put(slot, entry);
|
||||||
|
return entry.getOutline()
|
||||||
|
.getParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void keep(Object slot) {
|
||||||
|
if (outlines.containsKey(slot))
|
||||||
|
outlines.get(slot).ticksTillRemoval = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//ADDED
|
||||||
|
public void keep(Object slot, int ticks) {
|
||||||
|
if (outlines.containsKey(slot))
|
||||||
|
outlines.get(slot).ticksTillRemoval = ticks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(Object slot) {
|
||||||
|
outlines.remove(slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<OutlineParams> edit(Object slot) {
|
||||||
|
keep(slot);
|
||||||
|
if (outlines.containsKey(slot))
|
||||||
|
return Optional.of(outlines.get(slot)
|
||||||
|
.getOutline()
|
||||||
|
.getParams());
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Object, OutlineEntry> getOutlines() {
|
||||||
|
return outlinesView;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Utility
|
||||||
|
|
||||||
|
private void createAABBOutlineIfMissing(Object slot, AABB bb) {
|
||||||
|
if (!outlines.containsKey(slot) || !(outlines.get(slot).outline instanceof AABBOutline)) {
|
||||||
|
ChasingAABBOutline outline = new ChasingAABBOutline(bb);
|
||||||
|
outlines.put(slot, new OutlineEntry(outline));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ChasingAABBOutline getAndRefreshAABB(Object slot) {
|
||||||
|
OutlineEntry entry = outlines.get(slot);
|
||||||
|
entry.ticksTillRemoval = 1;
|
||||||
|
return (ChasingAABBOutline) entry.getOutline();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ChasingAABBOutline getAndRefreshAABB(Object slot, int ttl) {
|
||||||
|
OutlineEntry entry = outlines.get(slot);
|
||||||
|
entry.ticksTillRemoval = ttl;
|
||||||
|
return (ChasingAABBOutline) entry.getOutline();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Maintenance
|
||||||
|
|
||||||
|
public void tickOutlines() {
|
||||||
|
Iterator<OutlineEntry> iterator = outlines.values()
|
||||||
|
.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
OutlineEntry entry = iterator.next();
|
||||||
|
entry.tick();
|
||||||
|
if (!entry.isAlive())
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void renderOutlines(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) {
|
||||||
|
outlines.forEach((key, entry) -> {
|
||||||
|
Outline outline = entry.getOutline();
|
||||||
|
OutlineParams params = outline.getParams();
|
||||||
|
params.alpha = 1;
|
||||||
|
if (entry.isFading()) {
|
||||||
|
int prevTicks = entry.ticksTillRemoval + 1;
|
||||||
|
float fadeticks = OutlineEntry.fadeTicks;
|
||||||
|
float lastAlpha = prevTicks >= 0 ? 1 : 1 + (prevTicks / fadeticks);
|
||||||
|
float currentAlpha = 1 + (entry.ticksTillRemoval / fadeticks);
|
||||||
|
float alpha = Mth.lerp(pt, lastAlpha, currentAlpha);
|
||||||
|
|
||||||
|
params.alpha = alpha * alpha * alpha;
|
||||||
|
if (params.alpha < 1 / 8f)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
outline.render(ms, buffer, pt);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class OutlineEntry {
|
||||||
|
|
||||||
|
static final int fadeTicks = 4;
|
||||||
|
private Outline outline;
|
||||||
|
private int ticksTillRemoval;
|
||||||
|
|
||||||
|
public OutlineEntry(Outline outline) {
|
||||||
|
this.outline = outline;
|
||||||
|
ticksTillRemoval = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tick() {
|
||||||
|
ticksTillRemoval--;
|
||||||
|
outline.tick();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAlive() {
|
||||||
|
return ticksTillRemoval >= -fadeTicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFading() {
|
||||||
|
return ticksTillRemoval < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Outline getOutline() {
|
||||||
|
return outline;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -35,7 +35,7 @@ public class WrappedServerWorld extends ServerLevel {
|
|||||||
(ServerLevelData) world.getLevelData(), world.dimension(),
|
(ServerLevelData) world.getLevelData(), world.dimension(),
|
||||||
new LevelStem(world.dimensionTypeRegistration(), world.getChunkSource().getGenerator()),
|
new LevelStem(world.dimensionTypeRegistration(), world.getChunkSource().getGenerator()),
|
||||||
new DummyStatusListener(), world.isDebug(), world.getBiomeManager().biomeZoomSeed,
|
new DummyStatusListener(), world.isDebug(), world.getBiomeManager().biomeZoomSeed,
|
||||||
Collections.emptyList(), false, world.getRandomSequences());
|
Collections.emptyList(), false);
|
||||||
this.world = world;
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ public class DiamondRandomizerBagContainer extends AbstractContainerMenu {
|
|||||||
@Override
|
@Override
|
||||||
public void removed(Player player) {
|
public void removed(Player player) {
|
||||||
super.removed(player);
|
super.removed(player);
|
||||||
if (!player.level().isClientSide) {
|
if (!player.level.isClientSide) {
|
||||||
broadcastChanges();
|
broadcastChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package nl.requios.effortlessbuilding.gui;
|
package nl.requios.effortlessbuilding.gui;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@@ -25,22 +26,24 @@ public class DiamondRandomizerBagScreen extends AbstractContainerScreen<DiamondR
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
|
public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
renderBackground(guiGraphics);
|
renderBackground(ms);
|
||||||
super.render(guiGraphics, mouseX, mouseY, partialTicks);
|
super.render(ms, mouseX, mouseY, partialTicks);
|
||||||
this.renderTooltip(guiGraphics, mouseX, mouseY);
|
this.renderTooltip(ms, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY) {
|
protected void renderLabels(PoseStack ms, int mouseX, int mouseY) {
|
||||||
guiGraphics.drawString(this.font, this.title, 8, 6, 0x404040, false);
|
this.font.draw(ms, this.title, 8, 6, 0x404040);
|
||||||
guiGraphics.drawString(this.font, this.playerInventoryTitle, 8, imageHeight - 96 + 2, 0x404040, false);
|
this.font.draw(ms, this.playerInventoryTitle, 8, imageHeight - 96 + 2, 0x404040);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int mouseX, int mouseY) {
|
protected void renderBg(PoseStack ms, float partialTicks, int mouseX, int mouseY) {
|
||||||
|
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1f);
|
||||||
|
RenderSystem.setShaderTexture(0, guiTextures);
|
||||||
int marginHorizontal = (width - imageWidth) / 2;
|
int marginHorizontal = (width - imageWidth) / 2;
|
||||||
int marginVertical = (height - imageHeight) / 2;
|
int marginVertical = (height - imageHeight) / 2;
|
||||||
guiGraphics.blit(guiTextures, marginHorizontal, marginVertical, 0, 0, imageWidth, imageHeight);
|
blit(ms, marginHorizontal, marginVertical, 0, 0, imageWidth, imageHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public class GoldenRandomizerBagContainer extends AbstractContainerMenu {
|
|||||||
@Override
|
@Override
|
||||||
public void removed(Player player) {
|
public void removed(Player player) {
|
||||||
super.removed(player);
|
super.removed(player);
|
||||||
if (!player.level().isClientSide) {
|
if (!player.level.isClientSide) {
|
||||||
broadcastChanges();
|
broadcastChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package nl.requios.effortlessbuilding.gui;
|
package nl.requios.effortlessbuilding.gui;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@@ -25,22 +26,24 @@ public class GoldenRandomizerBagScreen extends AbstractContainerScreen<GoldenRan
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
|
public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
renderBackground(guiGraphics);
|
renderBackground(ms);
|
||||||
super.render(guiGraphics, mouseX, mouseY, partialTicks);
|
super.render(ms, mouseX, mouseY, partialTicks);
|
||||||
this.renderTooltip(guiGraphics, mouseX, mouseY);
|
this.renderTooltip(ms, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY) {
|
protected void renderLabels(PoseStack ms, int mouseX, int mouseY) {
|
||||||
guiGraphics.drawString(this.font, this.title, 8, 6, 0x404040, false);
|
this.font.draw(ms, this.title, 8, 6, 0x404040);
|
||||||
guiGraphics.drawString(this.font, this.playerInventoryTitle, 8, imageHeight - 96 + 2, 0x404040, false);
|
this.font.draw(ms, this.playerInventoryTitle, 8, imageHeight - 96 + 2, 0x404040);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int mouseX, int mouseY) {
|
protected void renderBg(PoseStack ms, float partialTicks, int mouseX, int mouseY) {
|
||||||
|
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1f);
|
||||||
|
RenderSystem.setShaderTexture(0, guiTextures);
|
||||||
int marginHorizontal = (width - imageWidth) / 2;
|
int marginHorizontal = (width - imageWidth) / 2;
|
||||||
int marginVertical = (height - imageHeight) / 2;
|
int marginVertical = (height - imageHeight) / 2;
|
||||||
guiGraphics.blit(guiTextures, marginHorizontal, marginVertical, 0, 0, imageWidth, imageHeight);
|
blit(ms, marginHorizontal, marginVertical, 0, 0, imageWidth, imageHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public class RandomizerBagContainer extends AbstractContainerMenu {
|
|||||||
@Override
|
@Override
|
||||||
public void removed(Player player) {
|
public void removed(Player player) {
|
||||||
super.removed(player);
|
super.removed(player);
|
||||||
if (!player.level().isClientSide) {
|
if (!player.level.isClientSide) {
|
||||||
broadcastChanges();
|
broadcastChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package nl.requios.effortlessbuilding.gui;
|
package nl.requios.effortlessbuilding.gui;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@@ -25,22 +26,24 @@ public class RandomizerBagScreen extends AbstractContainerScreen<RandomizerBagCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
|
public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
renderBackground(guiGraphics);
|
renderBackground(ms);
|
||||||
super.render(guiGraphics, mouseX, mouseY, partialTicks);
|
super.render(ms, mouseX, mouseY, partialTicks);
|
||||||
this.renderTooltip(guiGraphics, mouseX, mouseY);
|
this.renderTooltip(ms, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY) {
|
protected void renderLabels(PoseStack ms, int mouseX, int mouseY) {
|
||||||
guiGraphics.drawString(this.font, this.title, 8, 6, 0x404040, false);
|
this.font.draw(ms, this.title, 8, 6, 0x404040);
|
||||||
guiGraphics.drawString(this.font, this.playerInventoryTitle, 8, imageHeight - 96 + 2, 0x404040, false);
|
this.font.draw(ms, this.playerInventoryTitle, 8, imageHeight - 96 + 2, 0x404040);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int mouseX, int mouseY) {
|
protected void renderBg(PoseStack ms, float partialTicks, int mouseX, int mouseY) {
|
||||||
|
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1f);
|
||||||
|
RenderSystem.setShaderTexture(0, guiTextures);
|
||||||
int marginHorizontal = (width - imageWidth) / 2;
|
int marginHorizontal = (width - imageWidth) / 2;
|
||||||
int marginVertical = (height - imageHeight) / 2;
|
int marginVertical = (height - imageHeight) / 2;
|
||||||
guiGraphics.blit(guiTextures, marginHorizontal, marginVertical, 0, 0, imageWidth, imageHeight);
|
blit(ms, marginHorizontal, marginVertical, 0, 0, imageWidth, imageHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.mojang.blaze3d.platform.GlStateManager;
|
|||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
@@ -67,19 +66,19 @@ public class PlayerSettingsGui extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
|
public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
this.renderBackground(guiGraphics);
|
this.renderBackground(ms);
|
||||||
|
|
||||||
int yy = top;
|
int yy = top;
|
||||||
guiGraphics.drawString(font, "Shader type", left, yy + 5, 0xFFFFFF, false);
|
font.draw(ms, "Shader type", left, yy + 5, 0xFFFFFF);
|
||||||
|
|
||||||
yy += 50;
|
yy += 50;
|
||||||
guiGraphics.drawString(font, "Shader speed", left, yy + 5, 0xFFFFFF, false);
|
font.draw(ms, "Shader speed", left, yy + 5, 0xFFFFFF);
|
||||||
|
|
||||||
super.render(guiGraphics, mouseX, mouseY, partialTicks);
|
super.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
if (showShaderList)
|
if (showShaderList)
|
||||||
this.shaderTypeList.render(guiGraphics, mouseX, mouseY, partialTicks);
|
this.shaderTypeList.render(ms, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -191,7 +190,7 @@ public class PlayerSettingsGui extends Screen {
|
|||||||
|
|
||||||
//From AbstractSelectionList, disabled parts
|
//From AbstractSelectionList, disabled parts
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, int p_render_1_, int p_render_2_, float p_render_3_) {
|
public void render(PoseStack guiGraphics, int p_render_1_, int p_render_2_, float p_render_3_) {
|
||||||
this.renderBackground(guiGraphics);
|
this.renderBackground(guiGraphics);
|
||||||
int i = this.getScrollbarPosition();
|
int i = this.getScrollbarPosition();
|
||||||
int j = i + 6;
|
int j = i + 6;
|
||||||
@@ -284,9 +283,9 @@ public class PlayerSettingsGui extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, int itemIndex, int rowTop, int rowLeft, int rowWidth, int rowHeight, int mouseX, int mouseY, boolean hovered, float partialTicks) {
|
public void render(PoseStack ms, int itemIndex, int rowTop, int rowLeft, int rowWidth, int rowHeight, int mouseX, int mouseY, boolean hovered, float partialTicks) {
|
||||||
if (rowTop + 10 > ShaderTypeList.this.y0 && rowTop + rowHeight - 5 < ShaderTypeList.this.y1)
|
if (rowTop + 10 > ShaderTypeList.this.y0 && rowTop + rowHeight - 5 < ShaderTypeList.this.y1)
|
||||||
guiGraphics.drawString(font, shaderType.name, ShaderTypeList.this.x0 + 8, rowTop + 4, 0xFFFFFF, false);
|
font.draw(ms, shaderType.name, ShaderTypeList.this.x0 + 8, rowTop + 4, 0xFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import com.mojang.blaze3d.vertex.VertexFormat;
|
|||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.KeyMapping;
|
import net.minecraft.client.KeyMapping;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.client.resources.language.I18n;
|
import net.minecraft.client.resources.language.I18n;
|
||||||
@@ -26,7 +26,6 @@ import nl.requios.effortlessbuilding.buildmode.BuildModeEnum;
|
|||||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions.ActionEnum;
|
import nl.requios.effortlessbuilding.buildmode.ModeOptions.ActionEnum;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions.OptionEnum;
|
import nl.requios.effortlessbuilding.buildmode.ModeOptions.OptionEnum;
|
||||||
import nl.requios.effortlessbuilding.capability.CapabilityHandler;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.item.ItemDescription;
|
import nl.requios.effortlessbuilding.create.foundation.item.ItemDescription;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.item.TooltipHelper;
|
import nl.requios.effortlessbuilding.create.foundation.item.TooltipHelper;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||||
@@ -103,10 +102,9 @@ public class RadialMenu extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, final int mouseX, final int mouseY, final float partialTicks) {
|
public void render(PoseStack ms, final int mouseX, final int mouseY, final float partialTicks) {
|
||||||
BuildModeEnum currentBuildMode = EffortlessBuildingClient.BUILD_MODES.getBuildMode();
|
BuildModeEnum currentBuildMode = EffortlessBuildingClient.BUILD_MODES.getBuildMode();
|
||||||
|
|
||||||
PoseStack ms = guiGraphics.pose();
|
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
ms.translate(0, 0, 200);
|
ms.translate(0, 0, 200);
|
||||||
|
|
||||||
@@ -116,7 +114,7 @@ public class RadialMenu extends Screen {
|
|||||||
final int startColor = (int) (visibility * 98) << 24;
|
final int startColor = (int) (visibility * 98) << 24;
|
||||||
final int endColor = (int) (visibility * 128) << 24;
|
final int endColor = (int) (visibility * 128) << 24;
|
||||||
|
|
||||||
guiGraphics.fillGradient(0, 0, width, height, startColor, endColor);
|
fillGradient(ms, 0, 0, width, height, startColor, endColor);
|
||||||
|
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||||
@@ -152,10 +150,8 @@ public class RadialMenu extends Screen {
|
|||||||
modes.add(new MenuRegion(mode));
|
modes.add(new MenuRegion(mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Add actions
|
//Add actions
|
||||||
boolean canReplace = CapabilityHandler.canReplaceBlocks(minecraft.player);
|
boolean canReplace = minecraft.player != null && EffortlessBuildingClient.POWER_LEVEL.canReplaceBlocks(minecraft.player);
|
||||||
|
|
||||||
// buttons.add(new MenuButton(ActionEnum.OPEN_PLAYER_SETTINGS, -buttonDistance - 65, -13, Direction.UP));
|
// buttons.add(new MenuButton(ActionEnum.OPEN_PLAYER_SETTINGS, -buttonDistance - 65, -13, Direction.UP));
|
||||||
if (canReplace) {
|
if (canReplace) {
|
||||||
@@ -194,9 +190,9 @@ public class RadialMenu extends Screen {
|
|||||||
tessellator.end();
|
tessellator.end();
|
||||||
RenderSystem.disableBlend();
|
RenderSystem.disableBlend();
|
||||||
|
|
||||||
drawIcons(guiGraphics, middleX, middleY, modes, buttons);
|
drawIcons(ms, middleX, middleY, modes, buttons);
|
||||||
|
|
||||||
drawTexts(guiGraphics, currentBuildMode, middleX, middleY, modes, buttons, options, mouseXX, mouseYY);
|
drawTexts(ms, currentBuildMode, middleX, middleY, modes, buttons, options, mouseXX, mouseYY);
|
||||||
|
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
}
|
}
|
||||||
@@ -298,9 +294,8 @@ public class RadialMenu extends Screen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawIcons(GuiGraphics guiGraphics, double middleX, double middleY,
|
private void drawIcons(PoseStack ms, double middleX, double middleY,
|
||||||
ArrayList<MenuRegion> modes, ArrayList<MenuButton> buttons) {
|
ArrayList<MenuRegion> modes, ArrayList<MenuButton> buttons) {
|
||||||
PoseStack ms = guiGraphics.pose();
|
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
|
|
||||||
//Draw buildmode icons
|
//Draw buildmode icons
|
||||||
@@ -309,7 +304,7 @@ public class RadialMenu extends Screen {
|
|||||||
final double x = (menuRegion.x1 + menuRegion.x2) * 0.5 * (ringOuterEdge * 0.55 + 0.45 * ringInnerEdge);
|
final double x = (menuRegion.x1 + menuRegion.x2) * 0.5 * (ringOuterEdge * 0.55 + 0.45 * ringInnerEdge);
|
||||||
final double y = (menuRegion.y1 + menuRegion.y2) * 0.5 * (ringOuterEdge * 0.55 + 0.45 * ringInnerEdge);
|
final double y = (menuRegion.y1 + menuRegion.y2) * 0.5 * (ringOuterEdge * 0.55 + 0.45 * ringInnerEdge);
|
||||||
|
|
||||||
menuRegion.mode.icon.render(guiGraphics, (int) (middleX + x - 8), (int) (middleY + y - 8));
|
menuRegion.mode.icon.render(ms, (int) (middleX + x - 8), (int) (middleY + y - 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Draw action icons
|
//Draw action icons
|
||||||
@@ -318,51 +313,51 @@ public class RadialMenu extends Screen {
|
|||||||
final double x = (button.x1 + button.x2) / 2 + 0.01;
|
final double x = (button.x1 + button.x2) / 2 + 0.01;
|
||||||
final double y = (button.y1 + button.y2) / 2 + 0.01;
|
final double y = (button.y1 + button.y2) / 2 + 0.01;
|
||||||
|
|
||||||
button.action.icon.render(guiGraphics, (int) (middleX + x - 8), (int) (middleY + y - 8));
|
button.action.icon.render(ms, (int) (middleX + x - 8), (int) (middleY + y - 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawTexts(GuiGraphics guiGraphics, BuildModeEnum currentBuildMode, double middleX, double middleY, ArrayList<MenuRegion> modes, ArrayList<MenuButton> buttons, OptionEnum[] options, int mouseX, int mouseY) {
|
private void drawTexts(PoseStack ms, BuildModeEnum currentBuildMode, double middleX, double middleY, ArrayList<MenuRegion> modes, ArrayList<MenuButton> buttons, OptionEnum[] options, int mouseX, int mouseY) {
|
||||||
//font.drawStringWithShadow("Actions", (int) (middleX - buttonDistance - 13) - font.getStringWidth("Actions") * 0.5f, (int) middleY - 38, 0xffffffff);
|
//font.drawStringWithShadow("Actions", (int) (middleX - buttonDistance - 13) - font.getStringWidth("Actions") * 0.5f, (int) middleY - 38, 0xffffffff);
|
||||||
|
|
||||||
//Draw option strings
|
//Draw option strings
|
||||||
for (int i = 0; i < currentBuildMode.options.length; i++) {
|
for (int i = 0; i < currentBuildMode.options.length; i++) {
|
||||||
OptionEnum option = options[i];
|
OptionEnum option = options[i];
|
||||||
guiGraphics.drawString(font, I18n.get(option.name), (int) (middleX + buttonDistance - 9), (int) middleY - 37 + i * 39, optionTextColor);
|
font.draw(ms, I18n.get(option.name), (int) (middleX + buttonDistance - 9), (int) middleY - 37 + i * 39, optionTextColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
String credits = "Effortless Building";
|
String credits = "Effortless Building";
|
||||||
guiGraphics.drawString(font, credits, width - font.width(credits) - 4, height - 10, watermarkTextColor);
|
font.draw(ms, credits, width - font.width(credits) - 4, height - 10, watermarkTextColor);
|
||||||
|
|
||||||
//Draw power level info
|
//Draw power level info
|
||||||
String powerLevelValue = minecraft.player.isCreative() ? "Creative" : String.valueOf(CapabilityHandler.getPowerLevel(minecraft.player));
|
String powerLevelValue = minecraft.player.isCreative() ? "Creative" : String.valueOf(EffortlessBuildingClient.POWER_LEVEL.getPowerLevel());
|
||||||
String powerLevelText = I18n.get("key.effortlessbuilding.power_level") + ": " + powerLevelValue;
|
String powerLevelText = I18n.get("key.effortlessbuilding.power_level") + ": " + powerLevelValue;
|
||||||
guiGraphics.drawString(font, powerLevelText, width - font.width(powerLevelText) - 4, height - 22, minecraft.player.isCreative() ? watermarkTextColor : ChatFormatting.DARK_PURPLE.getColor());
|
font.draw(ms, powerLevelText, width - font.width(powerLevelText) - 4, height - 22, minecraft.player.isCreative() ? watermarkTextColor : ChatFormatting.DARK_PURPLE.getColor());
|
||||||
|
|
||||||
//if hover over power level info, show tooltip
|
//if hover over power level info, show tooltip
|
||||||
if (mouseX >= width - font.width(powerLevelText) - 14 && mouseX <= width && mouseY >= height - 24 && mouseY <= height) {
|
if (mouseX >= width - font.width(powerLevelText) - 14 && mouseX <= width && mouseY >= height - 24 && mouseY <= height) {
|
||||||
var tooltip = new ArrayList<Component>();
|
var tooltip = new ArrayList<Component>();
|
||||||
tooltip.add(Components.literal(powerLevelText).withStyle(ChatFormatting.DARK_PURPLE));
|
tooltip.add(Components.literal(powerLevelText).withStyle(ChatFormatting.DARK_PURPLE));
|
||||||
int placementReach = CapabilityHandler.getPlacementReach(minecraft.player, false);
|
int placementReach = EffortlessBuildingClient.POWER_LEVEL.getPlacementReach(minecraft.player);
|
||||||
tooltip.add(Components.translatable("key.effortlessbuilding.placement_reach").withStyle(ChatFormatting.GRAY).append(": " + (placementReach == 0 ? "vanilla" : placementReach + " blocks")));
|
tooltip.add(Components.translatable("key.effortlessbuilding.placement_reach").withStyle(ChatFormatting.GRAY).append(": " + (placementReach == 0 ? "vanilla" : placementReach + " blocks")));
|
||||||
tooltip.add(Components.translatable("key.effortlessbuilding.max_blocks_per_axis").withStyle(ChatFormatting.GRAY).append(": " + CapabilityHandler.getMaxBlocksPerAxis(minecraft.player, false)));
|
tooltip.add(Components.translatable("key.effortlessbuilding.max_blocks_per_axis").withStyle(ChatFormatting.GRAY).append(": " + EffortlessBuildingClient.POWER_LEVEL.getMaxBlocksPerAxis(minecraft.player)));
|
||||||
tooltip.add(Components.translatable("key.effortlessbuilding.max_blocks_placed_at_once").withStyle(ChatFormatting.GRAY).append(": " + CapabilityHandler.getMaxBlocksPlacedAtOnce(minecraft.player, false)));
|
tooltip.add(Components.translatable("key.effortlessbuilding.max_blocks_placed_at_once").withStyle(ChatFormatting.GRAY).append(": " + EffortlessBuildingClient.POWER_LEVEL.getMaxBlocksPlacedAtOnce(minecraft.player)));
|
||||||
tooltip.add(Components.translatable("key.effortlessbuilding.max_mirror_radius").withStyle(ChatFormatting.GRAY).append(": " + CapabilityHandler.getMaxMirrorRadius(minecraft.player, false) + " blocks"));
|
tooltip.add(Components.translatable("key.effortlessbuilding.max_mirror_radius").withStyle(ChatFormatting.GRAY).append(": " + EffortlessBuildingClient.POWER_LEVEL.getMaxMirrorRadius(minecraft.player) + " blocks"));
|
||||||
|
|
||||||
if (CapabilityHandler.canIncreasePowerLevel(minecraft.player) && !minecraft.player.isCreative()) {
|
if (EffortlessBuildingClient.POWER_LEVEL.canIncreasePowerLevel() && !minecraft.player.isCreative()) {
|
||||||
tooltip.add(Components.literal(""));
|
tooltip.add(Components.literal(""));
|
||||||
tooltip.add(Components.translatable("key.effortlessbuilding.next_power_level").withStyle(ChatFormatting.DARK_AQUA).append(": " + CapabilityHandler.getNextPowerLevel(minecraft.player)));
|
tooltip.add(Components.translatable("key.effortlessbuilding.next_power_level").withStyle(ChatFormatting.DARK_AQUA).append(": " + EffortlessBuildingClient.POWER_LEVEL.getNextPowerLevel()));
|
||||||
tooltip.add(Components.translatable("key.effortlessbuilding.placement_reach").withStyle(ChatFormatting.GRAY).append(": " + CapabilityHandler.getPlacementReach(minecraft.player, true) + " blocks"));
|
tooltip.add(Components.translatable("key.effortlessbuilding.placement_reach").withStyle(ChatFormatting.GRAY).append(": " + EffortlessBuildingClient.POWER_LEVEL.getPlacementReach(minecraft.player, true) + " blocks"));
|
||||||
tooltip.add(Components.translatable("key.effortlessbuilding.max_blocks_per_axis").withStyle(ChatFormatting.GRAY).append(": " + CapabilityHandler.getMaxBlocksPerAxis(minecraft.player, true)));
|
tooltip.add(Components.translatable("key.effortlessbuilding.max_blocks_per_axis").withStyle(ChatFormatting.GRAY).append(": " + EffortlessBuildingClient.POWER_LEVEL.getMaxBlocksPerAxis(minecraft.player, true)));
|
||||||
tooltip.add(Components.translatable("key.effortlessbuilding.max_blocks_placed_at_once").withStyle(ChatFormatting.GRAY).append(": " + CapabilityHandler.getMaxBlocksPlacedAtOnce(minecraft.player, true)));
|
tooltip.add(Components.translatable("key.effortlessbuilding.max_blocks_placed_at_once").withStyle(ChatFormatting.GRAY).append(": " + EffortlessBuildingClient.POWER_LEVEL.getMaxBlocksPlacedAtOnce(minecraft.player, true)));
|
||||||
tooltip.add(Components.translatable("key.effortlessbuilding.max_mirror_radius").withStyle(ChatFormatting.GRAY).append(": " + CapabilityHandler.getMaxMirrorRadius(minecraft.player, true) + " blocks"));
|
tooltip.add(Components.translatable("key.effortlessbuilding.max_mirror_radius").withStyle(ChatFormatting.GRAY).append(": " + EffortlessBuildingClient.POWER_LEVEL.getMaxMirrorRadius(minecraft.player, true) + " blocks"));
|
||||||
tooltip.add(Components.literal(""));
|
tooltip.add(Components.literal(""));
|
||||||
tooltip.addAll(TooltipHelper.cutTextComponent(Components.translatable("key.effortlessbuilding.next_power_level_how"), ChatFormatting.GRAY, ChatFormatting.WHITE));
|
tooltip.addAll(TooltipHelper.cutTextComponent(Components.translatable("key.effortlessbuilding.next_power_level_how"), ChatFormatting.GRAY, ChatFormatting.WHITE));
|
||||||
}
|
}
|
||||||
|
|
||||||
guiGraphics.renderComponentTooltip(font, tooltip, mouseX, mouseY);
|
renderComponentTooltip(ms, tooltip, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -383,11 +378,11 @@ public class RadialMenu extends Screen {
|
|||||||
fixed_x -= font.width(text) / 2;
|
fixed_x -= font.width(text) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
guiGraphics.drawString(font, text, (int) middleX + fixed_x, (int) middleY + fixed_y, whiteTextColor);
|
font.draw(ms, text, (int) middleX + fixed_x, (int) middleY + fixed_y, whiteTextColor);
|
||||||
|
|
||||||
//Draw description
|
//Draw description
|
||||||
text = I18n.get(menuRegion.mode.getDescriptionKey());
|
text = I18n.get(menuRegion.mode.getDescriptionKey());
|
||||||
guiGraphics.drawString(font, text, (int) ((int) middleX - font.width(text) / 2f), (int) middleY + buildModeDescriptionHeight, descriptionTextColor);
|
font.draw(ms, text, (int) ((int) middleX - font.width(text) / 2f), (int) middleY + buildModeDescriptionHeight, descriptionTextColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,7 +405,7 @@ public class RadialMenu extends Screen {
|
|||||||
var keybind = findKeybind(button);
|
var keybind = findKeybind(button);
|
||||||
if (keybind != null)
|
if (keybind != null)
|
||||||
tooltip.add(Lang.translateDirect("tooltip.keybind", keybind.withStyle(ChatFormatting.GRAY)).withStyle(ChatFormatting.DARK_GRAY));
|
tooltip.add(Lang.translateDirect("tooltip.keybind", keybind.withStyle(ChatFormatting.GRAY)).withStyle(ChatFormatting.DARK_GRAY));
|
||||||
guiGraphics.renderComponentTooltip(font, tooltip, mouseX, mouseY);
|
renderComponentTooltip(ms, tooltip, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import nl.requios.effortlessbuilding.AllGuiTextures;
|
import nl.requios.effortlessbuilding.AllGuiTextures;
|
||||||
|
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.Array;
|
import nl.requios.effortlessbuilding.buildmodifier.Array;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.BaseModifier;
|
import nl.requios.effortlessbuilding.buildmodifier.BaseModifier;
|
||||||
import nl.requios.effortlessbuilding.capability.CapabilityHandler;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.ScrollInput;
|
import nl.requios.effortlessbuilding.create.foundation.gui.widget.ScrollInput;
|
||||||
import nl.requios.effortlessbuilding.gui.elements.LabeledScrollInput;
|
import nl.requios.effortlessbuilding.gui.elements.LabeledScrollInput;
|
||||||
import nl.requios.effortlessbuilding.utilities.MathHelper;
|
import nl.requios.effortlessbuilding.utilities.MathHelper;
|
||||||
@@ -59,25 +59,25 @@ public class ArrayEntry extends BaseModifierEntry<Array> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) {
|
public void render(PoseStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) {
|
||||||
super.render(guiGraphics, index, y, x, width, height, mouseX, mouseY, p_230432_9_, partialTicks);
|
super.render(ms, index, y, x, width, height, mouseX, mouseY, p_230432_9_, partialTicks);
|
||||||
|
|
||||||
//draw offset inputs
|
//draw offset inputs
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
offsetInputs.get(i).setX(left + 49 + 20 * i);
|
offsetInputs.get(i).setX(left + 49 + 20 * i);
|
||||||
offsetInputs.get(i).setY(top + 19);
|
offsetInputs.get(i).setY(top + 19);
|
||||||
offsetInputs.get(i).render(guiGraphics, mouseX, mouseY, partialTicks);
|
offsetInputs.get(i).render(ms, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
//draw count input
|
//draw count input
|
||||||
countInput.setX(left + 49);
|
countInput.setX(left + 49);
|
||||||
countInput.setY(top + 41);
|
countInput.setY(top + 41);
|
||||||
countInput.render(guiGraphics, mouseX, mouseY, partialTicks);
|
countInput.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
//draw reach label
|
//draw reach label
|
||||||
reachLabel.setX(right - 8 - getFont().width(reachLabel.text));
|
reachLabel.setX(right - 8 - getFont().width(reachLabel.text));
|
||||||
reachLabel.setY(top + 24);
|
reachLabel.setY(top + 24);
|
||||||
reachLabel.render(guiGraphics, mouseX, mouseY, partialTicks);
|
reachLabel.render(ms, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -85,7 +85,7 @@ public class ArrayEntry extends BaseModifierEntry<Array> {
|
|||||||
super.onValueChanged();
|
super.onValueChanged();
|
||||||
|
|
||||||
int currentReach = Math.max(-1, getArrayReach());
|
int currentReach = Math.max(-1, getArrayReach());
|
||||||
int maxReach = CapabilityHandler.getMaxBlocksPerAxis(Minecraft.getInstance().player, false);
|
int maxReach = EffortlessBuildingClient.POWER_LEVEL.getMaxBlocksPerAxis(Minecraft.getInstance().player);
|
||||||
ChatFormatting reachColor = isCurrentReachValid(currentReach, maxReach) ? ChatFormatting.GRAY : ChatFormatting.RED;
|
ChatFormatting reachColor = isCurrentReachValid(currentReach, maxReach) ? ChatFormatting.GRAY : ChatFormatting.RED;
|
||||||
var reachText = "" + reachColor + currentReach + ChatFormatting.GRAY + "/" + ChatFormatting.GRAY + maxReach;
|
var reachText = "" + reachColor + currentReach + ChatFormatting.GRAY + "/" + ChatFormatting.GRAY + maxReach;
|
||||||
reachLabel.text = Component.literal(reachText);
|
reachLabel.text = Component.literal(reachText);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import nl.requios.effortlessbuilding.AllGuiTextures;
|
import nl.requios.effortlessbuilding.AllGuiTextures;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.BaseModifier;
|
import nl.requios.effortlessbuilding.buildmodifier.BaseModifier;
|
||||||
@@ -80,39 +80,39 @@ public abstract class BaseModifierEntry<T extends BaseModifier> extends Modifier
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) {
|
public void render(PoseStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) {
|
||||||
|
|
||||||
left = x + width / 2 - BACKGROUND_WIDTH / 2;
|
left = x + width / 2 - BACKGROUND_WIDTH / 2;
|
||||||
right = x + width / 2 + BACKGROUND_WIDTH / 2;
|
right = x + width / 2 + BACKGROUND_WIDTH / 2;
|
||||||
top = y;
|
top = y;
|
||||||
bottom = y + BACKGROUND_HEIGHT;
|
bottom = y + BACKGROUND_HEIGHT;
|
||||||
|
|
||||||
background.render(guiGraphics, left, top);
|
background.render(ms, left, top);
|
||||||
|
|
||||||
enableButton.setX(left + 4);
|
enableButton.setX(left + 4);
|
||||||
enableButton.setY(top + 3);
|
enableButton.setY(top + 3);
|
||||||
enableButton.render(guiGraphics, mouseX, mouseY, partialTicks);
|
enableButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
if (modifier.enabled)
|
if (modifier.enabled)
|
||||||
AllGuiTextures.CHECKMARK.render(guiGraphics, left + 5, top + 3);
|
AllGuiTextures.CHECKMARK.render(ms, left + 5, top + 3);
|
||||||
|
|
||||||
nameLabel.setX(left + 18);
|
nameLabel.setX(left + 18);
|
||||||
nameLabel.setY(top + 4);
|
nameLabel.setY(top + 4);
|
||||||
nameLabel.render(guiGraphics, mouseX, mouseY, partialTicks);
|
nameLabel.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
moveUpButton.visible = screen.canMoveUp(this);
|
moveUpButton.visible = screen.canMoveUp(this);
|
||||||
moveDownButton.visible = screen.canMoveDown(this);
|
moveDownButton.visible = screen.canMoveDown(this);
|
||||||
|
|
||||||
moveUpButton.setX(right - 31);
|
moveUpButton.setX(right - 31);
|
||||||
moveUpButton.setY(top + 3);
|
moveUpButton.setY(top + 3);
|
||||||
moveUpButton.render(guiGraphics, mouseX, mouseY, partialTicks);
|
moveUpButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
moveDownButton.setX(right - 22);
|
moveDownButton.setX(right - 22);
|
||||||
moveDownButton.setY(top + 3);
|
moveDownButton.setY(top + 3);
|
||||||
moveDownButton.render(guiGraphics, mouseX, mouseY, partialTicks);
|
moveDownButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
removeButton.setX(right - 13);
|
removeButton.setX(right - 13);
|
||||||
removeButton.setY(top + 3);
|
removeButton.setY(top + 3);
|
||||||
removeButton.render(guiGraphics, mouseX, mouseY, partialTicks);
|
removeButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onValueChanged() {
|
public void onValueChanged() {
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import nl.requios.effortlessbuilding.AllGuiTextures;
|
import nl.requios.effortlessbuilding.AllGuiTextures;
|
||||||
import nl.requios.effortlessbuilding.AllIcons;
|
import nl.requios.effortlessbuilding.AllIcons;
|
||||||
|
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.BaseModifier;
|
import nl.requios.effortlessbuilding.buildmodifier.BaseModifier;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.Mirror;
|
import nl.requios.effortlessbuilding.buildmodifier.Mirror;
|
||||||
import nl.requios.effortlessbuilding.capability.CapabilityHandler;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.IconButton;
|
import nl.requios.effortlessbuilding.create.foundation.gui.widget.IconButton;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.ScrollInput;
|
import nl.requios.effortlessbuilding.create.foundation.gui.widget.ScrollInput;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||||
@@ -101,7 +101,7 @@ public class MirrorEntry extends BaseModifierEntry<Mirror> {
|
|||||||
|
|
||||||
//Radius
|
//Radius
|
||||||
radiusInput = new LabeledScrollInput(0, 0, 27, 18)
|
radiusInput = new LabeledScrollInput(0, 0, 27, 18)
|
||||||
.withRange(0, CapabilityHandler.getMaxMirrorRadius(Minecraft.getInstance().player, false))
|
.withRange(0, EffortlessBuildingClient.POWER_LEVEL.getMaxMirrorRadius(Minecraft.getInstance().player))
|
||||||
.titled(Minecraft.getInstance().player.isCreative() ?
|
.titled(Minecraft.getInstance().player.isCreative() ?
|
||||||
Component.literal("Radius") :
|
Component.literal("Radius") :
|
||||||
Component.literal("Radius. Use Reach Upgrade items to increase maximum."))
|
Component.literal("Radius. Use Reach Upgrade items to increase maximum."))
|
||||||
@@ -135,49 +135,49 @@ public class MirrorEntry extends BaseModifierEntry<Mirror> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) {
|
public void render(PoseStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) {
|
||||||
super.render(guiGraphics, index, y, x, width, height, mouseX, mouseY, p_230432_9_, partialTicks);
|
super.render(ms, index, y, x, width, height, mouseX, mouseY, p_230432_9_, partialTicks);
|
||||||
|
|
||||||
//draw position inputs
|
//draw position inputs
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
ScrollInput input = positionInputs.get(i);
|
ScrollInput input = positionInputs.get(i);
|
||||||
input.setX(left + 49 + 38 * i);
|
input.setX(left + 49 + 38 * i);
|
||||||
input.setY(top + 19);
|
input.setY(top + 19);
|
||||||
input.render(guiGraphics, mouseX, mouseY, partialTicks);
|
input.render(ms, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
//draw player position button
|
//draw player position button
|
||||||
playerPositionButton.setX(left + 163);
|
playerPositionButton.setX(left + 163);
|
||||||
playerPositionButton.setY(top + 19);
|
playerPositionButton.setY(top + 19);
|
||||||
playerPositionButton.render(guiGraphics, mouseX, mouseY, partialTicks);
|
playerPositionButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
//draw toggle offset button
|
//draw toggle offset button
|
||||||
toggleOffsetButton.setX(left + 183);
|
toggleOffsetButton.setX(left + 183);
|
||||||
toggleOffsetButton.setY(top + 19);
|
toggleOffsetButton.setY(top + 19);
|
||||||
toggleOffsetButton.render(guiGraphics, mouseX, mouseY, partialTicks);
|
toggleOffsetButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
//draw axis buttons
|
//draw axis buttons
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
IconButton button = axisButtons.get(i);
|
IconButton button = axisButtons.get(i);
|
||||||
button.setX(left + 49 + 18 * i);
|
button.setX(left + 49 + 18 * i);
|
||||||
button.setY(top + 41);
|
button.setY(top + 41);
|
||||||
button.render(guiGraphics, mouseX, mouseY, partialTicks);
|
button.render(ms, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
//draw radius input
|
//draw radius input
|
||||||
radiusInput.setX(left + 134);
|
radiusInput.setX(left + 134);
|
||||||
radiusInput.setY(top + 41);
|
radiusInput.setY(top + 41);
|
||||||
radiusInput.render(guiGraphics, mouseX, mouseY, partialTicks);
|
radiusInput.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
//draw show lines button
|
//draw show lines button
|
||||||
showLinesButton.setX(left + 163);
|
showLinesButton.setX(left + 163);
|
||||||
showLinesButton.setY(top + 41);
|
showLinesButton.setY(top + 41);
|
||||||
showLinesButton.render(guiGraphics, mouseX, mouseY, partialTicks);
|
showLinesButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
//draw show areas button
|
//draw show areas button
|
||||||
showAreasButton.setX(left + 183);
|
showAreasButton.setX(left + 183);
|
||||||
showAreasButton.setY(top + 41);
|
showAreasButton.setY(top + 41);
|
||||||
showAreasButton.render(guiGraphics, mouseX, mouseY, partialTicks);
|
showAreasButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
@@ -145,7 +145,7 @@ public class ModifiersScreen extends AbstractSimiScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderWindow(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
|
protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package nl.requios.effortlessbuilding.gui.buildmodifier;
|
|||||||
|
|
||||||
import com.mojang.blaze3d.platform.Window;
|
import com.mojang.blaze3d.platform.Window;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
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.components.ObjectSelectionList;
|
import net.minecraft.client.gui.components.ObjectSelectionList;
|
||||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
@@ -30,30 +30,30 @@ public class ModifiersScreenList extends ObjectSelectionList<ModifiersScreenList
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
|
public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
Color c = new Color(0x60_000000);
|
Color c = new Color(0x60_000000);
|
||||||
UIRenderHelper.angledGradient(guiGraphics, 90, x0 + width / 2, y0, width, 5, c, Color.TRANSPARENT_BLACK);
|
UIRenderHelper.angledGradient(ms, 90, x0 + width / 2, y0, width, 5, c, Color.TRANSPARENT_BLACK);
|
||||||
UIRenderHelper.angledGradient(guiGraphics, -90, x0 + width / 2, y1, width, 5, c, Color.TRANSPARENT_BLACK);
|
UIRenderHelper.angledGradient(ms, -90, x0 + width / 2, y1, width, 5, c, Color.TRANSPARENT_BLACK);
|
||||||
UIRenderHelper.angledGradient(guiGraphics, 0, x0, y0 + height / 2, height, 5, c, Color.TRANSPARENT_BLACK);
|
UIRenderHelper.angledGradient(ms, 0, x0, y0 + height / 2, height, 5, c, Color.TRANSPARENT_BLACK);
|
||||||
UIRenderHelper.angledGradient(guiGraphics, 180, x1, y0 + height / 2, height, 5, c, Color.TRANSPARENT_BLACK);
|
UIRenderHelper.angledGradient(ms, 180, x1, y0 + height / 2, height, 5, c, Color.TRANSPARENT_BLACK);
|
||||||
|
|
||||||
super.render(guiGraphics, mouseX, mouseY, partialTicks);
|
super.render(ms, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderList(GuiGraphics guiGraphics, int p_239229_, int p_239230_, float p_239231_) {
|
protected void renderList(PoseStack ms, int p_239229_, int p_239230_, float p_239231_) {
|
||||||
Window window = minecraft.getWindow();
|
Window window = minecraft.getWindow();
|
||||||
double d0 = window.getGuiScale();
|
double d0 = window.getGuiScale();
|
||||||
RenderSystem.enableScissor((int) (this.x0 * d0), (int) (window.getHeight() - (this.y1 * d0)), (int) (this.width * d0), (int) (this.height * d0));
|
RenderSystem.enableScissor((int) (this.x0 * d0), (int) (window.getHeight() - (this.y1 * d0)), (int) (this.width * d0), (int) (this.height * d0));
|
||||||
super.renderList(guiGraphics, p_239229_, p_239230_, p_239231_);
|
super.renderList(ms, p_239229_, p_239230_, p_239231_);
|
||||||
RenderSystem.disableScissor();
|
RenderSystem.disableScissor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderWindowForeground(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
|
public void renderWindowForeground(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
renderListForeground(guiGraphics, mouseX, mouseY, partialTicks);
|
renderListForeground(ms, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderListForeground(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPartialTick) {
|
protected void renderListForeground(PoseStack ms, int pMouseX, int pMouseY, float pPartialTick) {
|
||||||
int i = this.getRowLeft();
|
int i = this.getRowLeft();
|
||||||
int j = this.getRowWidth();
|
int j = this.getRowWidth();
|
||||||
int k = this.itemHeight - 4;
|
int k = this.itemHeight - 4;
|
||||||
@@ -63,14 +63,14 @@ public class ModifiersScreenList extends ObjectSelectionList<ModifiersScreenList
|
|||||||
int j1 = this.getRowTop(i1);
|
int j1 = this.getRowTop(i1);
|
||||||
int k1 = j1 + itemHeight;
|
int k1 = j1 + itemHeight;
|
||||||
if (k1 >= this.y0 && j1 <= this.y1) {
|
if (k1 >= this.y0 && j1 <= this.y1) {
|
||||||
renderItemForeground(guiGraphics, pMouseX, pMouseY, pPartialTick, i1, i, j1, j, k);
|
renderItemForeground(ms, pMouseX, pMouseY, pPartialTick, i1, i, j1, j, k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderItemForeground(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPartialTick, int pIndex, int pLeft, int pTop, int pWidth, int pHeight) {
|
protected void renderItemForeground(PoseStack ms, int pMouseX, int pMouseY, float pPartialTick, int pIndex, int pLeft, int pTop, int pWidth, int pHeight) {
|
||||||
Entry e = this.getEntry(pIndex);
|
Entry e = this.getEntry(pIndex);
|
||||||
e.renderForeground(guiGraphics, pIndex, pTop, pLeft, pWidth, pHeight, pMouseX, pMouseY, Objects.equals(this.getHovered(), e), pPartialTick);
|
e.renderForeground(ms, pIndex, pTop, pLeft, pWidth, pHeight, pMouseX, pMouseY, Objects.equals(this.getHovered(), e), pPartialTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -146,14 +146,12 @@ public class ModifiersScreenList extends ObjectSelectionList<ModifiersScreenList
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) {
|
public void render(PoseStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) {
|
||||||
|
// UIRenderHelper.streak(ms, 0, x - 10, y + height / 2, height - 6, width, 0xdd_000000);
|
||||||
// UIRenderHelper.streak(guiGraphics, 0, x - 10, y + height / 2, height - 6, width, 0xdd_000000);
|
// UIRenderHelper.streak(ms, 180, x + (int) (width * 1.35f) + 10, y + height / 2, height - 6, width / 8 * 7, 0xdd_000000);
|
||||||
// UIRenderHelper.streak(guiGraphics, 180, x + (int) (width * 1.35f) + 10, y + height / 2, height - 6, width / 8 * 7, 0xdd_000000);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderForeground(GuiGraphics guiGraphics, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) {
|
public void renderForeground(PoseStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) {
|
||||||
|
|
||||||
for (var listener : listeners) {
|
for (var listener : listeners) {
|
||||||
if (listener instanceof AbstractSimiWidget simiWidget && simiWidget.isHoveredOrFocused()
|
if (listener instanceof AbstractSimiWidget simiWidget && simiWidget.isHoveredOrFocused()
|
||||||
@@ -163,7 +161,7 @@ public class ModifiersScreenList extends ObjectSelectionList<ModifiersScreenList
|
|||||||
continue;
|
continue;
|
||||||
int ttx = simiWidget.lockedTooltipX == -1 ? mouseX : simiWidget.lockedTooltipX + simiWidget.getX();
|
int ttx = simiWidget.lockedTooltipX == -1 ? mouseX : simiWidget.lockedTooltipX + simiWidget.getX();
|
||||||
int tty = simiWidget.lockedTooltipY == -1 ? mouseY : simiWidget.lockedTooltipY + simiWidget.getY();
|
int tty = simiWidget.lockedTooltipY == -1 ? mouseY : simiWidget.lockedTooltipY + simiWidget.getY();
|
||||||
guiGraphics.renderComponentTooltip(getFont(), tooltip, ttx, tty);
|
screen.renderComponentTooltip(ms, tooltip, ttx, tty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import nl.requios.effortlessbuilding.AllGuiTextures;
|
import nl.requios.effortlessbuilding.AllGuiTextures;
|
||||||
import nl.requios.effortlessbuilding.AllIcons;
|
import nl.requios.effortlessbuilding.AllIcons;
|
||||||
|
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.BaseModifier;
|
import nl.requios.effortlessbuilding.buildmodifier.BaseModifier;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.RadialMirror;
|
import nl.requios.effortlessbuilding.buildmodifier.RadialMirror;
|
||||||
import nl.requios.effortlessbuilding.capability.CapabilityHandler;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.IconButton;
|
import nl.requios.effortlessbuilding.create.foundation.gui.widget.IconButton;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.ScrollInput;
|
import nl.requios.effortlessbuilding.create.foundation.gui.widget.ScrollInput;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||||
@@ -107,7 +107,7 @@ public class RadialMirrorEntry extends BaseModifierEntry<RadialMirror> {
|
|||||||
|
|
||||||
//Radius
|
//Radius
|
||||||
radiusInput = new LabeledScrollInput(0, 0, 27, 18)
|
radiusInput = new LabeledScrollInput(0, 0, 27, 18)
|
||||||
.withRange(0, CapabilityHandler.getMaxMirrorRadius(Minecraft.getInstance().player, false))
|
.withRange(0, EffortlessBuildingClient.POWER_LEVEL.getMaxMirrorRadius(Minecraft.getInstance().player))
|
||||||
.titled(Minecraft.getInstance().player.isCreative() ?
|
.titled(Minecraft.getInstance().player.isCreative() ?
|
||||||
Component.literal("Radius") :
|
Component.literal("Radius") :
|
||||||
Component.literal("Radius. Use Reach Upgrade items to increase maximum."))
|
Component.literal("Radius. Use Reach Upgrade items to increase maximum."))
|
||||||
@@ -141,51 +141,51 @@ public class RadialMirrorEntry extends BaseModifierEntry<RadialMirror> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) {
|
public void render(PoseStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) {
|
||||||
super.render(guiGraphics, index, y, x, width, height, mouseX, mouseY, p_230432_9_, partialTicks);
|
super.render(ms, index, y, x, width, height, mouseX, mouseY, p_230432_9_, partialTicks);
|
||||||
|
|
||||||
//draw position inputs
|
//draw position inputs
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
ScrollInput input = positionInputs.get(i);
|
ScrollInput input = positionInputs.get(i);
|
||||||
input.setX(left + 49 + 38 * i);
|
input.setX(left + 49 + 38 * i);
|
||||||
input.setY(top + 19);
|
input.setY(top + 19);
|
||||||
input.render(guiGraphics, mouseX, mouseY, partialTicks);
|
input.render(ms, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
//draw player position button
|
//draw player position button
|
||||||
playerPositionButton.setX(left + 163);
|
playerPositionButton.setX(left + 163);
|
||||||
playerPositionButton.setY(top + 19);
|
playerPositionButton.setY(top + 19);
|
||||||
playerPositionButton.render(guiGraphics, mouseX, mouseY, partialTicks);
|
playerPositionButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
//draw toggle offset button
|
//draw toggle offset button
|
||||||
toggleOffsetButton.setX(left + 183);
|
toggleOffsetButton.setX(left + 183);
|
||||||
toggleOffsetButton.setY(top + 19);
|
toggleOffsetButton.setY(top + 19);
|
||||||
toggleOffsetButton.render(guiGraphics, mouseX, mouseY, partialTicks);
|
toggleOffsetButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
//draw slices input
|
//draw slices input
|
||||||
slicesInput.setX(left + 49);
|
slicesInput.setX(left + 49);
|
||||||
slicesInput.setY(top + 41);
|
slicesInput.setY(top + 41);
|
||||||
slicesInput.render(guiGraphics, mouseX, mouseY, partialTicks);
|
slicesInput.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
//draw alternate button
|
//draw alternate button
|
||||||
alternateButton.setX(left + 78);
|
alternateButton.setX(left + 78);
|
||||||
alternateButton.setY(top + 41);
|
alternateButton.setY(top + 41);
|
||||||
alternateButton.render(guiGraphics, mouseX, mouseY, partialTicks);
|
alternateButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
//draw radius input
|
//draw radius input
|
||||||
radiusInput.setX(left + 134);
|
radiusInput.setX(left + 134);
|
||||||
radiusInput.setY(top + 41);
|
radiusInput.setY(top + 41);
|
||||||
radiusInput.render(guiGraphics, mouseX, mouseY, partialTicks);
|
radiusInput.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
//draw show lines button
|
//draw show lines button
|
||||||
showLinesButton.setX(left + 163);
|
showLinesButton.setX(left + 163);
|
||||||
showLinesButton.setY(top + 41);
|
showLinesButton.setY(top + 41);
|
||||||
showLinesButton.render(guiGraphics, mouseX, mouseY, partialTicks);
|
showLinesButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
//draw show areas button
|
//draw show areas button
|
||||||
showAreasButton.setX(left + 183);
|
showAreasButton.setX(left + 183);
|
||||||
showAreasButton.setY(top + 41);
|
showAreasButton.setY(top + 41);
|
||||||
showAreasButton.render(guiGraphics, mouseX, mouseY, partialTicks);
|
showAreasButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package nl.requios.effortlessbuilding.gui.elements;
|
package nl.requios.effortlessbuilding.gui.elements;
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
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.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
@@ -29,11 +29,11 @@ public class GuiCheckBoxFixed extends Button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partial) {
|
public void renderWidget(PoseStack ms, int mouseX, int mouseY, float partial) {
|
||||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||||
RenderSystem.setShaderTexture(0, WIDGETS_LOCATION);
|
RenderSystem.setShaderTexture(0, WIDGETS_LOCATION);
|
||||||
//Is deprecated but still works
|
//Is deprecated but still works
|
||||||
ScreenUtils.blitWithBorder(guiGraphics, this.getX(), this.getY(), 0, 46, this.boxWidth, this.height, 200, 20, 2, 3, 2, 2, 0);
|
ScreenUtils.blitWithBorder(ms, this.getX(), this.getY(), 0, 46, this.boxWidth, this.height, 200, 20, 2, 3, 2, 2, 0);
|
||||||
int color = 14737632;
|
int color = 14737632;
|
||||||
|
|
||||||
if (packedFGColor != 0) {
|
if (packedFGColor != 0) {
|
||||||
@@ -45,9 +45,9 @@ public class GuiCheckBoxFixed extends Button {
|
|||||||
Font font = Minecraft.getInstance().font;
|
Font font = Minecraft.getInstance().font;
|
||||||
|
|
||||||
if (this.isChecked)
|
if (this.isChecked)
|
||||||
guiGraphics.drawCenteredString(font, "x", this.getX() + this.boxWidth / 2 + 1, this.getY() + 1, 14737632);
|
drawCenteredString(ms, font, "x", this.getX() + this.boxWidth / 2 + 1, this.getY() + 1, 14737632);
|
||||||
|
|
||||||
guiGraphics.drawString(font, getMessage(), this.getX() + this.boxWidth + 2, this.getY() + 2, color, false);
|
font.draw(ms, getMessage(), this.getX() + this.boxWidth + 2, this.getY() + 2, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package nl.requios.effortlessbuilding.gui.elements;
|
package nl.requios.effortlessbuilding.gui.elements;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
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.components.Renderable;
|
import net.minecraft.client.gui.components.Renderable;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
@@ -39,7 +39,7 @@ public abstract class GuiCollapsibleScrollEntry implements GuiScrollPane.IScroll
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawTooltip(GuiGraphics guiGraphics, Screen guiScreen, int mouseX, int mouseY) {
|
public void drawTooltip(PoseStack ms, Screen guiScreen, int mouseX, int mouseY) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package nl.requios.effortlessbuilding.gui.elements;
|
package nl.requios.effortlessbuilding.gui.elements;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@@ -50,7 +51,9 @@ public class GuiIconButton extends Button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
|
public void renderWidget(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
|
RenderSystem.setShaderTexture(0, this.resourceLocation);
|
||||||
|
|
||||||
int currentIconX = this.iconX;
|
int currentIconX = this.iconX;
|
||||||
int currentIconY = this.iconY;
|
int currentIconY = this.iconY;
|
||||||
|
|
||||||
@@ -60,14 +63,14 @@ public class GuiIconButton extends Button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Draws a textured rectangle at the current z-value. Used to be drawTexturedModalRect in Gui.
|
//Draws a textured rectangle at the current z-value. Used to be drawTexturedModalRect in Gui.
|
||||||
guiGraphics.blit(resourceLocation, this.getX(), this.getY(), currentIconX, currentIconY, this.iconWidth, this.iconHeight);
|
blit(ms, this.getX(), this.getY(), currentIconX, currentIconY, this.iconWidth, this.iconHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawTooltip(GuiGraphics guiGraphics, Screen screen, int mouseX, int mouseY) {
|
public void drawTooltip(PoseStack ms, Screen screen, int mouseX, int mouseY) {
|
||||||
boolean flag = mouseX >= getX() && mouseX < getX() + width && mouseY >= getY() && mouseY < getY() + height;
|
boolean flag = mouseX >= getX() && mouseX < getX() + width && mouseY >= getY() && mouseY < getY() + height;
|
||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
guiGraphics.renderComponentTooltip(screen.getMinecraft().font, tooltip, mouseX - 10, mouseY + 25);
|
screen.renderComponentTooltip(ms, tooltip, mouseX - 10, mouseY + 25);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package nl.requios.effortlessbuilding.gui.elements;
|
package nl.requios.effortlessbuilding.gui.elements;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||||
import net.minecraft.client.gui.Font;
|
import net.minecraft.client.gui.Font;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.gui.components.EditBox;
|
import net.minecraft.client.gui.components.EditBox;
|
||||||
import net.minecraft.client.gui.components.Renderable;
|
import net.minecraft.client.gui.components.Renderable;
|
||||||
@@ -95,17 +95,17 @@ public class GuiNumberField {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawNumberField(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
public void drawNumberField(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
textField.setY(y + 1);
|
textField.setY(y + 1);
|
||||||
minusButton.setY(y - 1);
|
minusButton.setY(y - 1);
|
||||||
plusButton.setY(y - 1);
|
plusButton.setY(y - 1);
|
||||||
|
|
||||||
textField.render(graphics, mouseX, mouseY, partialTicks);
|
textField.render(ms, mouseX, mouseY, partialTicks);
|
||||||
minusButton.render(graphics, mouseX, mouseY, partialTicks);
|
minusButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
plusButton.render(graphics, mouseX, mouseY, partialTicks);
|
plusButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawTooltip(GuiGraphics graphics, Screen screen, int mouseX, int mouseY) {
|
public void drawTooltip(PoseStack ms, Screen screen, int mouseX, int mouseY) {
|
||||||
boolean insideTextField = mouseX >= x + buttonWidth && mouseX < x + width - buttonWidth && mouseY >= y && mouseY < y + height;
|
boolean insideTextField = mouseX >= x + buttonWidth && mouseX < x + width - buttonWidth && mouseY >= y && mouseY < y + height;
|
||||||
boolean insideMinusButton = mouseX >= x && mouseX < x + buttonWidth && mouseY >= y && mouseY < y + height;
|
boolean insideMinusButton = mouseX >= x && mouseX < x + buttonWidth && mouseY >= y && mouseY < y + height;
|
||||||
boolean insidePlusButton = mouseX >= x + width - buttonWidth && mouseX < x + width && mouseY >= y && mouseY < y + height;
|
boolean insidePlusButton = mouseX >= x + width - buttonWidth && mouseX < x + width && mouseY >= y && mouseY < y + height;
|
||||||
@@ -133,7 +133,7 @@ public class GuiNumberField {
|
|||||||
textLines.add(Component.literal("Hold ").append(Component.literal("ctrl ").withStyle(ChatFormatting.DARK_GREEN)).append("for ")
|
textLines.add(Component.literal("Hold ").append(Component.literal("ctrl ").withStyle(ChatFormatting.DARK_GREEN)).append("for ")
|
||||||
.append(Component.literal("5").withStyle(ChatFormatting.RED)));
|
.append(Component.literal("5").withStyle(ChatFormatting.RED)));
|
||||||
}
|
}
|
||||||
graphics.renderComponentTooltip(screen.getMinecraft().font, textLines, mouseX - 10, mouseY + 25);
|
screen.renderComponentTooltip(ms, textLines, mouseX - 10, mouseY + 25);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
|||||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||||
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.components.Renderable;
|
import net.minecraft.client.gui.components.Renderable;
|
||||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
@@ -72,7 +71,7 @@ public class GuiScrollPane extends SlotGui {
|
|||||||
|
|
||||||
//Removed background
|
//Removed background
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, int mouseXIn, int mouseYIn, float partialTicks) {
|
public void render(PoseStack guiGraphics, int mouseXIn, int mouseYIn, float partialTicks) {
|
||||||
if (this.visible) {
|
if (this.visible) {
|
||||||
this.mouseX = mouseXIn;
|
this.mouseX = mouseXIn;
|
||||||
this.mouseY = mouseYIn;
|
this.mouseY = mouseYIn;
|
||||||
@@ -170,8 +169,8 @@ public class GuiScrollPane extends SlotGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderItem(GuiGraphics guiGraphics, int slotIndex, int xPos, int yPos, int heightIn, int mouseXIn, int mouseYIn, float partialTicks) {
|
protected void renderItem(PoseStack ms, int slotIndex, int xPos, int yPos, int heightIn, int mouseXIn, int mouseYIn, float partialTicks) {
|
||||||
this.getListEntry(slotIndex).drawEntry(guiGraphics, slotIndex, xPos, yPos, this.getRowWidth(), heightIn, mouseXIn, mouseYIn,
|
this.getListEntry(slotIndex).drawEntry(ms, slotIndex, xPos, yPos, this.getRowWidth(), heightIn, mouseXIn, mouseYIn,
|
||||||
this.getSlotIndexFromScreenCoords(mouseXIn, mouseYIn) == slotIndex, partialTicks);
|
this.getSlotIndexFromScreenCoords(mouseXIn, mouseYIn) == slotIndex, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,7 +323,7 @@ public class GuiScrollPane extends SlotGui {
|
|||||||
|
|
||||||
//Draw in center if it fits
|
//Draw in center if it fits
|
||||||
@Override
|
@Override
|
||||||
protected void renderList(GuiGraphics guiGraphics, int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks) {
|
protected void renderList(PoseStack guiGraphics, int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks) {
|
||||||
int itemCount = this.getItemCount();
|
int itemCount = this.getItemCount();
|
||||||
Tesselator tessellator = Tesselator.getInstance();
|
Tesselator tessellator = Tesselator.getInstance();
|
||||||
BufferBuilder bufferbuilder = tessellator.getBuilder();
|
BufferBuilder bufferbuilder = tessellator.getBuilder();
|
||||||
@@ -405,7 +404,7 @@ public class GuiScrollPane extends SlotGui {
|
|||||||
entry.updateScreen();
|
entry.updateScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawTooltip(GuiGraphics guiGraphics, Screen guiScreen, int mouseX, int mouseY) {
|
public void drawTooltip(PoseStack guiGraphics, Screen guiScreen, int mouseX, int mouseY) {
|
||||||
for (IScrollEntry entry : this.listEntries)
|
for (IScrollEntry entry : this.listEntries)
|
||||||
entry.drawTooltip(guiGraphics, guiScreen, mouseX, mouseY);
|
entry.drawTooltip(guiGraphics, guiScreen, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
@@ -436,7 +435,7 @@ public class GuiScrollPane extends SlotGui {
|
|||||||
|
|
||||||
void updateScreen();
|
void updateScreen();
|
||||||
|
|
||||||
void drawTooltip(GuiGraphics guiGraphics, Screen guiScreen, int mouseX, int mouseY);
|
void drawTooltip(PoseStack guiGraphics, Screen guiScreen, int mouseX, int mouseY);
|
||||||
|
|
||||||
boolean charTyped(char eventChar, int eventKey);
|
boolean charTyped(char eventChar, int eventKey);
|
||||||
|
|
||||||
@@ -446,7 +445,7 @@ public class GuiScrollPane extends SlotGui {
|
|||||||
|
|
||||||
void updatePosition(int slotIndex, int x, int y, float partialTicks);
|
void updatePosition(int slotIndex, int x, int y, float partialTicks);
|
||||||
|
|
||||||
void drawEntry(GuiGraphics guiGraphics, int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float partialTicks);
|
void drawEntry(PoseStack guiGraphics, int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float partialTicks);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the mouse is clicked within this entry. Returning true means that something within this entry was
|
* Called when the mouse is clicked within this entry. Returning true means that something within this entry was
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package nl.requios.effortlessbuilding.gui.elements;
|
package nl.requios.effortlessbuilding.gui.elements;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
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.widget.Label;
|
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.ScrollInput;
|
||||||
@@ -31,12 +31,12 @@ public class LabeledScrollInput extends ScrollInput {
|
|||||||
|
|
||||||
//TODO: Check if this works
|
//TODO: Check if this works
|
||||||
@Override
|
@Override
|
||||||
public void doRender(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
|
public void doRender(@NotNull PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
super.doRender(guiGraphics, mouseX, mouseY, partialTicks);
|
super.doRender(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
label.setX(getX() + width / 2 - Minecraft.getInstance().font.width(label.text) / 2);
|
label.setX(getX() + width / 2 - Minecraft.getInstance().font.width(label.text) / 2);
|
||||||
label.setY(getY() + height / 2 - Minecraft.getInstance().font.lineHeight / 2);
|
label.setY(getY() + height / 2 - Minecraft.getInstance().font.lineHeight / 2);
|
||||||
label.render(guiGraphics, mouseX, mouseY, partialTicks);
|
label.render(ms, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ package nl.requios.effortlessbuilding.gui.elements;
|
|||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.mojang.blaze3d.vertex.Tesselator;
|
import com.mojang.blaze3d.vertex.Tesselator;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.client.gui.components.Renderable;
|
import net.minecraft.client.gui.components.Renderable;
|
||||||
import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
|
import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
|
||||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||||
@@ -76,7 +76,7 @@ public abstract class SlotGui extends AbstractContainerEventHandler implements R
|
|||||||
protected void updateItemPosition(int p_updateItemPosition_1_, int p_updateItemPosition_2_, int p_updateItemPosition_3_, float p_updateItemPosition_4_) {
|
protected void updateItemPosition(int p_updateItemPosition_1_, int p_updateItemPosition_2_, int p_updateItemPosition_3_, float p_updateItemPosition_4_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void renderItem(GuiGraphics guiGraphics, int p_renderItem_1_, int p_renderItem_2_, int p_renderItem_3_, int p_renderItem_4_, int p_renderItem_5_, int p_renderItem_6_, float p_renderItem_7_);
|
protected abstract void renderItem(PoseStack ms, int p_renderItem_1_, int p_renderItem_2_, int p_renderItem_3_, int p_renderItem_4_, int p_renderItem_5_, int p_renderItem_6_, float p_renderItem_7_);
|
||||||
|
|
||||||
protected void renderHeader(int p_renderHeader_1_, int p_renderHeader_2_, Tesselator p_renderHeader_3_) {
|
protected void renderHeader(int p_renderHeader_1_, int p_renderHeader_2_, Tesselator p_renderHeader_3_) {
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ public abstract class SlotGui extends AbstractContainerEventHandler implements R
|
|||||||
return p_isMouseInList_3_ >= (double) this.y0 && p_isMouseInList_3_ <= (double) this.y1 && p_isMouseInList_1_ >= (double) this.x0 && p_isMouseInList_1_ <= (double) this.x1;
|
return p_isMouseInList_3_ >= (double) this.y0 && p_isMouseInList_3_ <= (double) this.y1 && p_isMouseInList_1_ >= (double) this.x0 && p_isMouseInList_1_ <= (double) this.x1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void render(GuiGraphics guiGraphics, int p_render_1_, int p_render_2_, float p_render_3_);
|
public abstract void render(PoseStack guiGraphics, int p_render_1_, int p_render_2_, float p_render_3_);
|
||||||
|
|
||||||
protected void updateScrollingState(double p_updateScrollingState_1_, double p_updateScrollingState_3_, int p_updateScrollingState_5_) {
|
protected void updateScrollingState(double p_updateScrollingState_1_, double p_updateScrollingState_3_, int p_updateScrollingState_5_) {
|
||||||
this.scrolling = p_updateScrollingState_5_ == 0 && p_updateScrollingState_1_ >= (double) this.getScrollbarPosition() && p_updateScrollingState_1_ < (double) (this.getScrollbarPosition() + 6);
|
this.scrolling = p_updateScrollingState_5_ == 0 && p_updateScrollingState_1_ >= (double) this.getScrollbarPosition() && p_updateScrollingState_1_ < (double) (this.getScrollbarPosition() + 6);
|
||||||
@@ -215,7 +215,7 @@ public abstract class SlotGui extends AbstractContainerEventHandler implements R
|
|||||||
return 220;
|
return 220;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderList(GuiGraphics guiGraphics, int p_renderList_1_, int p_renderList_2_, int p_renderList_3_, int p_renderList_4_, float p_renderList_5_) {
|
protected void renderList(PoseStack guiGraphics, int p_renderList_1_, int p_renderList_2_, int p_renderList_3_, int p_renderList_4_, float p_renderList_5_) {
|
||||||
int i = this.getItemCount();
|
int i = this.getItemCount();
|
||||||
Tesselator tessellator = Tesselator.getInstance();
|
Tesselator tessellator = Tesselator.getInstance();
|
||||||
BufferBuilder bufferbuilder = tessellator.getBuilder();
|
BufferBuilder bufferbuilder = tessellator.getBuilder();
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package nl.requios.effortlessbuilding.item;
|
|||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResultHolder;
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
@@ -13,8 +13,7 @@ import net.minecraft.world.item.ItemStack;
|
|||||||
import net.minecraft.world.item.TooltipFlag;
|
import net.minecraft.world.item.TooltipFlag;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.capability.CapabilityHandler;
|
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||||
import nl.requios.effortlessbuilding.capability.IPowerLevel;
|
|
||||||
import nl.requios.effortlessbuilding.create.foundation.item.TooltipHelper;
|
import nl.requios.effortlessbuilding.create.foundation.item.TooltipHelper;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -30,34 +29,33 @@ public class PowerLevelItem extends Item {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
|
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
|
||||||
ItemStack stack = player.getItemInHand(hand);
|
|
||||||
IPowerLevel powerLevel = player.getCapability(CapabilityHandler.POWER_LEVEL_CAPABILITY).orElse(null);
|
|
||||||
if (powerLevel != null) {
|
|
||||||
if (powerLevel.canIncreasePowerLevel()) {
|
|
||||||
if (!world.isClientSide) {
|
|
||||||
powerLevel.increasePowerLevel();
|
|
||||||
EffortlessBuilding.log(player, "Upgraded power level to " + powerLevel.getPowerLevel());
|
|
||||||
|
|
||||||
stack.shrink(1);
|
if (world.isClientSide){
|
||||||
|
|
||||||
world.playSound((Player) null, player.blockPosition(), SoundEvents.PLAYER_LEVELUP, SoundSource.PLAYERS, 1f, 1f);
|
if (EffortlessBuildingClient.POWER_LEVEL.canIncreasePowerLevel()) {
|
||||||
|
|
||||||
CapabilityHandler.syncToClient(player);
|
EffortlessBuildingClient.POWER_LEVEL.increasePowerLevel();
|
||||||
}
|
EffortlessBuilding.log(player, "Upgraded power level to " + EffortlessBuildingClient.POWER_LEVEL.getPowerLevel());
|
||||||
|
player.setItemInHand(hand, ItemStack.EMPTY);
|
||||||
|
|
||||||
|
SoundEvent soundEvent = SoundEvent.createVariableRangeEvent(new ResourceLocation("entity.player.levelup"));
|
||||||
|
player.playSound(soundEvent, 1f, 1f);
|
||||||
|
|
||||||
|
return InteractionResultHolder.consume(player.getItemInHand(hand));
|
||||||
|
|
||||||
return InteractionResultHolder.sidedSuccess(stack, world.isClientSide());
|
|
||||||
} else {
|
} else {
|
||||||
if (!world.isClientSide) {
|
|
||||||
EffortlessBuilding.log(player, "Already reached maximum power level!");
|
|
||||||
|
|
||||||
world.playSound((Player) null, player.blockPosition(), SoundEvents.ARMOR_EQUIP_LEATHER, SoundSource.PLAYERS, 1f, 1f);
|
EffortlessBuilding.log(player, "Already reached maximum power level!");
|
||||||
}
|
|
||||||
|
SoundEvent soundEvent = SoundEvent.createVariableRangeEvent(new ResourceLocation("item.armor.equip_leather"));
|
||||||
|
player.playSound(soundEvent, 1f, 1f);
|
||||||
|
|
||||||
return InteractionResultHolder.fail(player.getItemInHand(hand));
|
return InteractionResultHolder.fail(player.getItemInHand(hand));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return super.use(world, player, hand);
|
} else {
|
||||||
|
return InteractionResultHolder.consume(player.getItemInHand(hand));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package nl.requios.effortlessbuilding.item;
|
|||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResultHolder;
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
@@ -14,8 +14,7 @@ import net.minecraft.world.item.TooltipFlag;
|
|||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import nl.requios.effortlessbuilding.CommonConfig;
|
import nl.requios.effortlessbuilding.CommonConfig;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.capability.CapabilityHandler;
|
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||||
import nl.requios.effortlessbuilding.capability.IPowerLevel;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
@@ -31,29 +30,28 @@ public class ReachUpgrade1Item extends Item {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
|
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
|
||||||
ItemStack stack = player.getItemInHand(hand);
|
|
||||||
IPowerLevel powerLevel = player.getCapability(CapabilityHandler.POWER_LEVEL_CAPABILITY).orElse(null);
|
|
||||||
if (powerLevel != null) {
|
|
||||||
int currentLevel = powerLevel.getPowerLevel();
|
|
||||||
if (currentLevel == 0) {
|
|
||||||
if (!world.isClientSide) {
|
|
||||||
powerLevel.increasePowerLevel();
|
|
||||||
EffortlessBuilding.log(player, "Upgraded power level to " + powerLevel.getPowerLevel());
|
|
||||||
|
|
||||||
stack.shrink(1);
|
if (!world.isClientSide) return InteractionResultHolder.consume(player.getItemInHand(hand));
|
||||||
|
|
||||||
world.playSound((Player) null, player.blockPosition(), SoundEvents.PLAYER_LEVELUP, SoundSource.PLAYERS, 1f, 1f);
|
int currentLevel = EffortlessBuildingClient.POWER_LEVEL.getPowerLevel();
|
||||||
|
if (currentLevel == 0) {
|
||||||
|
|
||||||
CapabilityHandler.syncToClient(player);
|
EffortlessBuildingClient.POWER_LEVEL.increasePowerLevel();
|
||||||
}
|
EffortlessBuilding.log(player, "Upgraded power level to " + EffortlessBuildingClient.POWER_LEVEL.getPowerLevel());
|
||||||
return InteractionResultHolder.sidedSuccess(stack, world.isClientSide());
|
player.setItemInHand(hand, ItemStack.EMPTY);
|
||||||
} else if (currentLevel > 0) {
|
|
||||||
if (!world.isClientSide && hand == InteractionHand.MAIN_HAND) {
|
SoundEvent soundEvent = SoundEvent.createVariableRangeEvent(new ResourceLocation("entity.player.levelup"));
|
||||||
EffortlessBuilding.log(player, "Already used this upgrade! Current power level is " + powerLevel.getPowerLevel() + ".");
|
player.playSound(soundEvent, 1f, 1f);
|
||||||
|
|
||||||
|
return InteractionResultHolder.consume(player.getItemInHand(hand));
|
||||||
|
|
||||||
|
} else if (currentLevel > 0) {
|
||||||
|
|
||||||
|
EffortlessBuilding.log(player, "Already used this upgrade! Current power level is " + EffortlessBuildingClient.POWER_LEVEL.getPowerLevel() + ".");
|
||||||
|
|
||||||
|
SoundEvent soundEvent = SoundEvent.createVariableRangeEvent(new ResourceLocation("item.armor.equip_leather"));
|
||||||
|
player.playSound(soundEvent, 1f, 1f);
|
||||||
|
|
||||||
world.playSound((Player) null, player.blockPosition(), SoundEvents.ARMOR_EQUIP_LEATHER, SoundSource.PLAYERS, 1f, 1f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return InteractionResultHolder.fail(player.getItemInHand(hand));
|
return InteractionResultHolder.fail(player.getItemInHand(hand));
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package nl.requios.effortlessbuilding.item;
|
|||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResultHolder;
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
@@ -14,8 +14,7 @@ import net.minecraft.world.item.TooltipFlag;
|
|||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import nl.requios.effortlessbuilding.CommonConfig;
|
import nl.requios.effortlessbuilding.CommonConfig;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.capability.CapabilityHandler;
|
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||||
import nl.requios.effortlessbuilding.capability.IPowerLevel;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
@@ -29,38 +28,38 @@ public class ReachUpgrade2Item extends Item {
|
|||||||
super(new Item.Properties().stacksTo(1));
|
super(new Item.Properties().stacksTo(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
|
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
|
||||||
ItemStack stack = player.getItemInHand(hand);
|
|
||||||
IPowerLevel powerLevel = player.getCapability(CapabilityHandler.POWER_LEVEL_CAPABILITY).orElse(null);
|
|
||||||
if (powerLevel != null) {
|
|
||||||
int currentLevel = powerLevel.getPowerLevel();
|
|
||||||
if (currentLevel == 1) {
|
|
||||||
if (!world.isClientSide) {
|
|
||||||
powerLevel.increasePowerLevel();
|
|
||||||
EffortlessBuilding.log(player, "Upgraded power level to " + powerLevel.getPowerLevel());
|
|
||||||
|
|
||||||
stack.shrink(1);
|
if (!world.isClientSide) return InteractionResultHolder.consume(player.getItemInHand(hand));
|
||||||
|
|
||||||
world.playSound((Player) null, player.blockPosition(), SoundEvents.PLAYER_LEVELUP, SoundSource.PLAYERS, 1f, 1f);
|
int currentLevel = EffortlessBuildingClient.POWER_LEVEL.getPowerLevel();
|
||||||
|
if (currentLevel == 1) {
|
||||||
|
|
||||||
CapabilityHandler.syncToClient(player);
|
EffortlessBuildingClient.POWER_LEVEL.increasePowerLevel();
|
||||||
}
|
EffortlessBuilding.log(player, "Upgraded power level to " + EffortlessBuildingClient.POWER_LEVEL.getPowerLevel());
|
||||||
return InteractionResultHolder.sidedSuccess(stack, world.isClientSide());
|
player.setItemInHand(hand, ItemStack.EMPTY);
|
||||||
} else if (currentLevel < 1) {
|
|
||||||
if (!world.isClientSide) {
|
|
||||||
EffortlessBuilding.log(player, "Use Reach Upgrade 1 first.");
|
|
||||||
|
|
||||||
world.playSound((Player) null, player.blockPosition(), SoundEvents.ARMOR_EQUIP_LEATHER, SoundSource.PLAYERS, 1f, 1f);
|
SoundEvent soundEvent = SoundEvent.createVariableRangeEvent(new ResourceLocation("entity.player.levelup"));
|
||||||
}
|
player.playSound(soundEvent, 1f, 1f);
|
||||||
} else if (currentLevel > 1) {
|
|
||||||
if (!world.isClientSide) {
|
return InteractionResultHolder.consume(player.getItemInHand(hand));
|
||||||
EffortlessBuilding.log(player, "Already used this upgrade! Current power level is " + powerLevel.getPowerLevel() + ".");
|
|
||||||
|
} else if (currentLevel < 1) {
|
||||||
|
|
||||||
|
EffortlessBuilding.log(player, "Use Reach Upgrade 1 first.");
|
||||||
|
|
||||||
|
SoundEvent soundEvent = SoundEvent.createVariableRangeEvent(new ResourceLocation("item.armor.equip_leather"));
|
||||||
|
player.playSound(soundEvent, 1f, 1f);
|
||||||
|
|
||||||
|
|
||||||
|
} else if (currentLevel > 1) {
|
||||||
|
|
||||||
|
EffortlessBuilding.log(player, "Already used this upgrade! Current power level is " + EffortlessBuildingClient.POWER_LEVEL.getPowerLevel() + ".");
|
||||||
|
|
||||||
|
SoundEvent soundEvent = SoundEvent.createVariableRangeEvent(new ResourceLocation("item.armor.equip_leather"));
|
||||||
|
player.playSound(soundEvent, 1f, 1f);
|
||||||
|
|
||||||
world.playSound((Player) null, player.blockPosition(), SoundEvents.ARMOR_EQUIP_LEATHER, SoundSource.PLAYERS, 1f, 1f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return InteractionResultHolder.fail(player.getItemInHand(hand));
|
return InteractionResultHolder.fail(player.getItemInHand(hand));
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package nl.requios.effortlessbuilding.item;
|
|||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResultHolder;
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
@@ -14,8 +14,7 @@ import net.minecraft.world.item.TooltipFlag;
|
|||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import nl.requios.effortlessbuilding.CommonConfig;
|
import nl.requios.effortlessbuilding.CommonConfig;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.capability.CapabilityHandler;
|
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||||
import nl.requios.effortlessbuilding.capability.IPowerLevel;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
@@ -31,36 +30,37 @@ public class ReachUpgrade3Item extends Item {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
|
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
|
||||||
ItemStack stack = player.getItemInHand(hand);
|
|
||||||
IPowerLevel powerLevel = player.getCapability(CapabilityHandler.POWER_LEVEL_CAPABILITY).orElse(null);
|
|
||||||
if (powerLevel != null) {
|
|
||||||
int currentLevel = powerLevel.getPowerLevel();
|
|
||||||
if (currentLevel == 2) {
|
|
||||||
if (!world.isClientSide) {
|
|
||||||
powerLevel.increasePowerLevel();
|
|
||||||
EffortlessBuilding.log(player, "Upgraded power level to " + powerLevel.getPowerLevel());
|
|
||||||
|
|
||||||
stack.shrink(1);
|
if (!world.isClientSide) return InteractionResultHolder.consume(player.getItemInHand(hand));
|
||||||
|
|
||||||
world.playSound((Player) null, player.blockPosition(), SoundEvents.PLAYER_LEVELUP, SoundSource.PLAYERS, 1f, 1f);
|
int currentLevel = EffortlessBuildingClient.POWER_LEVEL.getPowerLevel();
|
||||||
|
if (currentLevel == 2) {
|
||||||
|
|
||||||
CapabilityHandler.syncToClient(player);
|
EffortlessBuildingClient.POWER_LEVEL.increasePowerLevel();
|
||||||
}
|
EffortlessBuilding.log(player, "Upgraded power level to " + EffortlessBuildingClient.POWER_LEVEL.getPowerLevel());
|
||||||
return InteractionResultHolder.sidedSuccess(stack, world.isClientSide());
|
player.setItemInHand(hand, ItemStack.EMPTY);
|
||||||
} else if (currentLevel < 2) {
|
|
||||||
if (!world.isClientSide) {
|
|
||||||
if (currentLevel == 0) EffortlessBuilding.log(player, "Use Reach Upgrade 1 and 2 first.");
|
|
||||||
if (currentLevel == 1) EffortlessBuilding.log(player, "Use Reach Upgrade 2 first.");
|
|
||||||
|
|
||||||
world.playSound((Player) null, player.blockPosition(), SoundEvents.ARMOR_EQUIP_LEATHER, SoundSource.PLAYERS, 1f, 1f);
|
SoundEvent soundEvent = SoundEvent.createVariableRangeEvent(new ResourceLocation("entity.player.levelup"));
|
||||||
}
|
player.playSound(soundEvent, 1f, 1f);
|
||||||
} else if (currentLevel > 2) {
|
|
||||||
if (!world.isClientSide) {
|
return InteractionResultHolder.consume(player.getItemInHand(hand));
|
||||||
EffortlessBuilding.log(player, "Already used this upgrade! Current power level is " + powerLevel.getPowerLevel() + ".");
|
|
||||||
|
} else if (currentLevel < 2) {
|
||||||
|
|
||||||
|
if (currentLevel == 0) EffortlessBuilding.log(player, "Use Reach Upgrade 1 and 2 first.");
|
||||||
|
if (currentLevel == 1) EffortlessBuilding.log(player, "Use Reach Upgrade 2 first.");
|
||||||
|
|
||||||
|
SoundEvent soundEvent = SoundEvent.createVariableRangeEvent(new ResourceLocation("item.armor.equip_leather"));
|
||||||
|
player.playSound(soundEvent, 1f, 1f);
|
||||||
|
|
||||||
|
|
||||||
|
} else if (currentLevel > 2) {
|
||||||
|
|
||||||
|
EffortlessBuilding.log(player, "Already used this upgrade! Current power level is " + EffortlessBuildingClient.POWER_LEVEL.getPowerLevel() + ".");
|
||||||
|
|
||||||
|
SoundEvent soundEvent = SoundEvent.createVariableRangeEvent(new ResourceLocation("item.armor.equip_leather"));
|
||||||
|
player.playSound(soundEvent, 1f, 1f);
|
||||||
|
|
||||||
world.playSound((Player) null, player.blockPosition(), SoundEvents.ARMOR_EQUIP_LEATHER, SoundSource.PLAYERS, 1f, 1f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return InteractionResultHolder.fail(player.getItemInHand(hand));
|
return InteractionResultHolder.fail(player.getItemInHand(hand));
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ public class PacketHandler {
|
|||||||
PROTOCOL_VERSION::equals
|
PROTOCOL_VERSION::equals
|
||||||
);
|
);
|
||||||
|
|
||||||
private static int id = 0;
|
|
||||||
|
|
||||||
public static void register() {
|
public static void register() {
|
||||||
|
int id = 0;
|
||||||
|
|
||||||
INSTANCE.registerMessage(id++, IsUsingBuildModePacket.class, IsUsingBuildModePacket::encode, IsUsingBuildModePacket::decode,
|
INSTANCE.registerMessage(id++, IsUsingBuildModePacket.class, IsUsingBuildModePacket::encode, IsUsingBuildModePacket::decode,
|
||||||
IsUsingBuildModePacket.Handler::handle, Optional.of(NetworkDirection.PLAY_TO_SERVER));
|
IsUsingBuildModePacket.Handler::handle, Optional.of(NetworkDirection.PLAY_TO_SERVER));
|
||||||
INSTANCE.registerMessage(id++, IsQuickReplacingPacket.class, IsQuickReplacingPacket::encode, IsQuickReplacingPacket::decode,
|
INSTANCE.registerMessage(id++, IsQuickReplacingPacket.class, IsQuickReplacingPacket::encode, IsQuickReplacingPacket::decode,
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
package nl.requios.effortlessbuilding.network;
|
package nl.requios.effortlessbuilding.network;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import nl.requios.effortlessbuilding.capability.CapabilityHandler;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
|
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sync power level from server to client
|
* Sync power level between server and client, for saving and loading.
|
||||||
*/
|
*/
|
||||||
public class PowerLevelPacket {
|
public class PowerLevelPacket {
|
||||||
|
|
||||||
@@ -32,23 +31,19 @@ public class PowerLevelPacket {
|
|||||||
|
|
||||||
public static class Handler {
|
public static class Handler {
|
||||||
public static void handle(PowerLevelPacket message, Supplier<NetworkEvent.Context> ctx) {
|
public static void handle(PowerLevelPacket message, Supplier<NetworkEvent.Context> ctx) {
|
||||||
NetworkEvent.Context context = ctx.get();
|
if (ctx.get().getDirection().getReceptionSide().isServer()) {
|
||||||
if (context.getDirection().getReceptionSide().isClient()) {
|
ctx.get().enqueueWork(() -> {
|
||||||
context.enqueueWork(new Runnable() {
|
var player = ctx.get().getSender();
|
||||||
// Use anon - lambda causes classloading issues
|
//To server, save to persistent player data
|
||||||
@Override
|
EffortlessBuilding.SERVER_POWER_LEVEL.setPowerLevel(player, message.powerLevel);
|
||||||
public void run() {
|
});
|
||||||
Player player = Minecraft.getInstance().player;
|
} else {
|
||||||
if (player != null) {
|
ctx.get().enqueueWork(() -> {
|
||||||
player.getCapability(CapabilityHandler.POWER_LEVEL_CAPABILITY, null)
|
//To client, load into system
|
||||||
.ifPresent(levelCap -> {
|
EffortlessBuildingClient.POWER_LEVEL.setPowerLevel(message.powerLevel);
|
||||||
levelCap.setPowerLevel(message.powerLevel);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
context.setPacketHandled(true);
|
ctx.get().setPacketHandled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
package nl.requios.effortlessbuilding.render;
|
package nl.requios.effortlessbuilding.render;
|
||||||
|
|
||||||
import net.createmod.catnip.data.Pair;
|
|
||||||
import net.createmod.catnip.outliner.Outliner;
|
|
||||||
import net.createmod.catnip.theme.Color;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
@@ -15,6 +12,7 @@ import nl.requios.effortlessbuilding.*;
|
|||||||
import nl.requios.effortlessbuilding.buildmode.BuildModeEnum;
|
import nl.requios.effortlessbuilding.buildmode.BuildModeEnum;
|
||||||
import nl.requios.effortlessbuilding.create.AllSpecialTextures;
|
import nl.requios.effortlessbuilding.create.AllSpecialTextures;
|
||||||
import nl.requios.effortlessbuilding.create.CreateClient;
|
import nl.requios.effortlessbuilding.create.CreateClient;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||||
import nl.requios.effortlessbuilding.systems.BuilderChain;
|
import nl.requios.effortlessbuilding.systems.BuilderChain;
|
||||||
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
||||||
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
||||||
@@ -78,25 +76,25 @@ public class BlockPreviews {
|
|||||||
if (ClientConfig.visuals.showBlockPreviews.get() && blocks.size() < ClientConfig.visuals.maxBlockPreviews.get()) {
|
if (ClientConfig.visuals.showBlockPreviews.get() && blocks.size() < ClientConfig.visuals.maxBlockPreviews.get()) {
|
||||||
renderBlockPreviews(blocks, false, 0f);
|
renderBlockPreviews(blocks, false, 0f);
|
||||||
|
|
||||||
Outliner.getInstance().showCluster(outlineID, coordinates)
|
CreateClient.OUTLINER.showCluster(outlineID, coordinates)
|
||||||
.withFaceTexture(AllSpecialTextures.CHECKERED)
|
.withFaceTexture(AllSpecialTextures.CHECKERED)
|
||||||
.disableLineNormals()
|
.disableNormals()
|
||||||
.lineWidth(1 / 32f)
|
.lineWidth(1 / 32f)
|
||||||
.colored(new Color(1f, 1f, 1f, 1f));
|
.colored(new Color(1f, 1f, 1f, 1f));
|
||||||
} else {
|
} else {
|
||||||
//Thicker outline without block previews
|
//Thicker outline without block previews
|
||||||
Outliner.getInstance().showCluster(outlineID, coordinates)
|
CreateClient.OUTLINER.showCluster(outlineID, coordinates)
|
||||||
.withFaceTexture(AllSpecialTextures.HIGHLIGHT_CHECKERED)
|
.withFaceTexture(AllSpecialTextures.HIGHLIGHT_CHECKERED)
|
||||||
.disableLineNormals()
|
.disableNormals()
|
||||||
.lineWidth(1 / 16f)
|
.lineWidth(1 / 16f)
|
||||||
.colored(new Color(1f, 1f, 1f, 1f));
|
.colored(new Color(1f, 1f, 1f, 1f));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//Breaking
|
//Breaking
|
||||||
Outliner.getInstance().showCluster(outlineID, coordinates)
|
CreateClient.OUTLINER.showCluster(outlineID, coordinates)
|
||||||
.withFaceTexture(AllSpecialTextures.THIN_CHECKERED)
|
.withFaceTexture(AllSpecialTextures.THIN_CHECKERED)
|
||||||
.disableLineNormals()
|
.disableNormals()
|
||||||
.lineWidth(1 / 16f)
|
.lineWidth(1 / 16f)
|
||||||
.colored(new Color(0.8f, 0.1f, 0.1f, 1f));
|
.colored(new Color(0.8f, 0.1f, 0.1f, 1f));
|
||||||
}
|
}
|
||||||
@@ -148,15 +146,15 @@ public class BlockPreviews {
|
|||||||
if (EffortlessBuildingClient.BUILDER_CHAIN.getLookingAtNear() != null) return;
|
if (EffortlessBuildingClient.BUILDER_CHAIN.getLookingAtNear() != null) return;
|
||||||
|
|
||||||
AABB aabb = new AABB(pos);
|
AABB aabb = new AABB(pos);
|
||||||
if (player.level().isLoaded(pos)) {
|
if (player.level.isLoaded(pos)) {
|
||||||
var blockState = player.level().getBlockState(pos);
|
var blockState = player.level.getBlockState(pos);
|
||||||
if (!blockState.isAir()) {
|
if (!blockState.isAir()) {
|
||||||
aabb = blockState.getShape(player.level(), pos).bounds().move(pos);
|
aabb = blockState.getShape(player.level, pos).bounds().move(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Outliner.getInstance().showAABB("break", aabb)
|
CreateClient.OUTLINER.showAABB("break", aabb)
|
||||||
.disableLineNormals()
|
.disableNormals()
|
||||||
.lineWidth(1 / 64f)
|
.lineWidth(1 / 64f)
|
||||||
.colored(0x222222);
|
.colored(0x222222);
|
||||||
}
|
}
|
||||||
@@ -229,7 +227,7 @@ public class BlockPreviews {
|
|||||||
|
|
||||||
placedBlocksList.add(new PlacedBlocksEntry(ClientEvents.ticksInGame, false, new BlockSet(blocks)));
|
placedBlocksList.add(new PlacedBlocksEntry(ClientEvents.ticksInGame, false, new BlockSet(blocks)));
|
||||||
|
|
||||||
Outliner.getInstance().keep(Pair.of(blocks.firstPos, ClientConfig.visuals.appearAnimationLength.get()));
|
CreateClient.OUTLINER.keep(blocks.firstPos, ClientConfig.visuals.appearAnimationLength.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onBlocksBroken(BlockSet blocks) {
|
public void onBlocksBroken(BlockSet blocks) {
|
||||||
@@ -238,7 +236,7 @@ public class BlockPreviews {
|
|||||||
|
|
||||||
placedBlocksList.add(new PlacedBlocksEntry(ClientEvents.ticksInGame, true, new BlockSet(blocks)));
|
placedBlocksList.add(new PlacedBlocksEntry(ClientEvents.ticksInGame, true, new BlockSet(blocks)));
|
||||||
|
|
||||||
Outliner.getInstance().keep(Pair.of(blocks.firstPos, ClientConfig.visuals.breakAnimationLength.get()));
|
CreateClient.OUTLINER.keep(blocks.firstPos, ClientConfig.visuals.breakAnimationLength.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sortOnDistanceToPlayer(List<BlockPos> coordinates, Player player) {
|
private void sortOnDistanceToPlayer(List<BlockPos> coordinates, Player player) {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user