Compare commits
22 Commits
1.17
...
1.19-hotfi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee235d0689 | ||
|
|
84d3c34d66 | ||
|
|
ea59fef099 | ||
|
|
5e6c42d372 | ||
|
|
14460c2c01 | ||
|
|
3b31a74780 | ||
|
|
911d4b5605 | ||
|
|
13ee819439 | ||
|
|
319fedc2dd | ||
|
|
c7e6230424 | ||
|
|
e7ef54bd80 | ||
|
|
d5af0b097e | ||
|
|
63b95df0ff | ||
|
|
b3730896e5 | ||
|
|
675a4930af | ||
|
|
6e22577d61 | ||
|
|
6e7aab673f | ||
|
|
ad2e81c54e | ||
|
|
780d5cc972 | ||
|
|
a1d30fd752 | ||
|
|
96ffc5c1a5 | ||
|
|
5ca826362b |
5
.gitattributes
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Disable autocrlf on generated files, they always generate with LF
|
||||||
|
# Add any extra files or paths here to make git stop saying they
|
||||||
|
# are changed when only line endings change.
|
||||||
|
src/generated/**/.cache/cache text eol=lf
|
||||||
|
src/generated/**/*.json text eol=lf
|
||||||
105
build.gradle
@@ -1,31 +1,24 @@
|
|||||||
buildscript {
|
plugins {
|
||||||
repositories {
|
id 'eclipse'
|
||||||
maven { url = 'https://files.minecraftforge.net/maven' }
|
id 'maven-publish'
|
||||||
mavenCentral()
|
id 'net.minecraftforge.gradle' version '5.1.+'
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1+', changing: true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
apply plugin: 'net.minecraftforge.gradle'
|
|
||||||
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
|
|
||||||
apply plugin: 'eclipse'
|
|
||||||
apply plugin: 'maven-publish'
|
|
||||||
|
|
||||||
version = '1.17.1-2.28'
|
version = '1.19-2.40'
|
||||||
group = 'nl.requios.effortlessbuilding' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
group = 'nl.requios.effortlessbuilding'
|
||||||
archivesBaseName = 'effortlessbuilding'
|
archivesBaseName = 'effortlessbuilding'
|
||||||
|
|
||||||
// Mojang ships Java 16 to end users in 1.17+ instead of Java 8 in 1.16 or lower, so your mod should target Java 16.
|
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
|
||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(16)
|
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'}"
|
||||||
minecraft {
|
minecraft {
|
||||||
// The mappings can be changed at any time, and must be in the following format.
|
// The mappings can be changed at any time, and must be in the following format.
|
||||||
// snapshot_YYYYMMDD Snapshot are built nightly.
|
// snapshot_YYYYMMDD Snapshot are built nightly.
|
||||||
// stable_# Stables are built at the discretion of the MCP team.
|
// stable_# Stables are built at the discretion of the MCP team.
|
||||||
// Use non-default mappings at your own risk. they may not always work.
|
// Use non-default mappings at your own risk. they may not always work.
|
||||||
// Simply re-run your setup task after changing the mappings to update your workspace.
|
// Simply re-run your setup task after changing the mappings to update your workspace.
|
||||||
mappings channel: 'official', version: '1.17.1'
|
mappings channel: 'official', version: '1.19.2'
|
||||||
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
||||||
|
|
||||||
@@ -41,6 +34,9 @@ minecraft {
|
|||||||
// Recommended logging level for the console
|
// Recommended logging level for the console
|
||||||
property 'forge.logging.console.level', 'debug'
|
property 'forge.logging.console.level', 'debug'
|
||||||
|
|
||||||
|
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
||||||
|
property 'forge.enabledGameTestNamespaces', 'effortlessbuilding'
|
||||||
|
|
||||||
mods {
|
mods {
|
||||||
effortlessbuilding {
|
effortlessbuilding {
|
||||||
source sourceSets.main
|
source sourceSets.main
|
||||||
@@ -51,12 +47,31 @@ minecraft {
|
|||||||
server {
|
server {
|
||||||
workingDirectory project.file('run')
|
workingDirectory project.file('run')
|
||||||
|
|
||||||
// Recommended logging data for a userdev environment (SCAN,REGISTRIES,REGISTRYDUMP)
|
|
||||||
property 'forge.logging.markers', 'REGISTRIES'
|
property 'forge.logging.markers', 'REGISTRIES'
|
||||||
|
|
||||||
// Recommended logging level for the console
|
|
||||||
property 'forge.logging.console.level', 'debug'
|
property 'forge.logging.console.level', 'debug'
|
||||||
|
|
||||||
|
property 'forge.enabledGameTestNamespaces', 'effortlessbuilding'
|
||||||
|
|
||||||
|
mods {
|
||||||
|
effortlessbuilding {
|
||||||
|
source sourceSets.main
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This run config launches GameTestServer and runs all registered gametests, then exits.
|
||||||
|
// By default, the server will crash when no gametests are provided.
|
||||||
|
// The gametest system is also enabled by default for other run configs under the /test command.
|
||||||
|
gameTestServer {
|
||||||
|
workingDirectory project.file('run')
|
||||||
|
|
||||||
|
property 'forge.logging.markers', 'REGISTRIES'
|
||||||
|
|
||||||
|
property 'forge.logging.console.level', 'debug'
|
||||||
|
|
||||||
|
property 'forge.enabledGameTestNamespaces', 'effortlessbuilding'
|
||||||
|
|
||||||
mods {
|
mods {
|
||||||
effortlessbuilding {
|
effortlessbuilding {
|
||||||
source sourceSets.main
|
source sourceSets.main
|
||||||
@@ -67,10 +82,8 @@ minecraft {
|
|||||||
data {
|
data {
|
||||||
workingDirectory project.file('run')
|
workingDirectory project.file('run')
|
||||||
|
|
||||||
// Recommended logging data for a userdev environment (SCAN,REGISTRIES,REGISTRYDUMP)
|
|
||||||
property 'forge.logging.markers', 'REGISTRIES'
|
property 'forge.logging.markers', 'REGISTRIES'
|
||||||
|
|
||||||
// Recommended logging level for the console
|
|
||||||
property 'forge.logging.console.level', 'debug'
|
property 'forge.logging.console.level', 'debug'
|
||||||
|
|
||||||
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
|
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
|
||||||
@@ -85,30 +98,36 @@ minecraft {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Include resources generated by data generators.
|
||||||
|
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
// Put repositories for dependencies here
|
||||||
|
// ForgeGradle automatically adds the Forge maven and Maven Central for you
|
||||||
|
|
||||||
|
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
|
||||||
|
// flatDir {
|
||||||
|
// dir 'libs'
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
|
// Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed
|
||||||
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
|
// that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
|
||||||
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
|
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
|
||||||
minecraft 'net.minecraftforge:forge:1.17.1-37.0.50'
|
minecraft 'net.minecraftforge:forge:1.19.2-43.1.47'
|
||||||
|
|
||||||
// You may put jars on which you depend on in ./libs or you may define them like so..
|
// Real mod deobf dependency examples - these get remapped to your current mappings
|
||||||
// compile "some.group:artifact:version:classifier"
|
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
|
||||||
// compile "some.group:artifact:version"
|
// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
|
||||||
|
// implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency
|
||||||
|
|
||||||
// Real examples
|
// Examples using mod jars from ./libs
|
||||||
// compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
|
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
|
||||||
// compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
|
|
||||||
|
|
||||||
// The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
|
|
||||||
// provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
|
|
||||||
|
|
||||||
// These dependencies get remapped to your current MCP mappings
|
|
||||||
// deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'
|
|
||||||
|
|
||||||
// For more info...
|
// For more info...
|
||||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
||||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example for how to get properties into the manifest for reading by the runtime..
|
// Example for how to get properties into the manifest for reading by the runtime..
|
||||||
@@ -119,18 +138,18 @@ jar {
|
|||||||
"Specification-Vendor": "requios",
|
"Specification-Vendor": "requios",
|
||||||
"Specification-Version": "1", // We are version 1 of ourselves
|
"Specification-Version": "1", // We are version 1 of ourselves
|
||||||
"Implementation-Title": project.name,
|
"Implementation-Title": project.name,
|
||||||
"Implementation-Version": "${version}",
|
"Implementation-Version": project.jar.archiveVersion,
|
||||||
"Implementation-Vendor" :"requios",
|
"Implementation-Vendor" :"requios",
|
||||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example configuration to allow publishing using the maven-publish task
|
// Example configuration to allow publishing using the maven-publish plugin
|
||||||
// This is the preferred method to reobfuscate your jar file
|
// This is the preferred method to reobfuscate your jar file
|
||||||
jar.finalizedBy('reobfJar')
|
jar.finalizedBy('reobfJar')
|
||||||
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
|
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
|
||||||
//publish.dependsOn('reobfJar')
|
// publish.dependsOn('reobfJar')
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
@@ -140,7 +159,11 @@ publishing {
|
|||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
url "file:///${project.projectDir}/mcmodsrepo"
|
url "file://${project.projectDir}/mcmodsrepo"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile).configureEach {
|
||||||
|
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
||||||
|
}
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
269
gradlew
vendored
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright 2015 the original author or authors.
|
# Copyright <20> 2015-2021 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -17,67 +17,101 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
#
|
||||||
## Gradle start up script for UN*X
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
##
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions <20>$var<61>, <20>${var}<7D>, <20>${var:-default}<7D>, <20>${var+SET}<7D>,
|
||||||
|
# <20>${var#prefix}<7D>, <20>${var%suffix}<7D>, and <20>$( cmd )<29>;
|
||||||
|
# * compound commands having a testable exit status, especially <20>case<73>;
|
||||||
|
# * various built-in commands including <20>command<6E>, <20>set<65>, and <20>ulimit<69>.
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
PRG="$0"
|
app_path=$0
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
# Need this for daisy-chained symlinks.
|
||||||
ls=`ls -ld "$PRG"`
|
while
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
[ -h "$app_path" ]
|
||||||
PRG="$link"
|
do
|
||||||
else
|
ls=$( ls -ld "$app_path" )
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
link=${ls#*' -> '}
|
||||||
fi
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
SAVED="`pwd`"
|
|
||||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
APP_HOME="`pwd -P`"
|
|
||||||
cd "$SAVED" >/dev/null
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
APP_NAME="Gradle"
|
||||||
APP_BASE_NAME=`basename "$0"`
|
APP_BASE_NAME=${0##*/}
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD=maximum
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "`uname`" in
|
case "$( uname )" in #(
|
||||||
CYGWIN* )
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
cygwin=true
|
Darwin* ) darwin=true ;; #(
|
||||||
;;
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
Darwin* )
|
NONSTOP* ) nonstop=true ;;
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MSYS* | MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
NONSTOP* )
|
|
||||||
nonstop=true
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
@@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
else
|
else
|
||||||
JAVACMD="$JAVA_HOME/bin/java"
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
@@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD="java"
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
@@ -106,78 +140,95 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
case $MAX_FD in #(
|
||||||
if [ $? -eq 0 ] ; then
|
max*)
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
MAX_FD="$MAX_FD_LIMIT"
|
warn "Could not query maximum file descriptor limit"
|
||||||
fi
|
esac
|
||||||
ulimit -n $MAX_FD
|
case $MAX_FD in #(
|
||||||
if [ $? -ne 0 ] ; then
|
'' | soft) :;; #(
|
||||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
*)
|
||||||
fi
|
ulimit -n "$MAX_FD" ||
|
||||||
else
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Darwin, add options to specify how the application appears in the dock
|
|
||||||
if $darwin; then
|
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
||||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
|
||||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
|
||||||
SEP=""
|
|
||||||
for dir in $ROOTDIRSRAW ; do
|
|
||||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
|
||||||
SEP="|"
|
|
||||||
done
|
|
||||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
|
||||||
# Add a user-defined pattern to the cygpath arguments
|
|
||||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
|
||||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
|
||||||
fi
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
i=0
|
|
||||||
for arg in "$@" ; do
|
|
||||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
|
||||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
|
||||||
|
|
||||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
|
||||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
|
||||||
else
|
|
||||||
eval `echo args$i`="\"$arg\""
|
|
||||||
fi
|
|
||||||
i=`expr $i + 1`
|
|
||||||
done
|
|
||||||
case $i in
|
|
||||||
0) set -- ;;
|
|
||||||
1) set -- "$args0" ;;
|
|
||||||
2) set -- "$args0" "$args1" ;;
|
|
||||||
3) set -- "$args0" "$args1" "$args2" ;;
|
|
||||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
|
||||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
|
||||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
|
||||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
|
||||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
|
||||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ARGV=("$@")
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
eval set -- $DEFAULT_JVM_OPTS
|
# * args from the command line
|
||||||
|
# * the main class name
|
||||||
|
# * -classpath
|
||||||
|
# * -D...appname settings
|
||||||
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
IFS=$'
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
' read -rd '' -a JAVA_OPTS_ARR <<< "$(echo $JAVA_OPTS | xargs -n1)"
|
if "$cygwin" || "$msys" ; then
|
||||||
IFS=$'
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
' read -rd '' -a GRADLE_OPTS_ARR <<< "$(echo $GRADLE_OPTS | xargs -n1)"
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
exec "$JAVACMD" "$@" "${JAVA_OPTS_ARR[@]}" "${GRADLE_OPTS_ARR[@]}" "-Dorg.gradle.appname=$APP_BASE_NAME" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "${ARGV[@]}"
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command;
|
||||||
|
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||||
|
# shell script including quotes and variable substitutions, so put them in
|
||||||
|
# double quotes to make sure that they get re-expanded; and
|
||||||
|
# * put everything else in single quotes, so that it's not re-expanded.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
|
|||||||
6
settings.gradle
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
gradlePluginPortal()
|
||||||
|
maven { url = 'https://maven.minecraftforge.net/' }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -54,33 +54,12 @@ public class BuildConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class SurvivalBalancers {
|
public static class SurvivalBalancers {
|
||||||
public final ForgeConfigSpec.ConfigValue<Boolean> breakFar;
|
|
||||||
public final ForgeConfigSpec.ConfigValue<Boolean> increasedMiningTime;
|
|
||||||
public final ForgeConfigSpec.ConfigValue<Integer> miningTimePercentage;
|
|
||||||
public final ForgeConfigSpec.ConfigValue<Integer> quickReplaceMiningLevel;
|
public final ForgeConfigSpec.ConfigValue<Integer> quickReplaceMiningLevel;
|
||||||
public final ForgeConfigSpec.ConfigValue<Integer> undoStackSize;
|
public final ForgeConfigSpec.ConfigValue<Integer> undoStackSize;
|
||||||
|
|
||||||
public SurvivalBalancers(ForgeConfigSpec.Builder builder) {
|
public SurvivalBalancers(ForgeConfigSpec.Builder builder) {
|
||||||
builder.push("SurvivalBalancers");
|
builder.push("SurvivalBalancers");
|
||||||
|
|
||||||
breakFar = builder
|
|
||||||
.comment("Allows a survival player to break blocks that are far away, in addition to placing blocks.",
|
|
||||||
"Note: this allows insta-breaking of blocks in survival.")
|
|
||||||
.define("breakFar", false);
|
|
||||||
|
|
||||||
increasedMiningTime = builder
|
|
||||||
.comment("Increases the time to mine a block when breaking multiple at once.",
|
|
||||||
"Mining time depends on how many blocks, what type of blocks, and the percentage below.",
|
|
||||||
"Example: breaking 1 dirt + 1 obsidian takes the time of breaking 1 dirt + 1 obsidian.")
|
|
||||||
.define("increasedMiningTime", true);
|
|
||||||
|
|
||||||
miningTimePercentage = builder
|
|
||||||
.comment("How much the mining time of each additional block counts towards an increased mining time.",
|
|
||||||
"A percentage between 0% and 100%, where 0% is the same as disabling it,",
|
|
||||||
"and 100% takes as much time as breaking each block individually.",
|
|
||||||
"The block in front of you always counts as 100%.")
|
|
||||||
.defineInRange("miningTimePercentage", 50, 0, 200);
|
|
||||||
|
|
||||||
quickReplaceMiningLevel = builder
|
quickReplaceMiningLevel = builder
|
||||||
.comment("Determines what blocks can be replaced in survival.",
|
.comment("Determines what blocks can be replaced in survival.",
|
||||||
"-1: only blocks that can be harvested by hand (default)",
|
"-1: only blocks that can be harvested by hand (default)",
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
package nl.requios.effortlessbuilding;
|
package nl.requios.effortlessbuilding;
|
||||||
|
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.MenuType;
|
import net.minecraft.world.inventory.MenuType;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent;
|
import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
@@ -15,8 +14,8 @@ import net.minecraftforge.fml.config.ModConfig;
|
|||||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
import net.minecraftforge.fmllegacy.RegistryObject;
|
import net.minecraftforge.network.IContainerFactory;
|
||||||
import net.minecraftforge.fmllegacy.network.IContainerFactory;
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import nl.requios.effortlessbuilding.capability.ModeCapabilityManager;
|
import nl.requios.effortlessbuilding.capability.ModeCapabilityManager;
|
||||||
@@ -44,7 +43,7 @@ public class EffortlessBuilding {
|
|||||||
|
|
||||||
//Registration
|
//Registration
|
||||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||||
private static final DeferredRegister<MenuType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.CONTAINERS, EffortlessBuilding.MODID);
|
private static final DeferredRegister<MenuType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.MENU_TYPES, EffortlessBuilding.MODID);
|
||||||
|
|
||||||
public static final RegistryObject<Item> RANDOMIZER_BAG_ITEM = ITEMS.register("randomizer_bag", RandomizerBagItem::new);
|
public static final RegistryObject<Item> RANDOMIZER_BAG_ITEM = ITEMS.register("randomizer_bag", RandomizerBagItem::new);
|
||||||
public static final RegistryObject<Item> GOLDEN_RANDOMIZER_BAG_ITEM = ITEMS.register("golden_randomizer_bag", GoldenRandomizerBagItem::new);
|
public static final RegistryObject<Item> GOLDEN_RANDOMIZER_BAG_ITEM = ITEMS.register("golden_randomizer_bag", GoldenRandomizerBagItem::new);
|
||||||
@@ -104,7 +103,7 @@ public class EffortlessBuilding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void log(Player player, String msg, boolean actionBar) {
|
public static void log(Player player, String msg, boolean actionBar) {
|
||||||
player.displayClientMessage(new TextComponent(msg), actionBar);
|
player.displayClientMessage(Component.literal(msg), actionBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Log with translation supported, call either on client or server (which then sends a message)
|
//Log with translation supported, call either on client or server (which then sends a message)
|
||||||
|
|||||||
@@ -1,38 +1,34 @@
|
|||||||
package nl.requios.effortlessbuilding;
|
package nl.requios.effortlessbuilding;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.InteractionHand;
|
||||||
|
import net.minecraft.world.item.BlockItem;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraftforge.common.util.FakePlayer;
|
import net.minecraftforge.common.util.FakePlayer;
|
||||||
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
||||||
|
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||||
import net.minecraftforge.event.world.BlockEvent;
|
import net.minecraftforge.event.level.BlockEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fmllegacy.network.PacketDistributor;
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
import net.minecraftforge.fmlserverevents.FMLServerStartingEvent;
|
|
||||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.BuildModifiers;
|
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.UndoRedo;
|
import nl.requios.effortlessbuilding.buildmodifier.UndoRedo;
|
||||||
import nl.requios.effortlessbuilding.capability.ModeCapabilityManager;
|
import nl.requios.effortlessbuilding.capability.ModeCapabilityManager;
|
||||||
import nl.requios.effortlessbuilding.capability.ModifierCapabilityManager;
|
import nl.requios.effortlessbuilding.capability.ModifierCapabilityManager;
|
||||||
import nl.requios.effortlessbuilding.command.CommandReach;
|
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
||||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||||
import nl.requios.effortlessbuilding.helper.SurvivalHelper;
|
|
||||||
import nl.requios.effortlessbuilding.network.AddUndoMessage;
|
import nl.requios.effortlessbuilding.network.AddUndoMessage;
|
||||||
import nl.requios.effortlessbuilding.network.ClearUndoMessage;
|
import nl.requios.effortlessbuilding.network.ClearUndoMessage;
|
||||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
import nl.requios.effortlessbuilding.network.PacketHandler;
|
||||||
import nl.requios.effortlessbuilding.network.RequestLookAtMessage;
|
import nl.requios.effortlessbuilding.network.RequestLookAtMessage;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = EffortlessBuilding.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE)
|
@Mod.EventBusSubscriber(modid = EffortlessBuilding.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE)
|
||||||
public class EventHandler {
|
public class EventHandler {
|
||||||
|
|
||||||
@@ -45,14 +41,9 @@ public class EventHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onServerStarting(FMLServerStartingEvent event) {
|
|
||||||
CommandReach.register(event.getServer().getCommands().getDispatcher());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onBlockPlaced(BlockEvent.EntityPlaceEvent event) {
|
public static void onBlockPlaced(BlockEvent.EntityPlaceEvent event) {
|
||||||
if (event.getWorld().isClientSide()) return;
|
if (event.getLevel().isClientSide()) return;
|
||||||
|
|
||||||
if (!(event.getEntity() instanceof Player)) return;
|
if (!(event.getEntity() instanceof Player)) return;
|
||||||
|
|
||||||
@@ -64,7 +55,15 @@ public class EventHandler {
|
|||||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
||||||
|
|
||||||
if (buildMode != BuildModes.BuildModeEnum.NORMAL) {
|
if (buildMode != BuildModes.BuildModeEnum.NORMAL) {
|
||||||
|
|
||||||
|
//Only cancel if itemblock in hand
|
||||||
|
//Fixed issue with e.g. Create Wrench shift-rightclick disassembling being cancelled.
|
||||||
|
ItemStack currentItemStack = player.getItemInHand(InteractionHand.MAIN_HAND);
|
||||||
|
if (currentItemStack.getItem() instanceof BlockItem ||
|
||||||
|
(CompatHelper.isItemBlockProxy(currentItemStack) && !player.isShiftKeyDown())) {
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
|
}
|
||||||
|
|
||||||
} else if (modifierSettings.doQuickReplace()) {
|
} else if (modifierSettings.doQuickReplace()) {
|
||||||
//Cancel event and send message if QuickReplace
|
//Cancel event and send message if QuickReplace
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
@@ -87,7 +86,7 @@ public class EventHandler {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onBlockBroken(BlockEvent.BreakEvent event) {
|
public static void onBlockBroken(BlockEvent.BreakEvent event) {
|
||||||
if (event.getWorld().isClientSide()) return;
|
if (event.getLevel().isClientSide()) return;
|
||||||
|
|
||||||
if (event.getPlayer() instanceof FakePlayer) return;
|
if (event.getPlayer() instanceof FakePlayer) return;
|
||||||
|
|
||||||
@@ -111,57 +110,18 @@ public class EventHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void breakSpeed(PlayerEvent.BreakSpeed event) {
|
|
||||||
//Disable if config says so
|
|
||||||
if (!BuildConfig.survivalBalancers.increasedMiningTime.get()) return;
|
|
||||||
|
|
||||||
if (event.getPlayer() instanceof FakePlayer) return;
|
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
Level world = player.level;
|
|
||||||
BlockPos pos = event.getPos();
|
|
||||||
|
|
||||||
//EffortlessBuilding.log(player, String.valueOf(event.getNewSpeed()));
|
|
||||||
|
|
||||||
float originalBlockHardness = event.getState().getDestroySpeed(world, pos);
|
|
||||||
if (originalBlockHardness < 0) return; //Dont break bedrock
|
|
||||||
float totalBlockHardness = 0;
|
|
||||||
//get coordinates
|
|
||||||
List<BlockPos> coordinates = BuildModifiers.findCoordinates(player, pos);
|
|
||||||
for (int i = 1; i < coordinates.size(); i++) {
|
|
||||||
BlockPos coordinate = coordinates.get(i);
|
|
||||||
//get existing blockstates at those coordinates
|
|
||||||
BlockState blockState = world.getBlockState(coordinate);
|
|
||||||
//add hardness for each blockstate, if can break
|
|
||||||
if (SurvivalHelper.canBreak(world, player, coordinate))
|
|
||||||
totalBlockHardness += blockState.getDestroySpeed(world, coordinate);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Grabbing percentage from config
|
|
||||||
float percentage = (float) BuildConfig.survivalBalancers.miningTimePercentage.get() / 100;
|
|
||||||
totalBlockHardness *= percentage;
|
|
||||||
totalBlockHardness += originalBlockHardness;
|
|
||||||
|
|
||||||
float newSpeed = event.getOriginalSpeed() / totalBlockHardness * originalBlockHardness;
|
|
||||||
if (Float.isNaN(newSpeed) || newSpeed == 0f) newSpeed = 1f;
|
|
||||||
event.setNewSpeed(newSpeed);
|
|
||||||
|
|
||||||
//EffortlessBuilding.log(player, String.valueOf(event.getNewSpeed()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
public static void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
||||||
if (event.getPlayer() instanceof FakePlayer) return;
|
if (event.getEntity() instanceof FakePlayer) return;
|
||||||
Player player = event.getPlayer();
|
Player player = event.getEntity();
|
||||||
ModifierSettingsManager.handleNewPlayer(player);
|
ModifierSettingsManager.handleNewPlayer(player);
|
||||||
ModeSettingsManager.handleNewPlayer(player);
|
ModeSettingsManager.handleNewPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) {
|
public static void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) {
|
||||||
if (event.getPlayer() instanceof FakePlayer) return;
|
if (event.getEntity() instanceof FakePlayer) return;
|
||||||
Player player = event.getPlayer();
|
Player player = event.getEntity();
|
||||||
if (player.getCommandSenderWorld().isClientSide) return;
|
if (player.getCommandSenderWorld().isClientSide) return;
|
||||||
|
|
||||||
UndoRedo.clear(player);
|
UndoRedo.clear(player);
|
||||||
@@ -170,16 +130,16 @@ public class EventHandler {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onPlayerRespawn(PlayerEvent.PlayerRespawnEvent event) {
|
public static void onPlayerRespawn(PlayerEvent.PlayerRespawnEvent event) {
|
||||||
if (event.getPlayer() instanceof FakePlayer) return;
|
if (event.getEntity() instanceof FakePlayer) return;
|
||||||
Player player = event.getPlayer();
|
Player player = event.getEntity();
|
||||||
ModifierSettingsManager.handleNewPlayer(player);
|
ModifierSettingsManager.handleNewPlayer(player);
|
||||||
ModeSettingsManager.handleNewPlayer(player);
|
ModeSettingsManager.handleNewPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onPlayerChangedDimension(PlayerEvent.PlayerChangedDimensionEvent event) {
|
public static void onPlayerChangedDimension(PlayerEvent.PlayerChangedDimensionEvent event) {
|
||||||
if (event.getPlayer() instanceof FakePlayer) return;
|
if (event.getEntity() instanceof FakePlayer) return;
|
||||||
Player player = event.getPlayer();
|
Player player = event.getEntity();
|
||||||
if (player.getCommandSenderWorld().isClientSide) return;
|
if (player.getCommandSenderWorld().isClientSide) return;
|
||||||
|
|
||||||
//Set build mode to normal
|
//Set build mode to normal
|
||||||
@@ -203,12 +163,12 @@ public class EventHandler {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onPlayerClone(PlayerEvent.Clone event) {
|
public static void onPlayerClone(PlayerEvent.Clone event) {
|
||||||
if (event.getPlayer() instanceof FakePlayer) return;
|
if (event.getEntity() instanceof FakePlayer) return;
|
||||||
//Attach capabilities on death, otherwise crash
|
//Attach capabilities on death, otherwise crash
|
||||||
Player oldPlayer = event.getOriginal();
|
Player oldPlayer = event.getOriginal();
|
||||||
oldPlayer.revive();
|
oldPlayer.revive();
|
||||||
|
|
||||||
Player newPlayer = event.getPlayer();
|
Player newPlayer = event.getEntity();
|
||||||
ModifierSettingsManager.setModifierSettings(newPlayer, ModifierSettingsManager.getModifierSettings(oldPlayer));
|
ModifierSettingsManager.setModifierSettings(newPlayer, ModifierSettingsManager.getModifierSettings(oldPlayer));
|
||||||
ModeSettingsManager.setModeSettings(newPlayer, ModeSettingsManager.getModeSettings(oldPlayer));
|
ModeSettingsManager.setModeSettings(newPlayer, ModeSettingsManager.getModeSettings(oldPlayer));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,46 @@
|
|||||||
package nl.requios.effortlessbuilding;
|
package nl.requios.effortlessbuilding;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.platform.InputConstants;
|
||||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.KeyMapping;
|
||||||
import net.minecraft.client.renderer.ShaderInstance;
|
import net.minecraft.client.renderer.ShaderInstance;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
|
||||||
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.client.event.RegisterKeyMappingsEvent;
|
||||||
import net.minecraftforge.client.event.RegisterShadersEvent;
|
import net.minecraftforge.client.event.RegisterShadersEvent;
|
||||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
import net.minecraftforge.client.settings.KeyConflictContext;
|
||||||
|
import net.minecraftforge.client.settings.KeyModifier;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
|
||||||
import nl.requios.effortlessbuilding.render.BuildRenderTypes;
|
import nl.requios.effortlessbuilding.render.BuildRenderTypes;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = {Dist.CLIENT})
|
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = {Dist.CLIENT})
|
||||||
public class ModClientEventHandler {
|
public class ModClientEventHandler {
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void registerKeyMappings(RegisterKeyMappingsEvent event) {
|
||||||
|
EffortlessBuilding.log("Registering KeyMappings!");
|
||||||
|
|
||||||
|
// register key bindings
|
||||||
|
ClientProxy.keyBindings = new KeyMapping[6];
|
||||||
|
|
||||||
|
// instantiate the key bindings
|
||||||
|
ClientProxy.keyBindings[0] = new KeyMapping("key.effortlessbuilding.hud.desc", KeyConflictContext.IN_GAME, InputConstants.getKey(GLFW.GLFW_KEY_KP_ADD, 0), "key.effortlessbuilding.category");
|
||||||
|
ClientProxy.keyBindings[1] = new KeyMapping("key.effortlessbuilding.replace.desc", KeyConflictContext.IN_GAME, InputConstants.getKey(GLFW.GLFW_KEY_KP_SUBTRACT, 0), "key.effortlessbuilding.category");
|
||||||
|
ClientProxy.keyBindings[2] = new KeyMapping("key.effortlessbuilding.mode.desc", KeyConflictContext.IN_GAME, InputConstants.getKey(GLFW.GLFW_KEY_LEFT_ALT, 0), "key.effortlessbuilding.category");
|
||||||
|
ClientProxy.keyBindings[3] = new KeyMapping("key.effortlessbuilding.undo.desc", KeyConflictContext.IN_GAME, KeyModifier.CONTROL, InputConstants.getKey(GLFW.GLFW_KEY_Z, 0), "key.effortlessbuilding.category");
|
||||||
|
ClientProxy.keyBindings[4] = new KeyMapping("key.effortlessbuilding.redo.desc", KeyConflictContext.IN_GAME, KeyModifier.CONTROL, InputConstants.getKey(GLFW.GLFW_KEY_Y, 0), "key.effortlessbuilding.category");
|
||||||
|
ClientProxy.keyBindings[5] = new KeyMapping("key.effortlessbuilding.altplacement.desc", KeyConflictContext.IN_GAME, InputConstants.getKey(GLFW.GLFW_KEY_LEFT_CONTROL, 0), "key.effortlessbuilding.category");
|
||||||
|
|
||||||
|
for (KeyMapping keyBinding : ClientProxy.keyBindings) {
|
||||||
|
event.register(keyBinding);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void registerShaders(RegisterShadersEvent event) throws IOException {
|
public static void registerShaders(RegisterShadersEvent event) throws IOException {
|
||||||
event.registerShader(new ShaderInstance(event.getResourceManager(),
|
event.registerShader(new ShaderInstance(event.getResourceManager(),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmode;
|
package nl.requios.effortlessbuilding.buildmode;
|
||||||
|
|
||||||
|
import com.mojang.math.Vector4f;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
@@ -52,7 +53,6 @@ public class BuildModes {
|
|||||||
startPos = message.getBlockPos();
|
startPos = message.getBlockPos();
|
||||||
|
|
||||||
//Offset in direction of sidehit if not quickreplace and not replaceable
|
//Offset in direction of sidehit if not quickreplace and not replaceable
|
||||||
//TODO 1.13 replaceable
|
|
||||||
boolean replaceable = player.level.getBlockState(startPos).getMaterial().isReplaceable();
|
boolean replaceable = player.level.getBlockState(startPos).getMaterial().isReplaceable();
|
||||||
boolean becomesDoubleSlab = SurvivalHelper.doesBecomeDoubleSlab(player, startPos, message.getSideHit());
|
boolean becomesDoubleSlab = SurvivalHelper.doesBecomeDoubleSlab(player, startPos, message.getSideHit());
|
||||||
if (!modifierSettings.doQuickReplace() && !replaceable && !becomesDoubleSlab) {
|
if (!modifierSettings.doQuickReplace() && !replaceable && !becomesDoubleSlab) {
|
||||||
@@ -98,7 +98,6 @@ public class BuildModes {
|
|||||||
//Only works when finishing a buildmode is equal to placing some blocks
|
//Only works when finishing a buildmode is equal to placing some blocks
|
||||||
//No intermediate blocks allowed
|
//No intermediate blocks allowed
|
||||||
currentlyBreaking.remove(player);
|
currentlyBreaking.remove(player);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Use a network message to break blocks in the distance using clientside mouse input
|
//Use a network message to break blocks in the distance using clientside mouse input
|
||||||
@@ -117,6 +116,8 @@ public class BuildModes {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ReachHelper.canBreakFar(player)) return;
|
||||||
|
|
||||||
//If first click
|
//If first click
|
||||||
if (currentlyBreaking.get(player) == null) {
|
if (currentlyBreaking.get(player) == null) {
|
||||||
//If startpos is null, dont do anything
|
//If startpos is null, dont do anything
|
||||||
@@ -245,27 +246,57 @@ public class BuildModes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum BuildModeEnum {
|
public enum BuildModeEnum {
|
||||||
NORMAL("effortlessbuilding.mode.normal", new Normal()),
|
NORMAL("normal", new Normal(), BuildModeCategoryEnum.BASIC),
|
||||||
NORMAL_PLUS("effortlessbuilding.mode.normal_plus", new NormalPlus(), OptionEnum.BUILD_SPEED),
|
NORMAL_PLUS("normal_plus", new NormalPlus(), BuildModeCategoryEnum.BASIC, OptionEnum.BUILD_SPEED),
|
||||||
LINE("effortlessbuilding.mode.line", new Line() /*, OptionEnum.THICKNESS*/),
|
LINE("line", new Line(), BuildModeCategoryEnum.BASIC /*, OptionEnum.THICKNESS*/),
|
||||||
WALL("effortlessbuilding.mode.wall", new Wall(), OptionEnum.FILL),
|
WALL("wall", new Wall(), BuildModeCategoryEnum.BASIC, OptionEnum.FILL),
|
||||||
FLOOR("effortlessbuilding.mode.floor", new Floor(), OptionEnum.FILL),
|
FLOOR("floor", new Floor(), BuildModeCategoryEnum.BASIC, OptionEnum.FILL),
|
||||||
DIAGONAL_LINE("effortlessbuilding.mode.diagonal_line", new DiagonalLine() /*, OptionEnum.THICKNESS*/),
|
CUBE("cube", new Cube(), BuildModeCategoryEnum.BASIC, OptionEnum.CUBE_FILL),
|
||||||
DIAGONAL_WALL("effortlessbuilding.mode.diagonal_wall", new DiagonalWall() /*, OptionEnum.FILL*/),
|
DIAGONAL_LINE("diagonal_line", new DiagonalLine(), BuildModeCategoryEnum.DIAGONAL /*, OptionEnum.THICKNESS*/),
|
||||||
SLOPE_FLOOR("effortlessbuilding.mode.slope_floor", new SlopeFloor(), OptionEnum.RAISED_EDGE),
|
DIAGONAL_WALL("diagonal_wall", new DiagonalWall(), BuildModeCategoryEnum.DIAGONAL /*, OptionEnum.FILL*/),
|
||||||
CIRCLE("effortlessbuilding.mode.circle", new Circle(), OptionEnum.CIRCLE_START, OptionEnum.FILL),
|
SLOPE_FLOOR("slope_floor", new SlopeFloor(), BuildModeCategoryEnum.DIAGONAL, OptionEnum.RAISED_EDGE),
|
||||||
CYLINDER("effortlessbuilding.mode.cylinder", new Cylinder(), OptionEnum.CIRCLE_START, OptionEnum.FILL),
|
CIRCLE("circle", new Circle(), BuildModeCategoryEnum.CIRCULAR, OptionEnum.CIRCLE_START, OptionEnum.FILL),
|
||||||
SPHERE("effortlessbuilding.mode.sphere", new Sphere(), OptionEnum.CIRCLE_START, OptionEnum.FILL),
|
CYLINDER("cylinder", new Cylinder(), BuildModeCategoryEnum.CIRCULAR, OptionEnum.CIRCLE_START, OptionEnum.FILL),
|
||||||
CUBE("effortlessbuilding.mode.cube", new Cube(), OptionEnum.CUBE_FILL);
|
SPHERE("sphere", new Sphere(), BuildModeCategoryEnum.CIRCULAR, OptionEnum.CIRCLE_START, OptionEnum.FILL);
|
||||||
|
// PYRAMID("pyramid", new Pyramid(), BuildModeCategoryEnum.ROOF),
|
||||||
|
// CONE("cone", new Cone(), BuildModeCategoryEnum.ROOF),
|
||||||
|
// DOME("dome", new Dome(), BuildModeCategoryEnum.ROOF);
|
||||||
|
|
||||||
public String name;
|
private final String name;
|
||||||
public IBuildMode instance;
|
public final IBuildMode instance;
|
||||||
public OptionEnum[] options;
|
public final BuildModeCategoryEnum category;
|
||||||
|
public final OptionEnum[] options;
|
||||||
|
|
||||||
BuildModeEnum(String name, IBuildMode instance, OptionEnum... options) {
|
BuildModeEnum(String name, IBuildMode instance, BuildModeCategoryEnum category, OptionEnum... options) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
|
this.category = category;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNameKey() {
|
||||||
|
return "effortlessbuilding.mode." + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescriptionKey() {
|
||||||
|
return "effortlessbuilding.modedescription." + name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum BuildModeCategoryEnum {
|
||||||
|
BASIC(new Vector4f(0f, .5f, 1f, .8f)),
|
||||||
|
DIAGONAL(new Vector4f(0.56f, 0.28f, 0.87f, .8f)),
|
||||||
|
CIRCULAR(new Vector4f(0.29f, 0.76f, 0.3f, 1f)),
|
||||||
|
ROOF(new Vector4f(0.83f, 0.87f, 0.23f, .8f));
|
||||||
|
|
||||||
|
public final Vector4f color;
|
||||||
|
|
||||||
|
BuildModeCategoryEnum(Vector4f color) {
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import net.minecraft.world.entity.player.Player;
|
|||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fmllegacy.network.PacketDistributor;
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.capability.ModeCapabilityManager;
|
import nl.requios.effortlessbuilding.capability.ModeCapabilityManager;
|
||||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||||
@@ -16,33 +16,24 @@ import javax.annotation.Nonnull;
|
|||||||
@Mod.EventBusSubscriber
|
@Mod.EventBusSubscriber
|
||||||
public class ModeSettingsManager {
|
public class ModeSettingsManager {
|
||||||
|
|
||||||
private static ModeSettings cache = null;
|
|
||||||
|
|
||||||
//Retrieves the buildsettings of a player through the modeCapability capability
|
//Retrieves the buildsettings of a player through the modeCapability capability
|
||||||
//Never returns null
|
//Never returns null
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static ModeSettings getModeSettings(Player player) {
|
public static ModeSettings getModeSettings(Player player) {
|
||||||
if (cache != null) return cache;
|
|
||||||
|
|
||||||
LazyOptional<ModeCapabilityManager.IModeCapability> modeCapability =
|
LazyOptional<ModeCapabilityManager.IModeCapability> modeCapability =
|
||||||
player.getCapability(ModeCapabilityManager.MODE_CAPABILITY, null);
|
player.getCapability(ModeCapabilityManager.MODE_CAPABILITY, null);
|
||||||
|
|
||||||
if (modeCapability.isPresent()) {
|
if (modeCapability.isPresent()) {
|
||||||
ModeCapabilityManager.IModeCapability capability = modeCapability.orElse(null);
|
ModeCapabilityManager.IModeCapability capability = modeCapability.orElse(null);
|
||||||
cache = capability.getModeData();
|
if (capability.getModeData() == null){
|
||||||
if (cache == null) {
|
capability.setModeData(new ModeSettings());
|
||||||
cache = new ModeSettings();
|
|
||||||
capability.setModeData(cache);
|
|
||||||
}
|
}
|
||||||
//Add invalidation listener, to invalidate cache
|
|
||||||
modeCapability.addListener(self -> cache = null);
|
|
||||||
return capability.getModeData();
|
return capability.getModeData();
|
||||||
}
|
}
|
||||||
|
|
||||||
EffortlessBuilding.logger.warn("Player does not have modeCapability: " + player);
|
// EffortlessBuilding.logger.warn("Player does not have modeCapability: " + player);
|
||||||
//Return dummy settings
|
//Return dummy settings
|
||||||
return new ModeSettings();
|
return new ModeSettings();
|
||||||
// throw new IllegalArgumentException("Player does not have modeCapability capability");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setModeSettings(Player player, ModeSettings modeSettings) {
|
public static void setModeSettings(Player player, ModeSettings modeSettings) {
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Cone extends ThreeClicksBuildMode {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected BlockPos findSecondPos(Player player, BlockPos firstPos, boolean skipRaytrace) {
|
||||||
|
return Floor.findFloor(player, firstPos, skipRaytrace);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected BlockPos findThirdPos(Player player, BlockPos firstPos, BlockPos secondPos, boolean skipRaytrace) {
|
||||||
|
return findHeight(player, secondPos, skipRaytrace);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<BlockPos> getIntermediateBlocks(Player player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||||
|
return Floor.getFloorBlocks(player, x1, y1, z1, x2, y2, z2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<BlockPos> getFinalBlocks(Player player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||||
|
//TODO
|
||||||
|
return SlopeFloor.getSlopeFloorBlocks(player, x1, y1, z1, x2, y2, z2, x3, y3, z3);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Dome extends ThreeClicksBuildMode {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected BlockPos findSecondPos(Player player, BlockPos firstPos, boolean skipRaytrace) {
|
||||||
|
return Floor.findFloor(player, firstPos, skipRaytrace);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected BlockPos findThirdPos(Player player, BlockPos firstPos, BlockPos secondPos, boolean skipRaytrace) {
|
||||||
|
return findHeight(player, secondPos, skipRaytrace);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<BlockPos> getIntermediateBlocks(Player player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||||
|
return Floor.getFloorBlocks(player, x1, y1, z1, x2, y2, z2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<BlockPos> getFinalBlocks(Player player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||||
|
//TODO
|
||||||
|
return SlopeFloor.getSlopeFloorBlocks(player, x1, y1, z1, x2, y2, z2, x3, y3, z3);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||||
|
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
||||||
|
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Pyramid extends ThreeClicksBuildMode {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected BlockPos findSecondPos(Player player, BlockPos firstPos, boolean skipRaytrace) {
|
||||||
|
return Floor.findFloor(player, firstPos, skipRaytrace);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected BlockPos findThirdPos(Player player, BlockPos firstPos, BlockPos secondPos, boolean skipRaytrace) {
|
||||||
|
return findHeight(player, secondPos, skipRaytrace);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<BlockPos> getIntermediateBlocks(Player player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||||
|
return Floor.getFloorBlocks(player, x1, y1, z1, x2, y2, z2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<BlockPos> getFinalBlocks(Player player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||||
|
//TODO
|
||||||
|
return SlopeFloor.getSlopeFloorBlocks(player, x1, y1, z1, x2, y2, z2, x3, y3, z3);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -198,12 +198,15 @@ public class BuildModifiers {
|
|||||||
for (BlockPos blockPos : posList) {
|
for (BlockPos blockPos : posList) {
|
||||||
if (!(itemStack.getItem() instanceof BlockItem)) itemBlock = CompatHelper.getItemBlockFromStack(itemStack);
|
if (!(itemStack.getItem() instanceof BlockItem)) itemBlock = CompatHelper.getItemBlockFromStack(itemStack);
|
||||||
BlockState blockState = getBlockStateFromItem(itemBlock, player, blockPos, facing, hitVec, InteractionHand.MAIN_HAND);
|
BlockState blockState = getBlockStateFromItem(itemBlock, player, blockPos, facing, hitVec, InteractionHand.MAIN_HAND);
|
||||||
|
if (blockState == null) continue;
|
||||||
|
|
||||||
blockStates.add(blockState);
|
blockStates.add(blockState);
|
||||||
itemStacks.add(itemBlock);
|
itemStacks.add(itemBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (BlockPos blockPos : posList) {
|
for (BlockPos blockPos : posList) {
|
||||||
BlockState blockState = getBlockStateFromItem(itemBlock, player, blockPos, facing, hitVec, InteractionHand.MAIN_HAND);
|
BlockState blockState = getBlockStateFromItem(itemBlock, player, blockPos, facing, hitVec, InteractionHand.MAIN_HAND);
|
||||||
|
if (blockState == null) continue;
|
||||||
|
|
||||||
List<BlockState> arrayBlockStates = Array.findBlockStates(player, blockPos, blockState, itemStack, itemStacks);
|
List<BlockState> arrayBlockStates = Array.findBlockStates(player, blockPos, blockState, itemStack, itemStacks);
|
||||||
blockStates.addAll(arrayBlockStates);
|
blockStates.addAll(arrayBlockStates);
|
||||||
@@ -214,6 +217,8 @@ public class BuildModifiers {
|
|||||||
for (int i = 0; i < arrayCoordinates.size(); i++) {
|
for (int i = 0; i < arrayCoordinates.size(); i++) {
|
||||||
BlockPos coordinate = arrayCoordinates.get(i);
|
BlockPos coordinate = arrayCoordinates.get(i);
|
||||||
BlockState blockState1 = arrayBlockStates.get(i);
|
BlockState blockState1 = arrayBlockStates.get(i);
|
||||||
|
if (blockState1 == null) continue;
|
||||||
|
|
||||||
blockStates.addAll(Mirror.findBlockStates(player, coordinate, blockState1, itemStack, itemStacks));
|
blockStates.addAll(Mirror.findBlockStates(player, coordinate, blockState1, itemStack, itemStacks));
|
||||||
blockStates.addAll(RadialMirror.findBlockStates(player, coordinate, blockState1, itemStack, itemStacks));
|
blockStates.addAll(RadialMirror.findBlockStates(player, coordinate, blockState1, itemStack, itemStacks));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import net.minecraft.world.entity.player.Player;
|
|||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fmllegacy.network.PacketDistributor;
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
import nl.requios.effortlessbuilding.BuildConfig;
|
import nl.requios.effortlessbuilding.BuildConfig;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.capability.ModifierCapabilityManager;
|
import nl.requios.effortlessbuilding.capability.ModifierCapabilityManager;
|
||||||
@@ -17,30 +17,23 @@ import javax.annotation.Nonnull;
|
|||||||
@Mod.EventBusSubscriber
|
@Mod.EventBusSubscriber
|
||||||
public class ModifierSettingsManager {
|
public class ModifierSettingsManager {
|
||||||
|
|
||||||
private static ModifierSettings cache = null;
|
|
||||||
|
|
||||||
//Retrieves the buildsettings of a player through the modifierCapability capability
|
//Retrieves the buildsettings of a player through the modifierCapability capability
|
||||||
//Never returns null
|
//Never returns null
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static ModifierSettings getModifierSettings(Player player) {
|
public static ModifierSettings getModifierSettings(Player player) {
|
||||||
if (cache != null) return cache;
|
|
||||||
|
|
||||||
LazyOptional<ModifierCapabilityManager.IModifierCapability> modifierCapability =
|
LazyOptional<ModifierCapabilityManager.IModifierCapability> modifierCapability =
|
||||||
player.getCapability(ModifierCapabilityManager.MODIFIER_CAPABILITY, null);
|
player.getCapability(ModifierCapabilityManager.MODIFIER_CAPABILITY, null);
|
||||||
|
|
||||||
if (modifierCapability.isPresent()) {
|
if (modifierCapability.isPresent()) {
|
||||||
ModifierCapabilityManager.IModifierCapability capability = modifierCapability.orElse(null);
|
ModifierCapabilityManager.IModifierCapability capability = modifierCapability.orElse(null);
|
||||||
cache = capability.getModifierData();
|
if (capability.getModifierData() == null){
|
||||||
if (cache == null) {
|
capability.setModifierData(new ModifierSettings());
|
||||||
cache = new ModifierSettings();
|
|
||||||
capability.setModifierData(cache);
|
|
||||||
}
|
}
|
||||||
//Add invalidation listener, to invalidate cache
|
return capability.getModifierData();
|
||||||
modifierCapability.addListener(self -> cache = null);
|
|
||||||
return cache;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EffortlessBuilding.logger.warn("Player does not have modifierCapability: " + player);
|
// EffortlessBuilding.logger.warn("Player does not have modifierCapability: " + player);
|
||||||
//Return dummy settings
|
//Return dummy settings
|
||||||
return new ModifierSettings();
|
return new ModifierSettings();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class RadialMirror {
|
|||||||
double startAngleInSlice = startAngleToCenterMod % sliceAngle;
|
double startAngleInSlice = startAngleToCenterMod % sliceAngle;
|
||||||
|
|
||||||
//Rotate the original blockstate
|
//Rotate the original blockstate
|
||||||
blockState = rotateOriginalBlockState(startAngleToCenter, blockState);
|
blockState = rotateOriginalBlockState(player, startPos, startAngleToCenter, blockState);
|
||||||
|
|
||||||
//Randomizer bag synergy
|
//Randomizer bag synergy
|
||||||
AbstractRandomizerBagItem randomizerBagItem = null;
|
AbstractRandomizerBagItem randomizerBagItem = null;
|
||||||
@@ -102,11 +102,11 @@ public class RadialMirror {
|
|||||||
newBlockState = BuildModifiers
|
newBlockState = BuildModifiers
|
||||||
.getBlockStateFromItem(itemStack, player, startPos, Direction.UP, new Vec3(0, 0, 0), InteractionHand.MAIN_HAND);
|
.getBlockStateFromItem(itemStack, player, startPos, Direction.UP, new Vec3(0, 0, 0), InteractionHand.MAIN_HAND);
|
||||||
|
|
||||||
newBlockState = rotateOriginalBlockState(startAngleToCenter, newBlockState);
|
newBlockState = rotateOriginalBlockState(player, startPos, startAngleToCenter, newBlockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
//rotate
|
//rotate
|
||||||
newBlockState = rotateBlockState(relNewVec, newBlockState, r.alternate && i % 2 == 1);
|
newBlockState = rotateBlockState(player, startPos, relNewVec, newBlockState, r.alternate && i % 2 == 1);
|
||||||
|
|
||||||
blockStates.add(newBlockState);
|
blockStates.add(newBlockState);
|
||||||
itemStacks.add(itemStack);
|
itemStacks.add(itemStack);
|
||||||
@@ -115,36 +115,36 @@ public class RadialMirror {
|
|||||||
return blockStates;
|
return blockStates;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BlockState rotateOriginalBlockState(double startAngleToCenter, BlockState blockState) {
|
private static BlockState rotateOriginalBlockState(Player player, BlockPos startPos, double startAngleToCenter, BlockState blockState) {
|
||||||
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(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(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(Rotation.CLOCKWISE_90);
|
newBlockState = blockState.rotate(player.level, startPos, Rotation.CLOCKWISE_90);
|
||||||
}
|
}
|
||||||
|
|
||||||
return newBlockState;
|
return newBlockState;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BlockState rotateBlockState(Vec3 relVec, BlockState blockState, boolean alternate) {
|
private static BlockState rotateBlockState(Player player, BlockPos startPos, Vec3 relVec, BlockState blockState, boolean alternate) {
|
||||||
BlockState newBlockState;
|
BlockState newBlockState;
|
||||||
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(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(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(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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,7 @@ package nl.requios.effortlessbuilding.capability;
|
|||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.*;
|
||||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
|
||||||
import net.minecraftforge.common.capabilities.CapabilityProvider;
|
|
||||||
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
@@ -21,8 +18,7 @@ import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager.ModeSettings;
|
|||||||
@Mod.EventBusSubscriber
|
@Mod.EventBusSubscriber
|
||||||
public class ModeCapabilityManager {
|
public class ModeCapabilityManager {
|
||||||
|
|
||||||
@CapabilityInject(IModeCapability.class)
|
public static Capability<IModeCapability> MODE_CAPABILITY = CapabilityManager.get(new CapabilityToken<>(){});
|
||||||
public final static Capability<IModeCapability> MODE_CAPABILITY = null;
|
|
||||||
|
|
||||||
// Allows for the capability to persist after death.
|
// Allows for the capability to persist after death.
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|||||||
@@ -5,10 +5,7 @@ import net.minecraft.nbt.Tag;
|
|||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.*;
|
||||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
|
||||||
import net.minecraftforge.common.capabilities.CapabilityProvider;
|
|
||||||
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
|
||||||
import net.minecraftforge.common.util.INBTSerializable;
|
import net.minecraftforge.common.util.INBTSerializable;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||||
@@ -26,8 +23,7 @@ import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager.Modif
|
|||||||
@Mod.EventBusSubscriber
|
@Mod.EventBusSubscriber
|
||||||
public class ModifierCapabilityManager {
|
public class ModifierCapabilityManager {
|
||||||
|
|
||||||
@CapabilityInject(IModifierCapability.class)
|
public final static Capability<IModifierCapability> MODIFIER_CAPABILITY = CapabilityManager.get(new CapabilityToken<>(){});
|
||||||
public final static Capability<IModifierCapability> MODIFIER_CAPABILITY = null;
|
|
||||||
|
|
||||||
// Allows for the capability to persist after death.
|
// Allows for the capability to persist after death.
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.command;
|
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
|
||||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
|
||||||
import net.minecraft.commands.Commands;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import net.minecraftforge.fmllegacy.network.PacketDistributor;
|
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
|
||||||
import nl.requios.effortlessbuilding.network.ModifierSettingsMessage;
|
|
||||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
|
||||||
|
|
||||||
public class CommandReach {
|
|
||||||
|
|
||||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
|
|
||||||
dispatcher.register(Commands.literal("reach").then(Commands.literal("set").then(Commands.argument("level", IntegerArgumentType.integer(0, 3)).executes((context) -> {
|
|
||||||
return setReachLevel(context.getSource().getPlayerOrException(), IntegerArgumentType.getInteger(context, "level"));
|
|
||||||
}))).then(Commands.literal("get").executes((context -> {
|
|
||||||
return getReachLevel(context.getSource().getPlayerOrException());
|
|
||||||
}))));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int setReachLevel(ServerPlayer player, int level) {
|
|
||||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
|
||||||
modifierSettings.setReachUpgrade(level);
|
|
||||||
ModifierSettingsManager.setModifierSettings(player, modifierSettings);
|
|
||||||
//Send to client
|
|
||||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), new ModifierSettingsMessage(modifierSettings));
|
|
||||||
|
|
||||||
player.sendMessage(new TextComponent("Reach level of " + player.getName().getString() + " set to " + modifierSettings.getReachUpgrade()), player.getUUID());
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int getReachLevel(ServerPlayer player) {
|
|
||||||
int reachUpgrade = ModifierSettingsManager.getModifierSettings(player).getReachUpgrade();
|
|
||||||
EffortlessBuilding.log(player, "Current reach: level " + reachUpgrade);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -12,14 +12,11 @@ import net.minecraft.client.gui.components.ObjectSelectionList;
|
|||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
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 net.minecraftforge.fmlclient.gui.widget.ExtendedButton;
|
import net.minecraftforge.client.gui.widget.ExtendedButton;
|
||||||
import net.minecraftforge.fmlclient.gui.widget.Slider;
|
import net.minecraftforge.client.gui.widget.ForgeSlider;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
|
||||||
|
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
@@ -34,7 +31,7 @@ public class PlayerSettingsGui extends Screen {
|
|||||||
private Button closeButton;
|
private Button closeButton;
|
||||||
|
|
||||||
public PlayerSettingsGui() {
|
public PlayerSettingsGui() {
|
||||||
super(new TranslatableComponent("effortlessbuilding.screen.player_settings"));
|
super(Component.translatable("effortlessbuilding.screen.player_settings"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -55,12 +52,10 @@ public class PlayerSettingsGui extends Screen {
|
|||||||
addRenderableOnly(shaderTypeButton);
|
addRenderableOnly(shaderTypeButton);
|
||||||
|
|
||||||
yy += 50;
|
yy += 50;
|
||||||
Slider slider = new Slider(right - 200, yy, 200, 20, TextComponent.EMPTY, TextComponent.EMPTY, 0.5, 2.0, 1.0, true, true, (button) -> {
|
ForgeSlider slider = new ForgeSlider(right - 200, yy, 200, 20, Component.empty(), Component.empty(), 0.5, 2.0, 1.0, true);
|
||||||
|
|
||||||
});
|
|
||||||
addRenderableOnly(slider);
|
addRenderableOnly(slider);
|
||||||
|
|
||||||
closeButton = new ExtendedButton(left + 50, bottom - 20, 180, 20, new TextComponent("Done"), (button) -> this.minecraft.player.closeContainer());
|
closeButton = new ExtendedButton(left + 50, bottom - 20, 180, 20, Component.literal("Done"), (button) -> this.minecraft.player.closeContainer());
|
||||||
addRenderableOnly(closeButton);
|
addRenderableOnly(closeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +107,7 @@ public class PlayerSettingsGui extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ShaderType(String name) {
|
ShaderType(String name) {
|
||||||
this.name = new TextComponent(name);
|
this.name = Component.literal(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +187,7 @@ public class PlayerSettingsGui extends Screen {
|
|||||||
return right - 6;
|
return right - 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
//From AbstractList, disabled parts
|
//From AbstractSelectionList, disabled parts
|
||||||
@Override
|
@Override
|
||||||
public void render(PoseStack ms, int p_render_1_, int p_render_2_, float p_render_3_) {
|
public void render(PoseStack ms, int p_render_1_, int p_render_2_, float p_render_3_) {
|
||||||
this.renderBackground(ms);
|
this.renderBackground(ms);
|
||||||
@@ -217,7 +212,7 @@ public class PlayerSettingsGui extends Screen {
|
|||||||
this.renderHeader(ms, k, l, tessellator);
|
this.renderHeader(ms, k, l, tessellator);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.renderList(ms, k, l, p_render_1_, p_render_2_, p_render_3_);
|
this.renderList(ms, p_render_1_, p_render_2_, p_render_3_);
|
||||||
RenderSystem.disableDepthTest();
|
RenderSystem.disableDepthTest();
|
||||||
// this.renderHoleBackground(0, this.y0, 255, 255);
|
// this.renderHoleBackground(0, this.y0, 255, 255);
|
||||||
// this.renderHoleBackground(this.y1, this.height, 255, 255);
|
// this.renderHoleBackground(this.y1, this.height, 255, 255);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package nl.requios.effortlessbuilding.gui.buildmode;
|
|||||||
|
|
||||||
import com.mojang.blaze3d.vertex.*;
|
import com.mojang.blaze3d.vertex.*;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.math.Vector4f;
|
||||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
@@ -12,10 +13,11 @@ import net.minecraft.client.KeyMapping;
|
|||||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
|
import net.minecraft.util.RandomSource;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
||||||
@@ -45,13 +47,34 @@ import nl.requios.effortlessbuilding.buildmode.ModeOptions.OptionEnum;
|
|||||||
public class RadialMenu extends Screen {
|
public class RadialMenu extends Screen {
|
||||||
|
|
||||||
public static final RadialMenu instance = new RadialMenu();
|
public static final RadialMenu instance = new RadialMenu();
|
||||||
|
|
||||||
|
private final Vector4f radialButtonColor = new Vector4f(0f, 0f, 0f, .5f);
|
||||||
|
private final Vector4f sideButtonColor = new Vector4f(.5f, .5f, .5f, .5f);
|
||||||
|
private final Vector4f highlightColor = new Vector4f(.6f, .8f, 1f, .6f);
|
||||||
|
private final Vector4f selectedColor = new Vector4f(0f, .5f, 1f, .5f);
|
||||||
|
private final Vector4f highlightSelectedColor = new Vector4f(0.2f, .7f, 1f, .7f);
|
||||||
|
|
||||||
|
private final int whiteTextColor = 0xffffffff;
|
||||||
|
private final int watermarkTextColor = 0x88888888;
|
||||||
|
private final int descriptionTextColor = 0xdd888888;
|
||||||
|
private final int optionTextColor = 0xeeeeeeff;
|
||||||
|
|
||||||
|
private final double ringInnerEdge = 30;
|
||||||
|
private final double ringOuterEdge = 65;
|
||||||
|
private final double categoryLineWidth = 1;
|
||||||
|
private final double textDistance = 75;
|
||||||
|
private final double buttonDistance = 105;
|
||||||
|
private final float fadeSpeed = 0.3f;
|
||||||
|
private final int descriptionHeight = 100;
|
||||||
|
|
||||||
public BuildModeEnum switchTo = null;
|
public BuildModeEnum switchTo = null;
|
||||||
public ActionEnum doAction = null;
|
public ActionEnum doAction = null;
|
||||||
public boolean performedActionUsingMouse;
|
public boolean performedActionUsingMouse;
|
||||||
|
|
||||||
private float visibility;
|
private float visibility;
|
||||||
|
|
||||||
public RadialMenu() {
|
public RadialMenu() {
|
||||||
super(new TranslatableComponent("effortlessbuilding.screen.radial_menu"));
|
super(Component.translatable("effortlessbuilding.screen.radial_menu"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVisible() {
|
public boolean isVisible() {
|
||||||
@@ -81,7 +104,7 @@ public class RadialMenu extends Screen {
|
|||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
ms.translate(0, 0, 200);
|
ms.translate(0, 0, 200);
|
||||||
|
|
||||||
visibility += 0.3f * partialTicks;
|
visibility += fadeSpeed * partialTicks;
|
||||||
if (visibility > 1f) visibility = 1f;
|
if (visibility > 1f) visibility = 1f;
|
||||||
|
|
||||||
final int startColor = (int) (visibility * 98) << 24;
|
final int startColor = (int) (visibility * 98) << 24;
|
||||||
@@ -109,10 +132,6 @@ public class RadialMenu extends Screen {
|
|||||||
final double mouseYCenter = mouseYY - middleY;
|
final double mouseYCenter = mouseYY - middleY;
|
||||||
double mouseRadians = Math.atan2(mouseYCenter, mouseXCenter);
|
double mouseRadians = Math.atan2(mouseYCenter, mouseXCenter);
|
||||||
|
|
||||||
final double ringInnerEdge = 30;
|
|
||||||
final double ringOuterEdge = 65;
|
|
||||||
final double textDistance = 75;
|
|
||||||
final double buttonDistance = 105;
|
|
||||||
final double quarterCircle = Math.PI / 2.0;
|
final double quarterCircle = Math.PI / 2.0;
|
||||||
|
|
||||||
if (mouseRadians < -quarterCircle) {
|
if (mouseRadians < -quarterCircle) {
|
||||||
@@ -147,34 +166,35 @@ public class RadialMenu extends Screen {
|
|||||||
doAction = null;
|
doAction = null;
|
||||||
|
|
||||||
//Draw buildmode backgrounds
|
//Draw buildmode backgrounds
|
||||||
drawBuildModeBackgrounds(currentBuildMode, buffer, middleX, middleY, mouseXCenter, mouseYCenter, mouseRadians, ringInnerEdge, ringOuterEdge, quarterCircle, modes);
|
drawRadialButtonBackgrounds(currentBuildMode, buffer, middleX, middleY, mouseXCenter, mouseYCenter, mouseRadians,
|
||||||
|
quarterCircle, modes);
|
||||||
|
|
||||||
//Draw action backgrounds
|
//Draw action backgrounds
|
||||||
drawActionBackgrounds(buffer, middleX, middleY, mouseXCenter, mouseYCenter, buttons);
|
drawSideButtonBackgrounds(buffer, middleX, middleY, mouseXCenter, mouseYCenter, buttons);
|
||||||
|
|
||||||
tessellator.end();
|
tessellator.end();
|
||||||
RenderSystem.disableBlend();
|
RenderSystem.disableBlend();
|
||||||
RenderSystem.enableTexture();
|
RenderSystem.enableTexture();
|
||||||
|
|
||||||
drawIcons(ms, tessellator, buffer, middleX, middleY, ringInnerEdge, ringOuterEdge, modes, buttons);
|
drawIcons(ms, middleX, middleY, modes, buttons);
|
||||||
|
|
||||||
drawTexts(ms, currentBuildMode, middleX, middleY, textDistance, buttonDistance, modes, buttons, options);
|
drawTexts(ms, currentBuildMode, middleX, middleY, modes, buttons, options);
|
||||||
|
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawBuildModeBackgrounds(BuildModeEnum currentBuildMode, BufferBuilder buffer, double middleX, double middleY, double mouseXCenter, double mouseYCenter, double mouseRadians, double ringInnerEdge, double ringOuterEdge, double quarterCircle, ArrayList<MenuRegion> modes) {
|
private void drawRadialButtonBackgrounds(BuildModeEnum currentBuildMode, BufferBuilder buffer, double middleX, double middleY,
|
||||||
|
double mouseXCenter, double mouseYCenter, double mouseRadians, double quarterCircle, ArrayList<MenuRegion> modes) {
|
||||||
if (!modes.isEmpty()) {
|
if (!modes.isEmpty()) {
|
||||||
final int totalModes = Math.max(3, modes.size());
|
final int totalModes = Math.max(3, modes.size());
|
||||||
int currentMode = 0;
|
final double fragment = Math.PI * 0.005; //gap between buttons in radians at inner edge
|
||||||
final double fragment = Math.PI * 0.005;
|
final double fragment2 = Math.PI * 0.0025; //gap between buttons in radians at outer edge
|
||||||
final double fragment2 = Math.PI * 0.0025;
|
final double radiansPerObject = 2.0 * Math.PI / totalModes;
|
||||||
final double perObject = 2.0 * Math.PI / totalModes;
|
|
||||||
|
|
||||||
for (int i = 0; i < modes.size(); i++) {
|
for (int i = 0; i < modes.size(); i++) {
|
||||||
MenuRegion menuRegion = modes.get(i);
|
MenuRegion menuRegion = modes.get(i);
|
||||||
final double beginRadians = currentMode * perObject - quarterCircle;
|
final double beginRadians = i * radiansPerObject - quarterCircle;
|
||||||
final double endRadians = (currentMode + 1) * perObject - quarterCircle;
|
final double endRadians = (i + 1) * radiansPerObject - quarterCircle;
|
||||||
|
|
||||||
menuRegion.x1 = Math.cos(beginRadians);
|
menuRegion.x1 = Math.cos(beginRadians);
|
||||||
menuRegion.x2 = Math.cos(endRadians);
|
menuRegion.x2 = Math.cos(endRadians);
|
||||||
@@ -191,82 +211,75 @@ public class RadialMenu extends Screen {
|
|||||||
final double y1m2 = Math.sin(beginRadians + fragment2) * ringOuterEdge;
|
final double y1m2 = Math.sin(beginRadians + fragment2) * ringOuterEdge;
|
||||||
final double y2m2 = Math.sin(endRadians - fragment2) * ringOuterEdge;
|
final double y2m2 = Math.sin(endRadians - fragment2) * ringOuterEdge;
|
||||||
|
|
||||||
float r = 0.0f;
|
final boolean isSelected = currentBuildMode.ordinal() == i;
|
||||||
float g = 0.0f;
|
|
||||||
float b = 0.0f;
|
|
||||||
float a = 0.5f;
|
|
||||||
|
|
||||||
//check if current mode
|
|
||||||
int buildMode = currentBuildMode.ordinal();
|
|
||||||
if (buildMode == i) {
|
|
||||||
r = 0f;
|
|
||||||
g = 0.5f;
|
|
||||||
b = 1f;
|
|
||||||
a = 0.5f;
|
|
||||||
//menuRegion.highlighted = true; //draw text
|
|
||||||
}
|
|
||||||
|
|
||||||
//check if mouse is over this region
|
|
||||||
final boolean isMouseInQuad = inTriangle(x1m1, y1m1, x2m2, y2m2, x2m1, y2m1, mouseXCenter, mouseYCenter)
|
final boolean isMouseInQuad = inTriangle(x1m1, y1m1, x2m2, y2m2, x2m1, y2m1, mouseXCenter, mouseYCenter)
|
||||||
|| inTriangle(x1m1, y1m1, x1m2, y1m2, x2m2, y2m2, mouseXCenter, mouseYCenter);
|
|| inTriangle(x1m1, y1m1, x1m2, y1m2, x2m2, y2m2, mouseXCenter, mouseYCenter);
|
||||||
|
final boolean isHighlighted = beginRadians <= mouseRadians && mouseRadians <= endRadians && isMouseInQuad;
|
||||||
|
|
||||||
if (beginRadians <= mouseRadians && mouseRadians <= endRadians && isMouseInQuad) {
|
Vector4f color = radialButtonColor;
|
||||||
r = 0.6f;
|
if (isSelected) color = selectedColor;
|
||||||
g = 0.8f;
|
if (isHighlighted) color = highlightColor;
|
||||||
b = 1f;
|
if (isSelected && isHighlighted) color = highlightSelectedColor;
|
||||||
a = 0.6f;
|
|
||||||
|
if (isHighlighted) {
|
||||||
menuRegion.highlighted = true;
|
menuRegion.highlighted = true;
|
||||||
switchTo = menuRegion.mode;
|
switchTo = menuRegion.mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.vertex(middleX + x1m1, middleY + y1m1, getBlitOffset()).color(r, g, b, a).endVertex();
|
buffer.vertex(middleX + x1m1, middleY + y1m1, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
buffer.vertex(middleX + x2m1, middleY + y2m1, getBlitOffset()).color(r, g, b, a).endVertex();
|
buffer.vertex(middleX + x2m1, middleY + y2m1, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
buffer.vertex(middleX + x2m2, middleY + y2m2, getBlitOffset()).color(r, g, b, a).endVertex();
|
buffer.vertex(middleX + x2m2, middleY + y2m2, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
buffer.vertex(middleX + x1m2, middleY + y1m2, getBlitOffset()).color(r, g, b, a).endVertex();
|
buffer.vertex(middleX + x1m2, middleY + y1m2, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
|
|
||||||
currentMode++;
|
//Category line
|
||||||
|
color = menuRegion.mode.category.color;
|
||||||
|
final double categoryLineOuterEdge = ringInnerEdge + categoryLineWidth;
|
||||||
|
|
||||||
|
final double x1m3 = Math.cos(beginRadians + fragment) * categoryLineOuterEdge;
|
||||||
|
final double x2m3 = Math.cos(endRadians - fragment) * categoryLineOuterEdge;
|
||||||
|
final double y1m3 = Math.sin(beginRadians + fragment) * categoryLineOuterEdge;
|
||||||
|
final double y2m3 = Math.sin(endRadians - fragment) * categoryLineOuterEdge;
|
||||||
|
|
||||||
|
buffer.vertex(middleX + x1m1, middleY + y1m1, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
|
buffer.vertex(middleX + x2m1, middleY + y2m1, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
|
buffer.vertex(middleX + x2m3, middleY + y2m3, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
|
buffer.vertex(middleX + x1m3, middleY + y1m3, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawActionBackgrounds(BufferBuilder buffer, double middleX, double middleY, double mouseXCenter, double mouseYCenter, ArrayList<MenuButton> buttons) {
|
private void drawSideButtonBackgrounds(BufferBuilder buffer, double middleX, double middleY, double mouseXCenter, double mouseYCenter, ArrayList<MenuButton> buttons) {
|
||||||
for (final MenuButton btn : buttons) {
|
for (final MenuButton btn : buttons) {
|
||||||
float r = 0.5f;
|
|
||||||
float g = 0.5f;
|
|
||||||
float b = 0.5f;
|
|
||||||
float a = 0.5f;
|
|
||||||
|
|
||||||
//highlight when active option
|
final boolean isSelected =
|
||||||
if (btn.action == getBuildSpeed() ||
|
btn.action == getBuildSpeed() ||
|
||||||
btn.action == getFill() ||
|
btn.action == getFill() ||
|
||||||
btn.action == getCubeFill() ||
|
btn.action == getCubeFill() ||
|
||||||
btn.action == getRaisedEdge() ||
|
btn.action == getRaisedEdge() ||
|
||||||
btn.action == getLineThickness() ||
|
btn.action == getLineThickness() ||
|
||||||
btn.action == getCircleStart()) {
|
btn.action == getCircleStart();
|
||||||
r = 0.0f;
|
|
||||||
g = 0.5f;
|
|
||||||
b = 1f;
|
|
||||||
a = 0.6f;
|
|
||||||
}
|
|
||||||
|
|
||||||
//highlight when mouse over
|
final boolean isHighlighted = btn.x1 <= mouseXCenter && btn.x2 >= mouseXCenter && btn.y1 <= mouseYCenter && btn.y2 >= mouseYCenter;
|
||||||
if (btn.x1 <= mouseXCenter && btn.x2 >= mouseXCenter && btn.y1 <= mouseYCenter && btn.y2 >= mouseYCenter) {
|
|
||||||
r = 0.6f;
|
Vector4f color = sideButtonColor;
|
||||||
g = 0.8f;
|
if (isSelected) color = selectedColor;
|
||||||
b = 1f;
|
if (isHighlighted) color = highlightColor;
|
||||||
a = 0.6f;
|
if (isSelected && isHighlighted) color = highlightSelectedColor;
|
||||||
|
|
||||||
|
if (isHighlighted) {
|
||||||
btn.highlighted = true;
|
btn.highlighted = true;
|
||||||
doAction = btn.action;
|
doAction = btn.action;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.vertex(middleX + btn.x1, middleY + btn.y1, getBlitOffset()).color(r, g, b, a).endVertex();
|
buffer.vertex(middleX + btn.x1, middleY + btn.y1, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
buffer.vertex(middleX + btn.x1, middleY + btn.y2, getBlitOffset()).color(r, g, b, a).endVertex();
|
buffer.vertex(middleX + btn.x1, middleY + btn.y2, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
buffer.vertex(middleX + btn.x2, middleY + btn.y2, getBlitOffset()).color(r, g, b, a).endVertex();
|
buffer.vertex(middleX + btn.x2, middleY + btn.y2, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
buffer.vertex(middleX + btn.x2, middleY + btn.y1, getBlitOffset()).color(r, g, b, a).endVertex();
|
buffer.vertex(middleX + btn.x2, middleY + btn.y1, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawIcons(PoseStack ms, Tesselator tessellator, BufferBuilder buffer, double middleX, double middleY, double ringInnerEdge, double ringOuterEdge, ArrayList<MenuRegion> modes, ArrayList<MenuButton> buttons) {
|
private void drawIcons(PoseStack ms, double middleX, double middleY,
|
||||||
|
ArrayList<MenuRegion> modes, ArrayList<MenuButton> buttons) {
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
RenderSystem.enableTexture();
|
RenderSystem.enableTexture();
|
||||||
RenderSystem.setShader(GameRenderer::getPositionColorTexShader);
|
RenderSystem.setShader(GameRenderer::getPositionColorTexShader);
|
||||||
@@ -275,10 +288,10 @@ public class RadialMenu extends Screen {
|
|||||||
//Draw buildmode icons
|
//Draw buildmode icons
|
||||||
for (final MenuRegion menuRegion : modes) {
|
for (final MenuRegion menuRegion : modes) {
|
||||||
|
|
||||||
final double x = (menuRegion.x1 + menuRegion.x2) * 0.5 * (ringOuterEdge * 0.6 + 0.4 * 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.6 + 0.4 * ringInnerEdge);
|
final double y = (menuRegion.y1 + menuRegion.y2) * 0.5 * (ringOuterEdge * 0.55 + 0.45 * ringInnerEdge);
|
||||||
|
|
||||||
RenderSystem.setShaderTexture(0, new ResourceLocation(EffortlessBuilding.MODID, "textures/icons/" + menuRegion.mode.name().toLowerCase() + ".png"));
|
RenderSystem.setShaderTexture(0, new ResourceLocation(EffortlessBuilding.MODID, "textures/icons/" + menuRegion.mode.getName() + ".png"));
|
||||||
blit(ms, (int) (middleX + x - 8), (int) (middleY + y - 8), 16, 16, 0, 0, 18, 18, 18, 18);
|
blit(ms, (int) (middleX + x - 8), (int) (middleY + y - 8), 16, 16, 0, 0, 18, 18, 18, 18);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,17 +308,17 @@ public class RadialMenu extends Screen {
|
|||||||
ms.popPose();
|
ms.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawTexts(PoseStack ms, BuildModeEnum currentBuildMode, double middleX, double middleY, double textDistance, double buttonDistance, ArrayList<MenuRegion> modes, ArrayList<MenuButton> buttons, OptionEnum[] options) {
|
private void drawTexts(PoseStack ms, BuildModeEnum currentBuildMode, double middleX, double middleY, ArrayList<MenuRegion> modes, ArrayList<MenuButton> buttons, OptionEnum[] options) {
|
||||||
//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];
|
||||||
font.drawShadow(ms, I18n.get(option.name), (int) (middleX + buttonDistance - 9), (int) middleY - 37 + i * 39, 0xeeeeeeff);
|
font.drawShadow(ms, I18n.get(option.name), (int) (middleX + buttonDistance - 9), (int) middleY - 37 + i * 39, optionTextColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
String credits = "Effortless Building";
|
String credits = "Effortless Building";
|
||||||
font.drawShadow(ms, credits, width - font.width(credits) - 4, height - 10, 0x88888888);
|
font.drawShadow(ms, credits, width - font.width(credits) - 4, height - 10, watermarkTextColor);
|
||||||
|
|
||||||
//Draw buildmode text
|
//Draw buildmode text
|
||||||
for (final MenuRegion menuRegion : modes) {
|
for (final MenuRegion menuRegion : modes) {
|
||||||
@@ -315,8 +328,8 @@ public class RadialMenu extends Screen {
|
|||||||
final double y = (menuRegion.y1 + menuRegion.y2) * 0.5;
|
final double y = (menuRegion.y1 + menuRegion.y2) * 0.5;
|
||||||
|
|
||||||
int fixed_x = (int) (x * textDistance);
|
int fixed_x = (int) (x * textDistance);
|
||||||
final int fixed_y = (int) (y * textDistance) - font.lineHeight / 2;
|
int fixed_y = (int) (y * textDistance) - font.lineHeight / 2;
|
||||||
final String text = I18n.get(menuRegion.mode.name);
|
String text = I18n.get(menuRegion.mode.getNameKey());
|
||||||
|
|
||||||
if (x <= -0.2) {
|
if (x <= -0.2) {
|
||||||
fixed_x -= font.width(text);
|
fixed_x -= font.width(text);
|
||||||
@@ -324,7 +337,11 @@ public class RadialMenu extends Screen {
|
|||||||
fixed_x -= font.width(text) / 2;
|
fixed_x -= font.width(text) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
font.drawShadow(ms, text, (int) middleX + fixed_x, (int) middleY + fixed_y, 0xffffffff);
|
font.drawShadow(ms, text, (int) middleX + fixed_x, (int) middleY + fixed_y, whiteTextColor);
|
||||||
|
|
||||||
|
//Draw description
|
||||||
|
text = I18n.get(menuRegion.mode.getDescriptionKey());
|
||||||
|
font.drawShadow(ms, text, (int) middleX - font.width(text) / 2f, (int) middleY + descriptionHeight, descriptionTextColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,28 +359,28 @@ public class RadialMenu extends Screen {
|
|||||||
if (button.textSide == Direction.WEST) {
|
if (button.textSide == Direction.WEST) {
|
||||||
|
|
||||||
font.draw(ms, text, (int) (middleX + button.x1 - 8) - font.width(text),
|
font.draw(ms, text, (int) (middleX + button.x1 - 8) - font.width(text),
|
||||||
(int) (middleY + button.y1 + 6), 0xffffffff);
|
(int) (middleY + button.y1 + 6), whiteTextColor);
|
||||||
|
|
||||||
} else if (button.textSide == Direction.EAST) {
|
} else if (button.textSide == Direction.EAST) {
|
||||||
|
|
||||||
font.draw(ms, text, (int) (middleX + button.x2 + 8),
|
font.draw(ms, text, (int) (middleX + button.x2 + 8),
|
||||||
(int) (middleY + button.y1 + 6), 0xffffffff);
|
(int) (middleY + button.y1 + 6), whiteTextColor);
|
||||||
|
|
||||||
} else if (button.textSide == Direction.UP || button.textSide == Direction.NORTH) {
|
} else if (button.textSide == Direction.UP || button.textSide == Direction.NORTH) {
|
||||||
|
|
||||||
font.draw(ms, keybindFormatted, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(keybindFormatted) * 0.5),
|
font.draw(ms, keybindFormatted, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(keybindFormatted) * 0.5),
|
||||||
(int) (middleY + button.y1 - 26), 0xffffffff);
|
(int) (middleY + button.y1 - 26), whiteTextColor);
|
||||||
|
|
||||||
font.draw(ms, text, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(text) * 0.5),
|
font.draw(ms, text, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(text) * 0.5),
|
||||||
(int) (middleY + button.y1 - 14), 0xffffffff);
|
(int) (middleY + button.y1 - 14), whiteTextColor);
|
||||||
|
|
||||||
} else if (button.textSide == Direction.DOWN || button.textSide == Direction.SOUTH) {
|
} else if (button.textSide == Direction.DOWN || button.textSide == Direction.SOUTH) {
|
||||||
|
|
||||||
font.draw(ms, text, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(text) * 0.5),
|
font.draw(ms, text, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(text) * 0.5),
|
||||||
(int) (middleY + button.y1 + 26), 0xffffffff);
|
(int) (middleY + button.y1 + 26), whiteTextColor);
|
||||||
|
|
||||||
font.draw(ms, keybindFormatted, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(keybindFormatted) * 0.5),
|
font.draw(ms, keybindFormatted, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(keybindFormatted) * 0.5),
|
||||||
(int) (middleY + button.y1 + 38), 0xffffffff);
|
(int) (middleY + button.y1 + 38), whiteTextColor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,7 +459,7 @@ public class RadialMenu extends Screen {
|
|||||||
ModeSettingsManager.setModeSettings(player, modeSettings);
|
ModeSettingsManager.setModeSettings(player, modeSettings);
|
||||||
PacketHandler.INSTANCE.sendToServer(new ModeSettingsMessage(modeSettings));
|
PacketHandler.INSTANCE.sendToServer(new ModeSettingsMessage(modeSettings));
|
||||||
|
|
||||||
EffortlessBuilding.log(player, I18n.get(modeSettings.getBuildMode().name), true);
|
EffortlessBuilding.log(player, I18n.get(modeSettings.getBuildMode().getNameKey()), true);
|
||||||
|
|
||||||
if (fromMouseClick) performedActionUsingMouse = true;
|
if (fromMouseClick) performedActionUsingMouse = true;
|
||||||
}
|
}
|
||||||
@@ -462,7 +479,8 @@ public class RadialMenu extends Screen {
|
|||||||
public static void playRadialMenuSound() {
|
public static void playRadialMenuSound() {
|
||||||
final float volume = 0.1f;
|
final float volume = 0.1f;
|
||||||
if (volume >= 0.0001f) {
|
if (volume >= 0.0001f) {
|
||||||
SimpleSoundInstance sound = new SimpleSoundInstance(SoundEvents.UI_BUTTON_CLICK, SoundSource.MASTER, volume, 1.0f, Minecraft.getInstance().player.blockPosition());
|
SimpleSoundInstance sound = new SimpleSoundInstance(SoundEvents.UI_BUTTON_CLICK, SoundSource.MASTER, volume,
|
||||||
|
1.0f, RandomSource.create(), Minecraft.getInstance().player.blockPosition());
|
||||||
Minecraft.getInstance().getSoundManager().play(sound);
|
Minecraft.getInstance().getSoundManager().play(sound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ package nl.requios.effortlessbuilding.gui.buildmodifier;
|
|||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.gui.components.Widget;
|
import net.minecraft.client.gui.components.Widget;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.client.gui.components.AbstractWidget;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
@@ -50,23 +49,23 @@ public class ArraySettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
y = top + 20;
|
y = top + 20;
|
||||||
textArrayOffsetX = new GuiNumberField(font, renderables, left + 70, y, 50, 18);
|
textArrayOffsetX = new GuiNumberField(font, renderables, left + 70, y, 50, 18);
|
||||||
textArrayOffsetX.setNumber(0);
|
textArrayOffsetX.setNumber(0);
|
||||||
textArrayOffsetX.setTooltip(new TextComponent("How much each copy is shifted."));
|
textArrayOffsetX.setTooltip(Component.literal("How much each copy is shifted."));
|
||||||
arrayNumberFieldList.add(textArrayOffsetX);
|
arrayNumberFieldList.add(textArrayOffsetX);
|
||||||
|
|
||||||
textArrayOffsetY = new GuiNumberField(font, renderables, left + 140, y, 50, 18);
|
textArrayOffsetY = new GuiNumberField(font, renderables, left + 140, y, 50, 18);
|
||||||
textArrayOffsetY.setNumber(0);
|
textArrayOffsetY.setNumber(0);
|
||||||
textArrayOffsetY.setTooltip(new TextComponent("How much each copy is shifted."));
|
textArrayOffsetY.setTooltip(Component.literal("How much each copy is shifted."));
|
||||||
arrayNumberFieldList.add(textArrayOffsetY);
|
arrayNumberFieldList.add(textArrayOffsetY);
|
||||||
|
|
||||||
textArrayOffsetZ = new GuiNumberField(font, renderables, left + 210, y, 50, 18);
|
textArrayOffsetZ = new GuiNumberField(font, renderables, left + 210, y, 50, 18);
|
||||||
textArrayOffsetZ.setNumber(0);
|
textArrayOffsetZ.setNumber(0);
|
||||||
textArrayOffsetZ.setTooltip(new TextComponent("How much each copy is shifted."));
|
textArrayOffsetZ.setTooltip(Component.literal("How much each copy is shifted."));
|
||||||
arrayNumberFieldList.add(textArrayOffsetZ);
|
arrayNumberFieldList.add(textArrayOffsetZ);
|
||||||
|
|
||||||
y = top + 50;
|
y = top + 50;
|
||||||
textArrayCount = new GuiNumberField(font, renderables, left + 55, y, 50, 18);
|
textArrayCount = new GuiNumberField(font, renderables, left + 55, y, 50, 18);
|
||||||
textArrayCount.setNumber(5);
|
textArrayCount.setNumber(5);
|
||||||
textArrayCount.setTooltip(new TextComponent("How many copies should be made."));
|
textArrayCount.setTooltip(Component.literal("How many copies should be made."));
|
||||||
arrayNumberFieldList.add(textArrayCount);
|
arrayNumberFieldList.add(textArrayCount);
|
||||||
|
|
||||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(mc.player);
|
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(mc.player);
|
||||||
|
|||||||
@@ -3,11 +3,10 @@ package nl.requios.effortlessbuilding.gui.buildmodifier;
|
|||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.gui.components.Widget;
|
import net.minecraft.client.gui.components.Widget;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.client.gui.components.AbstractWidget;
|
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
@@ -58,17 +57,17 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
textMirrorPosX = new GuiNumberField(font, renderables, left + 58, y, 62, 18);
|
textMirrorPosX = new GuiNumberField(font, renderables, left + 58, y, 62, 18);
|
||||||
textMirrorPosX.setNumber(0);
|
textMirrorPosX.setNumber(0);
|
||||||
textMirrorPosX.setTooltip(
|
textMirrorPosX.setTooltip(
|
||||||
Arrays.asList(new TextComponent("The position of the mirror."), new TextComponent("For odd numbered builds add 0.5.").withStyle(ChatFormatting.GRAY)));
|
Arrays.asList(Component.literal("The position of the mirror."), Component.literal("For odd numbered builds add 0.5.").withStyle(ChatFormatting.GRAY)));
|
||||||
mirrorNumberFieldList.add(textMirrorPosX);
|
mirrorNumberFieldList.add(textMirrorPosX);
|
||||||
|
|
||||||
textMirrorPosY = new GuiNumberField(font, renderables, left + 138, y, 62, 18);
|
textMirrorPosY = new GuiNumberField(font, renderables, left + 138, y, 62, 18);
|
||||||
textMirrorPosY.setNumber(64);
|
textMirrorPosY.setNumber(64);
|
||||||
textMirrorPosY.setTooltip(Arrays.asList(new TextComponent("The position of the mirror."), new TextComponent("For odd numbered builds add 0.5.").withStyle(ChatFormatting.GRAY)));
|
textMirrorPosY.setTooltip(Arrays.asList(Component.literal("The position of the mirror."), Component.literal("For odd numbered builds add 0.5.").withStyle(ChatFormatting.GRAY)));
|
||||||
mirrorNumberFieldList.add(textMirrorPosY);
|
mirrorNumberFieldList.add(textMirrorPosY);
|
||||||
|
|
||||||
textMirrorPosZ = new GuiNumberField(font, renderables, left + 218, y, 62, 18);
|
textMirrorPosZ = new GuiNumberField(font, renderables, left + 218, y, 62, 18);
|
||||||
textMirrorPosZ.setNumber(0);
|
textMirrorPosZ.setNumber(0);
|
||||||
textMirrorPosZ.setTooltip(Arrays.asList(new TextComponent("The position of the mirror."), new TextComponent("For odd numbered builds add 0.5.").withStyle(ChatFormatting.GRAY)));
|
textMirrorPosZ.setTooltip(Arrays.asList(Component.literal("The position of the mirror."), Component.literal("For odd numbered builds add 0.5.").withStyle(ChatFormatting.GRAY)));
|
||||||
mirrorNumberFieldList.add(textMirrorPosZ);
|
mirrorNumberFieldList.add(textMirrorPosZ);
|
||||||
|
|
||||||
y = top + 50;
|
y = top + 50;
|
||||||
@@ -85,9 +84,9 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
textMirrorRadius = new GuiNumberField(font, renderables, left + 218, y, 62, 18);
|
textMirrorRadius = new GuiNumberField(font, renderables, left + 218, y, 62, 18);
|
||||||
textMirrorRadius.setNumber(50);
|
textMirrorRadius.setNumber(50);
|
||||||
//TODO change to diameter (remove /2)
|
//TODO change to diameter (remove /2)
|
||||||
textMirrorRadius.setTooltip(Arrays.asList(new TextComponent("How far the mirror reaches in any direction."),
|
textMirrorRadius.setTooltip(Arrays.asList(Component.literal("How far the mirror reaches in any direction."),
|
||||||
new TextComponent("Max: ").withStyle(ChatFormatting.GRAY).append(new TextComponent(String.valueOf(ReachHelper.getMaxReach(mc.player) / 2)).withStyle(ChatFormatting.GOLD)),
|
Component.literal("Max: ").withStyle(ChatFormatting.GRAY).append(Component.literal(String.valueOf(ReachHelper.getMaxReach(mc.player) / 2)).withStyle(ChatFormatting.GOLD)),
|
||||||
new TextComponent("Upgradeable in survival with reach upgrades.").withStyle(ChatFormatting.GRAY)));
|
Component.literal("Upgradeable in survival with reach upgrades.").withStyle(ChatFormatting.GRAY)));
|
||||||
mirrorNumberFieldList.add(textMirrorRadius);
|
mirrorNumberFieldList.add(textMirrorRadius);
|
||||||
|
|
||||||
y = top + 72;
|
y = top + 72;
|
||||||
@@ -97,41 +96,41 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
textMirrorPosY.setNumber(pos.y);
|
textMirrorPosY.setNumber(pos.y);
|
||||||
textMirrorPosZ.setNumber(pos.z);
|
textMirrorPosZ.setNumber(pos.z);
|
||||||
});
|
});
|
||||||
buttonCurrentPosition.setTooltip(new TextComponent("Set mirror position to current player position"));
|
buttonCurrentPosition.setTooltip(Component.literal("Set mirror position to current player position"));
|
||||||
mirrorIconButtonList.add(buttonCurrentPosition);
|
mirrorIconButtonList.add(buttonCurrentPosition);
|
||||||
|
|
||||||
buttonToggleOdd = new GuiIconButton(left + 35, y, 0, 20, BUILDING_ICONS, button -> {
|
buttonToggleOdd = new GuiIconButton(left + 35, y, 0, 20, BUILDING_ICONS, button -> {
|
||||||
toggleOdd = !toggleOdd;
|
toggleOdd = !toggleOdd;
|
||||||
buttonToggleOdd.setUseAlternateIcon(toggleOdd);
|
buttonToggleOdd.setUseAlternateIcon(toggleOdd);
|
||||||
if (toggleOdd) {
|
if (toggleOdd) {
|
||||||
buttonToggleOdd.setTooltip(Arrays.asList(new TextComponent("Set mirror position to corner of block"), new TextComponent("for even numbered builds")));
|
buttonToggleOdd.setTooltip(Arrays.asList(Component.literal("Set mirror position to corner of block"), Component.literal("for even numbered builds")));
|
||||||
textMirrorPosX.setNumber(textMirrorPosX.getNumber() + 0.5);
|
textMirrorPosX.setNumber(textMirrorPosX.getNumber() + 0.5);
|
||||||
textMirrorPosY.setNumber(textMirrorPosY.getNumber() + 0.5);
|
textMirrorPosY.setNumber(textMirrorPosY.getNumber() + 0.5);
|
||||||
textMirrorPosZ.setNumber(textMirrorPosZ.getNumber() + 0.5);
|
textMirrorPosZ.setNumber(textMirrorPosZ.getNumber() + 0.5);
|
||||||
} else {
|
} else {
|
||||||
buttonToggleOdd.setTooltip(Arrays.asList(new TextComponent("Set mirror position to middle of block"), new TextComponent("for odd numbered builds")));
|
buttonToggleOdd.setTooltip(Arrays.asList(Component.literal("Set mirror position to middle of block"), Component.literal("for odd numbered builds")));
|
||||||
textMirrorPosX.setNumber(Math.floor(textMirrorPosX.getNumber()));
|
textMirrorPosX.setNumber(Math.floor(textMirrorPosX.getNumber()));
|
||||||
textMirrorPosY.setNumber(Math.floor(textMirrorPosY.getNumber()));
|
textMirrorPosY.setNumber(Math.floor(textMirrorPosY.getNumber()));
|
||||||
textMirrorPosZ.setNumber(Math.floor(textMirrorPosZ.getNumber()));
|
textMirrorPosZ.setNumber(Math.floor(textMirrorPosZ.getNumber()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
buttonToggleOdd.setTooltip(Arrays.asList(new TextComponent("Set mirror position to middle of block"), new TextComponent("for odd numbered builds")));
|
buttonToggleOdd.setTooltip(Arrays.asList(Component.literal("Set mirror position to middle of block"), Component.literal("for odd numbered builds")));
|
||||||
mirrorIconButtonList.add(buttonToggleOdd);
|
mirrorIconButtonList.add(buttonToggleOdd);
|
||||||
|
|
||||||
buttonDrawLines = new GuiIconButton(left + 65, y, 0, 40, BUILDING_ICONS, button -> {
|
buttonDrawLines = new GuiIconButton(left + 65, y, 0, 40, BUILDING_ICONS, button -> {
|
||||||
drawLines = !drawLines;
|
drawLines = !drawLines;
|
||||||
buttonDrawLines.setUseAlternateIcon(drawLines);
|
buttonDrawLines.setUseAlternateIcon(drawLines);
|
||||||
buttonDrawLines.setTooltip(new TextComponent(drawLines ? "Hide lines" : "Show lines"));
|
buttonDrawLines.setTooltip(Component.literal(drawLines ? "Hide lines" : "Show lines"));
|
||||||
});
|
});
|
||||||
buttonDrawLines.setTooltip(new TextComponent("Show lines"));
|
buttonDrawLines.setTooltip(Component.literal("Show lines"));
|
||||||
mirrorIconButtonList.add(buttonDrawLines);
|
mirrorIconButtonList.add(buttonDrawLines);
|
||||||
|
|
||||||
buttonDrawPlanes = new GuiIconButton(left + 95, y, 0, 60, BUILDING_ICONS, button -> {
|
buttonDrawPlanes = new GuiIconButton(left + 95, y, 0, 60, BUILDING_ICONS, button -> {
|
||||||
drawPlanes = !drawPlanes;
|
drawPlanes = !drawPlanes;
|
||||||
buttonDrawPlanes.setUseAlternateIcon(drawPlanes);
|
buttonDrawPlanes.setUseAlternateIcon(drawPlanes);
|
||||||
buttonDrawPlanes.setTooltip(new TextComponent(drawPlanes ? "Hide area" : "Show area"));
|
buttonDrawPlanes.setTooltip(Component.literal(drawPlanes ? "Hide area" : "Show area"));
|
||||||
});
|
});
|
||||||
buttonDrawPlanes.setTooltip(new TextComponent("Show area"));
|
buttonDrawPlanes.setTooltip(Component.literal("Show area"));
|
||||||
mirrorIconButtonList.add(buttonDrawPlanes);
|
mirrorIconButtonList.add(buttonDrawPlanes);
|
||||||
|
|
||||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(mc.player);
|
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(mc.player);
|
||||||
@@ -149,14 +148,14 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
drawPlanes = m.drawPlanes;
|
drawPlanes = m.drawPlanes;
|
||||||
buttonDrawLines.setUseAlternateIcon(drawLines);
|
buttonDrawLines.setUseAlternateIcon(drawLines);
|
||||||
buttonDrawPlanes.setUseAlternateIcon(drawPlanes);
|
buttonDrawPlanes.setUseAlternateIcon(drawPlanes);
|
||||||
buttonDrawLines.setTooltip(new TextComponent(drawLines ? "Hide lines" : "Show lines"));
|
buttonDrawLines.setTooltip(Component.literal(drawLines ? "Hide lines" : "Show lines"));
|
||||||
buttonDrawPlanes.setTooltip(new TextComponent(drawPlanes ? "Hide area" : "Show area"));
|
buttonDrawPlanes.setTooltip(Component.literal(drawPlanes ? "Hide area" : "Show area"));
|
||||||
if (textMirrorPosX.getNumber() == Math.floor(textMirrorPosX.getNumber())) {
|
if (textMirrorPosX.getNumber() == Math.floor(textMirrorPosX.getNumber())) {
|
||||||
toggleOdd = false;
|
toggleOdd = false;
|
||||||
buttonToggleOdd.setTooltip(Arrays.asList(new TextComponent("Set mirror position to middle of block"), new TextComponent("for odd numbered builds")));
|
buttonToggleOdd.setTooltip(Arrays.asList(Component.literal("Set mirror position to middle of block"), Component.literal("for odd numbered builds")));
|
||||||
} else {
|
} else {
|
||||||
toggleOdd = true;
|
toggleOdd = true;
|
||||||
buttonToggleOdd.setTooltip(Arrays.asList(new TextComponent("Set mirror position to corner of block"), new TextComponent("for even numbered builds")));
|
buttonToggleOdd.setTooltip(Arrays.asList(Component.literal("Set mirror position to corner of block"), Component.literal("for even numbered builds")));
|
||||||
}
|
}
|
||||||
buttonToggleOdd.setUseAlternateIcon(toggleOdd);
|
buttonToggleOdd.setUseAlternateIcon(toggleOdd);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,9 @@ package nl.requios.effortlessbuilding.gui.buildmodifier;
|
|||||||
|
|
||||||
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.components.AbstractWidget;
|
|
||||||
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.network.chat.TextComponent;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
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.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
@@ -19,9 +17,6 @@ import nl.requios.effortlessbuilding.network.ModifierSettingsMessage;
|
|||||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
import nl.requios.effortlessbuilding.network.PacketHandler;
|
||||||
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public class ModifierSettingsGui extends Screen {
|
public class ModifierSettingsGui extends Screen {
|
||||||
|
|
||||||
@@ -33,7 +28,7 @@ public class ModifierSettingsGui extends Screen {
|
|||||||
private RadialMirrorSettingsGui radialMirrorSettingsGui;
|
private RadialMirrorSettingsGui radialMirrorSettingsGui;
|
||||||
|
|
||||||
public ModifierSettingsGui() {
|
public ModifierSettingsGui() {
|
||||||
super(new TranslatableComponent("effortlessbuilding.screen.modifier_settings"));
|
super(Component.translatable("effortlessbuilding.screen.modifier_settings"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -55,7 +50,7 @@ public class ModifierSettingsGui extends Screen {
|
|||||||
|
|
||||||
//Close button
|
//Close button
|
||||||
int y = height - 26;
|
int y = height - 26;
|
||||||
buttonClose = new Button(width / 2 - 100, y, 200, 20, new TextComponent("Close"), (button) -> {
|
buttonClose = new Button(width / 2 - 100, y, 200, 20, Component.literal("Close"), (button) -> {
|
||||||
Minecraft.getInstance().player.closeContainer();
|
Minecraft.getInstance().player.closeContainer();
|
||||||
});
|
});
|
||||||
addRenderableOnly(buttonClose);
|
addRenderableOnly(buttonClose);
|
||||||
|
|||||||
@@ -3,11 +3,10 @@ package nl.requios.effortlessbuilding.gui.buildmodifier;
|
|||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.gui.components.Widget;
|
import net.minecraft.client.gui.components.Widget;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.client.gui.components.AbstractWidget;
|
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
@@ -58,31 +57,31 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
textRadialMirrorPosX = new GuiNumberField(font, renderables, left + 58, y, 62, 18);
|
textRadialMirrorPosX = new GuiNumberField(font, renderables, left + 58, y, 62, 18);
|
||||||
textRadialMirrorPosX.setNumber(0);
|
textRadialMirrorPosX.setNumber(0);
|
||||||
textRadialMirrorPosX.setTooltip(
|
textRadialMirrorPosX.setTooltip(
|
||||||
Arrays.asList(new TextComponent("The position of the radial mirror."), new TextComponent("For odd numbered builds add 0.5.").withStyle(ChatFormatting.GRAY)));
|
Arrays.asList(Component.literal("The position of the radial mirror."), Component.literal("For odd numbered builds add 0.5.").withStyle(ChatFormatting.GRAY)));
|
||||||
radialMirrorNumberFieldList.add(textRadialMirrorPosX);
|
radialMirrorNumberFieldList.add(textRadialMirrorPosX);
|
||||||
|
|
||||||
textRadialMirrorPosY = new GuiNumberField(font, renderables, left + 138, y, 62, 18);
|
textRadialMirrorPosY = new GuiNumberField(font, renderables, left + 138, y, 62, 18);
|
||||||
textRadialMirrorPosY.setNumber(64);
|
textRadialMirrorPosY.setNumber(64);
|
||||||
textRadialMirrorPosY.setTooltip(Arrays.asList(new TextComponent("The position of the radial mirror."), new TextComponent("For odd numbered builds add 0.5.").withStyle(ChatFormatting.GRAY)));
|
textRadialMirrorPosY.setTooltip(Arrays.asList(Component.literal("The position of the radial mirror."), Component.literal("For odd numbered builds add 0.5.").withStyle(ChatFormatting.GRAY)));
|
||||||
radialMirrorNumberFieldList.add(textRadialMirrorPosY);
|
radialMirrorNumberFieldList.add(textRadialMirrorPosY);
|
||||||
|
|
||||||
textRadialMirrorPosZ = new GuiNumberField(font, renderables, left + 218, y, 62, 18);
|
textRadialMirrorPosZ = new GuiNumberField(font, renderables, left + 218, y, 62, 18);
|
||||||
textRadialMirrorPosZ.setNumber(0);
|
textRadialMirrorPosZ.setNumber(0);
|
||||||
textRadialMirrorPosZ.setTooltip(Arrays.asList(new TextComponent("The position of the radial mirror."), new TextComponent("For odd numbered builds add 0.5.").withStyle(ChatFormatting.GRAY)));
|
textRadialMirrorPosZ.setTooltip(Arrays.asList(Component.literal("The position of the radial mirror."), Component.literal("For odd numbered builds add 0.5.").withStyle(ChatFormatting.GRAY)));
|
||||||
radialMirrorNumberFieldList.add(textRadialMirrorPosZ);
|
radialMirrorNumberFieldList.add(textRadialMirrorPosZ);
|
||||||
|
|
||||||
y = top + 47;
|
y = top + 47;
|
||||||
textRadialMirrorSlices = new GuiNumberField(font, renderables, left + 55, y, 50, 18);
|
textRadialMirrorSlices = new GuiNumberField(font, renderables, left + 55, y, 50, 18);
|
||||||
textRadialMirrorSlices.setNumber(4);
|
textRadialMirrorSlices.setNumber(4);
|
||||||
textRadialMirrorSlices.setTooltip(Arrays.asList(new TextComponent("The number of repeating slices."), new TextComponent("Minimally 2.").withStyle(ChatFormatting.GRAY)));
|
textRadialMirrorSlices.setTooltip(Arrays.asList(Component.literal("The number of repeating slices."), Component.literal("Minimally 2.").withStyle(ChatFormatting.GRAY)));
|
||||||
radialMirrorNumberFieldList.add(textRadialMirrorSlices);
|
radialMirrorNumberFieldList.add(textRadialMirrorSlices);
|
||||||
|
|
||||||
textRadialMirrorRadius = new GuiNumberField(font, renderables, left + 218, y, 62, 18);
|
textRadialMirrorRadius = new GuiNumberField(font, renderables, left + 218, y, 62, 18);
|
||||||
textRadialMirrorRadius.setNumber(50);
|
textRadialMirrorRadius.setNumber(50);
|
||||||
//TODO change to diameter (remove /2)
|
//TODO change to diameter (remove /2)
|
||||||
textRadialMirrorRadius.setTooltip(Arrays.asList(new TextComponent("How far the radial mirror reaches from its center position."),
|
textRadialMirrorRadius.setTooltip(Arrays.asList(Component.literal("How far the radial mirror reaches from its center position."),
|
||||||
new TextComponent("Max: ").withStyle(ChatFormatting.GRAY).append(new TextComponent(String.valueOf(ReachHelper.getMaxReach(mc.player) / 2)).withStyle(ChatFormatting.GOLD)),
|
Component.literal("Max: ").withStyle(ChatFormatting.GRAY).append(Component.literal(String.valueOf(ReachHelper.getMaxReach(mc.player) / 2)).withStyle(ChatFormatting.GOLD)),
|
||||||
new TextComponent("Upgradeable in survival with reach upgrades.").withStyle(ChatFormatting.GRAY)));
|
Component.literal("Upgradeable in survival with reach upgrades.").withStyle(ChatFormatting.GRAY)));
|
||||||
radialMirrorNumberFieldList.add(textRadialMirrorRadius);
|
radialMirrorNumberFieldList.add(textRadialMirrorRadius);
|
||||||
|
|
||||||
y = top + 72;
|
y = top + 72;
|
||||||
@@ -92,41 +91,41 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
textRadialMirrorPosY.setNumber(pos.y);
|
textRadialMirrorPosY.setNumber(pos.y);
|
||||||
textRadialMirrorPosZ.setNumber(pos.z);
|
textRadialMirrorPosZ.setNumber(pos.z);
|
||||||
});
|
});
|
||||||
buttonCurrentPosition.setTooltip(new TextComponent("Set radial mirror position to current player position"));
|
buttonCurrentPosition.setTooltip(Component.literal("Set radial mirror position to current player position"));
|
||||||
radialMirrorIconButtonList.add(buttonCurrentPosition);
|
radialMirrorIconButtonList.add(buttonCurrentPosition);
|
||||||
|
|
||||||
buttonToggleOdd = new GuiIconButton(left + 35, y, 0, 20, BUILDING_ICONS, button -> {
|
buttonToggleOdd = new GuiIconButton(left + 35, y, 0, 20, BUILDING_ICONS, button -> {
|
||||||
toggleOdd = !toggleOdd;
|
toggleOdd = !toggleOdd;
|
||||||
buttonToggleOdd.setUseAlternateIcon(toggleOdd);
|
buttonToggleOdd.setUseAlternateIcon(toggleOdd);
|
||||||
if (toggleOdd) {
|
if (toggleOdd) {
|
||||||
buttonToggleOdd.setTooltip(Arrays.asList(new TextComponent("Set mirror position to corner of block"), new TextComponent("for even numbered builds")));
|
buttonToggleOdd.setTooltip(Arrays.asList(Component.literal("Set mirror position to corner of block"), Component.literal("for even numbered builds")));
|
||||||
textRadialMirrorPosX.setNumber(textRadialMirrorPosX.getNumber() + 0.5);
|
textRadialMirrorPosX.setNumber(textRadialMirrorPosX.getNumber() + 0.5);
|
||||||
textRadialMirrorPosY.setNumber(textRadialMirrorPosY.getNumber() + 0.5);
|
textRadialMirrorPosY.setNumber(textRadialMirrorPosY.getNumber() + 0.5);
|
||||||
textRadialMirrorPosZ.setNumber(textRadialMirrorPosZ.getNumber() + 0.5);
|
textRadialMirrorPosZ.setNumber(textRadialMirrorPosZ.getNumber() + 0.5);
|
||||||
} else {
|
} else {
|
||||||
buttonToggleOdd.setTooltip(Arrays.asList(new TextComponent("Set mirror position to middle of block"), new TextComponent("for odd numbered builds")));
|
buttonToggleOdd.setTooltip(Arrays.asList(Component.literal("Set mirror position to middle of block"), Component.literal("for odd numbered builds")));
|
||||||
textRadialMirrorPosX.setNumber(Math.floor(textRadialMirrorPosX.getNumber()));
|
textRadialMirrorPosX.setNumber(Math.floor(textRadialMirrorPosX.getNumber()));
|
||||||
textRadialMirrorPosY.setNumber(Math.floor(textRadialMirrorPosY.getNumber()));
|
textRadialMirrorPosY.setNumber(Math.floor(textRadialMirrorPosY.getNumber()));
|
||||||
textRadialMirrorPosZ.setNumber(Math.floor(textRadialMirrorPosZ.getNumber()));
|
textRadialMirrorPosZ.setNumber(Math.floor(textRadialMirrorPosZ.getNumber()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
buttonToggleOdd.setTooltip(Arrays.asList(new TextComponent("Set radial mirror position to middle of block"), new TextComponent("for odd numbered builds")));
|
buttonToggleOdd.setTooltip(Arrays.asList(Component.literal("Set radial mirror position to middle of block"), Component.literal("for odd numbered builds")));
|
||||||
radialMirrorIconButtonList.add(buttonToggleOdd);
|
radialMirrorIconButtonList.add(buttonToggleOdd);
|
||||||
|
|
||||||
buttonDrawLines = new GuiIconButton(left + 65, y, 0, 40, BUILDING_ICONS, button -> {
|
buttonDrawLines = new GuiIconButton(left + 65, y, 0, 40, BUILDING_ICONS, button -> {
|
||||||
drawLines = !drawLines;
|
drawLines = !drawLines;
|
||||||
buttonDrawLines.setUseAlternateIcon(drawLines);
|
buttonDrawLines.setUseAlternateIcon(drawLines);
|
||||||
buttonDrawLines.setTooltip(new TextComponent(drawLines ? "Hide lines" : "Show lines"));
|
buttonDrawLines.setTooltip(Component.literal(drawLines ? "Hide lines" : "Show lines"));
|
||||||
});
|
});
|
||||||
buttonDrawLines.setTooltip(new TextComponent("Show lines"));
|
buttonDrawLines.setTooltip(Component.literal("Show lines"));
|
||||||
radialMirrorIconButtonList.add(buttonDrawLines);
|
radialMirrorIconButtonList.add(buttonDrawLines);
|
||||||
|
|
||||||
buttonDrawPlanes = new GuiIconButton(left + 95, y, 0, 60, BUILDING_ICONS, button -> {
|
buttonDrawPlanes = new GuiIconButton(left + 95, y, 0, 60, BUILDING_ICONS, button -> {
|
||||||
drawPlanes = !drawPlanes;
|
drawPlanes = !drawPlanes;
|
||||||
buttonDrawPlanes.setUseAlternateIcon(drawPlanes);
|
buttonDrawPlanes.setUseAlternateIcon(drawPlanes);
|
||||||
buttonDrawPlanes.setTooltip(new TextComponent(drawPlanes ? "Hide area" : "Show area"));
|
buttonDrawPlanes.setTooltip(Component.literal(drawPlanes ? "Hide area" : "Show area"));
|
||||||
});
|
});
|
||||||
buttonDrawPlanes.setTooltip(new TextComponent("Show area"));
|
buttonDrawPlanes.setTooltip(Component.literal("Show area"));
|
||||||
radialMirrorIconButtonList.add(buttonDrawPlanes);
|
radialMirrorIconButtonList.add(buttonDrawPlanes);
|
||||||
|
|
||||||
y = top + 76;
|
y = top + 76;
|
||||||
@@ -147,14 +146,14 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
drawPlanes = r.drawPlanes;
|
drawPlanes = r.drawPlanes;
|
||||||
buttonDrawLines.setUseAlternateIcon(drawLines);
|
buttonDrawLines.setUseAlternateIcon(drawLines);
|
||||||
buttonDrawPlanes.setUseAlternateIcon(drawPlanes);
|
buttonDrawPlanes.setUseAlternateIcon(drawPlanes);
|
||||||
buttonDrawLines.setTooltip(new TextComponent(drawLines ? "Hide lines" : "Show lines"));
|
buttonDrawLines.setTooltip(Component.literal(drawLines ? "Hide lines" : "Show lines"));
|
||||||
buttonDrawPlanes.setTooltip(new TextComponent(drawPlanes ? "Hide area" : "Show area"));
|
buttonDrawPlanes.setTooltip(Component.literal(drawPlanes ? "Hide area" : "Show area"));
|
||||||
if (textRadialMirrorPosX.getNumber() == Math.floor(textRadialMirrorPosX.getNumber())) {
|
if (textRadialMirrorPosX.getNumber() == Math.floor(textRadialMirrorPosX.getNumber())) {
|
||||||
toggleOdd = false;
|
toggleOdd = false;
|
||||||
buttonToggleOdd.setTooltip(Arrays.asList(new TextComponent("Set radial mirror position to middle of block"), new TextComponent("for odd numbered builds")));
|
buttonToggleOdd.setTooltip(Arrays.asList(Component.literal("Set radial mirror position to middle of block"), Component.literal("for odd numbered builds")));
|
||||||
} else {
|
} else {
|
||||||
toggleOdd = true;
|
toggleOdd = true;
|
||||||
buttonToggleOdd.setTooltip(Arrays.asList(new TextComponent("Set radial mirror position to corner of block"), new TextComponent("for even numbered builds")));
|
buttonToggleOdd.setTooltip(Arrays.asList(Component.literal("Set radial mirror position to corner of block"), Component.literal("for even numbered builds")));
|
||||||
}
|
}
|
||||||
buttonToggleOdd.setUseAlternateIcon(toggleOdd);
|
buttonToggleOdd.setUseAlternateIcon(toggleOdd);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package nl.requios.effortlessbuilding.gui.elements;
|
|||||||
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.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraftforge.fmlclient.gui.GuiUtils;
|
import net.minecraftforge.client.gui.ScreenUtils;
|
||||||
|
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ public class GuiCheckBoxFixed extends Button {
|
|||||||
private boolean isChecked;
|
private boolean isChecked;
|
||||||
|
|
||||||
public GuiCheckBoxFixed(int xPos, int yPos, String displayString, boolean isChecked) {
|
public GuiCheckBoxFixed(int xPos, int yPos, String displayString, boolean isChecked) {
|
||||||
super(xPos, yPos, Minecraft.getInstance().font.width(displayString) + 2 + 11, 11, new TextComponent(displayString), b -> {
|
super(xPos, yPos, Minecraft.getInstance().font.width(displayString) + 2 + 11, 11, Component.literal(displayString), b -> {
|
||||||
});
|
});
|
||||||
this.isChecked = isChecked;
|
this.isChecked = isChecked;
|
||||||
this.boxWidth = 11;
|
this.boxWidth = 11;
|
||||||
@@ -30,7 +30,7 @@ public class GuiCheckBoxFixed extends Button {
|
|||||||
if (this.visible) {
|
if (this.visible) {
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.boxWidth && mouseY < this.y + this.height;
|
this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.boxWidth && mouseY < this.y + this.height;
|
||||||
GuiUtils.drawContinuousTexturedBox(ms, WIDGETS_LOCATION, this.x, this.y, 0, 46, this.boxWidth, this.height, 200, 20, 2, 3, 2, 2, this.getBlitOffset());
|
ScreenUtils.blitWithBorder(ms, WIDGETS_LOCATION, this.x, this.y, 0, 46, this.boxWidth, this.height, 200, 20, 2, 3, 2, 2, this.getBlitOffset());
|
||||||
this.renderBg(ms, mc, mouseX, mouseY);
|
this.renderBg(ms, mc, mouseX, mouseY);
|
||||||
int color = 14737632;
|
int color = 14737632;
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,10 @@ 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 com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
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;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
@@ -30,7 +28,7 @@ public class GuiIconButton extends Button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public GuiIconButton(int x, int y, int width, int height, int iconX, int iconY, int iconWidth, int iconHeight, int iconAltX, int iconAltY, ResourceLocation resourceLocation, Button.OnPress onPress) {
|
public GuiIconButton(int x, int y, int width, int height, int iconX, int iconY, int iconWidth, int iconHeight, int iconAltX, int iconAltY, ResourceLocation resourceLocation, Button.OnPress onPress) {
|
||||||
super(x, y, width, height, TextComponent.EMPTY, onPress);
|
super(x, y, width, height, Component.empty(), onPress);
|
||||||
this.iconX = iconX;
|
this.iconX = iconX;
|
||||||
this.iconY = iconY;
|
this.iconY = iconY;
|
||||||
this.iconWidth = iconWidth;
|
this.iconWidth = iconWidth;
|
||||||
|
|||||||
@@ -7,15 +7,14 @@ import net.minecraft.client.gui.Font;
|
|||||||
import net.minecraft.client.gui.components.Widget;
|
import net.minecraft.client.gui.components.Widget;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.client.gui.components.EditBox;
|
import net.minecraft.client.gui.components.EditBox;
|
||||||
import net.minecraft.client.gui.components.AbstractWidget;
|
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
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 javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
import java.awt.*;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -41,15 +40,15 @@ public class GuiNumberField extends GuiComponent {
|
|||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
|
|
||||||
textField = new EditBox(font, x + buttonWidth + 1, y + 1, width - 2 * buttonWidth - 2, height - 2, TextComponent.EMPTY);
|
textField = new EditBox(font, x + buttonWidth + 1, y + 1, width - 2 * buttonWidth - 2, height - 2, Component.empty());
|
||||||
minusButton = new Button(x, y - 1, buttonWidth, height + 2, new TextComponent("-"), button -> {
|
minusButton = new Button(x, y - 1, buttonWidth, height + 2, Component.literal("-"), button -> {
|
||||||
float valueChanged = 1f;
|
float valueChanged = 1f;
|
||||||
if (Screen.hasControlDown()) valueChanged = 5f;
|
if (Screen.hasControlDown()) valueChanged = 5f;
|
||||||
if (Screen.hasShiftDown()) valueChanged = 10f;
|
if (Screen.hasShiftDown()) valueChanged = 10f;
|
||||||
|
|
||||||
setNumber(getNumber() - valueChanged);
|
setNumber(getNumber() - valueChanged);
|
||||||
});
|
});
|
||||||
plusButton = new Button(x + width - buttonWidth, y - 1, buttonWidth, height + 2, new TextComponent("+"), button -> {
|
plusButton = new Button(x + width - buttonWidth, y - 1, buttonWidth, height + 2, Component.literal("+"), button -> {
|
||||||
float valueChanged = 1f;
|
float valueChanged = 1f;
|
||||||
if (Screen.hasControlDown()) valueChanged = 5f;
|
if (Screen.hasControlDown()) valueChanged = 5f;
|
||||||
if (Screen.hasShiftDown()) valueChanged = 10f;
|
if (Screen.hasShiftDown()) valueChanged = 10f;
|
||||||
@@ -124,17 +123,17 @@ public class GuiNumberField extends GuiComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (insideMinusButton) {
|
if (insideMinusButton) {
|
||||||
textLines.add(new TextComponent("Hold ").append(new TextComponent("shift ").withStyle(ChatFormatting.AQUA)).append("for ")
|
textLines.add(Component.literal("Hold ").append(Component.literal("shift ").withStyle(ChatFormatting.AQUA)).append("for ")
|
||||||
.append(new TextComponent("10").withStyle(ChatFormatting.RED)));
|
.append(Component.literal("10").withStyle(ChatFormatting.RED)));
|
||||||
textLines.add(new TextComponent("Hold ").append(new TextComponent("ctrl ").withStyle(ChatFormatting.AQUA)).append("for ")
|
textLines.add(Component.literal("Hold ").append(Component.literal("ctrl ").withStyle(ChatFormatting.AQUA)).append("for ")
|
||||||
.append(new TextComponent("5").withStyle(ChatFormatting.RED)));
|
.append(Component.literal("5").withStyle(ChatFormatting.RED)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (insidePlusButton) {
|
if (insidePlusButton) {
|
||||||
textLines.add(new TextComponent("Hold ").append(new TextComponent("shift ").withStyle(ChatFormatting.DARK_GREEN)).append("for ")
|
textLines.add(Component.literal("Hold ").append(Component.literal("shift ").withStyle(ChatFormatting.DARK_GREEN)).append("for ")
|
||||||
.append(new TextComponent("10").withStyle(ChatFormatting.RED)));
|
.append(Component.literal("10").withStyle(ChatFormatting.RED)));
|
||||||
textLines.add(new TextComponent("Hold ").append(new TextComponent("ctrl ").withStyle(ChatFormatting.DARK_GREEN)).append("for ")
|
textLines.add(Component.literal("Hold ").append(Component.literal("ctrl ").withStyle(ChatFormatting.DARK_GREEN)).append("for ")
|
||||||
.append(new TextComponent("5").withStyle(ChatFormatting.RED)));
|
.append(Component.literal("5").withStyle(ChatFormatting.RED)));
|
||||||
}
|
}
|
||||||
|
|
||||||
screen.renderComponentTooltip(ms, textLines, mouseX - 10, mouseY + 25);
|
screen.renderComponentTooltip(ms, textLines, mouseX - 10, mouseY + 25);
|
||||||
|
|||||||
@@ -49,6 +49,6 @@ public class ReachHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canBreakFar(Player player) {
|
public static boolean canBreakFar(Player player) {
|
||||||
return player.isCreative() || BuildConfig.survivalBalancers.breakFar.get();
|
return player.isCreative();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +1,36 @@
|
|||||||
package nl.requios.effortlessbuilding.helper;
|
package nl.requios.effortlessbuilding.helper;
|
||||||
|
|
||||||
import net.minecraft.advancements.CriteriaTriggers;
|
import net.minecraft.advancements.CriteriaTriggers;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.core.Registry;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.tags.BlockTags;
|
import net.minecraft.tags.BlockTags;
|
||||||
import net.minecraft.tags.Tag;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.level.material.Material;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
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.minecraft.world.level.block.state.pattern.BlockInWorld;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.world.InteractionHand;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraftforge.common.data.ForgeBlockTagsProvider;
|
|
||||||
import net.minecraftforge.event.ForgeEventFactory;
|
|
||||||
import nl.requios.effortlessbuilding.BuildConfig;
|
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
|
||||||
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.SlabBlock;
|
import net.minecraft.world.level.block.SlabBlock;
|
||||||
import net.minecraft.world.level.block.SoundType;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.block.state.pattern.BlockInWorld;
|
||||||
|
import net.minecraft.world.level.material.Material;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
import net.minecraftforge.event.ForgeEventFactory;
|
||||||
|
import nl.requios.effortlessbuilding.BuildConfig;
|
||||||
|
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||||
|
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class SurvivalHelper {
|
public class SurvivalHelper {
|
||||||
|
|
||||||
private static final Tag.Named<Block> NEEDS_NETHERITE_TOOL = BlockTags.bind("forge:needs_netherite_tool");
|
|
||||||
|
|
||||||
//Used for all placing of blocks in this mod.
|
//Used for all placing of blocks in this mod.
|
||||||
//Checks if area is loaded, if player has the right permissions, if existing block can be replaced (drops it if so) and consumes an item from the stack.
|
//Checks if area is loaded, if player has the right permissions, if existing block can be replaced (drops it if so) and consumes an item from the stack.
|
||||||
//Based on ItemBlock#onItemUse
|
//Based on ItemBlock#onItemUse
|
||||||
@@ -221,17 +215,13 @@ public class SurvivalHelper {
|
|||||||
case 0:
|
case 0:
|
||||||
return !state.is(BlockTags.NEEDS_STONE_TOOL) &&
|
return !state.is(BlockTags.NEEDS_STONE_TOOL) &&
|
||||||
!state.is(BlockTags.NEEDS_IRON_TOOL) &&
|
!state.is(BlockTags.NEEDS_IRON_TOOL) &&
|
||||||
!state.is(BlockTags.NEEDS_DIAMOND_TOOL) &&
|
!state.is(BlockTags.NEEDS_DIAMOND_TOOL);
|
||||||
!state.is(NEEDS_NETHERITE_TOOL);
|
|
||||||
case 1:
|
case 1:
|
||||||
return !state.is(BlockTags.NEEDS_IRON_TOOL) &&
|
return !state.is(BlockTags.NEEDS_IRON_TOOL) &&
|
||||||
!state.is(BlockTags.NEEDS_DIAMOND_TOOL) &&
|
!state.is(BlockTags.NEEDS_DIAMOND_TOOL);
|
||||||
!state.is(NEEDS_NETHERITE_TOOL);
|
|
||||||
case 2:
|
case 2:
|
||||||
return !state.is(BlockTags.NEEDS_DIAMOND_TOOL) &&
|
return !state.is(BlockTags.NEEDS_DIAMOND_TOOL);
|
||||||
!state.is(NEEDS_NETHERITE_TOOL);
|
|
||||||
case 3:
|
case 3:
|
||||||
return !state.is(NEEDS_NETHERITE_TOOL);
|
|
||||||
case 4:
|
case 4:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -239,7 +229,7 @@ public class SurvivalHelper {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//From EntityPlayer#canPlayerEdit
|
//From Player#mayUseItemAt
|
||||||
private static boolean canPlayerEdit(Player player, Level world, BlockPos pos, ItemStack stack) {
|
private static boolean canPlayerEdit(Player player, Level world, BlockPos pos, ItemStack stack) {
|
||||||
if (!world.mayInteract(player, pos)) return false;
|
if (!world.mayInteract(player, pos)) return false;
|
||||||
|
|
||||||
@@ -248,9 +238,8 @@ public class SurvivalHelper {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
//Adventure mode
|
//Adventure mode
|
||||||
BlockInWorld blockworldstate = new BlockInWorld(world, pos, false);
|
BlockInWorld blockinworld = new BlockInWorld(world, pos, false);
|
||||||
return stack.hasAdventureModePlaceTagForBlock(world.getTagManager(), blockworldstate);
|
return stack.hasAdventureModePlaceTagForBlock(world.registryAccess().registryOrThrow(Registry.BLOCK_REGISTRY), blockinworld);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,8 @@ import net.minecraft.world.level.block.Block;
|
|||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.item.TooltipFlag;
|
import net.minecraft.world.item.TooltipFlag;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.level.material.Fluids;
|
import net.minecraft.world.level.material.Fluids;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
|
||||||
import net.minecraft.world.MenuProvider;
|
import net.minecraft.world.MenuProvider;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.InteractionResultHolder;
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
@@ -19,19 +17,16 @@ import net.minecraft.core.BlockPos;
|
|||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkHooks;
|
import net.minecraftforge.network.NetworkHooks;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||||
import nl.requios.effortlessbuilding.capability.ItemHandlerCapabilityProvider;
|
import nl.requios.effortlessbuilding.capability.ItemHandlerCapabilityProvider;
|
||||||
import nl.requios.effortlessbuilding.gui.RandomizerBagContainer;
|
|
||||||
import nl.requios.effortlessbuilding.helper.SurvivalHelper;
|
import nl.requios.effortlessbuilding.helper.SurvivalHelper;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -134,7 +129,7 @@ public abstract class AbstractRandomizerBagItem extends Item {
|
|||||||
if (ctx.getPlayer() != null && ctx.getPlayer().isShiftKeyDown()) { //ctx.isPlacerSneaking()
|
if (ctx.getPlayer() != null && ctx.getPlayer().isShiftKeyDown()) { //ctx.isPlacerSneaking()
|
||||||
if (world.isClientSide) return InteractionResult.SUCCESS;
|
if (world.isClientSide) return InteractionResult.SUCCESS;
|
||||||
//Open inventory
|
//Open inventory
|
||||||
NetworkHooks.openGui((ServerPlayer) player, getContainerProvider(item));
|
NetworkHooks.openScreen((ServerPlayer) player, getContainerProvider(item));
|
||||||
} else {
|
} else {
|
||||||
if (world.isClientSide) return InteractionResult.SUCCESS;
|
if (world.isClientSide) return InteractionResult.SUCCESS;
|
||||||
|
|
||||||
@@ -187,7 +182,7 @@ public abstract class AbstractRandomizerBagItem extends Item {
|
|||||||
if (player.isShiftKeyDown()) {
|
if (player.isShiftKeyDown()) {
|
||||||
if (world.isClientSide) return new InteractionResultHolder<>(InteractionResult.SUCCESS, bag);
|
if (world.isClientSide) return new InteractionResultHolder<>(InteractionResult.SUCCESS, bag);
|
||||||
//Open inventory
|
//Open inventory
|
||||||
NetworkHooks.openGui((ServerPlayer) player, getContainerProvider(bag));
|
NetworkHooks.openScreen((ServerPlayer) player, getContainerProvider(bag));
|
||||||
} else {
|
} else {
|
||||||
//Use item
|
//Use item
|
||||||
//Get bag inventory
|
//Get bag inventory
|
||||||
@@ -216,15 +211,10 @@ public abstract class AbstractRandomizerBagItem extends Item {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendHoverText(ItemStack stack, @Nullable Level world, List<Component> tooltip, TooltipFlag flag) {
|
public void appendHoverText(ItemStack stack, @Nullable Level world, List<Component> tooltip, TooltipFlag flag) {
|
||||||
tooltip.add(new TextComponent(ChatFormatting.BLUE + "Rightclick" + ChatFormatting.GRAY + " to place a random block"));
|
tooltip.add(Component.literal(ChatFormatting.BLUE + "Rightclick" + ChatFormatting.GRAY + " to place a random block"));
|
||||||
tooltip.add(new TextComponent(ChatFormatting.BLUE + "Sneak + rightclick" + ChatFormatting.GRAY + " to open inventory"));
|
tooltip.add(Component.literal(ChatFormatting.BLUE + "Sneak + rightclick" + ChatFormatting.GRAY + " to open inventory"));
|
||||||
if (world != null && world.players().size() > 1) {
|
if (world != null && world.players().size() > 1) {
|
||||||
tooltip.add(new TextComponent(ChatFormatting.YELLOW + "Experimental on servers: may lose inventory"));
|
tooltip.add(Component.literal(ChatFormatting.YELLOW + "Experimental on servers: may lose inventory"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescriptionId() {
|
|
||||||
return this.getRegistryName().toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package nl.requios.effortlessbuilding.item;
|
package nl.requios.effortlessbuilding.item;
|
||||||
|
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
import net.minecraft.world.MenuProvider;
|
import net.minecraft.world.MenuProvider;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
@@ -34,7 +33,7 @@ public class DiamondRandomizerBagItem extends AbstractRandomizerBagItem{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getDisplayName() {
|
public Component getDisplayName() {
|
||||||
return new TranslatableComponent("effortlessbuilding:diamond_randomizer_bag");
|
return Component.translatable("effortlessbuilding:diamond_randomizer_bag");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package nl.requios.effortlessbuilding.item;
|
package nl.requios.effortlessbuilding.item;
|
||||||
|
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
import net.minecraft.world.MenuProvider;
|
import net.minecraft.world.MenuProvider;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
@@ -34,7 +33,7 @@ public class GoldenRandomizerBagItem extends AbstractRandomizerBagItem{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getDisplayName() {
|
public Component getDisplayName() {
|
||||||
return new TranslatableComponent("effortlessbuilding:golden_randomizer_bag");
|
return Component.translatable("effortlessbuilding:golden_randomizer_bag");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package nl.requios.effortlessbuilding.item;
|
package nl.requios.effortlessbuilding.item;
|
||||||
|
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
import net.minecraft.world.MenuProvider;
|
import net.minecraft.world.MenuProvider;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
@@ -34,7 +33,7 @@ public class RandomizerBagItem extends AbstractRandomizerBagItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getDisplayName() {
|
public Component getDisplayName() {
|
||||||
return new TranslatableComponent("effortlessbuilding:randomizer_bag");
|
return Component.translatable("effortlessbuilding:randomizer_bag");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import net.minecraft.world.item.Item;
|
|||||||
import net.minecraft.world.item.CreativeModeTab;
|
import net.minecraft.world.item.CreativeModeTab;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import nl.requios.effortlessbuilding.BuildConfig;
|
import nl.requios.effortlessbuilding.BuildConfig;
|
||||||
@@ -64,11 +63,7 @@ public class ReachUpgrade1Item extends Item {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendHoverText(ItemStack stack, @Nullable Level world, List<Component> tooltip, TooltipFlag flag) {
|
public void appendHoverText(ItemStack stack, @Nullable Level world, List<Component> tooltip, TooltipFlag flag) {
|
||||||
tooltip.add(new TextComponent(ChatFormatting.GRAY + "Consume to increase reach to " + ChatFormatting.BLUE + BuildConfig.reach.maxReachLevel1.get()));
|
tooltip.add(Component.literal(ChatFormatting.GRAY + "Consume to increase reach to " + ChatFormatting.BLUE + BuildConfig.reach.maxReachLevel1.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescriptionId() {
|
|
||||||
return this.getRegistryName().toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import net.minecraft.world.item.Item;
|
|||||||
import net.minecraft.world.item.CreativeModeTab;
|
import net.minecraft.world.item.CreativeModeTab;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import nl.requios.effortlessbuilding.BuildConfig;
|
import nl.requios.effortlessbuilding.BuildConfig;
|
||||||
@@ -17,6 +16,7 @@ import nl.requios.effortlessbuilding.helper.ReachHelper;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
import java.awt.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@@ -68,12 +68,7 @@ public class ReachUpgrade2Item extends Item {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendHoverText(ItemStack stack, @Nullable Level world, List<Component> tooltip, TooltipFlag flag) {
|
public void appendHoverText(ItemStack stack, @Nullable Level world, List<Component> tooltip, TooltipFlag flag) {
|
||||||
tooltip.add(new TextComponent(ChatFormatting.GRAY + "Consume to increase reach to " + ChatFormatting.BLUE + BuildConfig.reach.maxReachLevel2.get()));
|
tooltip.add(Component.literal(ChatFormatting.GRAY + "Consume to increase reach to " + ChatFormatting.BLUE + BuildConfig.reach.maxReachLevel2.get()));
|
||||||
tooltip.add(new TextComponent(ChatFormatting.GRAY + "Previous upgrades need to be consumed first"));
|
tooltip.add(Component.literal(ChatFormatting.GRAY + "Previous upgrades need to be consumed first"));
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescriptionId() {
|
|
||||||
return this.getRegistryName().toString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import net.minecraft.world.item.Item;
|
|||||||
import net.minecraft.world.item.CreativeModeTab;
|
import net.minecraft.world.item.CreativeModeTab;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import nl.requios.effortlessbuilding.BuildConfig;
|
import nl.requios.effortlessbuilding.BuildConfig;
|
||||||
@@ -71,12 +70,8 @@ public class ReachUpgrade3Item extends Item {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendHoverText(ItemStack stack, @Nullable Level world, List<Component> tooltip, TooltipFlag flag) {
|
public void appendHoverText(ItemStack stack, @Nullable Level world, List<Component> tooltip, TooltipFlag flag) {
|
||||||
tooltip.add(new TextComponent(ChatFormatting.GRAY + "Consume to increase reach to " + ChatFormatting.BLUE + BuildConfig.reach.maxReachLevel3.get()));
|
tooltip.add(Component.literal(ChatFormatting.GRAY + "Consume to increase reach to " + ChatFormatting.BLUE + BuildConfig.reach.maxReachLevel3.get()));
|
||||||
tooltip.add(new TextComponent(ChatFormatting.GRAY + "Previous upgrades need to be consumed first"));
|
tooltip.add(Component.literal(ChatFormatting.GRAY + "Previous upgrades need to be consumed first"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescriptionId() {
|
|
||||||
return this.getRegistryName().toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,15 @@ import net.minecraft.world.entity.player.Player;
|
|||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
import net.minecraftforge.fml.LogicalSide;
|
import net.minecraftforge.fml.LogicalSide;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.BlockSet;
|
import nl.requios.effortlessbuilding.buildmodifier.BlockSet;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.UndoRedo;
|
import nl.requios.effortlessbuilding.buildmodifier.UndoRedo;
|
||||||
|
import nl.requios.effortlessbuilding.render.BlockPreviewRenderer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@@ -67,7 +71,16 @@ public class AddUndoMessage {
|
|||||||
ctx.get().enqueueWork(() -> {
|
ctx.get().enqueueWork(() -> {
|
||||||
if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) {
|
if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) {
|
||||||
//Received clientside
|
//Received clientside
|
||||||
|
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> ClientHandler.handle(message, ctx));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ctx.get().setPacketHandled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public static class ClientHandler {
|
||||||
|
public static void handle(AddUndoMessage message, Supplier<NetworkEvent.Context> ctx) {
|
||||||
Player player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
Player player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||||
//Add to undo stack clientside
|
//Add to undo stack clientside
|
||||||
//Only the appropriate player that needs to add this to the undo stack gets this message
|
//Only the appropriate player that needs to add this to the undo stack gets this message
|
||||||
@@ -84,8 +97,5 @@ public class AddUndoMessage {
|
|||||||
new Vec3(0, 0, 0),
|
new Vec3(0, 0, 0),
|
||||||
message.getCoordinate(), message.getCoordinate()));
|
message.getCoordinate(), message.getCoordinate()));
|
||||||
}
|
}
|
||||||
});
|
|
||||||
ctx.get().setPacketHandled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import net.minecraft.world.phys.BlockHitResult;
|
|||||||
import net.minecraft.world.phys.HitResult;
|
import net.minecraft.world.phys.HitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.fml.LogicalSide;
|
import net.minecraftforge.fml.LogicalSide;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|||||||
@@ -6,8 +6,11 @@ import net.minecraft.core.BlockPos;
|
|||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.HitResult;
|
import net.minecraft.world.phys.HitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
import net.minecraftforge.fml.LogicalSide;
|
import net.minecraftforge.fml.LogicalSide;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||||
import nl.requios.effortlessbuilding.render.BlockPreviewRenderer;
|
import nl.requios.effortlessbuilding.render.BlockPreviewRenderer;
|
||||||
|
|
||||||
@@ -95,8 +98,7 @@ public class BlockPlacedMessage {
|
|||||||
ctx.get().enqueueWork(() -> {
|
ctx.get().enqueueWork(() -> {
|
||||||
if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) {
|
if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) {
|
||||||
//Received clientside
|
//Received clientside
|
||||||
//Nod RenderHandler to do the dissolve shader effect
|
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> ClientHandler.handle(message, ctx));
|
||||||
BlockPreviewRenderer.onBlocksPlaced();
|
|
||||||
} else {
|
} else {
|
||||||
//Received serverside
|
//Received serverside
|
||||||
BuildModes.onBlockPlacedMessage(ctx.get().getSender(), message);
|
BuildModes.onBlockPlacedMessage(ctx.get().getSender(), message);
|
||||||
@@ -105,4 +107,12 @@ public class BlockPlacedMessage {
|
|||||||
ctx.get().setPacketHandled(true);
|
ctx.get().setPacketHandled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public static class ClientHandler {
|
||||||
|
public static void handle(BlockPlacedMessage message, Supplier<NetworkEvent.Context> ctx) {
|
||||||
|
//Nod RenderHandler to do the dissolve shader effect
|
||||||
|
BlockPreviewRenderer.onBlocksPlaced();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package nl.requios.effortlessbuilding.network;
|
|||||||
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,14 @@ package nl.requios.effortlessbuilding.network;
|
|||||||
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
import net.minecraftforge.fml.LogicalSide;
|
import net.minecraftforge.fml.LogicalSide;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.UndoRedo;
|
import nl.requios.effortlessbuilding.buildmodifier.UndoRedo;
|
||||||
|
import nl.requios.effortlessbuilding.render.BlockPreviewRenderer;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@@ -30,13 +34,20 @@ public class ClearUndoMessage {
|
|||||||
ctx.get().enqueueWork(() -> {
|
ctx.get().enqueueWork(() -> {
|
||||||
if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) {
|
if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) {
|
||||||
//Received clientside
|
//Received clientside
|
||||||
Player player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> ClientHandler.handle(message, ctx));
|
||||||
|
|
||||||
//Add to undo stack clientside
|
|
||||||
UndoRedo.clear(player);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ctx.get().setPacketHandled(true);
|
ctx.get().setPacketHandled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public static class ClientHandler {
|
||||||
|
public static void handle(ClearUndoMessage message, Supplier<NetworkEvent.Context> ctx) {
|
||||||
|
Player player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||||
|
|
||||||
|
//Add to undo stack clientside
|
||||||
|
UndoRedo.clear(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package nl.requios.effortlessbuilding.network;
|
|||||||
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package nl.requios.effortlessbuilding.network;
|
|||||||
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import net.minecraft.world.entity.player.Player;
|
|||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.Array;
|
import nl.requios.effortlessbuilding.buildmodifier.Array;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.Mirror;
|
import nl.requios.effortlessbuilding.buildmodifier.Mirror;
|
||||||
@@ -13,8 +13,6 @@ import nl.requios.effortlessbuilding.buildmodifier.RadialMirror;
|
|||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import static nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager.ModifierSettings;
|
|
||||||
|
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager.ModifierSettings;
|
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager.ModifierSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
package nl.requios.effortlessbuilding.network;
|
package nl.requios.effortlessbuilding.network;
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkRegistry;
|
import net.minecraftforge.network.NetworkRegistry;
|
||||||
import net.minecraftforge.fmllegacy.network.simple.SimpleChannel;
|
import net.minecraftforge.network.simple.SimpleChannel;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
|
|
||||||
public class PacketHandler {
|
public class PacketHandler {
|
||||||
private static final String PROTOCOL_VERSION = "1";
|
private static final String PROTOCOL_VERSION = "1";
|
||||||
public static final SimpleChannel INSTANCE = NetworkRegistry.newSimpleChannel(
|
public static final SimpleChannel INSTANCE = NetworkRegistry.newSimpleChannel(
|
||||||
new ResourceLocation(EffortlessBuilding.MODID, "main_channel"),
|
new ResourceLocation(EffortlessBuilding.MODID, "main"),
|
||||||
() -> PROTOCOL_VERSION,
|
() -> PROTOCOL_VERSION,
|
||||||
PROTOCOL_VERSION::equals,
|
PROTOCOL_VERSION::equals,
|
||||||
PROTOCOL_VERSION::equals
|
PROTOCOL_VERSION::equals
|
||||||
|
|||||||
@@ -4,10 +4,14 @@ import net.minecraft.world.entity.player.Player;
|
|||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.HitResult;
|
import net.minecraft.world.phys.HitResult;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
import net.minecraftforge.fml.LogicalSide;
|
import net.minecraftforge.fml.LogicalSide;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
||||||
|
import nl.requios.effortlessbuilding.render.BlockPreviewRenderer;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@@ -44,6 +48,16 @@ public class RequestLookAtMessage {
|
|||||||
ctx.get().enqueueWork(() -> {
|
ctx.get().enqueueWork(() -> {
|
||||||
if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) {
|
if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) {
|
||||||
//Received clientside
|
//Received clientside
|
||||||
|
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> ClientHandler.handle(message, ctx));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ctx.get().setPacketHandled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public static class ClientHandler {
|
||||||
|
public static void handle(RequestLookAtMessage message, Supplier<NetworkEvent.Context> ctx) {
|
||||||
//Send back your info
|
//Send back your info
|
||||||
Player player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
Player player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||||
|
|
||||||
@@ -55,8 +69,5 @@ public class RequestLookAtMessage {
|
|||||||
PacketHandler.INSTANCE.sendToServer(new BlockPlacedMessage());
|
PacketHandler.INSTANCE.sendToServer(new BlockPlacedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
ctx.get().setPacketHandled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,14 @@ package nl.requios.effortlessbuilding.network;
|
|||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.fml.LogicalSide;
|
import net.minecraftforge.fml.LogicalSide;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send packet to client to translate and log the containing message
|
||||||
|
*/
|
||||||
public class TranslatedLogMessage {
|
public class TranslatedLogMessage {
|
||||||
private final String prefix;
|
private final String prefix;
|
||||||
private final String translationKey;
|
private final String translationKey;
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ import net.minecraft.world.phys.Vec3;
|
|||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.client.event.GuiOpenEvent;
|
|
||||||
import net.minecraftforge.client.event.InputEvent;
|
import net.minecraftforge.client.event.InputEvent;
|
||||||
|
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
|
||||||
|
import net.minecraftforge.client.event.ScreenEvent;
|
||||||
import net.minecraftforge.client.settings.KeyConflictContext;
|
import net.minecraftforge.client.settings.KeyConflictContext;
|
||||||
import net.minecraftforge.client.settings.KeyModifier;
|
import net.minecraftforge.client.settings.KeyModifier;
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.minecraftforge.event.TickEvent;
|
||||||
@@ -33,8 +34,7 @@ import net.minecraftforge.fml.LogicalSide;
|
|||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.minecraftforge.fmlclient.registry.ClientRegistry;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||||
@@ -71,21 +71,7 @@ public class ClientProxy implements IProxy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clientSetup(FMLClientSetupEvent event) {
|
public void clientSetup(FMLClientSetupEvent event) {
|
||||||
// register key bindings
|
//Keybindings are setup and registered in ModClientEventHandler
|
||||||
keyBindings = new KeyMapping[6];
|
|
||||||
|
|
||||||
// instantiate the key bindings
|
|
||||||
keyBindings[0] = new KeyMapping("key.effortlessbuilding.hud.desc", KeyConflictContext.UNIVERSAL, InputConstants.getKey(GLFW.GLFW_KEY_KP_ADD, 0), "key.effortlessbuilding.category");
|
|
||||||
keyBindings[1] = new KeyMapping("key.effortlessbuilding.replace.desc", KeyConflictContext.IN_GAME, InputConstants.getKey(GLFW.GLFW_KEY_KP_SUBTRACT, 0), "key.effortlessbuilding.category");
|
|
||||||
keyBindings[2] = new KeyMapping("key.effortlessbuilding.mode.desc", KeyConflictContext.IN_GAME, InputConstants.getKey(GLFW.GLFW_KEY_LEFT_ALT, 0), "key.effortlessbuilding.category");
|
|
||||||
keyBindings[3] = new KeyMapping("key.effortlessbuilding.undo.desc", KeyConflictContext.IN_GAME, KeyModifier.CONTROL, InputConstants.getKey(GLFW.GLFW_KEY_Z, 0), "key.effortlessbuilding.category");
|
|
||||||
keyBindings[4] = new KeyMapping("key.effortlessbuilding.redo.desc", KeyConflictContext.IN_GAME, KeyModifier.CONTROL, InputConstants.getKey(GLFW.GLFW_KEY_Y, 0), "key.effortlessbuilding.category");
|
|
||||||
keyBindings[5] = new KeyMapping("key.effortlessbuilding.altplacement.desc", KeyConflictContext.IN_GAME, InputConstants.getKey(GLFW.GLFW_KEY_LEFT_CONTROL, 0), "key.effortlessbuilding.category");
|
|
||||||
|
|
||||||
// register all the key bindings
|
|
||||||
for (KeyMapping keyBinding : keyBindings) {
|
|
||||||
ClientRegistry.registerKeyBinding(keyBinding);
|
|
||||||
}
|
|
||||||
|
|
||||||
MenuScreens.register(EffortlessBuilding.RANDOMIZER_BAG_CONTAINER.get(), RandomizerBagScreen::new);
|
MenuScreens.register(EffortlessBuilding.RANDOMIZER_BAG_CONTAINER.get(), RandomizerBagScreen::new);
|
||||||
MenuScreens.register(EffortlessBuilding.GOLDEN_RANDOMIZER_BAG_CONTAINER.get(), GoldenRandomizerBagScreen::new);
|
MenuScreens.register(EffortlessBuilding.GOLDEN_RANDOMIZER_BAG_CONTAINER.get(), GoldenRandomizerBagScreen::new);
|
||||||
@@ -135,7 +121,7 @@ public class ClientProxy implements IProxy {
|
|||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode();
|
BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode();
|
||||||
|
|
||||||
if (Minecraft.getInstance().screen != null ||
|
if (mc.screen != null ||
|
||||||
buildMode == BuildModes.BuildModeEnum.NORMAL ||
|
buildMode == BuildModes.BuildModeEnum.NORMAL ||
|
||||||
RadialMenu.instance.isVisible()) {
|
RadialMenu.instance.isVisible()) {
|
||||||
return;
|
return;
|
||||||
@@ -192,12 +178,6 @@ public class ClientProxy implements IProxy {
|
|||||||
if (breakCooldown <= 0) {
|
if (breakCooldown <= 0) {
|
||||||
breakCooldown = 4;
|
breakCooldown = 4;
|
||||||
|
|
||||||
//Early out if cant break far, coming from own mouse event (not block broken event)
|
|
||||||
//To make breaking blocks in survival possible like array
|
|
||||||
//TODO this causes not being able to cancel placement in survival
|
|
||||||
// moving it to after buildmodes fixes that, but introduces this bug
|
|
||||||
if (!ReachHelper.canBreakFar(player)) return;
|
|
||||||
|
|
||||||
HitResult lookingAt = getLookingAt(player);
|
HitResult lookingAt = getLookingAt(player);
|
||||||
if (lookingAt != null && lookingAt.getType() == HitResult.Type.BLOCK) {
|
if (lookingAt != null && lookingAt.getType() == HitResult.Type.BLOCK) {
|
||||||
BlockHitResult blockLookingAt = (BlockHitResult) lookingAt;
|
BlockHitResult blockLookingAt = (BlockHitResult) lookingAt;
|
||||||
@@ -232,7 +212,7 @@ public class ClientProxy implements IProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent(receiveCanceled = true)
|
@SubscribeEvent(receiveCanceled = true)
|
||||||
public static void onKeyPress(InputEvent.KeyInputEvent event) {
|
public static void onKeyPress(InputEvent.Key event) {
|
||||||
LocalPlayer player = Minecraft.getInstance().player;
|
LocalPlayer player = Minecraft.getInstance().player;
|
||||||
if (player == null)
|
if (player == null)
|
||||||
return;
|
return;
|
||||||
@@ -316,7 +296,7 @@ public class ClientProxy implements IProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onGuiOpen(GuiOpenEvent event) {
|
public static void onGuiOpen(ScreenEvent event) {
|
||||||
Player player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
BuildModes.initializeMode(player);
|
BuildModes.initializeMode(player);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package nl.requios.effortlessbuilding.proxy;
|
|||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import net.minecraft.world.entity.player.Player;
|
|||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.minecraftforge.fmllegacy.network.PacketDistributor;
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
import nl.requios.effortlessbuilding.network.PacketHandler;
|
||||||
import nl.requios.effortlessbuilding.network.TranslatedLogMessage;
|
import nl.requios.effortlessbuilding.network.TranslatedLogMessage;
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class BlockPreviewRenderer {
|
|||||||
lookingAt = Minecraft.getInstance().hitResult;
|
lookingAt = Minecraft.getInstance().hitResult;
|
||||||
|
|
||||||
ItemStack mainhand = player.getMainHandItem();
|
ItemStack mainhand = player.getMainHandItem();
|
||||||
boolean toolInHand = !(!mainhand.isEmpty() && CompatHelper.isItemBlockProxy(mainhand));
|
boolean noBlockInHand = !(!mainhand.isEmpty() && CompatHelper.isItemBlockProxy(mainhand));
|
||||||
|
|
||||||
BlockPos startPos = null;
|
BlockPos startPos = null;
|
||||||
Direction sideHit = null;
|
Direction sideHit = null;
|
||||||
@@ -91,12 +91,12 @@ public class BlockPreviewRenderer {
|
|||||||
//TODO 1.13 replaceable
|
//TODO 1.13 replaceable
|
||||||
boolean replaceable = player.level.getBlockState(startPos).getMaterial().isReplaceable();
|
boolean replaceable = player.level.getBlockState(startPos).getMaterial().isReplaceable();
|
||||||
boolean becomesDoubleSlab = SurvivalHelper.doesBecomeDoubleSlab(player, startPos, blockLookingAt.getDirection());
|
boolean becomesDoubleSlab = SurvivalHelper.doesBecomeDoubleSlab(player, startPos, blockLookingAt.getDirection());
|
||||||
if (!modifierSettings.doQuickReplace() && !toolInHand && !replaceable && !becomesDoubleSlab) {
|
if (!modifierSettings.doQuickReplace() && !noBlockInHand && !replaceable && !becomesDoubleSlab) {
|
||||||
startPos = startPos.relative(blockLookingAt.getDirection());
|
startPos = startPos.relative(blockLookingAt.getDirection());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get under tall grass and other replaceable blocks
|
//Get under tall grass and other replaceable blocks
|
||||||
if (modifierSettings.doQuickReplace() && !toolInHand && replaceable) {
|
if (modifierSettings.doQuickReplace() && !noBlockInHand && replaceable) {
|
||||||
startPos = startPos.below();
|
startPos = startPos.below();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,12 +236,13 @@ public class BlockPreviewRenderer {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexConsumer buffer = RenderHandler.beginLines(renderTypeBuffer);
|
//Draw outlines if no block in hand
|
||||||
//Draw outlines if tool in hand
|
|
||||||
//Find proper raytrace: either normal range or increased range depending on canBreakFar
|
//Find proper raytrace: either normal range or increased range depending on canBreakFar
|
||||||
|
VertexConsumer buffer = RenderHandler.beginLines(renderTypeBuffer);
|
||||||
HitResult objectMouseOver = Minecraft.getInstance().hitResult;
|
HitResult objectMouseOver = Minecraft.getInstance().hitResult;
|
||||||
HitResult breakingRaytrace = ReachHelper.canBreakFar(player) ? lookingAt : objectMouseOver;
|
HitResult breakingRaytrace = ReachHelper.canBreakFar(player) ? lookingAt : objectMouseOver;
|
||||||
if (toolInHand && breakingRaytrace != null && breakingRaytrace.getType() == HitResult.Type.BLOCK) {
|
|
||||||
|
if (player.isCreative() && noBlockInHand && breakingRaytrace != null && breakingRaytrace.getType() == HitResult.Type.BLOCK) {
|
||||||
BlockHitResult blockBreakingRaytrace = (BlockHitResult) breakingRaytrace;
|
BlockHitResult blockBreakingRaytrace = (BlockHitResult) breakingRaytrace;
|
||||||
List<BlockPos> breakCoordinates = BuildModifiers.findCoordinates(player, blockBreakingRaytrace.getBlockPos());
|
List<BlockPos> breakCoordinates = BuildModifiers.findCoordinates(player, blockBreakingRaytrace.getBlockPos());
|
||||||
|
|
||||||
|
|||||||
@@ -2,24 +2,18 @@ package nl.requios.effortlessbuilding.render;
|
|||||||
|
|
||||||
import com.mojang.blaze3d.shaders.Uniform;
|
import com.mojang.blaze3d.shaders.Uniform;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
import net.minecraft.Util;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.renderer.RenderStateShard;
|
import net.minecraft.client.renderer.RenderStateShard;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.ShaderInstance;
|
import net.minecraft.client.renderer.ShaderInstance;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
|
||||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import nl.requios.effortlessbuilding.BuildConfig;
|
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import org.lwjgl.opengl.*;
|
|
||||||
|
|
||||||
import java.util.OptionalDouble;
|
import java.util.OptionalDouble;
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public class BuildRenderTypes extends RenderType {
|
public class BuildRenderTypes extends RenderType {
|
||||||
public static ResourceLocation shaderMaskTextureLocation = new ResourceLocation(EffortlessBuilding.MODID, "textures/shader_mask.png");
|
public static ResourceLocation shaderMaskTextureLocation = new ResourceLocation(EffortlessBuilding.MODID, "textures/shader_mask.png");
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ import net.minecraft.world.phys.AABB;
|
|||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
import net.minecraftforge.client.event.RenderLevelStageEvent;
|
||||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
import net.minecraftforge.client.model.data.ModelData;
|
||||||
import net.minecraftforge.eventbus.api.EventPriority;
|
import net.minecraftforge.eventbus.api.EventPriority;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
@@ -28,6 +28,8 @@ import nl.requios.effortlessbuilding.EffortlessBuilding;
|
|||||||
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||||
|
|
||||||
|
import static net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Main render class for Effortless Building
|
* Main render class for Effortless Building
|
||||||
*/
|
*/
|
||||||
@@ -35,11 +37,11 @@ import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
|||||||
public class RenderHandler {
|
public class RenderHandler {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onRender(RenderWorldLastEvent event) {
|
public static void onRender(RenderLevelStageEvent event) {
|
||||||
if (event.getPhase() != EventPriority.NORMAL)
|
if (event.getPhase() != EventPriority.NORMAL || event.getStage() != AFTER_PARTICLES)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PoseStack matrixStack = event.getMatrixStack();
|
PoseStack matrixStack = event.getPoseStack();
|
||||||
BufferBuilder bufferBuilder = Tesselator.getInstance().getBuilder();
|
BufferBuilder bufferBuilder = Tesselator.getInstance().getBuilder();
|
||||||
MultiBufferSource.BufferSource renderTypeBuffer = MultiBufferSource.immediate(bufferBuilder);
|
MultiBufferSource.BufferSource renderTypeBuffer = MultiBufferSource.immediate(bufferBuilder);
|
||||||
|
|
||||||
@@ -91,15 +93,10 @@ public class RenderHandler {
|
|||||||
RenderType blockPreviewRenderType = BuildRenderTypes.getBlockPreviewRenderType(dissolve, blockPos, firstPos, secondPos, red);
|
RenderType blockPreviewRenderType = BuildRenderTypes.getBlockPreviewRenderType(dissolve, blockPos, firstPos, secondPos, red);
|
||||||
VertexConsumer buffer = renderTypeBuffer.getBuffer(blockPreviewRenderType);
|
VertexConsumer buffer = renderTypeBuffer.getBuffer(blockPreviewRenderType);
|
||||||
|
|
||||||
// MinecraftServer server = Minecraft.getInstance().getIntegratedServer();
|
|
||||||
// World world = DimensionManager.getWorld(server, DimensionType.OVERWORLD, false, true);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BakedModel model = dispatcher.getBlockModel(blockState);
|
BakedModel model = dispatcher.getBlockModel(blockState);
|
||||||
dispatcher.getModelRenderer().renderModel(matrixStack.last(), buffer, blockState, model,
|
dispatcher.getModelRenderer().renderModel(matrixStack.last(), buffer, blockState, model,
|
||||||
1f, 1f, 1f, 0, OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE);
|
1f, 1f, 1f, 0, OverlayTexture.NO_OVERLAY, ModelData.EMPTY, blockPreviewRenderType);
|
||||||
// blockRendererDispatcher.getBlockModelRenderer().renderModel(world, blockRendererDispatcher.getModelForState(blockState),
|
|
||||||
// blockState, logicPos, matrixStack, renderTypeBuffer.getBuffer(renderType), true, new Random(), blockState.getPositionRandom(logicPos), i);
|
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
EffortlessBuilding.logger.warn("RenderHandler::renderBlockPreview cannot render " + blockState.getBlock().toString());
|
EffortlessBuilding.logger.warn("RenderHandler::renderBlockPreview cannot render " + blockState.getBlock().toString());
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
modLoader="javafml"
|
modLoader="javafml"
|
||||||
# Forge for 1.17.1 is version 37
|
# Forge for 1.17.1 is version 37
|
||||||
loaderVersion="[37,)"
|
loaderVersion="[41,)"
|
||||||
license="GNU LESSER GENERAL PUBLIC LICENSE"
|
license="GNU LESSER GENERAL PUBLIC LICENSE"
|
||||||
issueTrackerURL="https://bitbucket.org/Requios/effortless-building/issues?status=new&status=open"
|
issueTrackerURL="https://bitbucket.org/Requios/effortless-building/issues?status=new&status=open"
|
||||||
showAsResourcePack=false
|
showAsResourcePack=false
|
||||||
|
|
||||||
[[mods]]
|
[[mods]]
|
||||||
modId="effortlessbuilding"
|
modId="effortlessbuilding"
|
||||||
version="1.0.0.0"
|
version="${file.jarVersion}"
|
||||||
displayName="Effortless Building"
|
displayName="Effortless Building"
|
||||||
displayURL="https://minecraft.curseforge.com/projects/effortless-building"
|
displayURL="https://minecraft.curseforge.com/projects/effortless-building"
|
||||||
logoFile="logo.png"
|
logoFile="logo.png"
|
||||||
@@ -20,13 +20,13 @@ Makes building easier by providing tools like mirrors, arrays, build modes and a
|
|||||||
[[dependencies.effortlessbuilding]]
|
[[dependencies.effortlessbuilding]]
|
||||||
modId="forge"
|
modId="forge"
|
||||||
mandatory=true
|
mandatory=true
|
||||||
versionRange="[37,)"
|
versionRange="[41,)"
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
side="BOTH"
|
side="BOTH"
|
||||||
|
|
||||||
[[dependencies.effortlessbuilding]]
|
[[dependencies.effortlessbuilding]]
|
||||||
modId="minecraft"
|
modId="minecraft"
|
||||||
mandatory=true
|
mandatory=true
|
||||||
versionRange="[1.17.1,1.18)"
|
versionRange="[1.18.1,1.20)"
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
side="BOTH"
|
side="BOTH"
|
||||||
@@ -18,8 +18,8 @@
|
|||||||
"effortlessbuilding:reach_upgrade2": "Reach Upgrade 2",
|
"effortlessbuilding:reach_upgrade2": "Reach Upgrade 2",
|
||||||
"effortlessbuilding:reach_upgrade3": "Reach Upgrade 3",
|
"effortlessbuilding:reach_upgrade3": "Reach Upgrade 3",
|
||||||
|
|
||||||
"effortlessbuilding.mode.normal": "Normal",
|
"effortlessbuilding.mode.normal": "Disable",
|
||||||
"effortlessbuilding.mode.normal_plus": "Normal+",
|
"effortlessbuilding.mode.normal_plus": "Single",
|
||||||
"effortlessbuilding.mode.line": "Line",
|
"effortlessbuilding.mode.line": "Line",
|
||||||
"effortlessbuilding.mode.wall": "Wall",
|
"effortlessbuilding.mode.wall": "Wall",
|
||||||
"effortlessbuilding.mode.floor": "Floor",
|
"effortlessbuilding.mode.floor": "Floor",
|
||||||
@@ -30,6 +30,25 @@
|
|||||||
"effortlessbuilding.mode.circle": "Circle",
|
"effortlessbuilding.mode.circle": "Circle",
|
||||||
"effortlessbuilding.mode.cylinder": "Cylinder",
|
"effortlessbuilding.mode.cylinder": "Cylinder",
|
||||||
"effortlessbuilding.mode.sphere": "Sphere",
|
"effortlessbuilding.mode.sphere": "Sphere",
|
||||||
|
"effortlessbuilding.mode.pyramid": "Pyramid",
|
||||||
|
"effortlessbuilding.mode.cone": "Cone",
|
||||||
|
"effortlessbuilding.mode.dome": "Dome",
|
||||||
|
|
||||||
|
"effortlessbuilding.modedescription.normal": "Disable mod and use vanilla placement rules",
|
||||||
|
"effortlessbuilding.modedescription.normal_plus": "Like vanilla, but with increased reach and placement preview",
|
||||||
|
"effortlessbuilding.modedescription.line": "",
|
||||||
|
"effortlessbuilding.modedescription.wall": "",
|
||||||
|
"effortlessbuilding.modedescription.floor": "",
|
||||||
|
"effortlessbuilding.modedescription.diagonal_line": "",
|
||||||
|
"effortlessbuilding.modedescription.diagonal_wall": "",
|
||||||
|
"effortlessbuilding.modedescription.slope_floor": "",
|
||||||
|
"effortlessbuilding.modedescription.cube": "",
|
||||||
|
"effortlessbuilding.modedescription.circle": "",
|
||||||
|
"effortlessbuilding.modedescription.cylinder": "",
|
||||||
|
"effortlessbuilding.modedescription.sphere": "",
|
||||||
|
"effortlessbuilding.modedescription.pyramid": "",
|
||||||
|
"effortlessbuilding.modedescription.cone": "",
|
||||||
|
"effortlessbuilding.modedescription.dome": "",
|
||||||
|
|
||||||
"effortlessbuilding.action.undo": "Undo",
|
"effortlessbuilding.action.undo": "Undo",
|
||||||
"effortlessbuilding.action.redo": "Redo",
|
"effortlessbuilding.action.redo": "Redo",
|
||||||
|
|||||||
79
src/main/resources/assets/effortlessbuilding/lang/ru_ru.json
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
{
|
||||||
|
"efortlessbuilding.screen.modifier_settings": "Настройки модификатора",
|
||||||
|
"efortlessbuilding.screen.radial_menu": "Режимы строительства",
|
||||||
|
"efortlessbuilding.screen.player_settings": "Настройки игрока",
|
||||||
|
|
||||||
|
"key.efortlessbuilding.category": "Строительство без усилий",
|
||||||
|
"key.efortlessbuilding.hud.desc": "Меню модификаторов",
|
||||||
|
"key.effortlessbuilding.replace.desc": "Переключить быструю замену",
|
||||||
|
"key.efortlessbuilding.mode.desc": "Круговое меню",
|
||||||
|
"key.efortlessbuilding.undo.desc": "Отменить",
|
||||||
|
"key.effortlessbuilding.redo.desc": "Повторить",
|
||||||
|
"key.efortlessbuilding.altplacement.desc": "Альтернативное размещение",
|
||||||
|
|
||||||
|
"efortlessbuilding:randomizer_bag": "Кожаная сумка рандомизатора",
|
||||||
|
"efortlessbuilding:golden_randomizer_bag": "Золотой мешок рандомизатора",
|
||||||
|
"efortlessbuilding:diamond_randomizer_bag": "Бриллиантовый рандомизатор",
|
||||||
|
"efortlessbuilding:reach_upgrade1": "Достичь улучшения 1",
|
||||||
|
"efortlessbuilding:reach_upgrade2": "Достичь улучшения 2",
|
||||||
|
"efortlessbuilding:reach_upgrade3": "Достичь улучшения 3",
|
||||||
|
|
||||||
|
"efortlessbuilding.mode.normal": "Отключить",
|
||||||
|
"efortlessbuilding.mode.normal_plus": "Одиночный",
|
||||||
|
"efortlessbuilding.mode.line": "Линия",
|
||||||
|
"efortlessbuilding.mode.wall": "Стена",
|
||||||
|
"efortlessbuilding.mode.floor": "Этаж",
|
||||||
|
"efortlessbuilding.mode.diagonal_line": "Диагональная линия",
|
||||||
|
"efortlessbuilding.mode.diagonal_wall": "Диагональная стена",
|
||||||
|
"effortlessbuilding.mode.slope_floor": "Наклонный этаж",
|
||||||
|
"effortlessbuilding.mode.cube": "Куб",
|
||||||
|
"efortlessbuilding.mode.circle": "Круг",
|
||||||
|
"efortlessbuilding.mode.cylinder": "Цилиндр",
|
||||||
|
"efortlessbuilding.mode.sphere": "Сфера",
|
||||||
|
"efortlessbuilding.mode.pyramid": "Пирамида",
|
||||||
|
"effortlessbuilding.mode.cone": "Конус",
|
||||||
|
"efortlessbuilding.mode.dome": "Купол",
|
||||||
|
|
||||||
|
"effortlessbuilding.modedescription.normal": "Отключить мод и использовать ванильные правила размещения",
|
||||||
|
"effortlessbuilding.modedescription.normal_plus": "Как и ваниль, но с увеличенным охватом и предварительным просмотром места размещения",
|
||||||
|
"efortlessbuilding.modedescription.line": "",
|
||||||
|
"efortlessbuilding.modedescription.wall": "",
|
||||||
|
"efortlessbuilding.modedescription.floor": "",
|
||||||
|
"efortlessbuilding.modedescription.diagonal_line": "",
|
||||||
|
"efortlessbuilding.modedescription.diagonal_wall": "",
|
||||||
|
"effortlessbuilding.modedescription.slope_floor": "",
|
||||||
|
"efortlessbuilding.modedescription.cube": "",
|
||||||
|
"efortlessbuilding.modedescription.circle": "",
|
||||||
|
"efortlessbuilding.modedescription.cylinder": "",
|
||||||
|
"efortlessbuilding.modedescription.sphere": "",
|
||||||
|
"efortlessbuilding.modedescription.pyramid": "",
|
||||||
|
"efortlessbuilding.modedescription.cone": "",
|
||||||
|
"efortlessbuilding.modedescription.dome": "",
|
||||||
|
|
||||||
|
"efortlessbuilding.action.undo": "Отменить",
|
||||||
|
"efortlessbuilding.action.redo": "Повторить",
|
||||||
|
"efortlessbuilding.action.replace": "Заменить",
|
||||||
|
"efortlessbuilding.action.open_modifier_settings": "Открыть настройки модификатора",
|
||||||
|
"efortlessbuilding.action.open_player_settings": "Открыть настройки",
|
||||||
|
|
||||||
|
"efortlessbuilding.action.build_speed": "Скорость сборки",
|
||||||
|
"efortlessbuilding.action.filling": "Заполнение",
|
||||||
|
"efortlessbuilding.action.raised_edge": "Приподнятый край",
|
||||||
|
"efortlessbuilding.action.thickness": "Толщина линии",
|
||||||
|
"efortlessbuilding.action.circle_start": "Начальная точка",
|
||||||
|
|
||||||
|
"efortlessbuilding.action.normal_speed": "Нормальный",
|
||||||
|
"efortlessbuilding.action.fast_speed": "Быстро",
|
||||||
|
"efortlessbuilding.action.full": "Заполнено",
|
||||||
|
"efortlessbuilding.action.hollow": "Пустой",
|
||||||
|
"efortlessbuilding.action.skeleton": "Скелет",
|
||||||
|
"efortlessbuilding.action.short_edge": "Короткая кромка",
|
||||||
|
"efortlessbuilding.action.long_edge": "Длинный край",
|
||||||
|
"efortlessbuilding.action.thickness_1": "Толщиной 1 блок",
|
||||||
|
"efortlessbuilding.action.thickness_3": "Толщиной 3 блока",
|
||||||
|
"efortlessbuilding.action.thickness_5": "Толщиной 5 блоков",
|
||||||
|
"efortlessbuilding.action.start_center": "Посередине",
|
||||||
|
"efortlessbuilding.action.start_corner": "Угол",
|
||||||
|
|
||||||
|
"commands.reach.usage": "/reach <уровень>"
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 361 B |
|
Before Width: | Height: | Size: 319 B After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 361 B |
|
Before Width: | Height: | Size: 317 B After Width: | Height: | Size: 333 B |
|
Before Width: | Height: | Size: 355 B After Width: | Height: | Size: 317 B |
|
After Width: | Height: | Size: 361 B |
|
Before Width: | Height: | Size: 603 B After Width: | Height: | Size: 625 B |
|
Before Width: | Height: | Size: 625 B After Width: | Height: | Size: 603 B |
@@ -10,7 +10,7 @@
|
|||||||
"item": "minecraft:ender_pearl"
|
"item": "minecraft:ender_pearl"
|
||||||
},
|
},
|
||||||
"#": {
|
"#": {
|
||||||
"item": "minecraft:prismarine_crystals"
|
"item": "minecraft:slime_ball"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
|
|||||||
@@ -1,19 +1,16 @@
|
|||||||
{
|
{
|
||||||
"type": "minecraft:crafting_shaped",
|
"type": "minecraft:crafting_shaped",
|
||||||
"pattern": [
|
"pattern": [
|
||||||
"x#x",
|
" # ",
|
||||||
"#O#",
|
"#O#",
|
||||||
"x#x"
|
" # "
|
||||||
],
|
],
|
||||||
"key": {
|
"key": {
|
||||||
"O": {
|
"O": {
|
||||||
"item": "minecraft:ender_pearl"
|
"item": "minecraft:ender_pearl"
|
||||||
},
|
},
|
||||||
"#": {
|
"#": {
|
||||||
"item": "minecraft:slime_ball"
|
"item": "minecraft:blaze_powder"
|
||||||
},
|
|
||||||
"x": {
|
|
||||||
"item": "minecraft:chorus_fruit"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
|
|||||||
@@ -7,13 +7,13 @@
|
|||||||
],
|
],
|
||||||
"key": {
|
"key": {
|
||||||
"O": {
|
"O": {
|
||||||
"item": "minecraft:nether_star"
|
"item": "minecraft:end_crystal"
|
||||||
},
|
},
|
||||||
"#": {
|
"#": {
|
||||||
"item": "minecraft:diamond"
|
"item": "minecraft:chorus_fruit"
|
||||||
},
|
},
|
||||||
"x": {
|
"x": {
|
||||||
"item": "minecraft:amethyst_shard"
|
"item": "minecraft:ghast_tear"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
|
|||||||