Update to 1.19
This commit is contained in:
@@ -15,7 +15,7 @@ buildscript {
|
||||
apply plugin: 'net.minecraftforge.gradle'
|
||||
apply plugin: 'eclipse'
|
||||
|
||||
version = '1.18.2-3.1.2'
|
||||
version = '1.19-3.1.2'
|
||||
group = 'exopandora.worldhandler' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'WorldHandler'
|
||||
|
||||
@@ -34,7 +34,7 @@ minecraft {
|
||||
//
|
||||
// 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.
|
||||
mappings channel: 'official', version: '1.18.2'
|
||||
mappings channel: 'official', version: '1.19'
|
||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
||||
|
||||
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
@@ -81,7 +81,7 @@ minecraft {
|
||||
// Recommended logging level for the console
|
||||
// property 'forge.logging.console.level', 'debug'
|
||||
|
||||
args '--mod', 'worldhandler', '--all', '--output', file('src/generated/resources/')
|
||||
args '--mod', 'worldhandler', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
|
||||
|
||||
mods {
|
||||
worldhandler {
|
||||
@@ -106,7 +106,7 @@ dependencies {
|
||||
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
|
||||
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
|
||||
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
|
||||
minecraft 'net.minecraftforge:forge:1.18.2-40.0.18'
|
||||
minecraft 'net.minecraftforge:forge:1.19-41.0.19'
|
||||
|
||||
// You may put jars on which you depend on in ./libs or you may define them like so..
|
||||
// compile "some.group:artifact:version:classifier"
|
||||
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
269
gradlew
vendored
269
gradlew
vendored
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (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 «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# 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
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
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.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MSYS* | MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
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 [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
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."
|
||||
fi
|
||||
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.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
@@ -106,80 +140,95 @@ location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
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" ;;
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * 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.
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
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" "$@"
|
||||
|
||||
@@ -11,7 +11,7 @@ public class Main
|
||||
{
|
||||
public static final String NAME = "World Handler";
|
||||
public static final String MODID = "worldhandler";
|
||||
public static final String MC_VERSION = "1.18.2";
|
||||
public static final String MC_VERSION = "1.19";
|
||||
public static final String MOD_VERSION = "3.1.2";
|
||||
public static final String URL = "https://minecraft.curseforge.com/projects/world-handler-command-gui";
|
||||
|
||||
|
||||
@@ -55,8 +55,8 @@ public class WorldHandler
|
||||
modEventBus.addListener(WorldHandler.this::registerClientReloadListeners);
|
||||
modEventBus.addListener(Content::createRegistry);
|
||||
modEventBus.addListener(Category::createRegistry);
|
||||
modEventBus.addGenericListener(Content.class, Content::register);
|
||||
modEventBus.addGenericListener(Category.class, Category::register);
|
||||
modEventBus.addListener(Content::register);
|
||||
modEventBus.addListener(Category::register);
|
||||
}
|
||||
});
|
||||
modLoadingContext.registerExtensionPoint(DisplayTest.class, () -> new DisplayTest(() -> "ANY", (remote, isServer) -> true));
|
||||
@@ -76,7 +76,7 @@ public class WorldHandler
|
||||
@SubscribeEvent
|
||||
public void registerCommands(RegisterCommandsEvent event)
|
||||
{
|
||||
CommandHelper.registerCommands(event.getDispatcher());
|
||||
CommandHelper.registerCommands(event.getDispatcher(), event.getBuildContext());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -15,7 +15,6 @@ import net.minecraft.advancements.critereon.MinMaxBounds;
|
||||
import net.minecraft.commands.arguments.EntityAnchorArgument.Anchor;
|
||||
import net.minecraft.core.Direction.Axis;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.Difficulty;
|
||||
import net.minecraft.world.scores.criteria.ObjectiveCriteria.RenderType;
|
||||
@@ -24,7 +23,7 @@ public class Arguments
|
||||
{
|
||||
public static PrimitiveArgument<Short> shortArg()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<Short>(string ->
|
||||
return PrimitiveArgument.builder(string ->
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -39,7 +38,7 @@ public class Arguments
|
||||
|
||||
public static PrimitiveArgument<Byte> byteArg()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<Byte>(string ->
|
||||
return PrimitiveArgument.builder(string ->
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -54,7 +53,7 @@ public class Arguments
|
||||
|
||||
public static PrimitiveArgument<Integer> intArg()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<Integer>(string ->
|
||||
return PrimitiveArgument.builder(string ->
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -69,7 +68,7 @@ public class Arguments
|
||||
|
||||
public static PrimitiveArgument<Float> floatArg()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<Float>(string ->
|
||||
return PrimitiveArgument.builder(string ->
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -84,7 +83,7 @@ public class Arguments
|
||||
|
||||
public static PrimitiveArgument<Double> doubleArg()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<Double>(string ->
|
||||
return PrimitiveArgument.builder(string ->
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -99,7 +98,7 @@ public class Arguments
|
||||
|
||||
public static PrimitiveArgument<Long> longArg()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<Long>(string ->
|
||||
return PrimitiveArgument.builder(string ->
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -114,7 +113,7 @@ public class Arguments
|
||||
|
||||
public static PrimitiveArgument<Boolean> boolArg()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<Boolean>(string ->
|
||||
return PrimitiveArgument.builder(string ->
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -129,14 +128,14 @@ public class Arguments
|
||||
|
||||
public static PrimitiveArgument<String> string()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<String>(Function.identity())
|
||||
return PrimitiveArgument.builder(Function.identity())
|
||||
.serializer(string -> string.isBlank() ? null : StringArgumentType.escapeIfRequired(string))
|
||||
.build();
|
||||
}
|
||||
|
||||
public static PrimitiveArgument<String> greedyString()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<String>(string -> string == null || string.isBlank() ? null : string)
|
||||
return PrimitiveArgument.builder(string -> string == null || string.isBlank() ? null : string)
|
||||
.serializer(string -> string.isBlank() ? null : string)
|
||||
.defaultOverride(string -> string == null || string.isBlank())
|
||||
.build();
|
||||
@@ -144,7 +143,7 @@ public class Arguments
|
||||
|
||||
public static PrimitiveArgument<String> word()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<String>(string -> string == null || string.isBlank() ? null : string)
|
||||
return PrimitiveArgument.builder(string -> string == null || string.isBlank() ? null : string)
|
||||
.serializer(string -> string.isBlank() ? null : string.replaceAll("[^0-9A-Za-z_\\-.+]", "_"))
|
||||
.defaultOverride(string -> string == null || string.isBlank())
|
||||
.build();
|
||||
@@ -152,7 +151,7 @@ public class Arguments
|
||||
|
||||
public static PrimitiveArgument<ResourceLocation> resourceLocation()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<ResourceLocation>(string -> string.isEmpty() ? null : new ResourceLocation(string)).build();
|
||||
return PrimitiveArgument.builder(string -> string.isEmpty() ? null : new ResourceLocation(string)).build();
|
||||
}
|
||||
|
||||
public static ItemArgument item()
|
||||
@@ -177,12 +176,12 @@ public class Arguments
|
||||
|
||||
public static PrimitiveArgument<Coordinate<Integer>> intCoordinate()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<Coordinate<Integer>>(Coordinate.Ints::parse).build();
|
||||
return PrimitiveArgument.<Coordinate<Integer>>builder(Coordinate.Ints::parse).build();
|
||||
}
|
||||
|
||||
public static PrimitiveArgument<Coordinate<Double>> doubleCoordinate()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<Coordinate<Double>>(Coordinate.Doubles::parse).build();
|
||||
return PrimitiveArgument.<Coordinate<Double>>builder(Coordinate.Doubles::parse).build();
|
||||
}
|
||||
|
||||
public static RangeArgument<Integer> intRange()
|
||||
@@ -232,7 +231,7 @@ public class Arguments
|
||||
|
||||
public static PrimitiveArgument<Gamemode> gamemode()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<Gamemode>(string -> EnumHelper.find(string, Gamemode.values(), Gamemode::toString)).build();
|
||||
return PrimitiveArgument.builder(string -> EnumHelper.find(string, Gamemode.values(), Gamemode::toString)).build();
|
||||
}
|
||||
|
||||
public static TimeArgument time()
|
||||
@@ -247,40 +246,40 @@ public class Arguments
|
||||
|
||||
public static PrimitiveArgument<Axis> axis()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<Axis>(string -> EnumHelper.find(string, Axis.values(), Axis::getName))
|
||||
return PrimitiveArgument.builder(string -> EnumHelper.find(string, Axis.values(), Axis::getName))
|
||||
.serializer(Axis::getName)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static PrimitiveArgument<Anchor> anchor()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<Anchor>(string -> EnumHelper.find(string, Anchor.values(), anchor -> anchor.name))
|
||||
return PrimitiveArgument.builder(string -> EnumHelper.find(string, Anchor.values(), anchor -> anchor.name))
|
||||
.serializer(anchor -> anchor.name)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static PrimitiveArgument<Difficulty> difficulty()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<Difficulty>(string -> EnumHelper.find(string, Difficulty.values(), Difficulty::getKey))
|
||||
return PrimitiveArgument.builder(string -> EnumHelper.find(string, Difficulty.values(), Difficulty::getKey))
|
||||
.serializer(Difficulty::getKey)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static PrimitiveArgument<RenderType> renderType()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<RenderType>(string -> EnumHelper.find(string, RenderType.values(), RenderType::getId))
|
||||
return PrimitiveArgument.builder(string -> EnumHelper.find(string, RenderType.values(), RenderType::getId))
|
||||
.serializer(RenderType::getId)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static PrimitiveArgument<PrimitiveArgument.Operation> operation()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<Operation>(string -> EnumHelper.find(string, Operation.values(), Operation::toString)).build();
|
||||
return PrimitiveArgument.builder(string -> EnumHelper.find(string, Operation.values(), Operation::toString)).build();
|
||||
}
|
||||
|
||||
public static PrimitiveArgument<Component> textComponent()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<Component>(string ->
|
||||
return PrimitiveArgument.<Component>builder(string ->
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -288,24 +287,24 @@ public class Arguments
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return new TextComponent(string);
|
||||
return Component.literal(string);
|
||||
}
|
||||
}).serializer(Component.Serializer::toJson).build();
|
||||
}
|
||||
|
||||
public static PrimitiveArgument<PrimitiveArgument.Relation> relation()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<Relation>(string -> EnumHelper.find(string, Relation.values(), Relation::toString)).build();
|
||||
return PrimitiveArgument.builder(string -> EnumHelper.find(string, Relation.values(), Relation::toString)).build();
|
||||
}
|
||||
|
||||
public static PrimitiveArgument<PrimitiveArgument.Type> type()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<Type>(string -> EnumHelper.find(string, Type.values(), Type::toString)).build();
|
||||
return PrimitiveArgument.builder(string -> EnumHelper.find(string, Type.values(), Type::toString)).build();
|
||||
}
|
||||
|
||||
public static PrimitiveArgument<PrimitiveArgument.Linkage> linkage()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<Linkage>(string -> EnumHelper.find(string, Linkage.values(), Linkage::toString)).build();
|
||||
return PrimitiveArgument.builder(string -> EnumHelper.find(string, Linkage.values(), Linkage::toString)).build();
|
||||
}
|
||||
|
||||
public static NbtPathArgument nbtPath()
|
||||
@@ -320,7 +319,7 @@ public class Arguments
|
||||
|
||||
public static PrimitiveArgument<String> criteria()
|
||||
{
|
||||
return new PrimitiveArgument.Builder<String>(string -> string == null || string.isBlank() ? null : string)
|
||||
return PrimitiveArgument.builder(string -> string == null || string.isBlank() ? null : string)
|
||||
.serializer(string -> string.isBlank() ? null : string.replaceAll(" ", "_"))
|
||||
.defaultOverride(string -> string == null || string.isBlank())
|
||||
.build();
|
||||
|
||||
@@ -9,14 +9,14 @@ import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import net.minecraft.commands.arguments.blocks.BlockStateParser;
|
||||
import exopandora.worldhandler.util.BlockPredicateParser;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class BlockPredicateArgument extends TagArgument
|
||||
{
|
||||
@@ -38,7 +38,7 @@ public class BlockPredicateArgument extends TagArgument
|
||||
{
|
||||
if(state != null)
|
||||
{
|
||||
this.resource = state.getBlock().getRegistryName();
|
||||
this.resource = ForgeRegistries.BLOCKS.getKey(state.getBlock());
|
||||
this.properties = propertiesToString(state.getValues());
|
||||
}
|
||||
else
|
||||
@@ -128,22 +128,12 @@ public class BlockPredicateArgument extends TagArgument
|
||||
{
|
||||
try
|
||||
{
|
||||
BlockStateParser parser = new BlockStateParser(new StringReader(predicate), true).parse(true);
|
||||
|
||||
if(parser.getState() != null)
|
||||
{
|
||||
this.resource = parser.getState().getBlock().getRegistryName();
|
||||
this.isTag = false;
|
||||
this.properties = propertiesToString(parser.getProperties());
|
||||
this.setTag(parser.getNbt());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.resource = parser.getTag().location();
|
||||
this.isTag = true;
|
||||
this.properties = parser.getVagueProperties();
|
||||
this.setTag(parser.getNbt());
|
||||
}
|
||||
BlockPredicateParser parser = new BlockPredicateParser(predicate);
|
||||
parser.parse(true);
|
||||
this.resource = parser.getResourceLocation();
|
||||
this.isTag = parser.isTag();
|
||||
this.properties = parser.getVagueProperties();
|
||||
this.setTag(parser.getNbt());
|
||||
}
|
||||
catch(CommandSyntaxException e)
|
||||
{
|
||||
@@ -205,14 +195,14 @@ public class BlockPredicateArgument extends TagArgument
|
||||
{
|
||||
return properties.entrySet().stream().map(entry ->
|
||||
{
|
||||
Property<?> property = entry.getKey();
|
||||
return new SimpleEntry<String, String>(property.getName(), getName(property, entry.getValue()));
|
||||
Property<?> property = entry.getKey();
|
||||
return new SimpleEntry<String, String>(property.getName(), getName(property, entry.getValue()));
|
||||
}).collect(Collectors.toMap(Entry::getKey, Entry::getValue));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T extends Comparable<T>> String getName(Property<T> key, Comparable<?> value)
|
||||
{
|
||||
return key.getName((T) value);
|
||||
}
|
||||
{
|
||||
return key.getName((T) value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,9 @@ package exopandora.worldhandler.builder.argument;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import net.minecraft.commands.arguments.blocks.BlockStateParser;
|
||||
import exopandora.worldhandler.util.BlockPredicateParser;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
@@ -63,9 +62,9 @@ public class BlockStateArgument extends TagArgument
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(@Nullable String block)
|
||||
public void deserialize(@Nullable String string)
|
||||
{
|
||||
if(block == null)
|
||||
if(string == null)
|
||||
{
|
||||
this.reset();
|
||||
}
|
||||
@@ -73,9 +72,13 @@ public class BlockStateArgument extends TagArgument
|
||||
{
|
||||
try
|
||||
{
|
||||
BlockStateParser parser = new BlockStateParser(new StringReader(block), false).parse(true);
|
||||
this.state = parser.getState();
|
||||
this.setTag(parser.getNbt());
|
||||
BlockPredicateParser parser = new BlockPredicateParser(string);
|
||||
parser.parse(false);
|
||||
parser.getBlock().ifPresentOrElse(block ->
|
||||
{
|
||||
this.state = block.defaultBlockState();
|
||||
this.setTag(parser.getNbt());
|
||||
}, this::reset);
|
||||
}
|
||||
catch(CommandSyntaxException e)
|
||||
{
|
||||
@@ -101,7 +104,7 @@ public class BlockStateArgument extends TagArgument
|
||||
|
||||
StringBuilder builder = new StringBuilder(this.state.toString());
|
||||
String block = this.state.getBlock().toString();
|
||||
builder.replace(0, block.length(), this.state.getBlock().getRegistryName().toString());
|
||||
builder.replace(0, block.length(), ForgeRegistries.BLOCKS.getKey(this.state.getBlock()).toString());
|
||||
String nbt = super.serialize();
|
||||
|
||||
if(nbt != null && this.state.hasBlockEntity())
|
||||
|
||||
@@ -55,7 +55,7 @@ public class DimensionArgument implements IDeserializableArgument
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.dimension.getRegistryName().toString();
|
||||
return this.dimension.location().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -54,7 +54,7 @@ public class EffectArgument implements IDeserializableArgument
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.effect.getRegistryName().toString();
|
||||
return ForgeRegistries.MOB_EFFECTS.getKey(this.effect).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -54,7 +54,7 @@ public class EnchantmentArgument implements IDeserializableArgument
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.enchantment.getRegistryName().toString();
|
||||
return ForgeRegistries.ENCHANTMENTS.getKey(this.enchantment).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,32 +16,32 @@ public class EntitySummonArgument implements IDeserializableArgument
|
||||
{
|
||||
private static final Map<String, ResourceLocation> ALIASES = Util.make(new HashMap<String, ResourceLocation>(), map ->
|
||||
{
|
||||
map.put("RedCow", EntityType.MOOSHROOM.getRegistryName());
|
||||
map.put("ChickenJockey", EntityType.CHICKEN.getRegistryName());
|
||||
map.put("Pigman", EntityType.PIGLIN.getRegistryName());
|
||||
map.put("ZombiePig", EntityType.PIGLIN.getRegistryName());
|
||||
map.put("ZombiePigman", EntityType.PIGLIN.getRegistryName());
|
||||
map.put("Dog", EntityType.WOLF.getRegistryName());
|
||||
map.put("Dragon", EntityType.ENDER_DRAGON.getRegistryName());
|
||||
map.put("SnowMan", EntityType.SNOW_GOLEM.getRegistryName());
|
||||
map.put("LavaCube", EntityType.MAGMA_CUBE.getRegistryName());
|
||||
map.put("MagmaSlime", EntityType.MAGMA_CUBE.getRegistryName());
|
||||
map.put("LavaSlime", EntityType.MAGMA_CUBE.getRegistryName());
|
||||
map.put("SpiderJockey", EntityType.SPIDER.getRegistryName());
|
||||
map.put("VillagerGolem", EntityType.IRON_GOLEM.getRegistryName());
|
||||
map.put("Ozelot", EntityType.OCELOT.getRegistryName());
|
||||
map.put("Kitty", EntityType.CAT.getRegistryName());
|
||||
map.put("Kitten", EntityType.CAT.getRegistryName());
|
||||
map.put("TESTIFICATE", EntityType.VILLAGER.getRegistryName());
|
||||
map.put("Octopus", EntityType.SQUID.getRegistryName());
|
||||
map.put("GlowingOctopus", EntityType.SQUID.getRegistryName());
|
||||
map.put("Exwife", EntityType.GHAST.getRegistryName());
|
||||
map.put("CommandMinecart", EntityType.COMMAND_BLOCK_MINECART.getRegistryName());
|
||||
map.put("Wizard", EntityType.EVOKER.getRegistryName());
|
||||
map.put("Johnny", EntityType.VINDICATOR.getRegistryName());
|
||||
map.put("BabyZombie", EntityType.ZOMBIE.getRegistryName());
|
||||
map.put("RedCow", ForgeRegistries.ENTITIES.getKey(EntityType.MOOSHROOM));
|
||||
map.put("ChickenJockey", ForgeRegistries.ENTITIES.getKey(EntityType.CHICKEN));
|
||||
map.put("Pigman", ForgeRegistries.ENTITIES.getKey(EntityType.PIGLIN));
|
||||
map.put("ZombiePig", ForgeRegistries.ENTITIES.getKey(EntityType.PIGLIN));
|
||||
map.put("ZombiePigman", ForgeRegistries.ENTITIES.getKey(EntityType.PIGLIN));
|
||||
map.put("Dog", ForgeRegistries.ENTITIES.getKey(EntityType.WOLF));
|
||||
map.put("Dragon", ForgeRegistries.ENTITIES.getKey(EntityType.ENDER_DRAGON));
|
||||
map.put("SnowMan", ForgeRegistries.ENTITIES.getKey(EntityType.SNOW_GOLEM));
|
||||
map.put("LavaCube", ForgeRegistries.ENTITIES.getKey(EntityType.MAGMA_CUBE));
|
||||
map.put("MagmaSlime", ForgeRegistries.ENTITIES.getKey(EntityType.MAGMA_CUBE));
|
||||
map.put("LavaSlime", ForgeRegistries.ENTITIES.getKey(EntityType.MAGMA_CUBE));
|
||||
map.put("SpiderJockey", ForgeRegistries.ENTITIES.getKey(EntityType.SPIDER));
|
||||
map.put("VillagerGolem", ForgeRegistries.ENTITIES.getKey(EntityType.IRON_GOLEM));
|
||||
map.put("Ozelot", ForgeRegistries.ENTITIES.getKey(EntityType.OCELOT));
|
||||
map.put("Kitty", ForgeRegistries.ENTITIES.getKey(EntityType.CAT));
|
||||
map.put("Kitten", ForgeRegistries.ENTITIES.getKey(EntityType.CAT));
|
||||
map.put("TESTIFICATE", ForgeRegistries.ENTITIES.getKey(EntityType.VILLAGER));
|
||||
map.put("Octopus", ForgeRegistries.ENTITIES.getKey(EntityType.SQUID));
|
||||
map.put("GlowingOctopus", ForgeRegistries.ENTITIES.getKey(EntityType.SQUID));
|
||||
map.put("Exwife", ForgeRegistries.ENTITIES.getKey(EntityType.GHAST));
|
||||
map.put("CommandMinecart", ForgeRegistries.ENTITIES.getKey(EntityType.COMMAND_BLOCK_MINECART));
|
||||
map.put("Wizard", ForgeRegistries.ENTITIES.getKey(EntityType.EVOKER));
|
||||
map.put("Johnny", ForgeRegistries.ENTITIES.getKey(EntityType.VINDICATOR));
|
||||
map.put("BabyZombie", ForgeRegistries.ENTITIES.getKey(EntityType.ZOMBIE));
|
||||
|
||||
ForgeRegistries.PROFESSIONS.getKeys().stream().forEach(profession -> map.put(profession.getPath(), EntityType.VILLAGER.getRegistryName()));
|
||||
ForgeRegistries.PROFESSIONS.getEntries().stream().forEach(profession -> map.put(profession.getKey().location().getPath(), profession.getKey().location()));
|
||||
});
|
||||
|
||||
private EntityType<?> entity;
|
||||
@@ -69,7 +69,7 @@ public class EntitySummonArgument implements IDeserializableArgument
|
||||
{
|
||||
EntityType<?> type = ForgeRegistries.ENTITIES.getValue(entity);
|
||||
|
||||
if(!ForgeRegistries.ENTITIES.getDefaultKey().equals(type.getRegistryName()) || type.getRegistryName().equals(entity))
|
||||
if(type != null)
|
||||
{
|
||||
this.set(type);
|
||||
}
|
||||
@@ -123,7 +123,7 @@ public class EntitySummonArgument implements IDeserializableArgument
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.entity.getRegistryName().toString();
|
||||
return ForgeRegistries.ENTITIES.getKey(this.entity).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,10 +2,9 @@ package exopandora.worldhandler.builder.argument;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import net.minecraft.commands.arguments.item.ItemParser;
|
||||
import exopandora.worldhandler.util.ItemPredicateParser;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
@@ -42,15 +41,23 @@ public class ItemArgument extends TagArgument
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(@Nullable String item)
|
||||
public void deserialize(@Nullable String string)
|
||||
{
|
||||
if(item != null)
|
||||
if(string != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
ItemParser parser = new ItemParser(new StringReader(item), false).parse();
|
||||
this.item = parser.getItem();
|
||||
this.setTag(parser.getNbt());
|
||||
ItemPredicateParser parser = new ItemPredicateParser(string);
|
||||
parser.parse(false);
|
||||
parser.getItem().ifPresentOrElse(item ->
|
||||
{
|
||||
this.item = item;
|
||||
this.setTag(parser.getNbt());
|
||||
}, () ->
|
||||
{
|
||||
this.item = null;
|
||||
this.setTag(null);
|
||||
});
|
||||
}
|
||||
catch(CommandSyntaxException e)
|
||||
{
|
||||
@@ -78,10 +85,10 @@ public class ItemArgument extends TagArgument
|
||||
|
||||
if(tag != null)
|
||||
{
|
||||
return this.item.getRegistryName().toString() + tag;
|
||||
return ForgeRegistries.ITEMS.getKey(this.item).toString() + tag;
|
||||
}
|
||||
|
||||
return this.item.getRegistryName().toString();
|
||||
return ForgeRegistries.ITEMS.getKey(this.item).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,12 +2,12 @@ package exopandora.worldhandler.builder.argument;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import net.minecraft.commands.arguments.item.ItemParser;
|
||||
import exopandora.worldhandler.util.ItemPredicateParser;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class ItemPredicateArgument extends TagArgument
|
||||
{
|
||||
@@ -28,7 +28,7 @@ public class ItemPredicateArgument extends TagArgument
|
||||
{
|
||||
if(item != null)
|
||||
{
|
||||
this.resource = item.getRegistryName();
|
||||
this.resource = ForgeRegistries.ITEMS.getKey(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -60,20 +60,11 @@ public class ItemPredicateArgument extends TagArgument
|
||||
{
|
||||
try
|
||||
{
|
||||
ItemParser parser = new ItemParser(new StringReader(predicate), true).parse();
|
||||
|
||||
if(parser.getItem() != null)
|
||||
{
|
||||
this.resource = parser.getItem().getRegistryName();
|
||||
this.setTag(parser.getNbt());
|
||||
this.isTag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.resource = parser.getTag().location();
|
||||
this.setTag(parser.getNbt());
|
||||
this.isTag = true;
|
||||
}
|
||||
ItemPredicateParser parser = new ItemPredicateParser(predicate);
|
||||
parser.parse(true);
|
||||
this.resource = parser.getResourceLocation();
|
||||
this.setTag(parser.getNbt());
|
||||
this.isTag = parser.isTag();
|
||||
}
|
||||
catch(CommandSyntaxException e)
|
||||
{
|
||||
|
||||
@@ -69,13 +69,18 @@ public class PrimitiveArgument<T> implements IDeserializableArgument
|
||||
return this.value == null;
|
||||
}
|
||||
|
||||
public static <T> Builder<T> builder(Function<String, T> deserializer)
|
||||
{
|
||||
return new Builder<T>(deserializer);
|
||||
}
|
||||
|
||||
public static class Builder<T>
|
||||
{
|
||||
private Function<T, Boolean> defaultOverride;
|
||||
private Function<String, T> deserializer;
|
||||
private Function<T, String> serializer;
|
||||
|
||||
public Builder(Function<String, T> deserializer)
|
||||
private Builder(Function<String, T> deserializer)
|
||||
{
|
||||
this.deserializer = deserializer;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class AttributeModifiersTag extends AbstractAttributeTag
|
||||
{
|
||||
@@ -23,7 +24,7 @@ public class AttributeModifiersTag extends AbstractAttributeTag
|
||||
if(entry.getValue() != 0)
|
||||
{
|
||||
CompoundTag attribute = new CompoundTag();
|
||||
String id = entry.getKey().getRegistryName().toString();
|
||||
String id = ForgeRegistries.ATTRIBUTES.getKey(entry.getKey()).toString();
|
||||
|
||||
attribute.putString("AttributeName", id);
|
||||
attribute.putDouble("Amount", entry.getValue() / 100);
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class AttributesTag extends AbstractAttributeTag
|
||||
{
|
||||
@@ -22,7 +23,7 @@ public class AttributesTag extends AbstractAttributeTag
|
||||
if(entry.getValue() != 0)
|
||||
{
|
||||
CompoundTag attribute = new CompoundTag();
|
||||
String id = entry.getKey().getRegistryName().toString();
|
||||
String id = ForgeRegistries.ATTRIBUTES.getKey(entry.getKey()).toString();
|
||||
|
||||
attribute.putString("Name", id);
|
||||
attribute.putDouble("Base", entry.getValue() / 100);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package exopandora.worldhandler.builder.argument.tag;
|
||||
|
||||
import exopandora.worldhandler.util.MutableTextComponent;
|
||||
import exopandora.worldhandler.util.UserStylableComponent;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
@@ -9,7 +9,7 @@ import net.minecraft.network.chat.Component;
|
||||
|
||||
public class DisplayTag implements ITagProvider
|
||||
{
|
||||
private MutableTextComponent name = new MutableTextComponent();
|
||||
private UserStylableComponent name = new UserStylableComponent();
|
||||
private Component[] lore = new Component[2];
|
||||
|
||||
@Override
|
||||
@@ -45,12 +45,12 @@ public class DisplayTag implements ITagProvider
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setName(MutableTextComponent name)
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
this.name.setText(name);
|
||||
}
|
||||
|
||||
public MutableTextComponent getName()
|
||||
public UserStylableComponent getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@@ -10,14 +10,15 @@ import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import exopandora.worldhandler.util.MutableTextComponent;
|
||||
import exopandora.worldhandler.util.NBTHelper;
|
||||
import exopandora.worldhandler.util.UserStylableComponent;
|
||||
import net.minecraft.nbt.ByteTag;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.IntTag;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.nbt.TagParser;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
@@ -34,7 +35,7 @@ public class EntityTag implements ITagProvider
|
||||
private boolean isBaby;
|
||||
private BlockState blockState;
|
||||
private AttributesTag attribute = new AttributesTag();
|
||||
private MutableTextComponent customName = new MutableTextComponent();
|
||||
private UserStylableComponent customName = new UserStylableComponent();
|
||||
private List<EntityTag> passengers = new ArrayList<EntityTag>();
|
||||
private Item[] armorItems = {Items.AIR, Items.AIR, Items.AIR, Items.AIR};
|
||||
private Item[] handItems = {Items.AIR, Items.AIR};
|
||||
@@ -86,8 +87,7 @@ public class EntityTag implements ITagProvider
|
||||
this.customName.setText(name);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MutableTextComponent getCustomName()
|
||||
public UserStylableComponent getCustomName()
|
||||
{
|
||||
return this.customName;
|
||||
}
|
||||
@@ -403,7 +403,10 @@ public class EntityTag implements ITagProvider
|
||||
NBTHelper.append(nbt, "HandItems", NBTHelper.serialize(this.handItems));
|
||||
NBTHelper.append(nbt, "BlockState", NBTHelper.serialize(this.blockState));
|
||||
|
||||
NBTHelper.append(nbt, "CustomName", this.customName.serialize());
|
||||
if(this.customName.getText() != null && !this.customName.getText().isEmpty())
|
||||
{
|
||||
NBTHelper.append(nbt, "CustomName", StringTag.valueOf(Component.Serializer.toJson(this.customName)));
|
||||
}
|
||||
|
||||
NBTHelper.append(nbt, this.potion);
|
||||
NBTHelper.append(nbt, this.attribute);
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
package exopandora.worldhandler.builder.argument.tag;
|
||||
|
||||
import exopandora.worldhandler.util.SignText;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import exopandora.worldhandler.util.UserStylableComponent;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class TextTag implements ITagProvider
|
||||
{
|
||||
private final int id;
|
||||
private final SignText text = new SignText();
|
||||
private final UserStylableComponent component = new UserStylableComponent();
|
||||
|
||||
public TextTag(int id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public SignText getText()
|
||||
public UserStylableComponent getComponent()
|
||||
{
|
||||
return this.text;
|
||||
return this.component;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -24,9 +28,10 @@ public class TextTag implements ITagProvider
|
||||
return "Text" + this.id;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Tag value()
|
||||
{
|
||||
return this.text.serialize();
|
||||
return StringTag.valueOf(Component.Serializer.toJson(this.component));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import exopandora.worldhandler.builder.impl.CloneCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.FillCommandBuilder;
|
||||
import exopandora.worldhandler.util.BlockHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.blocks.BlockInput;
|
||||
@@ -27,7 +28,7 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class CommandWH
|
||||
{
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext buildContext)
|
||||
{
|
||||
dispatcher.register(Commands.literal("wh")
|
||||
.then(Commands.literal("pos1")
|
||||
@@ -36,18 +37,18 @@ public class CommandWH
|
||||
.executes(context -> pos2(context.getSource())))
|
||||
.then(Commands.literal("fill")
|
||||
.requires(source -> source.hasPermission(2))
|
||||
.then(Commands.argument("block", BlockStateArgument.block())
|
||||
.then(Commands.argument("block", BlockStateArgument.block(buildContext))
|
||||
.executes(context -> fill(context.getSource(), BlockStateArgument.getBlock(context, "block")))))
|
||||
.then(Commands.literal("replace")
|
||||
.requires(source -> source.hasPermission(2))
|
||||
.then(Commands.argument("filter", BlockPredicateArgument.blockPredicate())
|
||||
.then(Commands.argument("block", BlockStateArgument.block())
|
||||
.then(Commands.argument("filter", BlockPredicateArgument.blockPredicate(buildContext))
|
||||
.then(Commands.argument("block", BlockStateArgument.block(buildContext))
|
||||
.executes(context -> replace(context.getSource(), getCommandNode("filter", context.getNodes()).getRange().get(context.getInput()), BlockStateArgument.getBlock(context, "block"))))))
|
||||
.then(Commands.literal("clone")
|
||||
.requires(source -> source.hasPermission(2))
|
||||
.executes(context -> clone(context.getSource(), "masked", null))
|
||||
.then(Commands.literal("filtered")
|
||||
.then(Commands.argument("filter", BlockPredicateArgument.blockPredicate())
|
||||
.then(Commands.argument("filter", BlockPredicateArgument.blockPredicate(buildContext))
|
||||
.executes(context -> clone(context.getSource(), "filter", getCommandNode("filter", context.getNodes()).getRange().get(context.getInput())))))
|
||||
.then(Commands.literal("masked")
|
||||
.executes(context -> clone(context.getSource(), "masked", null)))
|
||||
|
||||
@@ -15,7 +15,9 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource.BufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.client.event.ClientChatEvent;
|
||||
@@ -66,7 +68,7 @@ public class ClientEventHandler
|
||||
if(!Minecraft.getInstance().hasSingleplayerServer() && Minecraft.getInstance().player != null)
|
||||
{
|
||||
CommandDispatcher<CommandSourceStack> dispatcher = new CommandDispatcher<CommandSourceStack>();
|
||||
CommandHelper.registerCommands(dispatcher);
|
||||
CommandHelper.registerCommands(dispatcher, new CommandBuildContext(RegistryAccess.BUILTIN.get()));
|
||||
|
||||
StringReader command = new StringReader(event.getMessage());
|
||||
command.skip();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package exopandora.worldhandler.gui;
|
||||
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class DummyScreen extends Screen
|
||||
{
|
||||
@@ -9,7 +9,7 @@ public class DummyScreen extends Screen
|
||||
|
||||
public DummyScreen(Runnable runnable)
|
||||
{
|
||||
super(TextComponent.EMPTY);
|
||||
super(Component.empty());
|
||||
this.runnable = runnable;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,17 +14,19 @@ import exopandora.worldhandler.usercontent.UsercontentConfig;
|
||||
import exopandora.worldhandler.usercontent.UsercontentLoader;
|
||||
import exopandora.worldhandler.usercontent.model.JsonTab;
|
||||
import exopandora.worldhandler.util.RegistryHelper;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.event.RegistryEvent.Register;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import net.minecraftforge.registries.NewRegistryEvent;
|
||||
import net.minecraftforge.registries.RegisterEvent;
|
||||
import net.minecraftforge.registries.RegistryBuilder;
|
||||
|
||||
public class Category extends ForgeRegistryEntry<Category>
|
||||
public class Category
|
||||
{
|
||||
public static IForgeRegistry<Category> REGISTRY;
|
||||
public static final ResourceKey<Registry<Category>> REGISTRY_KEY = ResourceKey.createRegistryKey(new ResourceLocation(Main.MODID, "category"));
|
||||
|
||||
private final List<ResourceLocation> contents;
|
||||
|
||||
@@ -79,39 +81,41 @@ public class Category extends ForgeRegistryEntry<Category>
|
||||
public static void createRegistry(NewRegistryEvent event)
|
||||
{
|
||||
event.create(new RegistryBuilder<Category>()
|
||||
.setType(Category.class)
|
||||
.setName(new ResourceLocation(Main.MODID + "_category"))
|
||||
.setName(REGISTRY_KEY.location())
|
||||
.disableSaving()
|
||||
.disableSync(), registry -> REGISTRY = registry);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void register(Register<Category> event)
|
||||
public static void register(RegisterEvent event)
|
||||
{
|
||||
RegistryHelper.register(event.getRegistry(), "main", new Category("main", "containers", "multiplayer"));
|
||||
RegistryHelper.register(event.getRegistry(), "entities", new Category("summon", "butcher"));
|
||||
RegistryHelper.register(event.getRegistry(), "items", new Category("custom_item", "enchantment", "recipes"));
|
||||
RegistryHelper.register(event.getRegistry(), "blocks", new Category("edit_blocks", "sign_editor", "note_editor"));
|
||||
RegistryHelper.register(event.getRegistry(), "world", new Category("world", "gamerules"));
|
||||
RegistryHelper.register(event.getRegistry(), "player", new Category("player", "experience", "advancements"));
|
||||
RegistryHelper.register(event.getRegistry(), "scoreboard", new Category("scoreboard_objectives", "scoreboard_teams", "scoreboard_players"));
|
||||
|
||||
for(UsercontentConfig config : UsercontentLoader.CONFIGS)
|
||||
if(event.getRegistryKey().equals(REGISTRY_KEY))
|
||||
{
|
||||
if(config.getContent().getGui() != null && config.getContent().getGui().getTab() != null)
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "main", () -> new Category("main", "containers", "multiplayer"));
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "entities", () -> new Category("summon", "butcher"));
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "items", () -> new Category("custom_item", "enchantment", "recipes"));
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "blocks", () -> new Category("edit_blocks", "sign_editor", "note_editor"));
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "world", () -> new Category("world", "gamerules"));
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "player", () -> new Category("player", "experience", "advancements"));
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "scoreboard", () -> new Category("scoreboard_objectives", "scoreboard_teams", "scoreboard_players"));
|
||||
|
||||
for(UsercontentConfig config : UsercontentLoader.CONFIGS)
|
||||
{
|
||||
Category.registerCategory(event.getRegistry(), config.getId(), config.getContent().getGui().getTab());
|
||||
if(config.getContent().getGui() != null && config.getContent().getGui().getTab() != null)
|
||||
{
|
||||
Category.registerCategory(event, config.getId(), config.getContent().getGui().getTab());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void registerCategory(IForgeRegistry<Category> registry, String id, JsonTab tab)
|
||||
private static void registerCategory(RegisterEvent event, String id, JsonTab tab)
|
||||
{
|
||||
if(tab.getCategory() != null && !tab.getCategory().isEmpty())
|
||||
{
|
||||
if(!Categories.isRegistered(tab.getCategory()))
|
||||
{
|
||||
RegistryHelper.register(registry, tab.getCategory(), new Category(id));
|
||||
RegistryHelper.register(event, REGISTRY_KEY, tab.getCategory(), () -> new Category(id));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ import net.minecraft.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.components.Widget;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class GuiWorldHandler extends Container
|
||||
{
|
||||
@@ -219,7 +219,7 @@ public class GuiWorldHandler extends Container
|
||||
stack.pushPose();
|
||||
stack.translate(versionWidth - 12, versionHeight + 12, 0);
|
||||
|
||||
this.renderTooltip(stack, new TextComponent(label), 0, 0);
|
||||
this.renderTooltip(stack, Component.literal(label), 0, 0);
|
||||
|
||||
stack.popPose();
|
||||
}
|
||||
|
||||
@@ -32,91 +32,95 @@ import exopandora.worldhandler.gui.content.impl.ContentSignEditor;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentSummon;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentUsercontent;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentWorldInfo;
|
||||
import exopandora.worldhandler.usercontent.UsercontentConfig;
|
||||
import exopandora.worldhandler.usercontent.UsercontentLoader;
|
||||
import exopandora.worldhandler.util.RegistryHelper;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.event.RegistryEvent.Register;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import net.minecraftforge.registries.NewRegistryEvent;
|
||||
import net.minecraftforge.registries.RegisterEvent;
|
||||
import net.minecraftforge.registries.RegistryBuilder;
|
||||
|
||||
public abstract class Content extends ForgeRegistryEntry<Content> implements IContent
|
||||
public abstract class Content implements IContent
|
||||
{
|
||||
public static IForgeRegistry<Content> REGISTRY;
|
||||
public static final ResourceKey<Registry<Content>> REGISTRY_KEY = ResourceKey.createRegistryKey(new ResourceLocation(Main.MODID, "content"));
|
||||
|
||||
@SubscribeEvent
|
||||
public static void createRegistry(NewRegistryEvent event)
|
||||
{
|
||||
event.create(new RegistryBuilder<Content>()
|
||||
.setType(Content.class)
|
||||
.setName(new ResourceLocation(Main.MODID + "_content"))
|
||||
.setName(REGISTRY_KEY.location())
|
||||
.disableSaving()
|
||||
.disableSync(), registry -> REGISTRY = registry);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void register(Register<Content> event)
|
||||
public static void register(RegisterEvent event)
|
||||
{
|
||||
//MAIN
|
||||
RegistryHelper.register(event.getRegistry(), "main", new ContentMain());
|
||||
RegistryHelper.register(event.getRegistry(), "containers", new ContentContainers());
|
||||
RegistryHelper.register(event.getRegistry(), "multiplayer", new ContentMultiplayer());
|
||||
|
||||
//ENTITIES
|
||||
RegistryHelper.register(event.getRegistry(), "summon", new ContentSummon());
|
||||
RegistryHelper.register(event.getRegistry(), "butcher", new ContentButcher());
|
||||
RegistryHelper.register(event.getRegistry(), "butcher_settings", new ContentButcherSettings());
|
||||
RegistryHelper.register(event.getRegistry(), "butcher_presets", new ContentButcherPresets());
|
||||
|
||||
//ITEMS
|
||||
RegistryHelper.register(event.getRegistry(), "custom_item", new ContentCustomItem());
|
||||
RegistryHelper.register(event.getRegistry(), "enchantment", new ContentEnchantment());
|
||||
RegistryHelper.register(event.getRegistry(), "recipes", new ContentRecipes());
|
||||
|
||||
//BLOCKS
|
||||
RegistryHelper.register(event.getRegistry(), "edit_blocks", new ContentEditBlocks());
|
||||
RegistryHelper.register(event.getRegistry(), "sign_editor", new ContentSignEditor());
|
||||
RegistryHelper.register(event.getRegistry(), "note_editor", new ContentNoteEditor());
|
||||
|
||||
//WORLD
|
||||
RegistryHelper.register(event.getRegistry(), "world", new ContentWorldInfo());
|
||||
RegistryHelper.register(event.getRegistry(), "gamerules", new ContentGamerules());
|
||||
|
||||
//PLAYER
|
||||
RegistryHelper.register(event.getRegistry(), "player", new ContentPlayer());
|
||||
RegistryHelper.register(event.getRegistry(), "experience", new ContentExperience());
|
||||
RegistryHelper.register(event.getRegistry(), "advancements", new ContentAdvancements());
|
||||
|
||||
//SCOREBOARD
|
||||
RegistryHelper.register(event.getRegistry(), "scoreboard_objectives", new ContentScoreboardObjectives());
|
||||
RegistryHelper.register(event.getRegistry(), "scoreboard_teams", new ContentScoreboardTeams());
|
||||
RegistryHelper.register(event.getRegistry(), "scoreboard_players", new ContentScoreboardPlayers());
|
||||
|
||||
//MISC
|
||||
RegistryHelper.register(event.getRegistry(), "change_world", new ContentChangeWorld());
|
||||
RegistryHelper.register(event.getRegistry(), "continue", new ContentContinue());
|
||||
|
||||
//NO CATEGORY
|
||||
RegistryHelper.register(event.getRegistry(), "potions", new ContentPotions());
|
||||
RegistryHelper.register(event.getRegistry(), "command_stack", new ContentCommandStack());
|
||||
RegistryHelper.register(event.getRegistry(), "settings", new ContentSettings());
|
||||
|
||||
//USERCONTENT
|
||||
UsercontentLoader.CONFIGS.forEach(config -> Content.registerContent(event.getRegistry(), config));
|
||||
}
|
||||
|
||||
private static void registerContent(IForgeRegistry<Content> registry, UsercontentConfig config)
|
||||
{
|
||||
try
|
||||
if(event.getRegistryKey().equals(REGISTRY_KEY))
|
||||
{
|
||||
RegistryHelper.register(registry, config.getId(), new ContentUsercontent(config));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
throw new RuntimeException("Error loading js for usercontent: " + config.getId(), e);
|
||||
//MAIN
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "main", () -> new ContentMain());
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "containers", () -> new ContentContainers());
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "multiplayer", () -> new ContentMultiplayer());
|
||||
|
||||
//ENTITIES
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "summon", () -> new ContentSummon());
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "butcher", () -> new ContentButcher());
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "butcher_settings", () -> new ContentButcherSettings());
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "butcher_presets", () -> new ContentButcherPresets());
|
||||
|
||||
//ITEMS
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "custom_item", () -> new ContentCustomItem());
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "enchantment", () -> new ContentEnchantment());
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "recipes", () -> new ContentRecipes());
|
||||
|
||||
//BLOCKS
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "edit_blocks", () -> new ContentEditBlocks());
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "sign_editor", () -> new ContentSignEditor());
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "note_editor", () -> new ContentNoteEditor());
|
||||
|
||||
//WORLD
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "world", () -> new ContentWorldInfo());
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "gamerules", () -> new ContentGamerules());
|
||||
|
||||
//PLAYER
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "player", () -> new ContentPlayer());
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "experience", () -> new ContentExperience());
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "advancements", () -> new ContentAdvancements());
|
||||
|
||||
//SCOREBOARD
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "scoreboard_objectives", () -> new ContentScoreboardObjectives());
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "scoreboard_teams", () -> new ContentScoreboardTeams());
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "scoreboard_players", () -> new ContentScoreboardPlayers());
|
||||
|
||||
//MISC
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "change_world", () -> new ContentChangeWorld());
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "continue", () -> new ContentContinue());
|
||||
|
||||
//NO CATEGORY
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "potions", () -> new ContentPotions());
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "command_stack", () -> new ContentCommandStack());
|
||||
RegistryHelper.register(event, REGISTRY_KEY, "settings", () -> new ContentSettings());
|
||||
|
||||
//USERCONTENT
|
||||
UsercontentLoader.CONFIGS.forEach(config ->
|
||||
{
|
||||
RegistryHelper.register(event, REGISTRY_KEY, config.getId(), () ->
|
||||
{
|
||||
try
|
||||
{
|
||||
return new ContentUsercontent(config);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
throw new RuntimeException("Error loading js for usercontent: " + config.getId(), e);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,9 +23,8 @@ import exopandora.worldhandler.util.AdvancementHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
||||
public class ContentAdvancements extends Content
|
||||
{
|
||||
@@ -59,7 +58,7 @@ public class ContentAdvancements extends Content
|
||||
@Override
|
||||
public MutableComponent toTooltip(Advancement item)
|
||||
{
|
||||
return new TextComponent(item.getId().toString());
|
||||
return Component.literal(item.getId().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,21 +87,21 @@ public class ContentAdvancements extends Content
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(new GuiButtonList<Mode>(x + 118, y, Arrays.asList(Mode.values()), 114, 20, container, new ILogicMapped<Mode>()
|
||||
{
|
||||
@Override
|
||||
public MutableComponent translate(Mode mode)
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.advancements." + mode.toString());
|
||||
return Component.translatable("gui.worldhandler.advancements." + mode.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent toTooltip(Mode mode)
|
||||
{
|
||||
return new TextComponent(mode.toString());
|
||||
return Component.literal(mode.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,15 +117,15 @@ public class ContentAdvancements extends Content
|
||||
}
|
||||
}));
|
||||
|
||||
container.add(new GuiButtonBase(x + 118, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.advancements.grant"), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.advancements.grant"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderAdvancement, this.mode.getGrant());
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.advancements.revoke"), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.advancements.revoke"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderAdvancement, this.mode.getRevoke());
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.actions.reset").withStyle(ChatFormatting.RED), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, Component.translatable("gui.worldhandler.actions.reset").withStyle(ChatFormatting.RED), () ->
|
||||
{
|
||||
ActionHelper.open(Contents.CONTINUE.withBuilder(this.builderAdvancement, AdvancementCommandBuilder.Label.REVOKE_EVERYTHING));
|
||||
}));
|
||||
@@ -141,13 +140,13 @@ public class ContentAdvancements extends Content
|
||||
@Override
|
||||
public MutableComponent getTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.title.player.advancements");
|
||||
return Component.translatable("gui.worldhandler.title.player.advancements");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent getTabTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.tab.player.advancements");
|
||||
return Component.translatable("gui.worldhandler.tab.player.advancements");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,8 +20,8 @@ import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
@@ -45,7 +45,7 @@ public class ContentButcher extends Content
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.radiusField = new GuiTextFieldTooltip(x + 58, y, 114, 20, new TranslatableComponent("gui.worldhandler.butcher.radius"));
|
||||
this.radiusField = new GuiTextFieldTooltip(x + 58, y, 114, 20, Component.translatable("gui.worldhandler.butcher.radius"));
|
||||
this.radiusField.setFilter(string ->
|
||||
{
|
||||
if(string == null)
|
||||
@@ -90,25 +90,25 @@ public class ContentButcher extends Content
|
||||
{
|
||||
GuiButtonBase slaughter;
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(this.radiusField);
|
||||
container.add(new GuiButtonBase(x + 58, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.butcher.configure"), () ->
|
||||
container.add(new GuiButtonBase(x + 58, y + 24, 114, 20, Component.translatable("gui.worldhandler.butcher.configure"), () ->
|
||||
{
|
||||
ActionHelper.open(Contents.BUTCHER_SETTINGS);
|
||||
}));
|
||||
|
||||
boolean enabled = this.radius != null && !this.radius.isEmpty();
|
||||
|
||||
container.add(slaughter = new GuiButtonBase(x + 58, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.butcher.slaughter"), () ->
|
||||
container.add(slaughter = new GuiButtonBase(x + 58, y + 48, 114, 20, Component.translatable("gui.worldhandler.butcher.slaughter"), () ->
|
||||
{
|
||||
Collection<EntityType<?>> entities = Config.getButcher().getEntities().stream().map(ForgeRegistries.ENTITIES::getValue).filter(Predicates.notNull()).collect(Collectors.toList());
|
||||
ContentButcher.slaughter(container.getPlayer(), entities, Integer.parseInt(this.radius));
|
||||
}));
|
||||
slaughter.active = enabled && !Config.getButcher().getEntities().isEmpty();
|
||||
|
||||
container.add(slaughter = new GuiButtonBase(x + 58, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.butcher.presets"), () ->
|
||||
container.add(slaughter = new GuiButtonBase(x + 58, y + 72, 114, 20, Component.translatable("gui.worldhandler.butcher.presets"), () ->
|
||||
{
|
||||
ActionHelper.open(Contents.BUTCHER_PRESETS.withBuilder(this.builderKill, KillCommandBuilder.Label.KILL_TARGETS).withRadius(Double.parseDouble(this.radius)));
|
||||
}));
|
||||
@@ -133,7 +133,7 @@ public class ContentButcher extends Content
|
||||
{
|
||||
KillCommandBuilder kill = new KillCommandBuilder();
|
||||
kill.targets().setSelectorType(SelectorTypes.ALL_ENTITIES);
|
||||
kill.targets().setType(entity.getRegistryName());
|
||||
kill.targets().setType(ForgeRegistries.ENTITIES.getKey(entity));
|
||||
kill.targets().setDistanceMax(radius);
|
||||
CommandHelper.sendCommand(username, kill, KillCommandBuilder.Label.KILL_TARGETS);
|
||||
}
|
||||
@@ -162,13 +162,13 @@ public class ContentButcher extends Content
|
||||
@Override
|
||||
public MutableComponent getTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.title.entities.butcher");
|
||||
return Component.translatable("gui.worldhandler.title.entities.butcher");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent getTabTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.tab.entities.butcher");
|
||||
return Component.translatable("gui.worldhandler.tab.entities.butcher");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,7 +6,7 @@ import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
@@ -37,25 +37,25 @@ public class ContentButcherPresets extends ContentChild
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(new GuiButtonBase(x + 58, y, 114, 20, new TranslatableComponent("gui.worldhandler.butcher.presets.passive_mobs"), () ->
|
||||
container.add(new GuiButtonBase(x + 58, y, 114, 20, Component.translatable("gui.worldhandler.butcher.presets.passive_mobs"), () ->
|
||||
{
|
||||
ContentButcher.slaughter(container.getPlayer(), ForgeRegistries.ENTITIES.getValues().stream().filter(entity -> !MobCategory.MONSTER.equals(entity.getCategory()) && !MobCategory.MISC.equals(entity.getCategory())).collect(Collectors.toList()), this.radius);
|
||||
ActionHelper.open(this.getParentContent());
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 58, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.butcher.presets.hostile_mobs"), () ->
|
||||
container.add(new GuiButtonBase(x + 58, y + 24, 114, 20, Component.translatable("gui.worldhandler.butcher.presets.hostile_mobs"), () ->
|
||||
{
|
||||
ContentButcher.slaughter(container.getPlayer(), ForgeRegistries.ENTITIES.getValues().stream().filter(entity -> MobCategory.MONSTER.equals(entity.getCategory())).collect(Collectors.toList()), this.radius);
|
||||
ActionHelper.open(this.getParentContent());
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 58, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.butcher.presets.players"), () ->
|
||||
container.add(new GuiButtonBase(x + 58, y + 48, 114, 20, Component.translatable("gui.worldhandler.butcher.presets.players"), () ->
|
||||
{
|
||||
ContentButcher.slaughter(container.getPlayer(), ForgeRegistries.ENTITIES.getValues().stream().filter(entity -> EntityType.PLAYER.equals(entity)).collect(Collectors.toList()), this.radius);
|
||||
ActionHelper.open(this.getParentContent());
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 58, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.butcher.presets.entities"), () ->
|
||||
container.add(new GuiButtonBase(x + 58, y + 72, 114, 20, Component.translatable("gui.worldhandler.butcher.presets.entities"), () ->
|
||||
{
|
||||
ContentButcher.slaughter(container.getPlayer(), ForgeRegistries.ENTITIES.getValues().stream().filter(entity -> MobCategory.MISC.equals(entity.getCategory()) && !EntityType.PLAYER.equals(entity)).collect(Collectors.toList()), this.radius);
|
||||
ActionHelper.open(this.getParentContent());
|
||||
|
||||
@@ -11,9 +11,8 @@ import exopandora.worldhandler.gui.widget.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.widget.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
@@ -32,19 +31,19 @@ public class ContentButcherSettings extends ContentChild
|
||||
@Override
|
||||
public MutableComponent translate(EntityType<?> item)
|
||||
{
|
||||
return new TranslatableComponent(item.getDescriptionId());
|
||||
return Component.translatable(item.getDescriptionId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent toTooltip(EntityType<?> item)
|
||||
{
|
||||
return new TextComponent(item.getRegistryName().toString());
|
||||
return Component.literal(ForgeRegistries.ENTITIES.getKey(item).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(EntityType<?> item)
|
||||
{
|
||||
ContentButcherSettings.this.entity = item.getRegistryName();
|
||||
ContentButcherSettings.this.entity = ForgeRegistries.ENTITIES.getKey(item);
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
@@ -70,15 +69,15 @@ public class ContentButcherSettings extends ContentChild
|
||||
GuiButtonBase button1;
|
||||
GuiButtonBase button2;
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.generic.enable"), () ->
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.generic.enable"), () ->
|
||||
{
|
||||
Config.CLIENT.getButcher().addEntity(this.entity);
|
||||
container.initButtons();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.generic.disable"), () ->
|
||||
container.add(button2 = new GuiButtonBase(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.generic.disable"), () ->
|
||||
{
|
||||
Config.CLIENT.getButcher().removeEntity(this.entity);
|
||||
container.initButtons();
|
||||
|
||||
@@ -18,24 +18,24 @@ import net.minecraft.client.gui.screens.multiplayer.SafetyScreen;
|
||||
import net.minecraft.client.gui.screens.worldselection.SelectWorldScreen;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.multiplayer.resolver.ServerAddress;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
public class ContentChangeWorld extends ContentChild
|
||||
{
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(new GuiButtonBase(x + 116 / 2, y + 24, 232 / 2, 20, new TranslatableComponent("gui.worldhandler.change_world.singleplayer"), () ->
|
||||
container.add(new GuiButtonBase(x + 116 / 2, y + 24, 232 / 2, 20, Component.translatable("gui.worldhandler.change_world.singleplayer"), () ->
|
||||
{
|
||||
IConnection connection = ContentChangeWorld.disconnect();
|
||||
Minecraft.getInstance().setScreen(new SelectWorldScreen(new DummyScreen(() -> ContentChangeWorld.reconnect(connection))));
|
||||
}));
|
||||
|
||||
container.add(new GuiButtonBase(x + 116 / 2, y + 48, 232 / 2, 20, new TranslatableComponent("gui.worldhandler.change_world.multiplayer"), () ->
|
||||
container.add(new GuiButtonBase(x + 116 / 2, y + 48, 232 / 2, 20, Component.translatable("gui.worldhandler.change_world.multiplayer"), () ->
|
||||
{
|
||||
IConnection connection = ContentChangeWorld.disconnect();
|
||||
DummyScreen dummy = new DummyScreen(() -> ContentChangeWorld.reconnect(connection));
|
||||
@@ -61,7 +61,7 @@ public class ContentChangeWorld extends ContentChild
|
||||
{
|
||||
String folder = Minecraft.getInstance().getSingleplayerServer().storageSource.getLevelId();
|
||||
Minecraft.getInstance().level.disconnect();
|
||||
Minecraft.getInstance().clearLevel(new GenericDirtMessageScreen(new TranslatableComponent("menu.savingLevel")));
|
||||
Minecraft.getInstance().clearLevel(new GenericDirtMessageScreen(Component.translatable("menu.savingLevel")));
|
||||
|
||||
return new IntegratedConnection(folder);
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class ContentChangeWorld extends ContentChild
|
||||
}
|
||||
else if(connection instanceof IntegratedConnection integrated)
|
||||
{
|
||||
Minecraft.getInstance().loadLevel(integrated.getFolder());;
|
||||
Minecraft.getInstance().createWorldOpenFlows().loadLevel(new TitleScreen(), integrated.getFolder());
|
||||
Minecraft.getInstance().mouseHandler.grabMouse();
|
||||
}
|
||||
else if(connection instanceof DedicatedConnection dedicated)
|
||||
@@ -101,6 +101,6 @@ public class ContentChangeWorld extends ContentChild
|
||||
@Override
|
||||
public MutableComponent getTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.title.change_world");
|
||||
return Component.translatable("gui.worldhandler.title.change_world");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,18 +27,18 @@ import exopandora.worldhandler.util.ActionHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class ContentCommandStack extends ContentChild
|
||||
{
|
||||
private static final int HEAD_LENGTH = 1;
|
||||
private static final int TAIL_LENGTH = 2;
|
||||
private static final TextComponent PLUS = new TextComponent("+");
|
||||
private static final TextComponent MINUS = new TextComponent("-");
|
||||
private static final Component PLUS = Component.literal("+");
|
||||
private static final Component MINUS = Component.literal("-");
|
||||
|
||||
private final List<GuiTextFieldTooltip> textfields = new ArrayList<GuiTextFieldTooltip>();
|
||||
private int scroll;
|
||||
@@ -60,14 +60,14 @@ public class ContentCommandStack extends ContentChild
|
||||
this.activatorRail.setBlockState(Blocks.ACTIVATOR_RAIL.defaultBlockState());
|
||||
this.builderCommandStack.nbt().addTagProvider(this.activatorRail);
|
||||
|
||||
EntityTag redstoneBlock = new EntityTag(EntityType.FALLING_BLOCK.getRegistryName());
|
||||
EntityTag redstoneBlock = new EntityTag(ForgeRegistries.ENTITIES.getKey(EntityType.FALLING_BLOCK));
|
||||
redstoneBlock.setTime(1);
|
||||
redstoneBlock.setBlockState(Blocks.REDSTONE_BLOCK.defaultBlockState());
|
||||
this.activatorRail.addPassenger(redstoneBlock);
|
||||
|
||||
this.addCommand(0);
|
||||
|
||||
EntityTag blockRemover = new EntityTag(EntityType.COMMAND_BLOCK_MINECART.getRegistryName());
|
||||
EntityTag blockRemover = new EntityTag(ForgeRegistries.ENTITIES.getKey(EntityType.COMMAND_BLOCK_MINECART));
|
||||
SetBlockCommandBuilder builder = new SetBlockCommandBuilder();
|
||||
builder.pos().setX(new Coordinate.Ints(Coordinate.Type.RELATIVE));
|
||||
builder.pos().setY(new Coordinate.Ints(-2, Coordinate.Type.RELATIVE));
|
||||
@@ -88,10 +88,10 @@ public class ContentCommandStack extends ContentChild
|
||||
blockRemover.setCommand(builder.toCommand(SetBlockCommandBuilder.Label.DESTROY, false));
|
||||
this.activatorRail.addPassenger(blockRemover);
|
||||
|
||||
EntityTag entityRemover = new EntityTag(EntityType.COMMAND_BLOCK_MINECART.getRegistryName());
|
||||
EntityTag entityRemover = new EntityTag(ForgeRegistries.ENTITIES.getKey(EntityType.COMMAND_BLOCK_MINECART));
|
||||
KillCommandBuilder kill = new KillCommandBuilder();
|
||||
kill.targets().setSelectorType(SelectorTypes.ALL_ENTITIES);
|
||||
kill.targets().setType(EntityType.COMMAND_BLOCK_MINECART.getRegistryName());
|
||||
kill.targets().setType(ForgeRegistries.ENTITIES.getKey(EntityType.COMMAND_BLOCK_MINECART));
|
||||
kill.targets().setDistanceMax(1.0D);
|
||||
entityRemover.setCommand(kill.toCommand(KillCommandBuilder.Label.KILL_TARGETS, false));
|
||||
this.activatorRail.addPassenger(entityRemover);
|
||||
@@ -112,7 +112,7 @@ public class ContentCommandStack extends ContentChild
|
||||
{
|
||||
int command = index + this.scroll;
|
||||
|
||||
GuiTextFieldTooltip textfield = new GuiTextFieldTooltip(x, y + 24 * index, 232 - 48, 20, new TranslatableComponent("gui.worldhandler.command_stack.command_n", command + 1));
|
||||
GuiTextFieldTooltip textfield = new GuiTextFieldTooltip(x, y + 24 * index, 232 - 48, 20, Component.translatable("gui.worldhandler.command_stack.command_n", command + 1));
|
||||
textfield.setFilter(Predicates.notNull());
|
||||
textfield.setValue(command < this.getCommandCount() ? this.getCommand(command) : null);
|
||||
textfield.setResponder(text ->
|
||||
@@ -130,8 +130,8 @@ public class ContentCommandStack extends ContentChild
|
||||
GuiButtonBase buttonScrollUp;
|
||||
GuiButtonBase buttonScrollDown;
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
this.iterate(index ->
|
||||
{
|
||||
@@ -139,17 +139,17 @@ public class ContentCommandStack extends ContentChild
|
||||
GuiButtonBase buttonDown;
|
||||
GuiButtonBase buttonRemove;
|
||||
|
||||
container.add(buttonUp = new GuiButtonIcon(x + 232 - 20 - 24, y + index * 24 - 1, 20, 10, EnumIcon.ARROW_UP, new TranslatableComponent("gui.worldhandler.actions.move_up"), () ->
|
||||
container.add(buttonUp = new GuiButtonIcon(x + 232 - 20 - 24, y + index * 24 - 1, 20, 10, EnumIcon.ARROW_UP, Component.translatable("gui.worldhandler.actions.move_up"), () ->
|
||||
{
|
||||
this.swapCommands(index + this.scroll, index + this.scroll - 1);
|
||||
container.init();
|
||||
}));
|
||||
container.add(buttonDown = new GuiButtonIcon(x + 232 - 20 - 24, y + index * 24 + 11, 20, 10, EnumIcon.ARROW_DOWN, new TranslatableComponent("gui.worldhandler.actions.move_down"), () ->
|
||||
container.add(buttonDown = new GuiButtonIcon(x + 232 - 20 - 24, y + index * 24 + 11, 20, 10, EnumIcon.ARROW_DOWN, Component.translatable("gui.worldhandler.actions.move_down"), () ->
|
||||
{
|
||||
this.swapCommands(index + this.scroll, index + this.scroll + 1);
|
||||
container.init();
|
||||
}));
|
||||
container.add(buttonRemove = new GuiButtonTooltip(x + 232 - 20, y + index * 24 - 1, 20, 10, MINUS, new TranslatableComponent("gui.worldhandler.command_stack.remove_command"), () ->
|
||||
container.add(buttonRemove = new GuiButtonTooltip(x + 232 - 20, y + index * 24 - 1, 20, 10, MINUS, Component.translatable("gui.worldhandler.command_stack.remove_command"), () ->
|
||||
{
|
||||
int pos = index + this.scroll;
|
||||
this.removeCommand(pos);
|
||||
@@ -161,7 +161,7 @@ public class ContentCommandStack extends ContentChild
|
||||
|
||||
container.init();
|
||||
}));
|
||||
container.add(new GuiButtonTooltip(x + 232 - 20, y + index * 24 + 11, 20, 10, PLUS, new TranslatableComponent("gui.worldhandler.command_stack.insert_command"), () ->
|
||||
container.add(new GuiButtonTooltip(x + 232 - 20, y + index * 24 + 11, 20, 10, PLUS, Component.translatable("gui.worldhandler.command_stack.insert_command"), () ->
|
||||
{
|
||||
int pos = index + this.scroll + 1;
|
||||
this.addCommand(pos);
|
||||
@@ -180,16 +180,16 @@ public class ContentCommandStack extends ContentChild
|
||||
buttonDown.active = index + this.scroll + 1 < this.getCommandCount();
|
||||
});
|
||||
|
||||
container.add(this.buttonCopy = new GuiButtonBase(x, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.command_stack.copy_command"), () ->
|
||||
container.add(this.buttonCopy = new GuiButtonBase(x, y + 72, 114, 20, Component.translatable("gui.worldhandler.command_stack.copy_command"), () ->
|
||||
{
|
||||
Minecraft.getInstance().keyboardHandler.setClipboard(this.builderCommandStack.toCommand(SummonCommandBuilder.Label.SUMMON_POS_NBT, false));
|
||||
}));
|
||||
container.add(buttonScrollUp = new GuiButtonIcon(x + 118, y + 72, 56, 20, EnumIcon.ARROW_UP, new TranslatableComponent("gui.worldhandler.actions.move_up"), () ->
|
||||
container.add(buttonScrollUp = new GuiButtonIcon(x + 118, y + 72, 56, 20, EnumIcon.ARROW_UP, Component.translatable("gui.worldhandler.actions.move_up"), () ->
|
||||
{
|
||||
this.scrollUp();
|
||||
container.init();
|
||||
}));
|
||||
container.add(buttonScrollDown = new GuiButtonIcon(x + 118 + 60, y + 72, 54, 20, EnumIcon.ARROW_DOWN, new TranslatableComponent("gui.worldhandler.actions.move_down"), () ->
|
||||
container.add(buttonScrollDown = new GuiButtonIcon(x + 118 + 60, y + 72, 54, 20, EnumIcon.ARROW_DOWN, Component.translatable("gui.worldhandler.actions.move_down"), () ->
|
||||
{
|
||||
this.scrollDown();
|
||||
container.init();
|
||||
@@ -265,7 +265,7 @@ public class ContentCommandStack extends ContentChild
|
||||
|
||||
private void addCommand(int index)
|
||||
{
|
||||
this.activatorRail.addPassenger(index + HEAD_LENGTH, new EntityTag(EntityType.COMMAND_BLOCK_MINECART.getRegistryName()));
|
||||
this.activatorRail.addPassenger(index + HEAD_LENGTH, new EntityTag(ForgeRegistries.ENTITIES.getKey(EntityType.COMMAND_BLOCK_MINECART)));
|
||||
}
|
||||
|
||||
private void removeCommand(int index)
|
||||
@@ -299,6 +299,6 @@ public class ContentCommandStack extends ContentChild
|
||||
@Override
|
||||
public MutableComponent getTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.title.command_stack");
|
||||
return Component.translatable("gui.worldhandler.title.command_stack");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.BlockHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
@@ -28,7 +28,7 @@ public class ContentContainers extends Content
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(new GuiButtonBase(x, y + 96, 232, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 232, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(new GuiButtonBase(x + 24, y, 208, 20, Blocks.CRAFTING_TABLE.getName(), () -> this.placeBlock(container.getPlayer(), Blocks.CRAFTING_TABLE)));
|
||||
container.add(new GuiButtonBase(x + 24, y + 24, 208, 20, Blocks.ENDER_CHEST.getName(), () -> this.placeBlock(container.getPlayer(), Blocks.ENDER_CHEST)));
|
||||
@@ -116,13 +116,13 @@ public class ContentContainers extends Content
|
||||
@Override
|
||||
public MutableComponent getTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.title.containers");
|
||||
return Component.translatable("gui.worldhandler.title.containers");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent getTabTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.tab.containers");
|
||||
return Component.translatable("gui.worldhandler.tab.containers");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,7 +9,7 @@ import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class ContentContinue extends ContentChild
|
||||
{
|
||||
@@ -50,16 +50,16 @@ public class ContentContinue extends ContentChild
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(this.commandField);
|
||||
container.add(new GuiButtonBase(x + 116 / 2, y + 36, 116, 20, new TranslatableComponent("gui.worldhandler.generic.yes").withStyle(ChatFormatting.RED), () ->
|
||||
container.add(new GuiButtonBase(x + 116 / 2, y + 36, 116, 20, Component.translatable("gui.worldhandler.generic.yes").withStyle(ChatFormatting.RED), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builder, this.label, this.special);
|
||||
ActionHelper.open(this.getParentContent());
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 116 / 2, y + 60, 116, 20, new TranslatableComponent("gui.worldhandler.generic.no"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 116 / 2, y + 60, 116, 20, Component.translatable("gui.worldhandler.generic.no"), () -> ActionHelper.back(this)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,9 +28,8 @@ import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import exopandora.worldhandler.util.TextUtils;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
@@ -91,7 +90,7 @@ public class ContentCustomItem extends Content
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.itemField = new GuiTextFieldTooltip(x + 118, y, 114, 20, new TranslatableComponent("gui.worldhandler.items.custom_item.start.item_id"));
|
||||
this.itemField = new GuiTextFieldTooltip(x + 118, y, 114, 20, Component.translatable("gui.worldhandler.items.custom_item.start.item_id"));
|
||||
this.itemField.setFilter(Predicates.<String>notNull());
|
||||
this.itemField.setValue(this.item);
|
||||
this.itemField.setResponder(text ->
|
||||
@@ -101,21 +100,21 @@ public class ContentCustomItem extends Content
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
this.itemLore1Field = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.items.custom_item.start.lore_1"));
|
||||
this.itemLore1Field = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.items.custom_item.start.lore_1"));
|
||||
this.itemLore1Field.setFilter(Predicates.<String>notNull());
|
||||
this.itemLore1Field.setText(this.display.getLore1());
|
||||
this.itemLore1Field.setResponder(text ->
|
||||
{
|
||||
this.display.setLore1(new TextComponent(text));
|
||||
this.display.setLore1(Component.literal(text));
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
this.itemLore2Field = new GuiTextFieldTooltip(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.items.custom_item.start.lore_2"));
|
||||
this.itemLore2Field = new GuiTextFieldTooltip(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.items.custom_item.start.lore_2"));
|
||||
this.itemLore2Field.setFilter(Predicates.<String>notNull());
|
||||
this.itemLore2Field.setText(this.display.getLore2());
|
||||
this.itemLore2Field.setResponder(text ->
|
||||
{
|
||||
this.display.setLore2(new TextComponent(text));
|
||||
this.display.setLore2(Component.literal(text));
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
@@ -133,13 +132,13 @@ public class ContentCustomItem extends Content
|
||||
@Override
|
||||
public MutableComponent translate(Enchantment item)
|
||||
{
|
||||
return new TranslatableComponent(item.getDescriptionId());
|
||||
return Component.translatable(item.getDescriptionId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent toTooltip(Enchantment item)
|
||||
{
|
||||
return new TextComponent(item.getRegistryName().toString());
|
||||
return Component.literal(ForgeRegistries.ENCHANTMENTS.getKey(item).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -151,7 +150,7 @@ public class ContentCustomItem extends Content
|
||||
@Override
|
||||
public GuiButtonBase onRegister(int x, int y, int width, int height, MutableComponent text, Enchantment item, ActionHandler actionHandler)
|
||||
{
|
||||
return new GuiSlider(x, y, width, height, 0, Config.getSliders().getMaxItemEnchantment(), 0, container, new LogicSliderSimple(item.getRegistryName().toString(), text, value ->
|
||||
return new GuiSlider(x, y, width, height, 0, Config.getSliders().getMaxItemEnchantment(), 0, container, new LogicSliderSimple(ForgeRegistries.ENCHANTMENTS.getKey(item).toString(), text, value ->
|
||||
{
|
||||
ContentCustomItem.this.enchantments.set(item, value.shortValue());
|
||||
}));
|
||||
@@ -178,13 +177,13 @@ public class ContentCustomItem extends Content
|
||||
@Override
|
||||
public MutableComponent translate(Attribute attribute)
|
||||
{
|
||||
return new TranslatableComponent(attribute.getDescriptionId());
|
||||
return Component.translatable(attribute.getDescriptionId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent toTooltip(Attribute attribute)
|
||||
{
|
||||
return new TextComponent(attribute.getRegistryName().toString());
|
||||
return Component.literal(ForgeRegistries.ATTRIBUTES.getKey(attribute).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -229,20 +228,20 @@ public class ContentCustomItem extends Content
|
||||
GuiButtonBase button5;
|
||||
GuiButtonBase button6;
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(button1 = new GuiButtonBase(x, y, 114, 20, new TranslatableComponent("gui.worldhandler.items.custom_item.start"), () ->
|
||||
container.add(button1 = new GuiButtonBase(x, y, 114, 20, Component.translatable("gui.worldhandler.items.custom_item.start"), () ->
|
||||
{
|
||||
this.page = Page.START;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.items.custom_item.enchantment"), () ->
|
||||
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, Component.translatable("gui.worldhandler.items.custom_item.enchantment"), () ->
|
||||
{
|
||||
this.page = Page.ENCHANT;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.items.custom_item.attributes"), () ->
|
||||
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, Component.translatable("gui.worldhandler.items.custom_item.attributes"), () ->
|
||||
{
|
||||
this.page = Page.ATTRIBUTES;
|
||||
container.init();
|
||||
@@ -284,13 +283,13 @@ public class ContentCustomItem extends Content
|
||||
button3.active = false;
|
||||
}
|
||||
|
||||
if(!this.builderCutomItem.needsCommandBlock(GiveCommandBuilder.Label.GIVE, false) && !this.display.getName().isSpecial())
|
||||
if(!this.builderCutomItem.needsCommandBlock(GiveCommandBuilder.Label.GIVE, false) && !this.display.getName().isStyled())
|
||||
{
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.items.custom_item.custom_item"), () -> this.giveItem(container.getPlayer())));
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, Component.translatable("gui.worldhandler.items.custom_item.custom_item"), () -> this.giveItem(container.getPlayer())));
|
||||
}
|
||||
else
|
||||
{
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.actions.place_command_block"), () -> this.giveItem(container.getPlayer())));
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, Component.translatable("gui.worldhandler.actions.place_command_block"), () -> this.giveItem(container.getPlayer())));
|
||||
}
|
||||
|
||||
button4.active = this.builderCutomItem.item().hasValue();
|
||||
@@ -298,7 +297,7 @@ public class ContentCustomItem extends Content
|
||||
|
||||
private void giveItem(String player)
|
||||
{
|
||||
CommandHelper.sendCommand(player, this.builderCutomItem, GiveCommandBuilder.Label.GIVE, this.display.getName().isSpecial());
|
||||
CommandHelper.sendCommand(player, this.builderCutomItem, GiveCommandBuilder.Label.GIVE, this.display.getName().isStyled());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -332,13 +331,13 @@ public class ContentCustomItem extends Content
|
||||
@Override
|
||||
public MutableComponent getTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.title.items.custom_item");
|
||||
return Component.translatable("gui.worldhandler.title.items.custom_item");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent getTabTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.tab.items.custom_item");
|
||||
return Component.translatable("gui.worldhandler.tab.items.custom_item");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,9 +7,9 @@ import com.google.common.base.Predicates;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import exopandora.worldhandler.builder.impl.CloneCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.CloneCommandBuilder.Label;
|
||||
import exopandora.worldhandler.builder.impl.FillCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.WHCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.CloneCommandBuilder.Label;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
@@ -23,9 +23,8 @@ import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.BlockHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
public class ContentEditBlocks extends Content
|
||||
{
|
||||
@@ -103,7 +102,7 @@ public class ContentEditBlocks extends Content
|
||||
this.z2Field.setValue("Z2: " + BlockHelper.pos2().getZ());
|
||||
this.z2Field.setResponder(text -> BlockHelper.pos2().setZ(this.parseCoordinate(text)));
|
||||
|
||||
this.block1Field = new GuiTextFieldTooltip(x + 118, y, 114, 20, Page.FILL.equals(this.page) ? new TranslatableComponent("gui.worldhandler.edit_blocks.fill.block_id_to_fill") : new TranslatableComponent("gui.worldhandler.edit_blocks.replace.block_id_replace"));
|
||||
this.block1Field = new GuiTextFieldTooltip(x + 118, y, 114, 20, Page.FILL.equals(this.page) ? Component.translatable("gui.worldhandler.edit_blocks.fill.block_id_to_fill") : Component.translatable("gui.worldhandler.edit_blocks.replace.block_id_replace"));
|
||||
this.block1Field.setFilter(Predicates.notNull());
|
||||
this.block1Field.setValue(this.block1);
|
||||
this.block1Field.setResponder(text ->
|
||||
@@ -113,7 +112,7 @@ public class ContentEditBlocks extends Content
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
this.block2Field = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.edit_blocks.replace.block_id_place"));
|
||||
this.block2Field = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.edit_blocks.replace.block_id_place"));
|
||||
this.block2Field.setFilter(Predicates.notNull());
|
||||
this.block2Field.setValue(this.block2);
|
||||
this.block2Field.setResponder(text ->
|
||||
@@ -123,7 +122,7 @@ public class ContentEditBlocks extends Content
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
this.filterField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.edit_blocks.clone.filter"));
|
||||
this.filterField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.edit_blocks.clone.filter"));
|
||||
this.filterField.setFilter(Predicates.notNull());
|
||||
this.filterField.setValue(this.filter);
|
||||
this.filterField.setResponder(text ->
|
||||
@@ -142,25 +141,25 @@ public class ContentEditBlocks extends Content
|
||||
GuiButtonBase button3;
|
||||
GuiButtonBase button4;
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(button1 = new GuiButtonBase(x, y, 114, 20, new TranslatableComponent("gui.worldhandler.edit_blocks.coordinates"), () ->
|
||||
container.add(button1 = new GuiButtonBase(x, y, 114, 20, Component.translatable("gui.worldhandler.edit_blocks.coordinates"), () ->
|
||||
{
|
||||
this.page = Page.COORDINATES;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.edit_blocks.fill"), () ->
|
||||
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, Component.translatable("gui.worldhandler.edit_blocks.fill"), () ->
|
||||
{
|
||||
this.page = Page.FILL;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.edit_blocks.replace"), () ->
|
||||
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, Component.translatable("gui.worldhandler.edit_blocks.replace"), () ->
|
||||
{
|
||||
this.page = Page.REPLACE;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.edit_blocks.clone"), () ->
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, Component.translatable("gui.worldhandler.edit_blocks.clone"), () ->
|
||||
{
|
||||
this.page = Page.CLONE;
|
||||
container.init();
|
||||
@@ -200,7 +199,7 @@ public class ContentEditBlocks extends Content
|
||||
xOffset2 = 0;
|
||||
|
||||
container.add(this.block1Field);
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.edit_blocks.fill"), () ->
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 72, 114, 20, Component.translatable("gui.worldhandler.edit_blocks.fill"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderFill, FillCommandBuilder.Label.FILL);
|
||||
}));
|
||||
@@ -218,7 +217,7 @@ public class ContentEditBlocks extends Content
|
||||
|
||||
container.add(this.block1Field);
|
||||
container.add(this.block2Field);
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.edit_blocks.replace"), () ->
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 72, 114, 20, Component.translatable("gui.worldhandler.edit_blocks.replace"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderFill, FillCommandBuilder.Label.REPLACE);
|
||||
}));
|
||||
@@ -240,7 +239,7 @@ public class ContentEditBlocks extends Content
|
||||
}
|
||||
else
|
||||
{
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 24, 114, 20, TextComponent.EMPTY, null));
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 24, 114, 20, Component.empty(), null));
|
||||
button1.active = false;
|
||||
}
|
||||
|
||||
@@ -249,13 +248,13 @@ public class ContentEditBlocks extends Content
|
||||
@Override
|
||||
public MutableComponent translate(Mask mask)
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.edit_blocks.clone.mode." + mask.toString());
|
||||
return Component.translatable("gui.worldhandler.edit_blocks.clone.mode." + mask.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent toTooltip(Mask mask)
|
||||
{
|
||||
return new TextComponent(mask.toString());
|
||||
return Component.literal(mask.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -272,7 +271,7 @@ public class ContentEditBlocks extends Content
|
||||
}
|
||||
}));
|
||||
|
||||
container.add(button2 = new GuiButtonBase(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.edit_blocks.clone"), () ->
|
||||
container.add(button2 = new GuiButtonBase(x + 118, y + 72, 114, 20, Component.translatable("gui.worldhandler.edit_blocks.clone"), () ->
|
||||
{
|
||||
System.out.println(this.builderClone.toCommand(this.mask.getLabel(), false));
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderClone, this.mask.getLabel());
|
||||
@@ -284,13 +283,13 @@ public class ContentEditBlocks extends Content
|
||||
}
|
||||
}
|
||||
|
||||
container.add(new GuiButtonBase(x + 118, y + yOffset1, width1, 20, new TranslatableComponent("gui.worldhandler.edit_blocks.pos.set_pos_1"), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + yOffset1, width1, 20, Component.translatable("gui.worldhandler.edit_blocks.pos.set_pos_1"), () ->
|
||||
{
|
||||
BlockHelper.pos1().set(BlockHelper.getFocusedBlockPos());
|
||||
this.updatePositions();
|
||||
container.init();
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118 + xOffset2, y + yOffset2, width2, 20, new TranslatableComponent("gui.worldhandler.edit_blocks.pos.set_pos_2"), () ->
|
||||
container.add(new GuiButtonBase(x + 118 + xOffset2, y + yOffset2, width2, 20, Component.translatable("gui.worldhandler.edit_blocks.pos.set_pos_2"), () ->
|
||||
{
|
||||
BlockHelper.pos2().set(BlockHelper.getFocusedBlockPos());
|
||||
this.updatePositions();
|
||||
@@ -399,13 +398,13 @@ public class ContentEditBlocks extends Content
|
||||
@Override
|
||||
public MutableComponent getTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.title.blocks.edit_blocks");
|
||||
return Component.translatable("gui.worldhandler.title.blocks.edit_blocks");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent getTabTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.tab.blocks.edit_blocks");
|
||||
return Component.translatable("gui.worldhandler.tab.blocks.edit_blocks");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,9 +17,8 @@ import exopandora.worldhandler.gui.widget.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
@@ -42,13 +41,13 @@ public class ContentEnchantment extends Content
|
||||
@Override
|
||||
public MutableComponent translate(Enchantment enchantment)
|
||||
{
|
||||
return new TranslatableComponent(enchantment.getDescriptionId());
|
||||
return Component.translatable(enchantment.getDescriptionId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent toTooltip(Enchantment enchantment)
|
||||
{
|
||||
return new TextComponent(enchantment.getRegistryName().toString());
|
||||
return Component.literal(ForgeRegistries.ENCHANTMENTS.getKey(enchantment).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,15 +77,15 @@ public class ContentEnchantment extends Content
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(new GuiSlider(x + 118, y + 24, 114, 20, 1, this.builderEnchantment.enchantment().getEnchantment().getMaxLevel(), 1, container, new LogicSliderSimple("enchantment", new TranslatableComponent("gui.worldhandler.items.enchantment.level"), value ->
|
||||
container.add(new GuiSlider(x + 118, y + 24, 114, 20, 1, this.builderEnchantment.enchantment().getEnchantment().getMaxLevel(), 1, container, new LogicSliderSimple("enchantment", Component.translatable("gui.worldhandler.items.enchantment.level"), value ->
|
||||
{
|
||||
this.builderEnchantment.level().set(value.intValue());
|
||||
})));
|
||||
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.items.enchantment.enchant"), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.items.enchantment.enchant"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderEnchantment, EnchantCommandBuilder.Label.ENCHANT_LEVEL);
|
||||
}));
|
||||
@@ -101,13 +100,13 @@ public class ContentEnchantment extends Content
|
||||
@Override
|
||||
public MutableComponent getTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.title.items.enchantment");
|
||||
return Component.translatable("gui.worldhandler.title.items.enchantment");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent getTabTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.tab.items.enchantment");
|
||||
return Component.translatable("gui.worldhandler.tab.items.enchantment");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,8 +13,8 @@ import exopandora.worldhandler.gui.widget.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.widget.button.LogicSliderSimple;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
public class ContentExperience extends Content
|
||||
{
|
||||
@@ -47,27 +47,27 @@ public class ContentExperience extends Content
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(new GuiSlider(x + 116 / 2, y, 114, 20, 0, Config.getSliders().getMaxExperience(), 0, container, new LogicSliderSimple("experience", new TranslatableComponent("gui.worldhandler.title.player.experience"), value ->
|
||||
container.add(new GuiSlider(x + 116 / 2, y, 114, 20, 0, Config.getSliders().getMaxExperience(), 0, container, new LogicSliderSimple("experience", Component.translatable("gui.worldhandler.title.player.experience"), value ->
|
||||
{
|
||||
this.builderExperience.amount().set(value);
|
||||
})));
|
||||
|
||||
container.add(this.buttonAdd = new GuiButtonBase(x + 116 / 2, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.actions.add"), () ->
|
||||
container.add(this.buttonAdd = new GuiButtonBase(x + 116 / 2, y + 24, 114, 20, Component.translatable("gui.worldhandler.actions.add"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderExperience, ExperienceCommandBuilder.Label.ADD_LEVELS);
|
||||
container.init();
|
||||
}));
|
||||
container.add(this.buttonRemove = new GuiButtonBase(x + 116 / 2, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.actions.remove"), () ->
|
||||
container.add(this.buttonRemove = new GuiButtonBase(x + 116 / 2, y + 48, 114, 20, Component.translatable("gui.worldhandler.actions.remove"), () ->
|
||||
{
|
||||
ExperienceCommandBuilder builder = new ExperienceCommandBuilder();
|
||||
builder.targets().setTarget(this.builderExperience.targets().getTarget());
|
||||
builder.amount().set(-this.builderExperience.amount().get());
|
||||
CommandHelper.sendCommand(container.getPlayer(), builder, ExperienceCommandBuilder.Label.ADD_LEVELS);
|
||||
}));
|
||||
container.add(new GuiButtonTooltip(x + 116 / 2, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.actions.reset"), new TranslatableComponent("gui.worldhandler.actions.set_to_0"), () ->
|
||||
container.add(new GuiButtonTooltip(x + 116 / 2, y + 72, 114, 20, Component.translatable("gui.worldhandler.actions.reset"), Component.translatable("gui.worldhandler.actions.set_to_0"), () ->
|
||||
{
|
||||
ExperienceCommandBuilder builder = new ExperienceCommandBuilder();
|
||||
builder.amount().set(0);
|
||||
@@ -99,13 +99,13 @@ public class ContentExperience extends Content
|
||||
@Override
|
||||
public MutableComponent getTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.title.player.experience");
|
||||
return Component.translatable("gui.worldhandler.title.player.experience");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent getTabTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.tab.player.experience");
|
||||
return Component.translatable("gui.worldhandler.tab.player.experience");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,9 +23,8 @@ import exopandora.worldhandler.gui.widget.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.GameRules.GameRuleTypeVisitor;
|
||||
|
||||
@@ -48,7 +47,7 @@ public class ContentGamerules extends Content
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.valueField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.generic.value"));
|
||||
this.valueField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.generic.value"));
|
||||
this.valueField.setFilter(Predicates.notNull());
|
||||
this.valueField.setValue(this.value);
|
||||
this.valueField.moveCursorToEnd();
|
||||
@@ -74,13 +73,13 @@ public class ContentGamerules extends Content
|
||||
@Override
|
||||
public MutableComponent translate(String rule)
|
||||
{
|
||||
return new TranslatableComponent("gamerule." + rule);
|
||||
return Component.translatable("gamerule." + rule);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent toTooltip(String rule)
|
||||
{
|
||||
return new TextComponent(rule);
|
||||
return Component.literal(rule);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,16 +119,16 @@ public class ContentGamerules extends Content
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
if(this.booleanValue)
|
||||
{
|
||||
container.add(new GuiButtonBase(x + 118, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.generic.enable"), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.generic.enable"), () ->
|
||||
{
|
||||
this.setGameRule(container.getPlayer(), String.valueOf(true));
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.generic.disable"), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.generic.disable"), () ->
|
||||
{
|
||||
this.setGameRule(container.getPlayer(), String.valueOf(false));
|
||||
}));
|
||||
@@ -137,7 +136,7 @@ public class ContentGamerules extends Content
|
||||
else
|
||||
{
|
||||
container.add(this.valueField);
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.actions.perform"), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.actions.perform"), () ->
|
||||
{
|
||||
this.setGameRule(container.getPlayer(), this.value);
|
||||
}));
|
||||
@@ -179,13 +178,13 @@ public class ContentGamerules extends Content
|
||||
@Override
|
||||
public MutableComponent getTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.title.world.gamerules");
|
||||
return Component.translatable("gui.worldhandler.title.world.gamerules");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent getTabTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.tab.world.gamerules");
|
||||
return Component.translatable("gui.worldhandler.tab.world.gamerules");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,45 +14,44 @@ import exopandora.worldhandler.util.ActionHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.OptionsScreen;
|
||||
import net.minecraft.client.gui.screens.packs.PackSelectionScreen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
public class ContentMain extends Content
|
||||
{
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(new GuiButtonIcon(x, y, 22, 20, EnumIcon.TIME_DAWN, new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.time", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.time.dawn", Config.getSettings().getDawn())), ActionHelper::timeDawn));
|
||||
container.add(new GuiButtonIcon(x + 26, y, 22, 20, EnumIcon.TIME_NOON, new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.time", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.time.noon", Config.getSettings().getNoon())), ActionHelper::timeNoon));
|
||||
container.add(new GuiButtonIcon(x + 26 * 2, y, 22, 20, EnumIcon.TIME_SUNSET, new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.time", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.time.sunset", Config.getSettings().getSunset())), ActionHelper::timeSunset));
|
||||
container.add(new GuiButtonIcon(x + 26 * 3, y, 23, 20, EnumIcon.TIME_MIDNIGHT, new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.time", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.time.midnight", Config.getSettings().getMidnight())), ActionHelper::timeMidnight));
|
||||
container.add(new GuiButtonIcon(x + 26 * 4, y, 24, 20, EnumIcon.DIFFICULTY_PEACEFUL, new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.difficulty", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.difficulty.peaceful")), ActionHelper::difficultyPeaceful));
|
||||
container.add(new GuiButtonIcon(x + 26 * 5 + 2, y, 23, 20, EnumIcon.DIFFICULTY_EASY, new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.difficulty", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.difficulty.easy")), ActionHelper::difficultyEasy));
|
||||
container.add(new GuiButtonIcon(x + 26 * 6 + 2, y, 22, 20, EnumIcon.DIFFICULTY_NORMAL, new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.difficulty", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.difficulty.normal")), ActionHelper::difficultyNormal));
|
||||
container.add(new GuiButtonIcon(x + 26 * 7 + 2, y, 22, 20, EnumIcon.DIFFICULTY_HARD, new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.difficulty", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.difficulty.hard")), ActionHelper::difficultyHard));
|
||||
container.add(new GuiButtonIcon(x + 26 * 8 + 2, y, 22, 20, EnumIcon.SETTINGS, new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.settings"), () -> ActionHelper.open(Contents.SETTINGS)));
|
||||
container.add(new GuiButtonIcon(x, y, 22, 20, EnumIcon.TIME_DAWN, Component.translatable("gui.worldhandler.shortcuts.tooltip.time", Component.translatable("gui.worldhandler.shortcuts.tooltip.time.dawn", Config.getSettings().getDawn())), ActionHelper::timeDawn));
|
||||
container.add(new GuiButtonIcon(x + 26, y, 22, 20, EnumIcon.TIME_NOON, Component.translatable("gui.worldhandler.shortcuts.tooltip.time", Component.translatable("gui.worldhandler.shortcuts.tooltip.time.noon", Config.getSettings().getNoon())), ActionHelper::timeNoon));
|
||||
container.add(new GuiButtonIcon(x + 26 * 2, y, 22, 20, EnumIcon.TIME_SUNSET, Component.translatable("gui.worldhandler.shortcuts.tooltip.time", Component.translatable("gui.worldhandler.shortcuts.tooltip.time.sunset", Config.getSettings().getSunset())), ActionHelper::timeSunset));
|
||||
container.add(new GuiButtonIcon(x + 26 * 3, y, 23, 20, EnumIcon.TIME_MIDNIGHT, Component.translatable("gui.worldhandler.shortcuts.tooltip.time", Component.translatable("gui.worldhandler.shortcuts.tooltip.time.midnight", Config.getSettings().getMidnight())), ActionHelper::timeMidnight));
|
||||
container.add(new GuiButtonIcon(x + 26 * 4, y, 24, 20, EnumIcon.DIFFICULTY_PEACEFUL, Component.translatable("gui.worldhandler.shortcuts.tooltip.difficulty", Component.translatable("gui.worldhandler.shortcuts.tooltip.difficulty.peaceful")), ActionHelper::difficultyPeaceful));
|
||||
container.add(new GuiButtonIcon(x + 26 * 5 + 2, y, 23, 20, EnumIcon.DIFFICULTY_EASY, Component.translatable("gui.worldhandler.shortcuts.tooltip.difficulty", Component.translatable("gui.worldhandler.shortcuts.tooltip.difficulty.easy")), ActionHelper::difficultyEasy));
|
||||
container.add(new GuiButtonIcon(x + 26 * 6 + 2, y, 22, 20, EnumIcon.DIFFICULTY_NORMAL, Component.translatable("gui.worldhandler.shortcuts.tooltip.difficulty", Component.translatable("gui.worldhandler.shortcuts.tooltip.difficulty.normal")), ActionHelper::difficultyNormal));
|
||||
container.add(new GuiButtonIcon(x + 26 * 7 + 2, y, 22, 20, EnumIcon.DIFFICULTY_HARD, Component.translatable("gui.worldhandler.shortcuts.tooltip.difficulty", Component.translatable("gui.worldhandler.shortcuts.tooltip.difficulty.hard")), ActionHelper::difficultyHard));
|
||||
container.add(new GuiButtonIcon(x + 26 * 8 + 2, y, 22, 20, EnumIcon.SETTINGS, Component.translatable("gui.worldhandler.shortcuts.tooltip.settings"), () -> ActionHelper.open(Contents.SETTINGS)));
|
||||
|
||||
container.add(new GuiButtonIcon(x, y + 24, 22, 20, EnumIcon.WEATHER_SUN, new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.weather", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.weather.clear")), ActionHelper::weatherClear));
|
||||
container.add(new GuiButtonIcon(x + 26, y + 24, 22, 20, EnumIcon.WEATHER_RAIN, new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.weather", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.weather.rainy")), ActionHelper::weatherRain));
|
||||
container.add(new GuiButtonIcon(x + 26 * 2, y + 24, 22, 20, EnumIcon.WEATHER_STORM, new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.weather", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.weather.thunder")), ActionHelper::weatherThunder));
|
||||
container.add(new GuiButtonIcon(x + 26 * 3, y + 24, 23, 20, EnumIcon.POTION, new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.potions"), () -> ActionHelper.open(Contents.POTIONS)));
|
||||
container.add(new GuiButtonIcon(x + 26 * 4, y + 24, 24, 20, EnumIcon.COMMAND_STACK, new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.command_stack"), () -> ActionHelper.open(Contents.COMMAND_STACK)));
|
||||
container.add(new GuiButtonIcon(x + 26 * 5 + 2, y + 24, 23, 20, EnumIcon.GAMEMODE_SURVIVAL, new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.gamemode", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.gamemode.survival")), ActionHelper::gamemodeSurvival));
|
||||
container.add(new GuiButtonIcon(x + 26 * 6 + 2, y + 24, 22, 20, EnumIcon.GAMEMODE_CREATIVE, new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.gamemode", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.gamemode.creative")), ActionHelper::gamemodeCreative));
|
||||
container.add(new GuiButtonIcon(x + 26 * 7 + 2, y + 24, 22, 20, EnumIcon.GAMEMODE_ADVENTURE, new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.gamemode", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.gamemode.adventure")), ActionHelper::gamemodeAdventure));
|
||||
container.add(new GuiButtonIcon(x + 26 * 8 + 2, y + 24, 22, 20, EnumIcon.GAMEMODE_SPECTATOR, new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.gamemode", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.gamemode.spectator")), ActionHelper::gamemodeSpectator));
|
||||
container.add(new GuiButtonIcon(x, y + 24, 22, 20, EnumIcon.WEATHER_SUN, Component.translatable("gui.worldhandler.shortcuts.tooltip.weather", Component.translatable("gui.worldhandler.shortcuts.tooltip.weather.clear")), ActionHelper::weatherClear));
|
||||
container.add(new GuiButtonIcon(x + 26, y + 24, 22, 20, EnumIcon.WEATHER_RAIN, Component.translatable("gui.worldhandler.shortcuts.tooltip.weather", Component.translatable("gui.worldhandler.shortcuts.tooltip.weather.rainy")), ActionHelper::weatherRain));
|
||||
container.add(new GuiButtonIcon(x + 26 * 2, y + 24, 22, 20, EnumIcon.WEATHER_STORM, Component.translatable("gui.worldhandler.shortcuts.tooltip.weather", Component.translatable("gui.worldhandler.shortcuts.tooltip.weather.thunder")), ActionHelper::weatherThunder));
|
||||
container.add(new GuiButtonIcon(x + 26 * 3, y + 24, 23, 20, EnumIcon.POTION, Component.translatable("gui.worldhandler.shortcuts.tooltip.potions"), () -> ActionHelper.open(Contents.POTIONS)));
|
||||
container.add(new GuiButtonIcon(x + 26 * 4, y + 24, 24, 20, EnumIcon.COMMAND_STACK, Component.translatable("gui.worldhandler.shortcuts.tooltip.command_stack"), () -> ActionHelper.open(Contents.COMMAND_STACK)));
|
||||
container.add(new GuiButtonIcon(x + 26 * 5 + 2, y + 24, 23, 20, EnumIcon.GAMEMODE_SURVIVAL, Component.translatable("gui.worldhandler.shortcuts.tooltip.gamemode", Component.translatable("gui.worldhandler.shortcuts.tooltip.gamemode.survival")), ActionHelper::gamemodeSurvival));
|
||||
container.add(new GuiButtonIcon(x + 26 * 6 + 2, y + 24, 22, 20, EnumIcon.GAMEMODE_CREATIVE, Component.translatable("gui.worldhandler.shortcuts.tooltip.gamemode", Component.translatable("gui.worldhandler.shortcuts.tooltip.gamemode.creative")), ActionHelper::gamemodeCreative));
|
||||
container.add(new GuiButtonIcon(x + 26 * 7 + 2, y + 24, 22, 20, EnumIcon.GAMEMODE_ADVENTURE, Component.translatable("gui.worldhandler.shortcuts.tooltip.gamemode", Component.translatable("gui.worldhandler.shortcuts.tooltip.gamemode.adventure")), ActionHelper::gamemodeAdventure));
|
||||
container.add(new GuiButtonIcon(x + 26 * 8 + 2, y + 24, 22, 20, EnumIcon.GAMEMODE_SPECTATOR, Component.translatable("gui.worldhandler.shortcuts.tooltip.gamemode", Component.translatable("gui.worldhandler.shortcuts.tooltip.gamemode.spectator")), ActionHelper::gamemodeSpectator));
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 48, 74, 20, new TranslatableComponent("gui.worldhandler.items"), () -> ActionHelper.open(Contents.CUSTOM_ITEM)));
|
||||
container.add(new GuiButtonBase(x + 78, y + 48, 76, 20, new TranslatableComponent("gui.worldhandler.blocks"), () -> ActionHelper.open(Contents.EDIT_BLOCKS)));
|
||||
container.add(new GuiButtonBase(x + 158, y + 48, 74, 20, new TranslatableComponent("gui.worldhandler.entities"), () -> ActionHelper.open(Contents.SUMMON)));
|
||||
container.add(new GuiButtonBase(x, y + 48, 74, 20, Component.translatable("gui.worldhandler.items"), () -> ActionHelper.open(Contents.CUSTOM_ITEM)));
|
||||
container.add(new GuiButtonBase(x + 78, y + 48, 76, 20, Component.translatable("gui.worldhandler.blocks"), () -> ActionHelper.open(Contents.EDIT_BLOCKS)));
|
||||
container.add(new GuiButtonBase(x + 158, y + 48, 74, 20, Component.translatable("gui.worldhandler.entities"), () -> ActionHelper.open(Contents.SUMMON)));
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 72, 74, 20, new TranslatableComponent("gui.worldhandler.world"), () -> ActionHelper.open(Contents.WORLD_INFO)));
|
||||
container.add(new GuiButtonBase(x + 78, y + 72, 76, 20, new TranslatableComponent("gui.worldhandler.player"), () -> ActionHelper.open(Contents.PLAYER)));
|
||||
container.add(new GuiButtonBase(x + 158, y + 72, 74, 20, new TranslatableComponent("gui.worldhandler.scoreboard"), () -> ActionHelper.open(Contents.SCOREBOARD_OBJECTIVES)));
|
||||
container.add(new GuiButtonBase(x, y + 72, 74, 20, Component.translatable("gui.worldhandler.world"), () -> ActionHelper.open(Contents.WORLD_INFO)));
|
||||
container.add(new GuiButtonBase(x + 78, y + 72, 76, 20, Component.translatable("gui.worldhandler.player"), () -> ActionHelper.open(Contents.PLAYER)));
|
||||
container.add(new GuiButtonBase(x + 158, y + 72, 74, 20, Component.translatable("gui.worldhandler.scoreboard"), () -> ActionHelper.open(Contents.SCOREBOARD_OBJECTIVES)));
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 96, 74, 20, new TranslatableComponent("gui.worldhandler.change_world"), () -> ActionHelper.open(Contents.CHANGE_WORLD)));
|
||||
container.add(new GuiButtonBase(x + 78, y + 96, 76, 20, new TranslatableComponent("gui.worldhandler.resourcepack"), () ->
|
||||
container.add(new GuiButtonBase(x, y + 96, 74, 20, Component.translatable("gui.worldhandler.change_world"), () -> ActionHelper.open(Contents.CHANGE_WORLD)));
|
||||
container.add(new GuiButtonBase(x + 78, y + 96, 76, 20, Component.translatable("gui.worldhandler.resourcepack"), () ->
|
||||
{
|
||||
Minecraft.getInstance().options.save();
|
||||
Minecraft.getInstance().setScreen(new PackSelectionScreen(container, Minecraft.getInstance().getResourcePackRepository(), resourcePackList ->
|
||||
@@ -60,9 +59,9 @@ public class ContentMain extends Content
|
||||
OptionsScreen optionsScreen = new OptionsScreen(container, Minecraft.getInstance().options);
|
||||
optionsScreen.init(Minecraft.getInstance(), 0, 0);
|
||||
optionsScreen.updatePackList(resourcePackList);
|
||||
}, Minecraft.getInstance().getResourcePackDirectory(), new TranslatableComponent("resourcePack.title")));
|
||||
}, Minecraft.getInstance().getResourcePackDirectory(), Component.translatable("resourcePack.title")));
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 158, y + 96, 74, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x + 158, y + 96, 74, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,13 +73,13 @@ public class ContentMain extends Content
|
||||
@Override
|
||||
public MutableComponent getTitle()
|
||||
{
|
||||
return new TextComponent(Main.NAME);
|
||||
return Component.literal(Main.NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent getTabTitle()
|
||||
{
|
||||
return new TextComponent(Main.NAME);
|
||||
return Component.literal(Main.NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,9 +27,8 @@ import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
public class ContentMultiplayer extends Content
|
||||
{
|
||||
@@ -93,7 +92,7 @@ public class ContentMultiplayer extends Content
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.playerField = new GuiTextFieldTooltip(x + 118, y + this.page.getShift(), 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.username"));
|
||||
this.playerField = new GuiTextFieldTooltip(x + 118, y + this.page.getShift(), 114, 20, Component.translatable("gui.worldhandler.multiplayer.username"));
|
||||
this.playerField.setFilter(Predicates.notNull());
|
||||
this.playerField.setFocus(false);
|
||||
this.playerField.setValue(this.builderKick.targets().getTarget());
|
||||
@@ -104,7 +103,7 @@ public class ContentMultiplayer extends Content
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
this.reasonField = new GuiTextFieldTooltip(x + 118, y + 24 + this.page.getShift(), 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.kick_ban.reason"));
|
||||
this.reasonField = new GuiTextFieldTooltip(x + 118, y + 24 + this.page.getShift(), 114, 20, Component.translatable("gui.worldhandler.multiplayer.kick_ban.reason"));
|
||||
this.reasonField.setFilter(Predicates.notNull());
|
||||
this.reasonField.setFocus(false);
|
||||
this.reasonField.setValue(this.builderKick.reason().get());
|
||||
@@ -126,29 +125,29 @@ public class ContentMultiplayer extends Content
|
||||
GuiButtonBase button6;
|
||||
GuiButtonBase button7;
|
||||
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(button1 = new GuiButtonBase(x, y, 114, 20, new TextComponent(I18n.get("gui.worldhandler.multiplayer.kick") + " / " + I18n.get("gui.worldhandler.multiplayer.ban")), () ->
|
||||
container.add(button1 = new GuiButtonBase(x, y, 114, 20, Component.literal(I18n.get("gui.worldhandler.multiplayer.kick") + " / " + I18n.get("gui.worldhandler.multiplayer.ban")), () ->
|
||||
{
|
||||
this.page = Page.KICK_AND_BAN;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.pardon"), () ->
|
||||
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, Component.translatable("gui.worldhandler.multiplayer.pardon"), () ->
|
||||
{
|
||||
this.page = Page.PARDON;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.permissions"), () ->
|
||||
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, Component.translatable("gui.worldhandler.multiplayer.permissions"), () ->
|
||||
{
|
||||
this.page = Page.PERMISSIONS;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.runtime"), () ->
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, Component.translatable("gui.worldhandler.multiplayer.runtime"), () ->
|
||||
{
|
||||
this.page = Page.RUNTIME;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button5 = new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.whitelist"), () ->
|
||||
container.add(button5 = new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.multiplayer.whitelist"), () ->
|
||||
{
|
||||
this.page = Page.WHITELIST;
|
||||
container.init();
|
||||
@@ -158,11 +157,11 @@ public class ContentMultiplayer extends Content
|
||||
{
|
||||
container.add(this.playerField);
|
||||
container.add(this.reasonField);
|
||||
container.add(button6 = new GuiButtonTooltip(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.kick"), new TextComponent(this.builderKick.toCommand(KickCommandBuilder.Label.KICK_REASON, false)), () ->
|
||||
container.add(button6 = new GuiButtonTooltip(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.multiplayer.kick"), Component.literal(this.builderKick.toCommand(KickCommandBuilder.Label.KICK_REASON, false)), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderKick, KickCommandBuilder.Label.KICK_REASON);
|
||||
}));
|
||||
container.add(button7 = new GuiButtonTooltip(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.ban"), new TextComponent(this.builderBan.toCommand(BanCommandBuilder.Label.BAN_REASON, false)), () ->
|
||||
container.add(button7 = new GuiButtonTooltip(x + 118, y + 72, 114, 20, Component.translatable("gui.worldhandler.multiplayer.ban"), Component.literal(this.builderBan.toCommand(BanCommandBuilder.Label.BAN_REASON, false)), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderBan, BanCommandBuilder.Label.BAN_REASON);
|
||||
}));
|
||||
@@ -178,7 +177,7 @@ public class ContentMultiplayer extends Content
|
||||
else if(Page.PARDON.equals(this.page))
|
||||
{
|
||||
container.add(this.playerField);
|
||||
container.add(button6 = new GuiButtonTooltip(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.pardon"), new TextComponent(this.builderPardon.toCommand(PardonCommandBuilder.Label.PARDON, false)), () ->
|
||||
container.add(button6 = new GuiButtonTooltip(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.multiplayer.pardon"), Component.literal(this.builderPardon.toCommand(PardonCommandBuilder.Label.PARDON, false)), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderPardon, PardonCommandBuilder.Label.PARDON);
|
||||
}));
|
||||
@@ -193,11 +192,11 @@ public class ContentMultiplayer extends Content
|
||||
else if(Page.PERMISSIONS.equals(this.page))
|
||||
{
|
||||
container.add(this.playerField);
|
||||
container.add(button6 = new GuiButtonTooltip(x + 118, y + 24 + 12, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.permissions.give"), new TextComponent(this.builderOp.toCommand(OpCommandBuilder.Label.OP, false)), () ->
|
||||
container.add(button6 = new GuiButtonTooltip(x + 118, y + 24 + 12, 114, 20, Component.translatable("gui.worldhandler.multiplayer.permissions.give"), Component.literal(this.builderOp.toCommand(OpCommandBuilder.Label.OP, false)), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderOp, OpCommandBuilder.Label.OP);
|
||||
}));
|
||||
container.add(button7 = new GuiButtonTooltip(x + 118, y + 48 + 12, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.permissions.take"), new TextComponent(this.builderDeop.toCommand(DeOpCommandBuilder.Label.DEOP, false)), () ->
|
||||
container.add(button7 = new GuiButtonTooltip(x + 118, y + 48 + 12, 114, 20, Component.translatable("gui.worldhandler.multiplayer.permissions.take"), Component.literal(this.builderDeop.toCommand(DeOpCommandBuilder.Label.DEOP, false)), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderDeop, DeOpCommandBuilder.Label.DEOP);
|
||||
}));
|
||||
@@ -212,19 +211,19 @@ public class ContentMultiplayer extends Content
|
||||
}
|
||||
else if(Page.RUNTIME.equals(this.page))
|
||||
{
|
||||
container.add(new GuiButtonTooltip(x + 118, y, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.runtime.save_world"), new TextComponent(this.builderSaveAll.toCommand(SaveAllCommandBuilder.Label.SAVE_ALL, false)), () ->
|
||||
container.add(new GuiButtonTooltip(x + 118, y, 114, 20, Component.translatable("gui.worldhandler.multiplayer.runtime.save_world"), Component.literal(this.builderSaveAll.toCommand(SaveAllCommandBuilder.Label.SAVE_ALL, false)), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderSaveAll, SaveAllCommandBuilder.Label.SAVE_ALL);
|
||||
}));
|
||||
container.add(new GuiButtonTooltip(x + 118, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.runtime.autosave", new TranslatableComponent("gui.worldhandler.generic.on")), new TextComponent(this.builderSaveOn.toCommand(SaveOnCommandBuilder.Label.SAVE_ON, false)), () ->
|
||||
container.add(new GuiButtonTooltip(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.multiplayer.runtime.autosave", Component.translatable("gui.worldhandler.generic.on")), Component.literal(this.builderSaveOn.toCommand(SaveOnCommandBuilder.Label.SAVE_ON, false)), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderSaveOn, SaveOnCommandBuilder.Label.SAVE_ON);
|
||||
}));
|
||||
container.add(new GuiButtonTooltip(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.runtime.autosave", new TranslatableComponent("gui.worldhandler.generic.off")).withStyle(ChatFormatting.RED), new TextComponent(this.builderSaveOff.toCommand(SaveOffCommandBuilder.Label.SAVE_OFF, false)), () ->
|
||||
container.add(new GuiButtonTooltip(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.multiplayer.runtime.autosave", Component.translatable("gui.worldhandler.generic.off")).withStyle(ChatFormatting.RED), Component.literal(this.builderSaveOff.toCommand(SaveOffCommandBuilder.Label.SAVE_OFF, false)), () ->
|
||||
{
|
||||
ActionHelper.open(Contents.CONTINUE.withBuilder(this.builderSaveOff, SaveOffCommandBuilder.Label.SAVE_OFF));
|
||||
}));
|
||||
container.add(new GuiButtonTooltip(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.runtime.stop_server").withStyle(ChatFormatting.RED), new TextComponent(this.builderStop.toCommand(StopCommandBuilder.Label.STOP, false)), () ->
|
||||
container.add(new GuiButtonTooltip(x + 118, y + 72, 114, 20, Component.translatable("gui.worldhandler.multiplayer.runtime.stop_server").withStyle(ChatFormatting.RED), Component.literal(this.builderStop.toCommand(StopCommandBuilder.Label.STOP, false)), () ->
|
||||
{
|
||||
ActionHelper.open(Contents.CONTINUE.withBuilder(this.builderStop, StopCommandBuilder.Label.STOP));
|
||||
}));
|
||||
@@ -234,25 +233,25 @@ public class ContentMultiplayer extends Content
|
||||
else if(Page.WHITELIST.equals(this.page))
|
||||
{
|
||||
container.add(this.playerField);
|
||||
container.add(button6 = new GuiButtonBase(x + 118, y + 24, 44, 20, new TranslatableComponent("gui.worldhandler.multiplayer.whitelist.add"), () ->
|
||||
container.add(button6 = new GuiButtonBase(x + 118, y + 24, 44, 20, Component.translatable("gui.worldhandler.multiplayer.whitelist.add"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderWhitelist, WhitelistCommandBuilder.Label.ADD);
|
||||
}));
|
||||
container.add(button7 = new GuiButtonBase(x + 118 + 47, y + 24, 44, 20, new TranslatableComponent("gui.worldhandler.multiplayer.whitelist.remove"), () ->
|
||||
container.add(button7 = new GuiButtonBase(x + 118 + 47, y + 24, 44, 20, Component.translatable("gui.worldhandler.multiplayer.whitelist.remove"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderWhitelist, WhitelistCommandBuilder.Label.REMOVE);
|
||||
}));
|
||||
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.whitelist.whitelist", new TranslatableComponent("gui.worldhandler.generic.on")), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.multiplayer.whitelist.whitelist", Component.translatable("gui.worldhandler.generic.on")), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderWhitelist, WhitelistCommandBuilder.Label.ON);
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.whitelist.whitelist", new TranslatableComponent("gui.worldhandler.generic.off")), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, Component.translatable("gui.worldhandler.multiplayer.whitelist.whitelist", Component.translatable("gui.worldhandler.generic.off")), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderWhitelist, WhitelistCommandBuilder.Label.OFF);
|
||||
}));
|
||||
|
||||
container.add(new GuiButtonIcon(x + 232 - 20, y + 24, 20, 20, EnumIcon.RELOAD, new TranslatableComponent("gui.worldhandler.multiplayer.whitelist.reload"), () ->
|
||||
container.add(new GuiButtonIcon(x + 232 - 20, y + 24, 20, 20, EnumIcon.RELOAD, Component.translatable("gui.worldhandler.multiplayer.whitelist.reload"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderWhitelist, WhitelistCommandBuilder.Label.RELOAD);
|
||||
}));
|
||||
@@ -320,13 +319,13 @@ public class ContentMultiplayer extends Content
|
||||
@Override
|
||||
public MutableComponent getTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.title.multiplayer");
|
||||
return Component.translatable("gui.worldhandler.title.multiplayer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent getTabTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.tab.multiplayer");
|
||||
return Component.translatable("gui.worldhandler.tab.multiplayer");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,9 +21,8 @@ import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -60,45 +59,45 @@ public class ContentNoteEditor extends Content
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
if(this.isActive)
|
||||
{
|
||||
BlockPos pos = this.builderNoteEditor.pos().getBlockPos();
|
||||
SoundEvent sound = this.getSoundEvent(pos.below());
|
||||
|
||||
container.add(new GuiButtonPiano(x - 3 + 15, y, 14, 92, new TranslatableComponent("gui.worldhandler.blocks.note_block_editor.g"), sound, 0.53F, Type.NORMAL, () -> this.setNote(container.getPlayer(), 1)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 2, y, 14, 92, new TranslatableComponent("gui.worldhandler.blocks.note_block_editor.a"), sound, 0.6F, Type.NORMAL, () -> this.setNote(container.getPlayer(), 3)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 3, y, 14, 92, new TranslatableComponent("gui.worldhandler.blocks.note_block_editor.b"), sound, 0.67F, Type.RIGHT, () -> this.setNote(container.getPlayer(), 5)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15, y, 14, 92, Component.translatable("gui.worldhandler.blocks.note_block_editor.g"), sound, 0.53F, Type.NORMAL, () -> this.setNote(container.getPlayer(), 1)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 2, y, 14, 92, Component.translatable("gui.worldhandler.blocks.note_block_editor.a"), sound, 0.6F, Type.NORMAL, () -> this.setNote(container.getPlayer(), 3)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 3, y, 14, 92, Component.translatable("gui.worldhandler.blocks.note_block_editor.b"), sound, 0.67F, Type.RIGHT, () -> this.setNote(container.getPlayer(), 5)));
|
||||
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 4, y, 14, 92, new TranslatableComponent("gui.worldhandler.blocks.note_block_editor.c"), sound, 0.7F, Type.LEFT, () -> this.setNote(container.getPlayer(), 6)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 5, y, 14, 92, new TranslatableComponent("gui.worldhandler.blocks.note_block_editor.d"), sound, 0.8F, Type.NORMAL, () -> this.setNote(container.getPlayer(), 8)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 6, y, 14, 92, new TranslatableComponent("gui.worldhandler.blocks.note_block_editor.e"), sound, 0.9F, Type.RIGHT, () -> this.setNote(container.getPlayer(), 10)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 7, y, 14, 92, new TranslatableComponent("gui.worldhandler.blocks.note_block_editor.f"), sound, 0.95F, Type.LEFT, () -> this.setNote(container.getPlayer(), 11)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 8, y, 14, 92, new TranslatableComponent("gui.worldhandler.blocks.note_block_editor.g"), sound, 1.05F, Type.NORMAL, () -> this.setNote(container.getPlayer(), 13)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 9, y, 14, 92, new TranslatableComponent("gui.worldhandler.blocks.note_block_editor.a"), sound, 1.2F, Type.NORMAL, () -> this.setNote(container.getPlayer(), 15)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 10, y, 14, 92, new TranslatableComponent("gui.worldhandler.blocks.note_block_editor.b"), sound, 1.32F, Type.RIGHT, () -> this.setNote(container.getPlayer(), 17)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 4, y, 14, 92, Component.translatable("gui.worldhandler.blocks.note_block_editor.c"), sound, 0.7F, Type.LEFT, () -> this.setNote(container.getPlayer(), 6)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 5, y, 14, 92, Component.translatable("gui.worldhandler.blocks.note_block_editor.d"), sound, 0.8F, Type.NORMAL, () -> this.setNote(container.getPlayer(), 8)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 6, y, 14, 92, Component.translatable("gui.worldhandler.blocks.note_block_editor.e"), sound, 0.9F, Type.RIGHT, () -> this.setNote(container.getPlayer(), 10)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 7, y, 14, 92, Component.translatable("gui.worldhandler.blocks.note_block_editor.f"), sound, 0.95F, Type.LEFT, () -> this.setNote(container.getPlayer(), 11)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 8, y, 14, 92, Component.translatable("gui.worldhandler.blocks.note_block_editor.g"), sound, 1.05F, Type.NORMAL, () -> this.setNote(container.getPlayer(), 13)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 9, y, 14, 92, Component.translatable("gui.worldhandler.blocks.note_block_editor.a"), sound, 1.2F, Type.NORMAL, () -> this.setNote(container.getPlayer(), 15)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 10, y, 14, 92, Component.translatable("gui.worldhandler.blocks.note_block_editor.b"), sound, 1.32F, Type.RIGHT, () -> this.setNote(container.getPlayer(), 17)));
|
||||
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 11, y, 14, 92, new TranslatableComponent("gui.worldhandler.blocks.note_block_editor.c"), sound, 1.4F, Type.LEFT, () -> this.setNote(container.getPlayer(), 18)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 12, y, 14, 92, new TranslatableComponent("gui.worldhandler.blocks.note_block_editor.d"), sound, 1.6F, Type.NORMAL, () -> this.setNote(container.getPlayer(), 20)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 13, y, 14, 92, new TranslatableComponent("gui.worldhandler.blocks.note_block_editor.e"), sound, 1.8F, Type.RIGHT, () -> this.setNote(container.getPlayer(), 22)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 14, y, 14, 92, new TranslatableComponent("gui.worldhandler.blocks.note_block_editor.f"), sound, 1.9F, Type.LEFT, () -> this.setNote(container.getPlayer(), 23)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 11, y, 14, 92, Component.translatable("gui.worldhandler.blocks.note_block_editor.c"), sound, 1.4F, Type.LEFT, () -> this.setNote(container.getPlayer(), 18)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 12, y, 14, 92, Component.translatable("gui.worldhandler.blocks.note_block_editor.d"), sound, 1.6F, Type.NORMAL, () -> this.setNote(container.getPlayer(), 20)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 13, y, 14, 92, Component.translatable("gui.worldhandler.blocks.note_block_editor.e"), sound, 1.8F, Type.RIGHT, () -> this.setNote(container.getPlayer(), 22)));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 14, y, 14, 92, Component.translatable("gui.worldhandler.blocks.note_block_editor.f"), sound, 1.9F, Type.LEFT, () -> this.setNote(container.getPlayer(), 23)));
|
||||
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15, y, 9, 58, new TextComponent("F#"), sound, 0.5F, Type.BLACK, () -> this.setNote(container.getPlayer(), 0)));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 2, y, 9, 58, new TextComponent("G#"), sound, 0.56F, Type.BLACK, () -> this.setNote(container.getPlayer(), 2)));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 3, y, 9, 58, new TextComponent("A#"), sound, 0.63F, Type.BLACK, () -> this.setNote(container.getPlayer(), 4)));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15, y, 9, 58, Component.literal("F#"), sound, 0.5F, Type.BLACK, () -> this.setNote(container.getPlayer(), 0)));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 2, y, 9, 58, Component.literal("G#"), sound, 0.56F, Type.BLACK, () -> this.setNote(container.getPlayer(), 2)));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 3, y, 9, 58, Component.literal("A#"), sound, 0.63F, Type.BLACK, () -> this.setNote(container.getPlayer(), 4)));
|
||||
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 5, y, 9, 58, new TextComponent("C#"), sound, 0.75F, Type.BLACK, () -> this.setNote(container.getPlayer(), 7)));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 6, y, 9, 58, new TextComponent("D#"), sound, 0.85F, Type.BLACK, () -> this.setNote(container.getPlayer(), 9)));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 5, y, 9, 58, Component.literal("C#"), sound, 0.75F, Type.BLACK, () -> this.setNote(container.getPlayer(), 7)));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 6, y, 9, 58, Component.literal("D#"), sound, 0.85F, Type.BLACK, () -> this.setNote(container.getPlayer(), 9)));
|
||||
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 8, y, 9, 58, new TextComponent("F#"), sound, 1.0F, Type.BLACK, () -> this.setNote(container.getPlayer(), 12)));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 9, y, 9, 58, new TextComponent("G#"), sound, 1.1F, Type.BLACK, () -> this.setNote(container.getPlayer(), 14)));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 10, y, 9, 58, new TextComponent("A#"), sound, 1.25F, Type.BLACK, () -> this.setNote(container.getPlayer(), 16)));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 8, y, 9, 58, Component.literal("F#"), sound, 1.0F, Type.BLACK, () -> this.setNote(container.getPlayer(), 12)));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 9, y, 9, 58, Component.literal("G#"), sound, 1.1F, Type.BLACK, () -> this.setNote(container.getPlayer(), 14)));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 10, y, 9, 58, Component.literal("A#"), sound, 1.25F, Type.BLACK, () -> this.setNote(container.getPlayer(), 16)));
|
||||
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 12, y, 9, 58, new TextComponent("C#"), sound, 1.5F, Type.BLACK, () -> this.setNote(container.getPlayer(), 19)));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 13, y, 9, 58, new TextComponent("D#"), sound, 1.7F, Type.BLACK, () -> this.setNote(container.getPlayer(), 21)));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 15, y, 9, 58, new TextComponent("F#"), sound, 2.0F, Type.BLACK, () -> this.setNote(container.getPlayer(), 24)));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 12, y, 9, 58, Component.literal("C#"), sound, 1.5F, Type.BLACK, () -> this.setNote(container.getPlayer(), 19)));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 13, y, 9, 58, Component.literal("D#"), sound, 1.7F, Type.BLACK, () -> this.setNote(container.getPlayer(), 21)));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 15, y, 9, 58, Component.literal("F#"), sound, 2.0F, Type.BLACK, () -> this.setNote(container.getPlayer(), 24)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +144,7 @@ public class ContentNoteEditor extends Content
|
||||
posestack.popPose();
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
|
||||
TranslatableComponent text = new TranslatableComponent("gui.worldhandler.blocks.note_block_editor.look_at_note_block", KeyHandler.KEY_WORLD_HANDLER.getTranslatedKeyMessage());
|
||||
MutableComponent text = Component.translatable("gui.worldhandler.blocks.note_block_editor.look_at_note_block", KeyHandler.KEY_WORLD_HANDLER.getTranslatedKeyMessage());
|
||||
Font font = Minecraft.getInstance().font;
|
||||
font.draw(matrix, text, x + 116 - font.width(text) / 2, y + 70, Config.getSkin().getLabelColor());
|
||||
}
|
||||
@@ -172,13 +171,13 @@ public class ContentNoteEditor extends Content
|
||||
@Override
|
||||
public MutableComponent getTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.title.blocks.note_block_editor");
|
||||
return Component.translatable("gui.worldhandler.title.blocks.note_block_editor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent getTabTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.tab.blocks.note_block_editor");
|
||||
return Component.translatable("gui.worldhandler.tab.blocks.note_block_editor");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,8 +21,8 @@ import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.screens.inventory.InventoryScreen;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public class ContentPlayer extends Content
|
||||
@@ -79,25 +79,25 @@ public class ContentPlayer extends Content
|
||||
GuiButtonBase button3;
|
||||
GuiButtonBase button4;
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(button1 = new GuiButtonBase(x, y, 114, 20, new TranslatableComponent("gui.worldhandler.entities.player.start"), () ->
|
||||
container.add(button1 = new GuiButtonBase(x, y, 114, 20, Component.translatable("gui.worldhandler.entities.player.start"), () ->
|
||||
{
|
||||
this.page = Page.START;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.entities.player.score"), () ->
|
||||
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, Component.translatable("gui.worldhandler.entities.player.score"), () ->
|
||||
{
|
||||
this.page = Page.SCORE;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.entities.player.position"), () ->
|
||||
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, Component.translatable("gui.worldhandler.entities.player.position"), () ->
|
||||
{
|
||||
this.page = Page.POSITION;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.entities.player.miscellaneous"), () ->
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, Component.translatable("gui.worldhandler.entities.player.miscellaneous"), () ->
|
||||
{
|
||||
this.page = Page.MISC;
|
||||
container.init();
|
||||
@@ -115,7 +115,7 @@ public class ContentPlayer extends Content
|
||||
{
|
||||
button3.active = false;
|
||||
|
||||
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.entities.player.position.copy_position"), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, Component.translatable("gui.worldhandler.entities.player.position.copy_position"), () ->
|
||||
{
|
||||
Player player = Minecraft.getInstance().player;
|
||||
|
||||
@@ -130,19 +130,19 @@ public class ContentPlayer extends Content
|
||||
{
|
||||
button4.active = false;
|
||||
|
||||
container.add(new GuiButtonBase(x + 118, y, 114, 20, new TranslatableComponent("gui.worldhandler.entities.player.miscellaneous.set_spawn").withStyle(ChatFormatting.RED), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y, 114, 20, Component.translatable("gui.worldhandler.entities.player.miscellaneous.set_spawn").withStyle(ChatFormatting.RED), () ->
|
||||
{
|
||||
ActionHelper.open(Contents.CONTINUE.withBuilder(this.builderSpawnpoint, SetSpawnCommandBuilder.Label.SPAWNPOINT));
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.entities.player.miscellaneous.set_global_spawn").withStyle(ChatFormatting.RED), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.entities.player.miscellaneous.set_global_spawn").withStyle(ChatFormatting.RED), () ->
|
||||
{
|
||||
ActionHelper.open(Contents.CONTINUE.withBuilder(this.builderSetWorldSpawn, SetWorldSpawnCommandBuilder.Label.SET_WORLD_SPAWN));
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.entities.player.miscellaneous.kill").withStyle(ChatFormatting.RED), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.entities.player.miscellaneous.kill").withStyle(ChatFormatting.RED), () ->
|
||||
{
|
||||
ActionHelper.open(Contents.CONTINUE.withBuilder(this.builderKill, KillCommandBuilder.Label.KILL));
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.entities.player.miscellaneous.clear_inventory").withStyle(ChatFormatting.RED), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, Component.translatable("gui.worldhandler.entities.player.miscellaneous.clear_inventory").withStyle(ChatFormatting.RED), () ->
|
||||
{
|
||||
ActionHelper.open(Contents.CONTINUE.withBuilder(this.builderClear, ClearInventoryCommandBuilder.Label.CLEAR));
|
||||
}));
|
||||
@@ -213,13 +213,13 @@ public class ContentPlayer extends Content
|
||||
@Override
|
||||
public MutableComponent getTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.title.player.player");
|
||||
return Component.translatable("gui.worldhandler.title.player.player");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent getTabTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.tab.player.player");
|
||||
return Component.translatable("gui.worldhandler.tab.player.player");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,9 +18,8 @@ import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import exopandora.worldhandler.util.TextUtils;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
@@ -77,13 +76,13 @@ public class ContentPotions extends ContentChild
|
||||
@Override
|
||||
public MutableComponent translate(MobEffect effect)
|
||||
{
|
||||
return new TranslatableComponent(effect.getDescriptionId());
|
||||
return Component.translatable(effect.getDescriptionId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent toTooltip(MobEffect effect)
|
||||
{
|
||||
return new TextComponent(effect.getRegistryName().toString());
|
||||
return Component.literal(ForgeRegistries.MOB_EFFECTS.getKey(effect).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -127,21 +126,21 @@ public class ContentPotions extends ContentChild
|
||||
GuiButtonBase button4;
|
||||
GuiButtonBase button5;
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
if(this.potionPage == 0)
|
||||
{
|
||||
container.add(new GuiButtonBase(x + 118, y + 12, 114, 20, new TranslatableComponent("gui.worldhandler.potions.effect.give"), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 12, 114, 20, Component.translatable("gui.worldhandler.potions.effect.give"), () ->
|
||||
{
|
||||
this.next(container);
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 36, 114, 20, new TranslatableComponent("gui.worldhandler.potions.effect.remove"), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 36, 114, 20, Component.translatable("gui.worldhandler.potions.effect.remove"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderPotion, EffectCommandBuilder.Label.CLEAR_TARGETS_EFFECT);
|
||||
container.init();
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 60, 114, 20, new TranslatableComponent("gui.worldhandler.potions.effect.remove_all"), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 60, 114, 20, Component.translatable("gui.worldhandler.potions.effect.remove_all"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderPotion, EffectCommandBuilder.Label.CLEAR);
|
||||
container.init();
|
||||
@@ -152,18 +151,18 @@ public class ContentPotions extends ContentChild
|
||||
MobEffect effect = this.builderPotion.effect().getEffect();
|
||||
EffectInstance tag = this.effects.getOrCreate(effect);
|
||||
|
||||
container.add(new GuiButtonBase(x + 118, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.potions.effect.ambient", tag.isAmbient() ? new TranslatableComponent("gui.worldhandler.generic.on") : new TranslatableComponent("gui.worldhandler.generic.off")), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.potions.effect.ambient", tag.isAmbient() ? Component.translatable("gui.worldhandler.generic.on") : Component.translatable("gui.worldhandler.generic.off")), () ->
|
||||
{
|
||||
tag.setAmbient(!tag.isAmbient());
|
||||
container.init();
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.potions.effect.particles", this.builderPotion.hideParticles().get() ? new TranslatableComponent("gui.worldhandler.generic.off") : new TranslatableComponent("gui.worldhandler.generic.on")), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.potions.effect.particles", this.builderPotion.hideParticles().get() ? Component.translatable("gui.worldhandler.generic.off") : Component.translatable("gui.worldhandler.generic.on")), () ->
|
||||
{
|
||||
this.builderPotion.hideParticles().set(!this.builderPotion.hideParticles().get());
|
||||
tag.setShowParticles(!tag.doShowParticles());
|
||||
container.init();
|
||||
}));
|
||||
container.add(new GuiSlider(x + 118, y, 114, 20, 1, Config.getSliders().getMaxPotionAmplifier(), 1, container, new LogicSliderSimple("amplifier" + effect.getRegistryName(), new TranslatableComponent("gui.worldhandler.potions.effect.amplifier"), value ->
|
||||
container.add(new GuiSlider(x + 118, y, 114, 20, 1, Config.getSliders().getMaxPotionAmplifier(), 1, container, new LogicSliderSimple("amplifier" + ForgeRegistries.MOB_EFFECTS.getKey(effect), Component.translatable("gui.worldhandler.potions.effect.amplifier"), value ->
|
||||
{
|
||||
this.builderPotion.amplifier().set((byte) (value.byteValue() - 1));
|
||||
tag.setAmplifier(value.byteValue());
|
||||
@@ -174,17 +173,17 @@ public class ContentPotions extends ContentChild
|
||||
MobEffect effect = this.builderPotion.effect().getEffect();
|
||||
EffectInstance tag = this.effects.getOrCreate(effect);
|
||||
|
||||
container.add(new GuiSlider(x + 118, y, 114, 20, 0, 59, 0, container, new LogicSliderSimple("s" + effect.getRegistryName(), new TranslatableComponent("gui.worldhandler.potion.time.seconds"), value ->
|
||||
container.add(new GuiSlider(x + 118, y, 114, 20, 0, 59, 0, container, new LogicSliderSimple("s" + ForgeRegistries.MOB_EFFECTS.getKey(effect), Component.translatable("gui.worldhandler.potion.time.seconds"), value ->
|
||||
{
|
||||
tag.setSeconds(value.intValue());
|
||||
this.builderPotion.seconds().set(tag.toSeconds());
|
||||
})));
|
||||
container.add(new GuiSlider(x + 118, y + 24, 114, 20, 0, 59, 0, container, new LogicSliderSimple("m" + effect.getRegistryName(), new TranslatableComponent("gui.worldhandler.potion.time.minutes"), value ->
|
||||
container.add(new GuiSlider(x + 118, y + 24, 114, 20, 0, 59, 0, container, new LogicSliderSimple("m" + ForgeRegistries.MOB_EFFECTS.getKey(effect), Component.translatable("gui.worldhandler.potion.time.minutes"), value ->
|
||||
{
|
||||
tag.setMinutes(value.intValue());
|
||||
this.builderPotion.seconds().set(tag.toSeconds());
|
||||
})));
|
||||
container.add(new GuiSlider(x + 118, y + 48, 114, 20, 0, 99, 0, container, new LogicSliderSimple("h" + effect.getRegistryName(), new TranslatableComponent("gui.worldhandler.potion.time.hours"), value ->
|
||||
container.add(new GuiSlider(x + 118, y + 48, 114, 20, 0, 99, 0, container, new LogicSliderSimple("h" + ForgeRegistries.MOB_EFFECTS.getKey(effect), Component.translatable("gui.worldhandler.potion.time.hours"), value ->
|
||||
{
|
||||
tag.setHours(value.intValue());
|
||||
this.builderPotion.seconds().set(tag.toSeconds());
|
||||
@@ -192,31 +191,31 @@ public class ContentPotions extends ContentChild
|
||||
}
|
||||
else if(this.potionPage == 3)
|
||||
{
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y, 114, 20, new TranslatableComponent("gui.worldhandler.potions.effect"), () ->
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y, 114, 20, Component.translatable("gui.worldhandler.potions.effect"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderPotion, EffectCommandBuilder.Label.GIVE_SECONDS_AMPLIFIER_HIDEPARTICLES);
|
||||
this.potionPage = 0;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x + 118, y + 24, 56, 20, new TranslatableComponent("gui.worldhandler.potions.effect.tipped_arrow"), () ->
|
||||
container.add(button2 = new GuiButtonBase(x + 118, y + 24, 56, 20, Component.translatable("gui.worldhandler.potions.effect.tipped_arrow"), () ->
|
||||
{
|
||||
this.giveItem(container.getPlayer(), Items.TIPPED_ARROW, 0.125F);
|
||||
this.potionPage = 0;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button3 = new GuiButtonTooltip(x + 178, y + 24, 55, 20, new TranslatableComponent("gui.worldhandler.potions.effect.bottle"), new TranslatableComponent("gui.worldhandler.actions.place_command_block"), () ->
|
||||
container.add(button3 = new GuiButtonTooltip(x + 178, y + 24, 55, 20, Component.translatable("gui.worldhandler.potions.effect.bottle"), Component.translatable("gui.worldhandler.actions.place_command_block"), () ->
|
||||
{
|
||||
this.giveItem(container.getPlayer(), Items.POTION, 1.0F);
|
||||
this.potionPage = 0;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button4 = new GuiButtonTooltip(x + 118, y + 48, 56, 20, new TranslatableComponent("gui.worldhandler.potions.effect.splash"), new TranslatableComponent("gui.worldhandler.actions.place_command_block"), () ->
|
||||
container.add(button4 = new GuiButtonTooltip(x + 118, y + 48, 56, 20, Component.translatable("gui.worldhandler.potions.effect.splash"), Component.translatable("gui.worldhandler.actions.place_command_block"), () ->
|
||||
{
|
||||
this.giveItem(container.getPlayer(), Items.SPLASH_POTION, 1.0F);
|
||||
this.potionPage = 0;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button5 = new GuiButtonTooltip(x + 178, y + 48, 55, 20, new TranslatableComponent("gui.worldhandler.potions.effect.lingering"), new TranslatableComponent("gui.worldhandler.actions.place_command_block"), () ->
|
||||
container.add(button5 = new GuiButtonTooltip(x + 178, y + 48, 55, 20, Component.translatable("gui.worldhandler.potions.effect.lingering"), Component.translatable("gui.worldhandler.actions.place_command_block"), () ->
|
||||
{
|
||||
this.giveItem(container.getPlayer(), Items.LINGERING_POTION, 0.25F);
|
||||
this.potionPage = 0;
|
||||
@@ -279,7 +278,7 @@ public class ContentPotions extends ContentChild
|
||||
@Override
|
||||
public MutableComponent getTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.title.potions");
|
||||
return Component.translatable("gui.worldhandler.title.potions");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,9 +17,8 @@ import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
|
||||
@@ -52,13 +51,13 @@ public class ContentRecipes extends Content
|
||||
return (MutableComponent) recipe.getResultItem().getHoverName();
|
||||
}
|
||||
|
||||
return new TextComponent(recipe.getId().toString());
|
||||
return Component.literal(recipe.getId().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent toTooltip(Recipe<?> recipe)
|
||||
{
|
||||
return new TextComponent(recipe.getId().toString());
|
||||
return Component.literal(recipe.getId().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,15 +86,15 @@ public class ContentRecipes extends Content
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(new GuiButtonBase(x + 118, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.recipes.give"), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.recipes.give"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderRecipe, RecipeCommandBuilder.Label.GIVE);
|
||||
container.initButtons();
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.recipes.take"), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.recipes.take"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderRecipe, RecipeCommandBuilder.Label.TAKE);
|
||||
container.initButtons();
|
||||
@@ -111,13 +110,13 @@ public class ContentRecipes extends Content
|
||||
@Override
|
||||
public MutableComponent getTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.title.items.recipes");
|
||||
return Component.translatable("gui.worldhandler.title.items.recipes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent getTabTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.tab.items.recipes");
|
||||
return Component.translatable("gui.worldhandler.tab.items.recipes");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,8 +5,8 @@ import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.util.ScoreboardHelper;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
public abstract class ContentScoreboard extends Content
|
||||
{
|
||||
@@ -27,6 +27,6 @@ public abstract class ContentScoreboard extends Content
|
||||
@Override
|
||||
public MutableComponent getTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.title.scoreboard");
|
||||
return Component.translatable("gui.worldhandler.title.scoreboard");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,8 @@ import exopandora.worldhandler.util.CommandHelper;
|
||||
import exopandora.worldhandler.util.RegistryHelper;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.stats.StatType;
|
||||
import net.minecraft.stats.Stats;
|
||||
@@ -44,7 +43,7 @@ public class ContentScoreboardObjectives extends ContentScoreboard
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.objectField = new GuiTextFieldTooltip(x + 118, y + this.page.getShift(), 114, 20, new TranslatableComponent("gui.worldhandler.scoreboard.objectives.objective"));
|
||||
this.objectField = new GuiTextFieldTooltip(x + 118, y + this.page.getShift(), 114, 20, Component.translatable("gui.worldhandler.scoreboard.objectives.objective"));
|
||||
this.objectField.setFilter(Predicates.notNull());
|
||||
this.objectField.setResponder(text ->
|
||||
{
|
||||
@@ -71,25 +70,25 @@ public class ContentScoreboardObjectives extends ContentScoreboard
|
||||
{
|
||||
if(type.equals(Stats.CUSTOM))
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.scoreboard.objectives.stat.custom");
|
||||
return Component.translatable("gui.worldhandler.scoreboard.objectives.stat.custom");
|
||||
}
|
||||
else if(type.equals(Stats.ENTITY_KILLED))
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.scoreboard.objectives.stat.killed");
|
||||
return Component.translatable("gui.worldhandler.scoreboard.objectives.stat.killed");
|
||||
}
|
||||
else if(type.equals(Stats.ENTITY_KILLED_BY))
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.scoreboard.objectives.stat.killed_by");
|
||||
return Component.translatable("gui.worldhandler.scoreboard.objectives.stat.killed_by");
|
||||
}
|
||||
|
||||
return new TranslatableComponent(type.getTranslationKey());
|
||||
return Component.translatable(type.getTranslationKey());
|
||||
}
|
||||
|
||||
String translation = RegistryHelper.translate(resource);
|
||||
|
||||
if(translation != null)
|
||||
{
|
||||
return new TranslatableComponent(translation);
|
||||
return Component.translatable(translation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,15 +96,15 @@ public class ContentScoreboardObjectives extends ContentScoreboard
|
||||
|
||||
if(!translation.equals(I18n.get(translation)))
|
||||
{
|
||||
return new TranslatableComponent(translation);
|
||||
return Component.translatable(translation);
|
||||
}
|
||||
|
||||
if(Arrays.stream(ChatFormatting.values()).map(ChatFormatting::getName).anyMatch(Predicates.equalTo(key)))
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.color." + key);
|
||||
return Component.translatable("gui.worldhandler.color." + key);
|
||||
}
|
||||
|
||||
return new TranslatableComponent("gui.worldhandler.scoreboard.objectives.stat." + key);
|
||||
return Component.translatable("gui.worldhandler.scoreboard.objectives.stat." + key);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -171,14 +170,14 @@ public class ContentScoreboardObjectives extends ContentScoreboard
|
||||
{
|
||||
if(depth == 0)
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.scoreboard.slot." + key);
|
||||
return Component.translatable("gui.worldhandler.scoreboard.slot." + key);
|
||||
}
|
||||
else if(depth == 1)
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.color." + key);
|
||||
return Component.translatable("gui.worldhandler.color." + key);
|
||||
}
|
||||
|
||||
return new TextComponent(key);
|
||||
return Component.literal(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -206,25 +205,25 @@ public class ContentScoreboardObjectives extends ContentScoreboard
|
||||
GuiButtonBase button3;
|
||||
GuiButtonBase button4;
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(button1 = new GuiButtonBase(x, y, 114, 20, new TranslatableComponent("gui.worldhandler.scoreboard.objectives.create"), () ->
|
||||
container.add(button1 = new GuiButtonBase(x, y, 114, 20, Component.translatable("gui.worldhandler.scoreboard.objectives.create"), () ->
|
||||
{
|
||||
this.page = Page.CREATE;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.scoreboard.objectives.display"), () ->
|
||||
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, Component.translatable("gui.worldhandler.scoreboard.objectives.display"), () ->
|
||||
{
|
||||
this.page = Page.DISPLAY;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.scoreboard.objectives.undisplay"), () ->
|
||||
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, Component.translatable("gui.worldhandler.scoreboard.objectives.undisplay"), () ->
|
||||
{
|
||||
this.page = Page.UNDISPLAY;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.scoreboard.objectives.remove"), () ->
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, Component.translatable("gui.worldhandler.scoreboard.objectives.remove"), () ->
|
||||
{
|
||||
this.page = Page.REMOVE;
|
||||
container.init();
|
||||
@@ -240,7 +239,7 @@ public class ContentScoreboardObjectives extends ContentScoreboard
|
||||
container.add(this.objectField);
|
||||
}
|
||||
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 72 - this.page.getShift(), 114, 20, new TranslatableComponent("gui.worldhandler.actions.perform"), () ->
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 72 - this.page.getShift(), 114, 20, Component.translatable("gui.worldhandler.actions.perform"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), BUILDER, this.page.getLabel());
|
||||
container.init();
|
||||
@@ -269,7 +268,7 @@ public class ContentScoreboardObjectives extends ContentScoreboard
|
||||
@Override
|
||||
public MutableComponent getTabTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.tab.scoreboard.objectives");
|
||||
return Component.translatable("gui.worldhandler.tab.scoreboard.objectives");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,8 +17,8 @@ import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.widget.button.LogicSliderSimple;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
public class ContentScoreboardPlayers extends ContentScoreboard
|
||||
{
|
||||
@@ -75,7 +75,7 @@ public class ContentScoreboardPlayers extends ContentScoreboard
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.objectField = new GuiTextFieldTooltip(x + 118, y, 114, 20, new TranslatableComponent("gui.worldhandler.scoreboard.objectives.objective"));
|
||||
this.objectField = new GuiTextFieldTooltip(x + 118, y, 114, 20, Component.translatable("gui.worldhandler.scoreboard.objectives.objective"));
|
||||
this.objectField.setFilter(Predicates.notNull());
|
||||
this.objectField.setResponder(text ->
|
||||
{
|
||||
@@ -86,7 +86,7 @@ public class ContentScoreboardPlayers extends ContentScoreboard
|
||||
});
|
||||
this.objectField.setValue(BUILDER.objective().get());
|
||||
|
||||
this.tagField = new GuiTextFieldTooltip(x + 118, y + 12, 114, 20, new TranslatableComponent("gui.worldhandler.scoreboard.players.tag"));
|
||||
this.tagField = new GuiTextFieldTooltip(x + 118, y + 12, 114, 20, Component.translatable("gui.worldhandler.scoreboard.players.tag"));
|
||||
this.tagField.setFilter(string -> string != null && !string.contains(" "));
|
||||
this.tagField.setValue(this.builderTag.name().get());
|
||||
this.tagField.setResponder(text ->
|
||||
@@ -103,20 +103,20 @@ public class ContentScoreboardPlayers extends ContentScoreboard
|
||||
GuiButtonBase button2;
|
||||
GuiButtonBase button3;
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(button1 = new GuiButtonBase(x, y + 12, 114, 20, new TranslatableComponent("gui.worldhandler.scoreboard.players.points"), () ->
|
||||
container.add(button1 = new GuiButtonBase(x, y + 12, 114, 20, Component.translatable("gui.worldhandler.scoreboard.players.points"), () ->
|
||||
{
|
||||
this.page = Page.ADD_SET_REMOVE;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x, y + 36, 114, 20, new TranslatableComponent("gui.worldhandler.scoreboard.players.tag"), () ->
|
||||
container.add(button2 = new GuiButtonBase(x, y + 36, 114, 20, Component.translatable("gui.worldhandler.scoreboard.players.tag"), () ->
|
||||
{
|
||||
this.page = Page.TAG;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button3 = new GuiButtonBase(x, y + 60, 114, 20, new TranslatableComponent("gui.worldhandler.scoreboard.players.trigger"), () ->
|
||||
container.add(button3 = new GuiButtonBase(x, y + 60, 114, 20, Component.translatable("gui.worldhandler.scoreboard.players.trigger"), () ->
|
||||
{
|
||||
this.page = Page.ENABLE;
|
||||
container.init();
|
||||
@@ -130,21 +130,21 @@ public class ContentScoreboardPlayers extends ContentScoreboard
|
||||
|
||||
if(Page.ADD_SET_REMOVE.equals(this.page))
|
||||
{
|
||||
container.add(new GuiSlider(x + 118, y + 24, 114, 20, 0, Config.getSliders().getMaxPlayerPoints(), 0, container, new LogicSliderSimple("points", new TranslatableComponent("gui.worldhandler.scoreboard.players.points"), value ->
|
||||
container.add(new GuiSlider(x + 118, y + 24, 114, 20, 0, Config.getSliders().getMaxPlayerPoints(), 0, container, new LogicSliderSimple("points", Component.translatable("gui.worldhandler.scoreboard.players.points"), value ->
|
||||
{
|
||||
BUILDER.score().set(value);
|
||||
})));
|
||||
container.add(this.addButton = new GuiButtonBase(x + 118, y + 48, 56, 20, new TranslatableComponent("gui.worldhandler.actions.add"), () ->
|
||||
container.add(this.addButton = new GuiButtonBase(x + 118, y + 48, 56, 20, Component.translatable("gui.worldhandler.actions.add"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), BUILDER, ScoreboardCommandBuilder.Label.PLAYERS_ADD_SCORE);
|
||||
container.init();
|
||||
}));
|
||||
container.add(this.removeButton = new GuiButtonBase(x + 118 + 114 / 2 + 1, y + 48, 56, 20, new TranslatableComponent("gui.worldhandler.actions.remove"), () ->
|
||||
container.add(this.removeButton = new GuiButtonBase(x + 118 + 114 / 2 + 1, y + 48, 56, 20, Component.translatable("gui.worldhandler.actions.remove"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), BUILDER, ScoreboardCommandBuilder.Label.PLAYERS_REMOVE_SCORE);
|
||||
container.init();
|
||||
}));
|
||||
container.add(button1 = new GuiButtonTooltip(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.actions.reset"), new TranslatableComponent("gui.worldhandler.actions.set_to_0"), () ->
|
||||
container.add(button1 = new GuiButtonTooltip(x + 118, y + 72, 114, 20, Component.translatable("gui.worldhandler.actions.reset"), Component.translatable("gui.worldhandler.actions.set_to_0"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), BUILDER, ScoreboardCommandBuilder.Label.PLAYERS_RESET_SCORE);
|
||||
container.init();
|
||||
@@ -158,12 +158,12 @@ public class ContentScoreboardPlayers extends ContentScoreboard
|
||||
}
|
||||
else if(Page.TAG.equals(this.page))
|
||||
{
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 36, 114, 20, new TranslatableComponent("gui.worldhandler.actions.add"), () ->
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 36, 114, 20, Component.translatable("gui.worldhandler.actions.add"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderTag, TagCommandBuilder.Label.ADD);
|
||||
container.init();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x + 118, y + 60, 114, 20, new TranslatableComponent("gui.worldhandler.actions.remove"), () ->
|
||||
container.add(button2 = new GuiButtonBase(x + 118, y + 60, 114, 20, Component.translatable("gui.worldhandler.actions.remove"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderTag, TagCommandBuilder.Label.REMOVE);
|
||||
container.init();
|
||||
@@ -176,21 +176,21 @@ public class ContentScoreboardPlayers extends ContentScoreboard
|
||||
}
|
||||
else if(Page.ENABLE.equals(this.page))
|
||||
{
|
||||
container.add(new GuiSlider(x + 118, y + 24, 114, 20, 0, Config.getSliders().getMaxTriggerValue(), 0, container, new LogicSliderSimple("enable", new TranslatableComponent("gui.worldhandler.generic.value"), value ->
|
||||
container.add(new GuiSlider(x + 118, y + 24, 114, 20, 0, Config.getSliders().getMaxTriggerValue(), 0, container, new LogicSliderSimple("enable", Component.translatable("gui.worldhandler.generic.value"), value ->
|
||||
{
|
||||
this.builderTrigger.value().set(value);
|
||||
})));
|
||||
container.add(this.addButton = new GuiButtonBase(x + 118, y + 48, 56, 20, new TranslatableComponent("gui.worldhandler.actions.add"), () ->
|
||||
container.add(this.addButton = new GuiButtonBase(x + 118, y + 48, 56, 20, Component.translatable("gui.worldhandler.actions.add"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderTrigger, TriggerCommandBuilder.Label.ADD);
|
||||
container.init();
|
||||
}));
|
||||
container.add(this.removeButton = new GuiButtonBase(x + 118 + 114 / 2 + 1, y + 48, 56, 20, new TranslatableComponent("gui.worldhandler.actions.set"), () ->
|
||||
container.add(this.removeButton = new GuiButtonBase(x + 118 + 114 / 2 + 1, y + 48, 56, 20, Component.translatable("gui.worldhandler.actions.set"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderTrigger, TriggerCommandBuilder.Label.SET);
|
||||
container.init();
|
||||
}));
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.generic.enable"), () ->
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 72, 114, 20, Component.translatable("gui.worldhandler.generic.enable"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), BUILDER, ScoreboardCommandBuilder.Label.PLAYERS_ENABLE_OBJECTIVE);
|
||||
container.init();
|
||||
@@ -255,7 +255,7 @@ public class ContentScoreboardPlayers extends ContentScoreboard
|
||||
@Override
|
||||
public MutableComponent getTabTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.tab.scoreboard.players");
|
||||
return Component.translatable("gui.worldhandler.tab.scoreboard.players");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,9 +18,8 @@ import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
public class ContentScoreboardTeams extends ContentScoreboard
|
||||
{
|
||||
@@ -58,7 +57,7 @@ public class ContentScoreboardTeams extends ContentScoreboard
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.teamField = new GuiTextFieldTooltip(x + 118, y + this.page.getShift(), 114, 20, new TranslatableComponent("gui.worldhandler.scoreboard.team.team"));
|
||||
this.teamField = new GuiTextFieldTooltip(x + 118, y + this.page.getShift(), 114, 20, Component.translatable("gui.worldhandler.scoreboard.team.team"));
|
||||
this.teamField.setFilter(Predicates.notNull());
|
||||
this.teamField.setValue(this.builderTeams.team().get());
|
||||
this.teamField.setResponder(text ->
|
||||
@@ -77,19 +76,19 @@ public class ContentScoreboardTeams extends ContentScoreboard
|
||||
{
|
||||
if(depth == 0)
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.scoreboard.team.options." + key);
|
||||
return Component.translatable("gui.worldhandler.scoreboard.team.options." + key);
|
||||
}
|
||||
else if(depth == 1)
|
||||
{
|
||||
if(Arrays.stream(ChatFormatting.values()).map(ChatFormatting::getName).anyMatch(Predicates.equalTo(key)))
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.color." + key);
|
||||
return Component.translatable("gui.worldhandler.color." + key);
|
||||
}
|
||||
|
||||
return new TranslatableComponent("gui.worldhandler.scoreboard.team.suboption." + key);
|
||||
return Component.translatable("gui.worldhandler.scoreboard.team.suboption." + key);
|
||||
}
|
||||
|
||||
return new TextComponent(key);
|
||||
return Component.literal(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -130,25 +129,25 @@ public class ContentScoreboardTeams extends ContentScoreboard
|
||||
GuiButtonBase button3;
|
||||
GuiButtonBase button4;
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(button1 = new GuiButtonBase(x, y, 114, 20, new TranslatableComponent("gui.worldhandler.scoreboard.team.create"), () ->
|
||||
container.add(button1 = new GuiButtonBase(x, y, 114, 20, Component.translatable("gui.worldhandler.scoreboard.team.create"), () ->
|
||||
{
|
||||
this.page = Page.ADD;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, new TextComponent(I18n.get("gui.worldhandler.scoreboard.team.join") + " / " + I18n.get("gui.worldhandler.scoreboard.team.leave")), () ->
|
||||
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, Component.literal(I18n.get("gui.worldhandler.scoreboard.team.join") + " / " + I18n.get("gui.worldhandler.scoreboard.team.leave")), () ->
|
||||
{
|
||||
this.page = Page.JOIN_OR_LEAVE;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, new TextComponent(I18n.get("gui.worldhandler.scoreboard.team.remove") + " / " + I18n.get("gui.worldhandler.scoreboard.team.empty")), () ->
|
||||
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, Component.literal(I18n.get("gui.worldhandler.scoreboard.team.remove") + " / " + I18n.get("gui.worldhandler.scoreboard.team.empty")), () ->
|
||||
{
|
||||
this.page = Page.REMOVE_OR_EMPTY;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.scoreboard.team.options"), () ->
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, Component.translatable("gui.worldhandler.scoreboard.team.options"), () ->
|
||||
{
|
||||
this.page = Page.OPTION;
|
||||
container.init();
|
||||
@@ -163,12 +162,12 @@ public class ContentScoreboardTeams extends ContentScoreboard
|
||||
|
||||
if(Page.JOIN_OR_LEAVE.equals(this.page))
|
||||
{
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 36, 114, 20, new TranslatableComponent("gui.worldhandler.scoreboard.team.join"), () ->
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 36, 114, 20, Component.translatable("gui.worldhandler.scoreboard.team.join"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderTeams, TeamCommandBuilder.Label.JOIN);
|
||||
container.initButtons();
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 60, 114, 20, new TranslatableComponent("gui.worldhandler.scoreboard.team.leave"), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 60, 114, 20, Component.translatable("gui.worldhandler.scoreboard.team.leave"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderTeams, TeamCommandBuilder.Label.LEAVE);
|
||||
container.initButtons();
|
||||
@@ -178,12 +177,12 @@ public class ContentScoreboardTeams extends ContentScoreboard
|
||||
}
|
||||
else if(Page.REMOVE_OR_EMPTY.equals(this.page))
|
||||
{
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 36, 114, 20, new TranslatableComponent("gui.worldhandler.scoreboard.team.remove"), () ->
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 36, 114, 20, Component.translatable("gui.worldhandler.scoreboard.team.remove"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderTeams, TeamCommandBuilder.Label.REMOVE);
|
||||
container.initButtons();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x + 118, y + 60, 114, 20, new TranslatableComponent("gui.worldhandler.scoreboard.team.empty"), () ->
|
||||
container.add(button2 = new GuiButtonBase(x + 118, y + 60, 114, 20, Component.translatable("gui.worldhandler.scoreboard.team.empty"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderTeams, TeamCommandBuilder.Label.EMPTY);
|
||||
container.initButtons();
|
||||
@@ -195,7 +194,7 @@ public class ContentScoreboardTeams extends ContentScoreboard
|
||||
|
||||
if(Page.ADD.equals(this.page) || Page.OPTION.equals(this.page))
|
||||
{
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 72 - this.page.getShift(), 114, 20, new TranslatableComponent("gui.worldhandler.actions.perform"), () ->
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 72 - this.page.getShift(), 114, 20, Component.translatable("gui.worldhandler.actions.perform"), () ->
|
||||
{
|
||||
if(Page.ADD.equals(this.page))
|
||||
{
|
||||
@@ -228,7 +227,7 @@ public class ContentScoreboardTeams extends ContentScoreboard
|
||||
@Override
|
||||
public MutableComponent getTabTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.tab.scoreboard.teams");
|
||||
return Component.translatable("gui.worldhandler.tab.scoreboard.teams");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,8 +18,8 @@ import exopandora.worldhandler.gui.widget.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.widget.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
public class ContentSettings extends ContentChild
|
||||
{
|
||||
@@ -54,7 +54,7 @@ public class ContentSettings extends ContentChild
|
||||
@Override
|
||||
public MutableComponent translate(Setting<?> item)
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.config.settings." + item.getKey());
|
||||
return Component.translatable("gui.worldhandler.config.settings." + item.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,7 +85,7 @@ public class ContentSettings extends ContentChild
|
||||
|
||||
container.add(settings);
|
||||
|
||||
this.valueField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.generic.value"));
|
||||
this.valueField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.generic.value"));
|
||||
this.valueField.setFilter(string ->
|
||||
{
|
||||
if(string == null)
|
||||
@@ -115,19 +115,19 @@ public class ContentSettings extends ContentChild
|
||||
GuiButtonBase button1;
|
||||
GuiButtonBase button2;
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
if(this.setting instanceof BooleanSetting)
|
||||
{
|
||||
BooleanSetting setting = (BooleanSetting) this.setting;
|
||||
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.generic.enable"), () ->
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.generic.enable"), () ->
|
||||
{
|
||||
setting.set(true);
|
||||
container.init();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.generic.disable"), () ->
|
||||
container.add(button2 = new GuiButtonBase(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.generic.disable"), () ->
|
||||
{
|
||||
setting.set(false);
|
||||
container.init();
|
||||
@@ -144,7 +144,7 @@ public class ContentSettings extends ContentChild
|
||||
this.valueField.setValue(String.valueOf(setting.get()));
|
||||
|
||||
container.add(this.valueField);
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.actions.set"), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.actions.set"), () ->
|
||||
{
|
||||
String text = this.valueField.getValue();
|
||||
|
||||
@@ -183,7 +183,7 @@ public class ContentSettings extends ContentChild
|
||||
@Override
|
||||
public MutableComponent getTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.settings");
|
||||
return Component.translatable("gui.worldhandler.shortcuts.tooltip.settings");
|
||||
}
|
||||
|
||||
public abstract static class Setting<T>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
@@ -26,8 +25,8 @@ import exopandora.worldhandler.util.BlockHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.SignBlock;
|
||||
@@ -74,17 +73,17 @@ public class ContentSignEditor extends Content
|
||||
{
|
||||
if(this.isActive)
|
||||
{
|
||||
this.commandField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.blocks.sign_editor.commmand"));
|
||||
this.commandField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.blocks.sign_editor.commmand"));
|
||||
this.commandField.setFilter(Predicates.notNull());
|
||||
this.commandField.setValue(this.texts[this.selectedLine].getText().getCommand());
|
||||
this.commandField.setValue(this.texts[this.selectedLine].getComponent().getCommand());
|
||||
this.commandField.moveCursorToEnd();
|
||||
this.commandField.setResponder(text ->
|
||||
{
|
||||
this.texts[this.selectedLine].getText().setCommand(text);
|
||||
this.texts[this.selectedLine].getComponent().setCommand(text);
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
MenuColorField colors = new MenuColorField(x, y, "gui.worldhandler.blocks.sign_editor.text_line_" + (this.selectedLine + 1), this.texts[this.selectedLine].getText(), new ILogicColorMenu()
|
||||
MenuColorField colors = new MenuColorField(x, y, "gui.worldhandler.blocks.sign_editor.text_line_" + (this.selectedLine + 1), this.texts[this.selectedLine].getComponent(), new ILogicColorMenu()
|
||||
{
|
||||
@Override
|
||||
public boolean validate(String text)
|
||||
@@ -117,27 +116,27 @@ public class ContentSignEditor extends Content
|
||||
GuiButtonBase button3;
|
||||
GuiButtonBase button4;
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
if(this.isActive)
|
||||
{
|
||||
container.add(button1 = new GuiButtonBase(x, y, 114, 20, new TranslatableComponent("gui.worldhandler.blocks.sign_editor.text_line_1"), () ->
|
||||
container.add(button1 = new GuiButtonBase(x, y, 114, 20, Component.translatable("gui.worldhandler.blocks.sign_editor.text_line_1"), () ->
|
||||
{
|
||||
this.selectedLine = 0;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.blocks.sign_editor.text_line_2"), () ->
|
||||
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, Component.translatable("gui.worldhandler.blocks.sign_editor.text_line_2"), () ->
|
||||
{
|
||||
this.selectedLine = 1;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.blocks.sign_editor.text_line_3"), () ->
|
||||
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, Component.translatable("gui.worldhandler.blocks.sign_editor.text_line_3"), () ->
|
||||
{
|
||||
this.selectedLine = 2;
|
||||
container.init();
|
||||
}));
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.blocks.sign_editor.text_line_4"), () ->
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, Component.translatable("gui.worldhandler.blocks.sign_editor.text_line_4"), () ->
|
||||
{
|
||||
this.selectedLine = 3;
|
||||
container.init();
|
||||
@@ -145,15 +144,15 @@ public class ContentSignEditor extends Content
|
||||
|
||||
if(this.editColor)
|
||||
{
|
||||
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.generic.done"), () -> this.toggleEditColor(container)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, Component.translatable("gui.worldhandler.generic.done"), () -> this.toggleEditColor(container)));
|
||||
}
|
||||
else
|
||||
{
|
||||
container.add(this.commandField);
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.blocks.sign_editor.format_text_line"), () -> this.toggleEditColor(container)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.actions.place_command_block"), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.blocks.sign_editor.format_text_line"), () -> this.toggleEditColor(container)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, Component.translatable("gui.worldhandler.actions.place_command_block"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderSignEditor, DataCommandBuilder.Label.MERGE_BLOCK, Arrays.stream(this.texts).anyMatch(text -> text.getText().isSpecial()));
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderSignEditor, DataCommandBuilder.Label.MERGE_BLOCK, Arrays.stream(this.texts).anyMatch(text -> text.getComponent().isStyled()));
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -203,7 +202,7 @@ public class ContentSignEditor extends Content
|
||||
posestack.popPose();
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
|
||||
TranslatableComponent text = new TranslatableComponent("gui.worldhandler.blocks.sign_editor.look_at_sign", KeyHandler.KEY_WORLD_HANDLER.getTranslatedKeyMessage());
|
||||
MutableComponent text = Component.translatable("gui.worldhandler.blocks.sign_editor.look_at_sign", KeyHandler.KEY_WORLD_HANDLER.getTranslatedKeyMessage());
|
||||
Font font = Minecraft.getInstance().font;
|
||||
font.draw(matrix, text, x + 116 - font.width(text) / 2, y + 70, Config.getSkin().getLabelColor());
|
||||
}
|
||||
@@ -218,13 +217,13 @@ public class ContentSignEditor extends Content
|
||||
@Override
|
||||
public MutableComponent getTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.title.blocks.sign_editor");
|
||||
return Component.translatable("gui.worldhandler.title.blocks.sign_editor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent getTabTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.tab.blocks.sign_editor");
|
||||
return Component.translatable("gui.worldhandler.tab.blocks.sign_editor");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,9 +47,8 @@ import net.minecraft.nbt.ByteTag;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.IntTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
@@ -183,7 +182,7 @@ public class ContentSummon extends Content
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.mobField = new GuiTextFieldTooltip(x + 118, y, 114, 20, new TranslatableComponent("gui.worldhandler.entities.summon.start.mob_id"));
|
||||
this.mobField = new GuiTextFieldTooltip(x + 118, y, 114, 20, Component.translatable("gui.worldhandler.entities.summon.start.mob_id"));
|
||||
this.mobField.setFilter(Predicates.notNull());
|
||||
this.mobField.setValue(this.mob);
|
||||
this.mobField.setResponder(text ->
|
||||
@@ -194,7 +193,7 @@ public class ContentSummon extends Content
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
this.nbtField = new GuiTextFieldTooltip(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.entities.summon.start.custom_nbt"));
|
||||
this.nbtField = new GuiTextFieldTooltip(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.entities.summon.start.custom_nbt"));
|
||||
this.nbtField.setFilter(Predicates.notNull());
|
||||
this.nbtField.setValue(this.nbt);
|
||||
this.nbtField.setResponder(text ->
|
||||
@@ -236,13 +235,13 @@ public class ContentSummon extends Content
|
||||
@Override
|
||||
public MutableComponent translate(Attribute attribute)
|
||||
{
|
||||
return new TranslatableComponent(attribute.getDescriptionId());
|
||||
return Component.translatable(attribute.getDescriptionId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent toTooltip(Attribute attribute)
|
||||
{
|
||||
return new TextComponent(attribute.getRegistryName().toString());
|
||||
return Component.literal(ForgeRegistries.ATTRIBUTES.getKey(attribute).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -310,7 +309,7 @@ public class ContentSummon extends Content
|
||||
container.add(new GuiButtonBase(x + 118, y + 24, 114, 20, "gui.worldhandler.entities.summon.start.custom_name", () -> this.toggleEditColor(container)));
|
||||
container.add(this.nbtField);
|
||||
|
||||
if(!this.builderSummon.needsCommandBlock(SummonCommandBuilder.Label.SUMMON_POS_NBT, false) && !this.entity.getCustomName().isSpecial())
|
||||
if(!this.builderSummon.needsCommandBlock(SummonCommandBuilder.Label.SUMMON_POS_NBT, false) && !this.entity.getCustomName().isStyled())
|
||||
{
|
||||
container.add(button3 = new GuiButtonBase(x + 118, y + 72, 114, 20, "gui.worldhandler.title.entities.summon", () -> this.send(container.getPlayer())));
|
||||
}
|
||||
@@ -362,15 +361,15 @@ public class ContentSummon extends Content
|
||||
{
|
||||
EffectInstance tag = this.effects.getOrCreate(effect);
|
||||
|
||||
container.add(new GuiSlider(x + 118, y, 114, 20, 0, Config.getSliders().getMaxSummonPotionAmplifier(), 0, container, new LogicSliderSimple("amplifier" + effect.getRegistryName(), new TranslatableComponent(effect.getDescriptionId()), value ->
|
||||
container.add(new GuiSlider(x + 118, y, 114, 20, 0, Config.getSliders().getMaxSummonPotionAmplifier(), 0, container, new LogicSliderSimple("amplifier" + ForgeRegistries.MOB_EFFECTS.getKey(effect), Component.translatable(effect.getDescriptionId()), value ->
|
||||
{
|
||||
tag.setAmplifier(value.byteValue());
|
||||
})));
|
||||
container.add(new GuiSlider(x + 118, y + 24, 114, 20, 0, Config.getSliders().getMaxSummonPotionMinutes(), 0, container, new LogicSliderSimple("duration" + effect.getRegistryName(), new TranslatableComponent("gui.worldhandler.potion.time.minutes"), value ->
|
||||
container.add(new GuiSlider(x + 118, y + 24, 114, 20, 0, Config.getSliders().getMaxSummonPotionMinutes(), 0, container, new LogicSliderSimple("duration" + ForgeRegistries.MOB_EFFECTS.getKey(effect), Component.translatable("gui.worldhandler.potion.time.minutes"), value ->
|
||||
{
|
||||
tag.setMinutes(value.intValue());
|
||||
})));
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.potions.effect.particles", tag.doShowParticles() ? new TranslatableComponent("gui.worldhandler.generic.on") : new TranslatableComponent("gui.worldhandler.generic.off")), () ->
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.potions.effect.particles", tag.doShowParticles() ? Component.translatable("gui.worldhandler.generic.on") : Component.translatable("gui.worldhandler.generic.off")), () ->
|
||||
{
|
||||
tag.setShowParticles(!tag.doShowParticles());
|
||||
container.init();
|
||||
@@ -431,7 +430,7 @@ public class ContentSummon extends Content
|
||||
|
||||
private void send(String player)
|
||||
{
|
||||
CommandHelper.sendCommand(player, this.builderSummon, SummonCommandBuilder.Label.SUMMON_POS_NBT, this.entity.getCustomName().isSpecial());
|
||||
CommandHelper.sendCommand(player, this.builderSummon, SummonCommandBuilder.Label.SUMMON_POS_NBT, this.entity.getCustomName().isStyled());
|
||||
}
|
||||
|
||||
private void updateMutableTag()
|
||||
@@ -450,7 +449,7 @@ public class ContentSummon extends Content
|
||||
if(StringUtils.equalsIgnoreCase(this.mob, profession.toString()))
|
||||
{
|
||||
CompoundTag villagerData = new CompoundTag();
|
||||
villagerData.putString("profession", profession.getRegistryName().toString());
|
||||
villagerData.putString("profession", ForgeRegistries.PROFESSIONS.getKey(profession).toString());
|
||||
|
||||
this.mutable.setKey("VillagerData");
|
||||
this.mutable.setTag(villagerData);
|
||||
@@ -469,7 +468,7 @@ public class ContentSummon extends Content
|
||||
else if(EntityType.CHICKEN.equals(entity) && StringUtils.containsIgnoreCase(this.mob, "Jockey") && !this.entity.hasPassengers())
|
||||
{
|
||||
ListTag list = new ListTag();
|
||||
EntityTag zombie = new EntityTag(EntityType.ZOMBIE.getRegistryName());
|
||||
EntityTag zombie = new EntityTag(ForgeRegistries.ENTITIES.getKey(EntityType.ZOMBIE));
|
||||
|
||||
zombie.setIsBaby(true);
|
||||
list.add(zombie.value());
|
||||
@@ -480,7 +479,7 @@ public class ContentSummon extends Content
|
||||
else if(EntityType.SPIDER.equals(entity) && StringUtils.containsIgnoreCase(this.mob, "Jockey") && !this.entity.hasPassengers())
|
||||
{
|
||||
ListTag list = new ListTag();
|
||||
EntityTag skeleton = new EntityTag(EntityType.SKELETON.getRegistryName());
|
||||
EntityTag skeleton = new EntityTag(ForgeRegistries.ENTITIES.getKey(EntityType.SKELETON));
|
||||
|
||||
skeleton.setHandItem(0, Items.BOW);
|
||||
list.add(skeleton.value());
|
||||
@@ -574,13 +573,13 @@ public class ContentSummon extends Content
|
||||
@Override
|
||||
public MutableComponent getTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.title.entities.summon");
|
||||
return Component.translatable("gui.worldhandler.title.entities.summon");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent getTabTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.tab.entities.summon");
|
||||
return Component.translatable("gui.worldhandler.tab.entities.summon");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,15 +34,12 @@ import exopandora.worldhandler.usercontent.model.JsonUsercontent;
|
||||
import exopandora.worldhandler.usercontent.model.JsonWidget;
|
||||
import exopandora.worldhandler.util.TextUtils;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.network.chat.ChatType;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
|
||||
public class ContentUsercontent extends Content
|
||||
{
|
||||
@@ -262,8 +259,8 @@ public class ContentUsercontent extends Content
|
||||
|
||||
private void printError(String type, int index, Throwable e)
|
||||
{
|
||||
Component message = new TextComponent("<" + Main.NAME + ":" + this.id + ":" + type + ":" + index + "> " + e.getMessage()).setStyle(Style.EMPTY.withColor(ChatFormatting.RED));
|
||||
Minecraft.getInstance().gui.handleChat(ChatType.CHAT, message, Util.NIL_UUID);
|
||||
Component message = Component.literal("<" + Main.NAME + ":" + this.id + ":" + type + ":" + index + "> " + e.getMessage()).setStyle(Style.EMPTY.withColor(ChatFormatting.RED));
|
||||
Minecraft.getInstance().player.sendSystemMessage(message);
|
||||
}
|
||||
|
||||
private void updateTextfields()
|
||||
|
||||
@@ -16,8 +16,8 @@ import exopandora.worldhandler.util.TextUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.client.server.IntegratedServer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
public class ContentWorldInfo extends Content
|
||||
@@ -71,20 +71,20 @@ public class ContentWorldInfo extends Content
|
||||
GuiButtonBase world;
|
||||
GuiButtonBase stats;
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, Component.translatable("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(start = new GuiButtonBase(x, y + 12, 114, 20, new TranslatableComponent("gui.worldhandler.world_info.start"), () ->
|
||||
container.add(start = new GuiButtonBase(x, y + 12, 114, 20, Component.translatable("gui.worldhandler.world_info.start"), () ->
|
||||
{
|
||||
this.page = Page.START;
|
||||
container.init();
|
||||
}));
|
||||
container.add(world = new GuiButtonBase(x, y + 36, 114, 20, new TranslatableComponent("gui.worldhandler.world_info.world"), () ->
|
||||
container.add(world = new GuiButtonBase(x, y + 36, 114, 20, Component.translatable("gui.worldhandler.world_info.world"), () ->
|
||||
{
|
||||
this.page = Page.WORLD;
|
||||
container.init();
|
||||
}));
|
||||
container.add(stats = new GuiButtonBase(x, y + 60, 114, 20, new TranslatableComponent("gui.worldhandler.world_info.statistics"), () ->
|
||||
container.add(stats = new GuiButtonBase(x, y + 60, 114, 20, Component.translatable("gui.worldhandler.world_info.statistics"), () ->
|
||||
{
|
||||
this.page = Page.STATS;
|
||||
container.init();
|
||||
@@ -100,7 +100,7 @@ public class ContentWorldInfo extends Content
|
||||
IntegratedServer server = Minecraft.getInstance().getSingleplayerServer();
|
||||
|
||||
world.active = false;
|
||||
container.add(seed = new GuiButtonBase(x + 118, y + 60, 114, 20, new TranslatableComponent("gui.worldhandler.world_info.world.copy_seed"), () ->
|
||||
container.add(seed = new GuiButtonBase(x + 118, y + 60, 114, 20, Component.translatable("gui.worldhandler.world_info.world.copy_seed"), () ->
|
||||
{
|
||||
Minecraft.getInstance().keyboardHandler.setClipboard(String.valueOf(server.overworld().getSeed()));
|
||||
}));
|
||||
@@ -191,13 +191,13 @@ public class ContentWorldInfo extends Content
|
||||
@Override
|
||||
public MutableComponent getTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.title.world.world");
|
||||
return Component.translatable("gui.worldhandler.title.world.world");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent getTabTitle()
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.tab.world.world");
|
||||
return Component.translatable("gui.worldhandler.tab.world.world");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,7 +9,6 @@ import exopandora.worldhandler.gui.widget.button.GuiButtonIcon;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
public class WidgetShortcuts implements IContainerWidget
|
||||
{
|
||||
@@ -42,63 +41,63 @@ public class WidgetShortcuts implements IContainerWidget
|
||||
{
|
||||
TIME_DAWN(EnumIcon.TIME_DAWN, ActionHelper::timeDawn, () ->
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.time", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.time.dawn", Config.getSettings().getDawn()));
|
||||
return Component.translatable("gui.worldhandler.shortcuts.tooltip.time", Component.translatable("gui.worldhandler.shortcuts.tooltip.time.dawn", Config.getSettings().getDawn()));
|
||||
}),
|
||||
TIME_NOON(EnumIcon.TIME_NOON, ActionHelper::timeNoon, () ->
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.time", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.time.noon", Config.getSettings().getNoon()));
|
||||
return Component.translatable("gui.worldhandler.shortcuts.tooltip.time", Component.translatable("gui.worldhandler.shortcuts.tooltip.time.noon", Config.getSettings().getNoon()));
|
||||
}),
|
||||
TIME_SUNSET(EnumIcon.TIME_SUNSET, ActionHelper::timeSunset, () ->
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.time", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.time.sunset", Config.getSettings().getSunset()));
|
||||
return Component.translatable("gui.worldhandler.shortcuts.tooltip.time", Component.translatable("gui.worldhandler.shortcuts.tooltip.time.sunset", Config.getSettings().getSunset()));
|
||||
}),
|
||||
TIME_MIDNIGHT(EnumIcon.TIME_MIDNIGHT, ActionHelper::timeMidnight, () ->
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.time", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.time.midnight", Config.getSettings().getMidnight()));
|
||||
return Component.translatable("gui.worldhandler.shortcuts.tooltip.time", Component.translatable("gui.worldhandler.shortcuts.tooltip.time.midnight", Config.getSettings().getMidnight()));
|
||||
}),
|
||||
WEATHER_SUN(EnumIcon.WEATHER_SUN, ActionHelper::weatherClear, () ->
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.weather", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.weather.clear"));
|
||||
return Component.translatable("gui.worldhandler.shortcuts.tooltip.weather", Component.translatable("gui.worldhandler.shortcuts.tooltip.weather.clear"));
|
||||
}),
|
||||
WEATHER_RAIN(EnumIcon.WEATHER_RAIN, ActionHelper::weatherRain, () ->
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.weather", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.weather.rainy"));
|
||||
return Component.translatable("gui.worldhandler.shortcuts.tooltip.weather", Component.translatable("gui.worldhandler.shortcuts.tooltip.weather.rainy"));
|
||||
}),
|
||||
WEATHER_STORM(EnumIcon.WEATHER_STORM, ActionHelper::weatherThunder, () ->
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.weather", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.weather.thunder"));
|
||||
return Component.translatable("gui.worldhandler.shortcuts.tooltip.weather", Component.translatable("gui.worldhandler.shortcuts.tooltip.weather.thunder"));
|
||||
}),
|
||||
DIFFICULTY_PEACEFUL(EnumIcon.DIFFICULTY_PEACEFUL, ActionHelper::difficultyPeaceful, () ->
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.difficulty", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.difficulty.peaceful"));
|
||||
return Component.translatable("gui.worldhandler.shortcuts.tooltip.difficulty", Component.translatable("gui.worldhandler.shortcuts.tooltip.difficulty.peaceful"));
|
||||
}),
|
||||
DIFFICULTY_EASY(EnumIcon.DIFFICULTY_EASY, ActionHelper::difficultyEasy, () ->
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.difficulty", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.difficulty.easy"));
|
||||
return Component.translatable("gui.worldhandler.shortcuts.tooltip.difficulty", Component.translatable("gui.worldhandler.shortcuts.tooltip.difficulty.easy"));
|
||||
}),
|
||||
DIFFICULTY_NORMAL(EnumIcon.DIFFICULTY_NORMAL, ActionHelper::difficultyNormal, () ->
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.difficulty", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.difficulty.normal"));
|
||||
return Component.translatable("gui.worldhandler.shortcuts.tooltip.difficulty", Component.translatable("gui.worldhandler.shortcuts.tooltip.difficulty.normal"));
|
||||
}),
|
||||
DIFFICULTY_HARD(EnumIcon.DIFFICULTY_HARD, ActionHelper::difficultyHard, () ->
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.difficulty", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.difficulty.hard"));
|
||||
return Component.translatable("gui.worldhandler.shortcuts.tooltip.difficulty", Component.translatable("gui.worldhandler.shortcuts.tooltip.difficulty.hard"));
|
||||
}),
|
||||
GAMEMODE_SURVIVAL(EnumIcon.GAMEMODE_SURVIVAL, ActionHelper::gamemodeSurvival, () ->
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.gamemode", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.gamemode.survival"));
|
||||
return Component.translatable("gui.worldhandler.shortcuts.tooltip.gamemode", Component.translatable("gui.worldhandler.shortcuts.tooltip.gamemode.survival"));
|
||||
}),
|
||||
GAMEMODE_CREATIVE(EnumIcon.GAMEMODE_CREATIVE, ActionHelper::gamemodeCreative, () ->
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.gamemode", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.gamemode.creative"));
|
||||
return Component.translatable("gui.worldhandler.shortcuts.tooltip.gamemode", Component.translatable("gui.worldhandler.shortcuts.tooltip.gamemode.creative"));
|
||||
}),
|
||||
GAMEMODE_ADVENTURE(EnumIcon.GAMEMODE_ADVENTURE, ActionHelper::gamemodeAdventure, () ->
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.gamemode", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.gamemode.adventure"));
|
||||
return Component.translatable("gui.worldhandler.shortcuts.tooltip.gamemode", Component.translatable("gui.worldhandler.shortcuts.tooltip.gamemode.adventure"));
|
||||
}),
|
||||
GAMEMODE_SPECTATOR(EnumIcon.GAMEMODE_SPECTATOR, ActionHelper::gamemodeSpectator, () ->
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.gamemode", new TranslatableComponent("gui.worldhandler.shortcuts.tooltip.gamemode.spectator"));
|
||||
return Component.translatable("gui.worldhandler.shortcuts.tooltip.gamemode", Component.translatable("gui.worldhandler.shortcuts.tooltip.gamemode.spectator"));
|
||||
});
|
||||
|
||||
private final EnumIcon icon;
|
||||
|
||||
@@ -7,7 +7,7 @@ import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.util.RenderUtils;
|
||||
import exopandora.worldhandler.util.TextUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class WidgetWatch implements IContainerWidget
|
||||
{
|
||||
@@ -28,7 +28,7 @@ public class WidgetWatch implements IContainerWidget
|
||||
|
||||
if(Config.getSettings().tooltips() && mouseX >= watchX && mouseX <= watchX + 9 && mouseY >= watchY && mouseY <= watchY + 9)
|
||||
{
|
||||
container.renderTooltip(matrix, new TextComponent(TextUtils.formatWorldTime(time)), mouseX, mouseY + 9);
|
||||
container.renderTooltip(matrix, Component.literal(TextUtils.formatWorldTime(time)), mouseX, mouseY + 9);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,13 +12,12 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
public class GuiButtonBase extends Button
|
||||
{
|
||||
public GuiButtonBase(int x, int y, int widthIn, int heightIn, String translationKey, ActionHandler actionHandler)
|
||||
{
|
||||
this(x, y, widthIn, heightIn, new TranslatableComponent(translationKey), actionHandler);
|
||||
this(x, y, widthIn, heightIn, Component.translatable(translationKey), actionHandler);
|
||||
}
|
||||
|
||||
public GuiButtonBase(int x, int y, int widthIn, int heightIn, Component buttonText, ActionHandler actionHandler)
|
||||
|
||||
@@ -13,7 +13,6 @@ import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
|
||||
public class GuiButtonList<T> extends GuiButtonTooltip
|
||||
{
|
||||
@@ -23,7 +22,7 @@ public class GuiButtonList<T> extends GuiButtonTooltip
|
||||
|
||||
public GuiButtonList(int x, int y, List<T> items, int widthIn, int heightIn, Container container, ILogicMapped<T> logic)
|
||||
{
|
||||
super(x, y, widthIn, heightIn, TextComponent.EMPTY, null, null);
|
||||
super(x, y, widthIn, heightIn, Component.empty(), null, null);
|
||||
this.items = items;
|
||||
this.logic = logic;
|
||||
this.persistence = container.getContent().getPersistence(this.logic.getId(), Persistence::new);
|
||||
|
||||
@@ -12,8 +12,8 @@ import exopandora.worldhandler.util.RenderUtils;
|
||||
import exopandora.worldhandler.util.TextUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
|
||||
public class GuiSlider extends GuiButtonBase
|
||||
{
|
||||
@@ -23,7 +23,7 @@ public class GuiSlider extends GuiButtonBase
|
||||
|
||||
public GuiSlider(int x, int y, int widthIn, int heightIn, double min, double max, double start, Container container, ILogicSlider logic)
|
||||
{
|
||||
super(x, y, widthIn, heightIn, TextComponent.EMPTY, null);
|
||||
super(x, y, widthIn, heightIn, Component.empty(), null);
|
||||
this.logic = Objects.requireNonNull(logic);
|
||||
this.container = Objects.requireNonNull(container);
|
||||
this.persistence = this.container.getContent().getPersistence(this.logic.getId(), () -> new Persistence(min, max, min == max ? 0.0 : ((start - min) / (max - min))));
|
||||
|
||||
@@ -2,20 +2,21 @@ package exopandora.worldhandler.gui.widget.button;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class LogicSliderAttribute extends LogicSliderSimple
|
||||
{
|
||||
public LogicSliderAttribute(Attribute attribute, MutableComponent text, Consumer<Integer> listener)
|
||||
{
|
||||
super(attribute.getRegistryName().toString(), text, listener);
|
||||
super(ForgeRegistries.ATTRIBUTES.getKey(attribute).toString(), text, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent formatSuffix(int value)
|
||||
{
|
||||
return new TextComponent("%");
|
||||
return Component.literal("%");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package exopandora.worldhandler.gui.widget.button;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import exopandora.worldhandler.gui.widget.button.GuiSlider.ILogicSlider;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
|
||||
public class LogicSliderSimple implements ILogicSlider
|
||||
{
|
||||
@@ -28,13 +28,13 @@ public class LogicSliderSimple implements ILogicSlider
|
||||
@Override
|
||||
public MutableComponent formatSuffix(int value)
|
||||
{
|
||||
return new TextComponent("");
|
||||
return Component.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent formatValue(int value)
|
||||
{
|
||||
return new TextComponent(": " + String.valueOf(value));
|
||||
return Component.literal(": " + String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package exopandora.worldhandler.gui.widget.menu.impl;
|
||||
|
||||
import exopandora.worldhandler.util.ILogic;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
|
||||
public interface ILogicMapped<T> extends ILogic
|
||||
{
|
||||
@@ -18,7 +18,7 @@ public interface ILogicMapped<T> extends ILogic
|
||||
return tooltip.append(String.format(" (%d/%d)", index, max));
|
||||
}
|
||||
|
||||
return (MutableComponent) TextComponent.EMPTY;
|
||||
return Component.empty();
|
||||
}
|
||||
|
||||
void onClick(T item);
|
||||
|
||||
@@ -15,8 +15,8 @@ import exopandora.worldhandler.gui.widget.button.GuiButtonList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonList.Persistence;
|
||||
import exopandora.worldhandler.gui.widget.menu.Menu;
|
||||
import exopandora.worldhandler.util.Node;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
|
||||
public class MenuButtonList extends Menu
|
||||
{
|
||||
@@ -61,7 +61,7 @@ public class MenuButtonList extends Menu
|
||||
@Override
|
||||
public MutableComponent toTooltip(Node item)
|
||||
{
|
||||
return new TextComponent(item.getKey());
|
||||
return Component.literal(item.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,7 +96,7 @@ public class MenuButtonList extends Menu
|
||||
{
|
||||
for(int x = this.getDepth() + 1; x < this.maxDepth; x++)
|
||||
{
|
||||
GuiButtonBase button = new GuiButtonBase(this.x, this.y + 24 * x, 114, 20, TextComponent.EMPTY, null);
|
||||
GuiButtonBase button = new GuiButtonBase(this.x, this.y + 24 * x, 114, 20, Component.empty(), null);
|
||||
button.active = false;
|
||||
container.add(button);
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.widget.menu.Menu;
|
||||
import exopandora.worldhandler.util.MutableTextComponent;
|
||||
import exopandora.worldhandler.util.UserStylableComponent;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
|
||||
public class MenuColorField extends Menu
|
||||
{
|
||||
@@ -43,34 +43,31 @@ public class MenuColorField extends Menu
|
||||
}
|
||||
|
||||
private GuiTextFieldTooltip textField;
|
||||
private final MutableTextComponent string;
|
||||
private final UserStylableComponent component;
|
||||
private final ILogicColorMenu logic;
|
||||
private final String translationKey;
|
||||
|
||||
public MenuColorField(int x, int y, String translationKey, MutableTextComponent string)
|
||||
public MenuColorField(int x, int y, String translationKey, UserStylableComponent wrappedComponent)
|
||||
{
|
||||
this(x, y, translationKey, string, new ILogicColorMenu(){});
|
||||
this(x, y, translationKey, wrappedComponent, new ILogicColorMenu(){});
|
||||
}
|
||||
|
||||
public MenuColorField(int x, int y, String translationKey, MutableTextComponent string, ILogicColorMenu logic)
|
||||
public MenuColorField(int x, int y, String translationKey, UserStylableComponent wrappedComponent, ILogicColorMenu logic)
|
||||
{
|
||||
super(x, y);
|
||||
this.translationKey = translationKey;
|
||||
this.string = string;
|
||||
this.component = wrappedComponent;
|
||||
this.logic = logic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container)
|
||||
{
|
||||
this.textField = new GuiTextFieldTooltip(this.x + 118, this.y, 114, 20, new TranslatableComponent(this.translationKey));
|
||||
this.textField = new GuiTextFieldTooltip(this.x + 118, this.y, 114, 20, Component.translatable(this.translationKey));
|
||||
this.textField.setFilter(this.logic::validate);
|
||||
this.textField.setFormatter(this.string::formatter);
|
||||
this.textField.setValue(this.string.getContents());
|
||||
this.textField.setResponder(text ->
|
||||
{
|
||||
this.string.setText(text);
|
||||
});
|
||||
this.textField.setFormatter((string, index) -> FormattedCharSequence.forward(string, this.component.getStyle()));
|
||||
this.textField.setValue(this.component.getText());
|
||||
this.textField.setResponder(this.component::setText);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,7 +85,7 @@ public class MenuColorField extends Menu
|
||||
@Override
|
||||
public MutableComponent translate(ChatFormatting item)
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.color").withStyle(item).append(": ").append(new TranslatableComponent("gui.worldhandler.color." + item.getName()));
|
||||
return Component.translatable("gui.worldhandler.color").withStyle(item).append(": ").append(Component.translatable("gui.worldhandler.color." + item.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,7 +103,7 @@ public class MenuColorField extends Menu
|
||||
@Override
|
||||
public void onClick(ChatFormatting item)
|
||||
{
|
||||
MenuColorField.this.string.withStyle(item);
|
||||
MenuColorField.this.component.withStyle(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,29 +113,29 @@ public class MenuColorField extends Menu
|
||||
}
|
||||
}));
|
||||
|
||||
container.add(new GuiButtonBase(this.x + 118, this.y + 48, 20, 20, new TextComponent("I").setStyle(Style.EMPTY.withItalic(this.string.getStyle().isItalic())), () ->
|
||||
container.add(new GuiButtonBase(this.x + 118, this.y + 48, 20, 20, Component.literal("I").setStyle(Style.EMPTY.withItalic(this.component.getStyle().isItalic())), () ->
|
||||
{
|
||||
this.string.setStyle(this.string.getStyle().withItalic(!this.string.getStyle().isItalic()));
|
||||
this.component.setStyle(this.component.getStyle().withItalic(!this.component.getStyle().isItalic()));
|
||||
container.init();
|
||||
}));
|
||||
container.add(new GuiButtonBase(this.x + 118 + 24 - 1, this.y + 48, 20, 20, new TextComponent("B").setStyle(Style.EMPTY.withBold(this.string.getStyle().isBold())), () ->
|
||||
container.add(new GuiButtonBase(this.x + 118 + 24 - 1, this.y + 48, 20, 20, Component.literal("B").setStyle(Style.EMPTY.withBold(this.component.getStyle().isBold())), () ->
|
||||
{
|
||||
this.string.setStyle(this.string.getStyle().withBold(!this.string.getStyle().isBold()));
|
||||
this.component.setStyle(this.component.getStyle().withBold(!this.component.getStyle().isBold()));
|
||||
container.init();
|
||||
}));
|
||||
container.add(new GuiButtonBase(this.x + 118 + 24 * 2 - 1, this.y + 48, 20, 20, new TextComponent("U").setStyle(Style.EMPTY.setUnderlined(this.string.getStyle().isUnderlined())), () ->
|
||||
container.add(new GuiButtonBase(this.x + 118 + 24 * 2 - 1, this.y + 48, 20, 20, Component.literal("U").setStyle(Style.EMPTY.withUnderlined(this.component.getStyle().isUnderlined())), () ->
|
||||
{
|
||||
this.string.setStyle(this.string.getStyle().setUnderlined(!this.string.getStyle().isUnderlined()));
|
||||
this.component.setStyle(this.component.getStyle().withUnderlined(!this.component.getStyle().isUnderlined()));
|
||||
container.init();
|
||||
}));
|
||||
container.add(new GuiButtonBase(this.x + 118 + 24 * 3 - 1, this.y + 48, 20, 20, new TextComponent("S").setStyle(Style.EMPTY.setStrikethrough(this.string.getStyle().isStrikethrough())), () ->
|
||||
container.add(new GuiButtonBase(this.x + 118 + 24 * 3 - 1, this.y + 48, 20, 20, Component.literal("S").setStyle(Style.EMPTY.withStrikethrough(this.component.getStyle().isStrikethrough())), () ->
|
||||
{
|
||||
this.string.setStyle(this.string.getStyle().setStrikethrough(!this.string.getStyle().isStrikethrough()));
|
||||
this.component.setStyle(this.component.getStyle().withStrikethrough(!this.component.getStyle().isStrikethrough()));
|
||||
container.init();
|
||||
}));
|
||||
container.add(new GuiButtonBase(this.x + 118 + 24 * 4 - 2, this.y + 48, 20, 20, new TextComponent("O").setStyle(Style.EMPTY.setObfuscated(this.string.getStyle().isObfuscated())), () ->
|
||||
container.add(new GuiButtonBase(this.x + 118 + 24 * 4 - 2, this.y + 48, 20, 20, Component.literal("O").setStyle(Style.EMPTY.withObfuscated(this.component.getStyle().isObfuscated())), () ->
|
||||
{
|
||||
this.string.setStyle(this.string.getStyle().setObfuscated(!this.string.getStyle().isObfuscated()));
|
||||
this.component.setStyle(this.component.getStyle().withObfuscated(!this.component.getStyle().isObfuscated()));
|
||||
container.init();
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ import exopandora.worldhandler.gui.widget.menu.Menu;
|
||||
import exopandora.worldhandler.util.TextUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
|
||||
public class MenuPageList<T> extends Menu
|
||||
{
|
||||
@@ -89,7 +89,7 @@ public class MenuPageList<T> extends Menu
|
||||
}
|
||||
else
|
||||
{
|
||||
button = new GuiButtonBase(this.x, this.y + (this.height + 4) * x, this.width, this.height, TextComponent.EMPTY, null);
|
||||
button = new GuiButtonBase(this.x, this.y + (this.height + 4) * x, this.width, this.height, Component.empty(), null);
|
||||
button.active = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,8 @@ import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.argument.IDeserializableArgument;
|
||||
import exopandora.worldhandler.builder.impl.UsercontentCommandBuilder;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.ChatType;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class UsercontentAPI
|
||||
{
|
||||
@@ -35,7 +33,7 @@ public class UsercontentAPI
|
||||
|
||||
public void addChatMessage(Object object)
|
||||
{
|
||||
Minecraft.getInstance().gui.handleChat(ChatType.CHAT, new TextComponent(object != null ? object.toString() : "null"), Util.NIL_UUID);
|
||||
Minecraft.getInstance().player.displayClientMessage(Component.literal(object != null ? object.toString() : "null"), false);
|
||||
}
|
||||
|
||||
public void setArgument(String command, String argument, String value)
|
||||
|
||||
@@ -9,9 +9,8 @@ import exopandora.worldhandler.usercontent.UsercontentAPI;
|
||||
import exopandora.worldhandler.usercontent.model.AbstractJsonWidget;
|
||||
import exopandora.worldhandler.usercontent.model.JsonItem;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
public abstract class AbstractWidgetFactory
|
||||
{
|
||||
@@ -56,16 +55,16 @@ public abstract class AbstractWidgetFactory
|
||||
{
|
||||
if(item.getTranslation() != null)
|
||||
{
|
||||
return new TranslatableComponent(item.getTranslation());
|
||||
return Component.translatable(item.getTranslation());
|
||||
}
|
||||
|
||||
return new TextComponent(item.getId());
|
||||
return Component.literal(item.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent toTooltip(JsonItem item)
|
||||
{
|
||||
return new TextComponent(item.getId());
|
||||
return Component.literal(item.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,13 +13,9 @@ import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentChild;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.network.chat.ChatType;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.Difficulty;
|
||||
import net.minecraft.world.level.block.NoteBlock;
|
||||
import net.minecraft.world.level.block.SignBlock;
|
||||
@@ -173,11 +169,11 @@ public class ActionHelper
|
||||
Minecraft.getInstance().setScreen(null);
|
||||
Minecraft.getInstance().mouseHandler.grabMouse();
|
||||
|
||||
Component message = new TranslatableComponent("<" + Main.NAME + "> %s", new TranslatableComponent("worldhandler.error.gui")).withStyle(ChatFormatting.RED);
|
||||
Component cause = new TextComponent(" " + e.getClass().getCanonicalName() + ": " + e.getMessage()).withStyle(ChatFormatting.RED);
|
||||
Component message = Component.translatable("<" + Main.NAME + "> %s", Component.translatable("worldhandler.error.gui")).withStyle(ChatFormatting.RED);
|
||||
Component cause = Component.literal(" " + e.getClass().getCanonicalName() + ": " + e.getMessage()).withStyle(ChatFormatting.RED);
|
||||
|
||||
Minecraft.getInstance().gui.handleChat(ChatType.SYSTEM, message, Util.NIL_UUID);
|
||||
Minecraft.getInstance().gui.handleChat(ChatType.SYSTEM, cause, Util.NIL_UUID);
|
||||
Minecraft.getInstance().gui.getChat().addMessage(message);
|
||||
Minecraft.getInstance().gui.getChat().addMessage(cause);
|
||||
|
||||
WorldHandler.LOGGER.throwing(e);
|
||||
}
|
||||
@@ -187,8 +183,8 @@ public class ActionHelper
|
||||
{
|
||||
if(!CommandHelper.canPlayerIssueCommand() && Config.getSettings().permissionQuery())
|
||||
{
|
||||
Minecraft.getInstance().gui.handleChat(ChatType.SYSTEM, new TextComponent(ChatFormatting.RED + I18n.get("worldhandler.permission.refused")), Util.NIL_UUID);
|
||||
Minecraft.getInstance().gui.handleChat(ChatType.SYSTEM, new TextComponent(ChatFormatting.RED + I18n.get("worldhandler.permission.refused.change", I18n.get("gui.worldhandler.config.settings.permission_query"))), Util.NIL_UUID);
|
||||
Minecraft.getInstance().gui.getChat().addMessage(Component.literal(ChatFormatting.RED + I18n.get("worldhandler.permission.refused")));
|
||||
Minecraft.getInstance().gui.getChat().addMessage(Component.literal(ChatFormatting.RED + I18n.get("worldhandler.permission.refused.change", I18n.get("gui.worldhandler.config.settings.permission_query"))));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -18,11 +18,12 @@ import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.util.Unit;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.level.storage.loot.PredicateManager;
|
||||
import net.minecraftforge.common.crafting.conditions.ICondition.IContext;
|
||||
|
||||
public class AdvancementHelper implements PreparableReloadListener
|
||||
{
|
||||
private static final AdvancementHelper INSTANCE = new AdvancementHelper();
|
||||
private final ServerAdvancementManager manager = new ServerAdvancementManager(new PredicateManager());
|
||||
private final ServerAdvancementManager manager = new ServerAdvancementManager(new PredicateManager(), IContext.EMPTY);
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> reload(PreparationBarrier stage, ResourceManager resourceManager, ProfilerFiller preparationsProfiler, ProfilerFiller reloadProfiler, Executor backgroundExecutor, Executor gameExecutor)
|
||||
|
||||
@@ -97,7 +97,7 @@ public class BlockHelper
|
||||
remove.to().setZ(new Coordinate.Ints(0, Coordinate.Type.RELATIVE));
|
||||
remove.block().set(Blocks.AIR);
|
||||
|
||||
Minecraft.getInstance().player.chat(place.toCommand(FillCommandBuilder.Label.FILL, false));
|
||||
Minecraft.getInstance().player.command(place.toCommand(FillCommandBuilder.Label.FILL, false).substring(1));
|
||||
|
||||
ExecuteCommandBuilder execute = new ExecuteCommandBuilder();
|
||||
AtOptionalArgument at = new AtOptionalArgument(AtOptionalArgument.Label.AT);
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
package exopandora.worldhandler.util;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import net.minecraft.commands.arguments.blocks.BlockStateParser;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.TagParser;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class BlockPredicateParser
|
||||
{
|
||||
private final StringReader reader;
|
||||
private final Map<String, String> vagueProperties = Maps.newHashMap();
|
||||
private ResourceLocation block = new ResourceLocation("");
|
||||
@Nullable
|
||||
private CompoundTag nbt;
|
||||
private boolean isTag;
|
||||
|
||||
public BlockPredicateParser(String string)
|
||||
{
|
||||
this(new StringReader(string));
|
||||
}
|
||||
|
||||
public BlockPredicateParser(StringReader reader)
|
||||
{
|
||||
this.reader = reader;
|
||||
}
|
||||
|
||||
public void parse(boolean allowTags) throws CommandSyntaxException
|
||||
{
|
||||
if(this.reader.canRead() && this.reader.peek() == '#')
|
||||
{
|
||||
if(!allowTags)
|
||||
{
|
||||
throw BlockStateParser.ERROR_NO_TAGS_ALLOWED.createWithContext(this.reader);
|
||||
}
|
||||
|
||||
this.readTag();
|
||||
|
||||
if(this.reader.canRead() && this.reader.peek() == '[')
|
||||
{
|
||||
this.readVagueProperties();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.readBlock();
|
||||
|
||||
if(this.reader.canRead() && this.reader.peek() == '[')
|
||||
{
|
||||
this.readVagueProperties();
|
||||
}
|
||||
}
|
||||
|
||||
if(this.reader.canRead() && this.reader.peek() == '{')
|
||||
{
|
||||
this.readNbt();
|
||||
}
|
||||
}
|
||||
|
||||
private void readBlock() throws CommandSyntaxException
|
||||
{
|
||||
this.block = ResourceLocation.read(this.reader);
|
||||
}
|
||||
|
||||
private void readTag() throws CommandSyntaxException
|
||||
{
|
||||
this.reader.expect('#');
|
||||
this.block = ResourceLocation.read(this.reader);
|
||||
this.isTag = true;
|
||||
}
|
||||
|
||||
private void readVagueProperties() throws CommandSyntaxException
|
||||
{
|
||||
this.reader.skip();
|
||||
this.reader.skipWhitespace();
|
||||
int cursor = -1;
|
||||
|
||||
while(true)
|
||||
{
|
||||
if(this.reader.canRead() && this.reader.peek() != ']')
|
||||
{
|
||||
this.reader.skipWhitespace();
|
||||
int j = this.reader.getCursor();
|
||||
String propertyKey = this.reader.readString();
|
||||
|
||||
if(this.vagueProperties.containsKey(propertyKey))
|
||||
{
|
||||
this.reader.setCursor(j);
|
||||
throw BlockStateParser.ERROR_DUPLICATE_PROPERTY.createWithContext(this.reader, this.block.toString(), propertyKey);
|
||||
}
|
||||
|
||||
this.reader.skipWhitespace();
|
||||
|
||||
if(!this.reader.canRead() || this.reader.peek() != '=')
|
||||
{
|
||||
this.reader.setCursor(j);
|
||||
throw BlockStateParser.ERROR_EXPECTED_VALUE.createWithContext(this.reader, this.block.toString(), propertyKey);
|
||||
}
|
||||
|
||||
this.reader.skip();
|
||||
this.reader.skipWhitespace();
|
||||
cursor = this.reader.getCursor();
|
||||
String propertyValue = this.reader.readString();
|
||||
this.vagueProperties.put(propertyKey, propertyValue);
|
||||
this.reader.skipWhitespace();
|
||||
|
||||
if(!this.reader.canRead())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
cursor = -1;
|
||||
|
||||
if(this.reader.peek() == ',')
|
||||
{
|
||||
this.reader.skip();
|
||||
continue;
|
||||
}
|
||||
|
||||
if(this.reader.peek() != ']')
|
||||
{
|
||||
throw BlockStateParser.ERROR_EXPECTED_END_OF_PROPERTIES.createWithContext(this.reader);
|
||||
}
|
||||
}
|
||||
|
||||
if(this.reader.canRead())
|
||||
{
|
||||
this.reader.skip();
|
||||
return;
|
||||
}
|
||||
|
||||
if(cursor >= 0)
|
||||
{
|
||||
this.reader.setCursor(cursor);
|
||||
}
|
||||
|
||||
throw BlockStateParser.ERROR_EXPECTED_END_OF_PROPERTIES.createWithContext(this.reader);
|
||||
}
|
||||
}
|
||||
|
||||
private void readNbt() throws CommandSyntaxException
|
||||
{
|
||||
this.nbt = new TagParser(this.reader).readStruct();
|
||||
}
|
||||
|
||||
public Optional<Block> getBlock()
|
||||
{
|
||||
Block block = ForgeRegistries.BLOCKS.getValue(this.block);
|
||||
|
||||
if(Blocks.AIR.equals(block))
|
||||
{
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
return Optional.ofNullable(block);
|
||||
}
|
||||
|
||||
public Map<String, String> getVagueProperties()
|
||||
{
|
||||
return this.vagueProperties;
|
||||
}
|
||||
|
||||
public ResourceLocation getResourceLocation()
|
||||
{
|
||||
return this.block;
|
||||
}
|
||||
|
||||
public CompoundTag getNbt()
|
||||
{
|
||||
return this.nbt;
|
||||
}
|
||||
|
||||
public boolean isTag()
|
||||
{
|
||||
return this.isTag;
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,9 @@ import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.command.CommandWH;
|
||||
import exopandora.worldhandler.command.CommandWorldHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class CommandHelper
|
||||
{
|
||||
@@ -16,7 +17,7 @@ public class CommandHelper
|
||||
|
||||
public static void sendFeedback(CommandSourceStack source, String message)
|
||||
{
|
||||
source.sendSuccess(new TextComponent(message), false);
|
||||
source.sendSuccess(Component.literal(message), false);
|
||||
}
|
||||
|
||||
public static boolean canPlayerIssueCommand()
|
||||
@@ -29,10 +30,10 @@ public class CommandHelper
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void registerCommands(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
public static void registerCommands(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext buildContext)
|
||||
{
|
||||
CommandWorldHandler.register(dispatcher);
|
||||
CommandWH.register(dispatcher);
|
||||
CommandWH.register(dispatcher, buildContext);
|
||||
}
|
||||
|
||||
public static void sendCommand(String player, ICommandBuilder builder, Object label)
|
||||
@@ -50,7 +51,7 @@ public class CommandHelper
|
||||
}
|
||||
else if(Minecraft.getInstance().player != null)
|
||||
{
|
||||
Minecraft.getInstance().player.chat(command);
|
||||
Minecraft.getInstance().player.command(command.substring(1));
|
||||
}
|
||||
|
||||
WorldHandler.LOGGER.info("Command: " + command);
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package exopandora.worldhandler.util;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import net.minecraft.commands.arguments.item.ItemParser;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.TagParser;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class ItemPredicateParser
|
||||
{
|
||||
private final StringReader reader;
|
||||
private ResourceLocation item = new ResourceLocation("");
|
||||
@Nullable
|
||||
private CompoundTag nbt;
|
||||
private boolean isTag;
|
||||
|
||||
public ItemPredicateParser(String string)
|
||||
{
|
||||
this(new StringReader(string));
|
||||
}
|
||||
|
||||
public ItemPredicateParser(StringReader reader)
|
||||
{
|
||||
this.reader = reader;
|
||||
}
|
||||
|
||||
public void parse(boolean allowTags) throws CommandSyntaxException
|
||||
{
|
||||
if(this.reader.canRead() && this.reader.peek() == '#')
|
||||
{
|
||||
if(!allowTags)
|
||||
{
|
||||
throw ItemParser.ERROR_NO_TAGS_ALLOWED.createWithContext(this.reader);
|
||||
}
|
||||
|
||||
this.readTag();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.readItem();
|
||||
}
|
||||
|
||||
if(this.reader.canRead() && this.reader.peek() == '{')
|
||||
{
|
||||
this.readNbt();
|
||||
}
|
||||
}
|
||||
|
||||
private void readItem() throws CommandSyntaxException
|
||||
{
|
||||
this.item = ResourceLocation.read(this.reader);
|
||||
}
|
||||
|
||||
private void readTag() throws CommandSyntaxException
|
||||
{
|
||||
this.reader.expect('#');
|
||||
this.item = ResourceLocation.read(this.reader);
|
||||
this.isTag = true;
|
||||
}
|
||||
|
||||
private void readNbt() throws CommandSyntaxException
|
||||
{
|
||||
this.nbt = new TagParser(this.reader).readStruct();
|
||||
}
|
||||
|
||||
public Optional<Item> getItem()
|
||||
{
|
||||
Item item = ForgeRegistries.ITEMS.getValue(this.item);
|
||||
|
||||
if(Items.AIR.equals(item))
|
||||
{
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
return Optional.ofNullable(item);
|
||||
}
|
||||
|
||||
public ResourceLocation getResourceLocation()
|
||||
{
|
||||
return this.item;
|
||||
}
|
||||
|
||||
public CompoundTag getNbt()
|
||||
{
|
||||
return this.nbt;
|
||||
}
|
||||
|
||||
public boolean isTag()
|
||||
{
|
||||
return this.isTag;
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
package exopandora.worldhandler.util;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
|
||||
public class MutableTextComponent extends TextComponent
|
||||
{
|
||||
public MutableTextComponent()
|
||||
{
|
||||
super("");
|
||||
}
|
||||
|
||||
public MutableTextComponent(String text)
|
||||
{
|
||||
super(text);
|
||||
}
|
||||
|
||||
public void setText(String text)
|
||||
{
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText()
|
||||
{
|
||||
if(this.isSpecial())
|
||||
{
|
||||
return MutableTextComponent.getSpecialFormattedText(this.text);
|
||||
}
|
||||
|
||||
return this.text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContents()
|
||||
{
|
||||
return this.text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString()
|
||||
{
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public boolean isSpecial()
|
||||
{
|
||||
return this.text != null && !this.text.isEmpty() && MutableTextComponent.getSpecialFormattedText(this.text).contains("\u00A7");
|
||||
}
|
||||
|
||||
public static String getSpecialFormattedText(String text)
|
||||
{
|
||||
String result = text.replaceAll("\u0026", "\u00A7").replaceAll("\u00A7\u00A7", "\u0026");
|
||||
|
||||
if(result.contains("\u00A7"))
|
||||
{
|
||||
result += ChatFormatting.RESET;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public FormattedCharSequence formatter(String string, Integer index)
|
||||
{
|
||||
return FormattedCharSequence.forward(string, this.getStyle());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Tag serialize()
|
||||
{
|
||||
if(this.getContents() != null && !this.getContents().isEmpty())
|
||||
{
|
||||
return StringTag.valueOf(this.toString());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
MutableTextComponent serial = (MutableTextComponent) this.copy();
|
||||
serial.setText(MutableTextComponent.getSpecialFormattedText(this.getContents()));
|
||||
return Component.Serializer.toJson(serial);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableTextComponent plainCopy()
|
||||
{
|
||||
return new MutableTextComponent(this.text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object)
|
||||
{
|
||||
if(this == object)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(!(object instanceof MutableTextComponent))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
MutableTextComponent stringtextcomponent = (MutableTextComponent) object;
|
||||
return this.text.equals(stringtextcomponent.getContents()) && super.equals(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class NBTHelper
|
||||
{
|
||||
@@ -61,7 +62,7 @@ public class NBTHelper
|
||||
for(Item item : itemArray)
|
||||
{
|
||||
CompoundTag compound = new CompoundTag();
|
||||
compound.putString("id", item.getRegistryName().toString());
|
||||
compound.putString("id", ForgeRegistries.ITEMS.getKey(item).toString());
|
||||
compound.putInt("Count", 1);
|
||||
list.add(compound);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,14 @@ package exopandora.worldhandler.util;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.Main;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.locale.Language;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
@@ -15,13 +18,12 @@ import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
import net.minecraftforge.registries.RegisterEvent;
|
||||
|
||||
public class RegistryHelper
|
||||
{
|
||||
private static final Map<IForgeRegistry<?>, Function<? extends ForgeRegistryEntry<?>, String>> FORGE = new HashMap<IForgeRegistry<?>, Function<? extends ForgeRegistryEntry<?>, String>>();
|
||||
private static final Map<IForgeRegistry<?>, Function<?, String>> FORGE = new HashMap<IForgeRegistry<?>, Function<?, String>>();
|
||||
|
||||
static
|
||||
{
|
||||
@@ -30,8 +32,8 @@ public class RegistryHelper
|
||||
registerRegistry(ForgeRegistries.MOB_EFFECTS, MobEffect::getDescriptionId);
|
||||
registerRegistry(ForgeRegistries.BIOMES, biome ->
|
||||
{
|
||||
ResourceLocation resource = biome.getRegistryName();
|
||||
String key = "biome." + biome.getRegistryName().getNamespace() + "." + resource.getPath();
|
||||
ResourceLocation resource = ForgeRegistries.BIOMES.getKey(biome);
|
||||
String key = "biome." + resource.getNamespace() + "." + resource.getPath();
|
||||
return Language.getInstance().has(key) ? key : resource.toString();
|
||||
});
|
||||
registerRegistry(ForgeRegistries.ENCHANTMENTS, Enchantment::getDescriptionId);
|
||||
@@ -39,14 +41,14 @@ public class RegistryHelper
|
||||
registerRegistry(ForgeRegistries.STAT_TYPES, stat -> "stat." + stat.toString().replace(':', '.'));
|
||||
}
|
||||
|
||||
private static <T extends ForgeRegistryEntry<T>> void registerRegistry(IForgeRegistry<T> registry, Function<T, String> mapper)
|
||||
private static <T> void registerRegistry(IForgeRegistry<T> registry, Function<T, String> mapper)
|
||||
{
|
||||
FORGE.put(registry, mapper);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends ForgeRegistryEntry<T>> String translate(ResourceLocation resource)
|
||||
public static <T> String translate(ResourceLocation resource)
|
||||
{
|
||||
for(IForgeRegistry<?> registry : FORGE.keySet())
|
||||
{
|
||||
@@ -59,13 +61,8 @@ public class RegistryHelper
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T extends IForgeRegistryEntry<T>> void register(IForgeRegistry<T> registry, String name, T entry)
|
||||
public static <T> void register(RegisterEvent event, ResourceKey<Registry<T>> key, String location, Supplier<T> valueSupplier)
|
||||
{
|
||||
register(registry, Main.MODID, name, entry);
|
||||
}
|
||||
|
||||
public static <T extends IForgeRegistryEntry<T>> void register(IForgeRegistry<T> registry, String modid, String name, T entry)
|
||||
{
|
||||
registry.register(entry.setRegistryName(new ResourceLocation(modid, name)));
|
||||
event.register(key, new ResourceLocation(Main.MODID, location), valueSupplier);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
package exopandora.worldhandler.util;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.ClickEvent.Action;
|
||||
|
||||
public class SignText extends MutableTextComponent
|
||||
{
|
||||
public void setCommand(String command)
|
||||
{
|
||||
if(command != null && !command.isEmpty())
|
||||
{
|
||||
this.setStyle(this.getStyle().withClickEvent(new ClickEvent(Action.RUN_COMMAND, command)));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setStyle(this.getStyle().withClickEvent(null));
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getCommand()
|
||||
{
|
||||
if(this.hasCommand())
|
||||
{
|
||||
return this.getStyle().getClickEvent().getValue();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasCommand()
|
||||
{
|
||||
return this.getStyle().getClickEvent() != null && this.getStyle().getClickEvent().getAction() == Action.RUN_COMMAND && this.getStyle().getClickEvent().getValue() != null;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Tag serialize()
|
||||
{
|
||||
return StringTag.valueOf(this.toString());
|
||||
}
|
||||
}
|
||||
@@ -2,40 +2,39 @@ package exopandora.worldhandler.util;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
public class TextUtils
|
||||
{
|
||||
public static final TextComponent ARROW_LEFT = new TextComponent("<");
|
||||
public static final TextComponent ARROW_RIGHT = new TextComponent(">");
|
||||
public static final MutableComponent ARROW_LEFT_BOLD = new TextComponent("<").withStyle(ChatFormatting.BOLD);
|
||||
public static final MutableComponent ARROW_RIGHT_BOLD = new TextComponent(">").withStyle(ChatFormatting.BOLD);
|
||||
public static final Component ARROW_LEFT = Component.literal("<");
|
||||
public static final Component ARROW_RIGHT = Component.literal(">");
|
||||
public static final MutableComponent ARROW_LEFT_BOLD = Component.literal("<").withStyle(ChatFormatting.BOLD);
|
||||
public static final MutableComponent ARROW_RIGHT_BOLD = Component.literal(">").withStyle(ChatFormatting.BOLD);
|
||||
|
||||
public static MutableComponent stripText(MutableComponent string, int maxWidth, Font font)
|
||||
{
|
||||
return TextUtils.stripText(string, (MutableComponent) TextComponent.EMPTY, maxWidth, font);
|
||||
return TextUtils.stripText(string, Component.empty(), maxWidth, font);
|
||||
}
|
||||
|
||||
public static MutableComponent stripText(MutableComponent string, MutableComponent prefix, int maxWidth, Font font)
|
||||
{
|
||||
if(font.width(prefix) + font.width(string) > (maxWidth - font.width(prefix)))
|
||||
{
|
||||
MutableComponent result = new TextComponent("").setStyle(string.getStyle());
|
||||
MutableComponent result = Component.empty().setStyle(string.getStyle());
|
||||
|
||||
for(char c : string.getString().toCharArray())
|
||||
{
|
||||
MutableComponent extension = new TextComponent(result.getString() + c + "...").setStyle(string.getStyle());
|
||||
MutableComponent extension = Component.literal(result.getString() + c + "...").setStyle(string.getStyle());
|
||||
|
||||
if(font.width(extension) < maxWidth)
|
||||
{
|
||||
result = new TextComponent(result.getString() + c).setStyle(string.getStyle());
|
||||
result = Component.literal(result.getString() + c).setStyle(string.getStyle());
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TextComponent(result.getString() + "...").setStyle(string.getStyle());
|
||||
return Component.literal(result.getString() + "...").setStyle(string.getStyle());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,9 +100,9 @@ public class TextUtils
|
||||
{
|
||||
if(text == null)
|
||||
{
|
||||
return (MutableComponent) TextComponent.EMPTY;
|
||||
return Component.empty();
|
||||
}
|
||||
|
||||
return new TranslatableComponent(text, parameters);
|
||||
return Component.translatable(text, parameters);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
package exopandora.worldhandler.util;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.ClickEvent.Action;
|
||||
import net.minecraft.network.chat.ComponentContents;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.network.chat.contents.LiteralContents;
|
||||
|
||||
public class UserStylableComponent extends MutableComponent
|
||||
{
|
||||
private String text = "";
|
||||
|
||||
public UserStylableComponent()
|
||||
{
|
||||
super(ComponentContents.EMPTY, Lists.newArrayList(), Style.EMPTY);
|
||||
}
|
||||
|
||||
public void setText(String text)
|
||||
{
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public String getText()
|
||||
{
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public void setCommand(String command)
|
||||
{
|
||||
if(command != null && !command.isEmpty())
|
||||
{
|
||||
this.setStyle(this.getStyle().withClickEvent(new ClickEvent(Action.RUN_COMMAND, command)));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setStyle(this.getStyle().withClickEvent(null));
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getCommand()
|
||||
{
|
||||
if(this.hasCommand())
|
||||
{
|
||||
return this.getStyle().getClickEvent().getValue();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasCommand()
|
||||
{
|
||||
return this.getStyle().getClickEvent() != null && Action.RUN_COMMAND.equals(this.getStyle().getClickEvent().getAction()) && this.getStyle().getClickEvent().getValue() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComponentContents getContents()
|
||||
{
|
||||
if(this.isStyled())
|
||||
{
|
||||
return new LiteralContents(applyStyleFormatting(this.text));
|
||||
}
|
||||
|
||||
return new LiteralContents(this.text);
|
||||
}
|
||||
|
||||
public boolean isStyled()
|
||||
{
|
||||
return this.text != null && !this.text.isEmpty() && applyStyleFormatting(this.text).contains("\u00A7");
|
||||
}
|
||||
|
||||
private static String applyStyleFormatting(String text)
|
||||
{
|
||||
String result = text.replaceAll("\u0026", "\u00A7").replaceAll("\u00A7\u00A7", "\u0026");
|
||||
|
||||
if(result.contains("\u00A7"))
|
||||
{
|
||||
result += ChatFormatting.RESET;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object)
|
||||
{
|
||||
if(this == object)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(object instanceof UserStylableComponent component)
|
||||
{
|
||||
return this.text.equals(component.text) && this.getStyle().equals(component.getStyle()) && this.getSiblings().equals(component.getSiblings());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash(this.text, this.getStyle(), this.getSiblings());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder(this.text);
|
||||
boolean hasStyle = !this.getStyle().isEmpty();
|
||||
boolean hasSiblings = !this.getSiblings().isEmpty();
|
||||
|
||||
if(hasStyle || hasSiblings)
|
||||
{
|
||||
builder.append('[');
|
||||
|
||||
if(hasStyle)
|
||||
{
|
||||
builder.append("style=");
|
||||
builder.append(this.getStyle());
|
||||
}
|
||||
|
||||
if(hasStyle && hasSiblings)
|
||||
{
|
||||
builder.append(", ");
|
||||
}
|
||||
|
||||
if(hasSiblings)
|
||||
{
|
||||
builder.append("siblings=");
|
||||
builder.append(this.getSiblings());
|
||||
}
|
||||
|
||||
builder.append(']');
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
@@ -4,4 +4,5 @@ public net.minecraft.client.gui.screens.OptionsScreen m_96244_(Lnet/minecraft/se
|
||||
public net.minecraft.commands.arguments.EntityAnchorArgument$Anchor f_90367_ # name
|
||||
public net.minecraft.commands.arguments.coordinates.LocalCoordinates m_119908_(Lcom/mojang/brigadier/StringReader;I)D # readDouble
|
||||
public net.minecraft.advancements.critereon.MinMaxBounds$Doubles <init>(Ljava/lang/Double;Ljava/lang/Double;)V # constructor
|
||||
protected-f net.minecraft.network.chat.TextComponent f_131283_ # text
|
||||
public net.minecraft.network.chat.MutableComponent <init>(Lnet/minecraft/network/chat/ComponentContents;Ljava/util/List;Lnet/minecraft/network/chat/Style;)V # constructor
|
||||
public net.minecraft.commands.arguments.item.ItemParser f_120991_ # ERROR_NO_TAGS_ALLOWED
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
modLoader="javafml"
|
||||
loaderVersion="[40,)"
|
||||
loaderVersion="[41,)"
|
||||
updateJSONURL="https://raw.githubusercontent.com/Exopandora/worldhandler/master/version.json"
|
||||
issueTrackerURL="https://github.com/Exopandora/WorldHandler/issues"
|
||||
displayURL="https://minecraft.curseforge.com/projects/world-handler-command-gui"
|
||||
@@ -11,13 +11,13 @@ license="GPL v3.0"
|
||||
|
||||
[[mods]]
|
||||
modId="worldhandler"
|
||||
version="1.18.2-3.1.2"
|
||||
version="1.19-3.1.2"
|
||||
displayName="World Handler"
|
||||
description="The World Handler provides a simple and easy to use graphical user interface for commands. It lets you create powerful and complex sub-commands alongside NBT-structures within seconds."
|
||||
|
||||
[[dependencies.worldhandler]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
versionRange="[1.18.2,)"
|
||||
versionRange="[1.19,)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"pack": {
|
||||
"description": "World Handler",
|
||||
"pack_format": 8
|
||||
"pack_format": 9
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user