diff --git a/README.md b/README.md
index 2c37671..2a3febf 100644
--- a/README.md
+++ b/README.md
@@ -42,6 +42,7 @@ Curseforge: https://minecraft.curseforge.com/projects/world-handler-command-gui
/spawnpoint
/summon
/time
+ /trigger
/weather
/xp
diff --git a/build.gradle b/build.gradle
index 75afcde..707a569 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,110 +1,132 @@
buildscript {
repositories {
+ maven { url = 'https://files.minecraftforge.net/maven' }
jcenter()
- maven { url = "http://files.minecraftforge.net/maven" }
+ mavenCentral()
}
dependencies {
- classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
+ classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
}
}
-apply plugin: 'net.minecraftforge.gradle.forge'
-//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
+apply plugin: 'net.minecraftforge.gradle'
+// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
+apply plugin: 'eclipse'
+apply plugin: 'maven-publish'
-def mcversion = "1.12.2"
-def modversion = "2.2.1"
-def mccompatible = "1.12"
-def url = "https://minecraft.curseforge.com/projects/world-handler-command-gui"
-def update_url = "https://raw.githubusercontent.com/Exopandora/worldhandler/master/version.json"
-def certificate = "d6261bb645f41db84c74f98e512c2bb43f188af2"
+version = '1.13.2-2.3'
+group = 'exopandora.worldhandler' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
+archivesBaseName = 'WorldHandler'
-version = mcversion + "-" + modversion
-group = "exopandora.worldhandler.WorldHandler" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
-archivesBaseName = "WorldHandler"
-
-sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
-compileJava {
- sourceCompatibility = targetCompatibility = '1.8'
-}
-
-jar {
- manifest {
- attributes 'Main-Class': 'exopandora.worldhandler.Main'
- }
-}
-
-task processMetadata(dependsOn: minecraft) {
- minecraft.replace '$version', modversion
- minecraft.replace '$mcversion', mcversion
- minecraft.replace '$compatible', mccompatible
- minecraft.replace '$url', url
- minecraft.replace '$update_url', update_url
- minecraft.replace '$certificate', certificate
-}
-
-if(project.hasProperty('keyStore')) {
- task signJar(type: SignJar, dependsOn: reobfJar) {
- keyStore = project.keyStore
- alias = project.keyStoreAlias
- storePass = project.keyStorePass
- keyPass = project.keyStoreKeyPass
- inputFile = jar.archivePath
- outputFile = jar.archivePath
- }
- build.dependsOn signJar
-}
+sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
minecraft {
- version = "1.12.2-14.23.4.2705"
- runDir = "run"
-
- // the mappings can be changed at any time, and must be in the following format.
- // snapshot_YYYYMMDD snapshot are built nightly.
- // stable_# stables are built at the discretion of the MCP team.
+ // The mappings can be changed at any time, and must be in the following format.
+ // snapshot_YYYYMMDD Snapshot are built nightly.
+ // stable_# Stables are built at the discretion of the MCP team.
// 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 = "snapshot_20171003"
+ // Simply re-run your setup task after changing the mappings to update your workspace.
+ mappings channel: 'snapshot', version: '20180921-1.13'
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
+
+ // accessTransformer = file('build/resources/main/META-INF/accesstransformer.cfg')
+
+ // Default run configurations.
+ // These can be tweaked, removed, or duplicated as needed.
+ runs {
+ client {
+ workingDirectory project.file('run')
+
+ // Recommended logging data for a userdev environment
+ // property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
+
+ // Recommended logging level for the console
+ // property 'forge.logging.console.level', 'debug'
+
+ mods {
+ worldhandler {
+ source sourceSets.main
+ }
+ }
+ }
+
+ server {
+ workingDirectory project.file('run')
+
+ // Recommended logging data for a userdev environment
+ // property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
+
+ // Recommended logging level for the console
+ // property 'forge.logging.console.level', 'debug'
+
+ mods {
+ worldhandler {
+ source sourceSets.main
+ }
+ }
+ }
+ }
}
dependencies {
- // you may put jars on which you depend on in ./libs
- // or you may define them like so..
- //compile "some.group:artifact:version:classifier"
- //compile "some.group:artifact:version"
-
- // real examples
- //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
- //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
+ // 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.13.2-25.0.100'
- // the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
- //provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
+ // You may put jars on which you depend on in ./libs or you may define them like so..
+ // compile "some.group:artifact:version:classifier"
+ // compile "some.group:artifact:version"
- // the deobf configurations: 'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided,
- // except that these dependencies get remapped to your current MCP mappings
- //deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev'
- //deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
+ // Real examples
+ // compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
+ // compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
- // for more info...
+ // The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
+ // provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
+
+ // These dependencies get remapped to your current MCP mappings
+ // deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'
+
+ // For more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
}
-processResources {
- // this will ensure that this task is redone when the versions change.
- inputs.property "version", project.version
- inputs.property "mcversion", project.minecraft.version
-
- // replace stuff in mcmod.info, nothing else
- from(sourceSets.main.resources.srcDirs) {
- include 'mcmod.info'
-
- // replace version and mcversion
- expand 'version':project.version, 'mcversion':project.minecraft.version
- }
-
- // copy everything else except the mcmod.info
- from(sourceSets.main.resources.srcDirs) {
- exclude 'mcmod.info'
+// Example for how to get properties into the manifest for reading by the runtime..
+jar {
+ manifest {
+ attributes([
+ "Specification-Title": "World Handler",
+ "Specification-Vendor": "Exopandora",
+ "Specification-Version": "1", // We are version 1 of ourselves
+ "Implementation-Title": project.name,
+ "Implementation-Version": "${version}",
+ "Implementation-Vendor" :"Exopandora",
+ "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
+ "Main-Class": "exopandora.worldhandler.Main"
+ ])
}
}
+
+// Example configuration to allow publishing using the maven-publish task
+// we define a custom artifact that is sourced from the reobfJar output task
+// and then declare that to be published
+// Note you'll need to add a repository here
+def reobfFile = file("$buildDir/reobfJar/output.jar")
+def reobfArtifact = artifacts.add('default', reobfFile) {
+ type 'jar'
+ builtBy 'reobfJar'
+}
+publishing {
+ publications {
+ mavenJava(MavenPublication) {
+ artifact reobfArtifact
+ }
+ }
+ repositories {
+ maven {
+ url "file:///${project.projectDir}/mcmodsrepo"
+ }
+ }
+}
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 30d399d..7a3265e 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index e18cba7..949819d 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Mon Sep 14 12:28:28 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
diff --git a/gradlew b/gradlew
index 91a7e26..cccdd3d 100644
--- a/gradlew
+++ b/gradlew
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
##############################################################################
##
@@ -6,47 +6,6 @@
##
##############################################################################
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn ( ) {
- echo "$*"
-}
-
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
-esac
-
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
@@ -61,9 +20,49 @@ while [ -h "$PRG" ] ; do
fi
done
SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >&-
+cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
-cd "$SAVED" >&-
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$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=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# 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
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@@ -90,7 +89,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+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
@@ -114,6 +113,7 @@ fi
if $cygwin ; 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`
@@ -154,11 +154,19 @@ if $cygwin ; then
esac
fi
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+APP_ARGS=$(save "$@")
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+# 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"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index 8a0b282..f955316 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -8,14 +8,14 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -46,10 +46,9 @@ echo location of your Java installation.
goto fail
:init
-@rem Get command-line arguments, handling Windowz variants
+@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@@ -60,11 +59,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
diff --git a/src/main/java/exopandora/worldhandler/Main.java b/src/main/java/exopandora/worldhandler/Main.java
index ddb79d8..cc05653 100644
--- a/src/main/java/exopandora/worldhandler/Main.java
+++ b/src/main/java/exopandora/worldhandler/Main.java
@@ -7,14 +7,14 @@ import java.util.Locale;
import javax.swing.UIManager;
import exopandora.worldhandler.installer.Window;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-@SideOnly(Side.CLIENT)
public class Main
{
public static final String NAME = "World Handler";
public static final String MODID = "worldhandler";
+ public static final String MC_VERSION = "1.13.2";
+ public static final String MOD_VERSION = "2.3";
+ public static final String URL = "https://minecraft.curseforge.com/projects/world-handler-command-gui";
public static void main(String[] args)
{
diff --git a/src/main/java/exopandora/worldhandler/WorldHandler.java b/src/main/java/exopandora/worldhandler/WorldHandler.java
index 09ced55..5df920a 100644
--- a/src/main/java/exopandora/worldhandler/WorldHandler.java
+++ b/src/main/java/exopandora/worldhandler/WorldHandler.java
@@ -1,195 +1,75 @@
package exopandora.worldhandler;
-import org.apache.commons.lang3.ArrayUtils;
+import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.lwjgl.input.Keyboard;
+import org.lwjgl.glfw.GLFW;
-import exopandora.worldhandler.builder.ICommandBuilder;
-import exopandora.worldhandler.builder.ICommandBuilderSyntax;
-import exopandora.worldhandler.command.CommandWH;
-import exopandora.worldhandler.command.CommandWorldHandler;
-import exopandora.worldhandler.config.ConfigButcher;
-import exopandora.worldhandler.config.ConfigSettings;
-import exopandora.worldhandler.config.ConfigSkin;
-import exopandora.worldhandler.config.ConfigSliders;
-import exopandora.worldhandler.event.EventListener;
+import exopandora.worldhandler.config.Config;
import exopandora.worldhandler.gui.category.Category;
import exopandora.worldhandler.gui.content.Content;
-import exopandora.worldhandler.helper.BlockHelper;
+import exopandora.worldhandler.helper.CommandHelper;
+import exopandora.worldhandler.proxy.ClientProxy;
import exopandora.worldhandler.proxy.CommonProxy;
import exopandora.worldhandler.util.UtilKeyBinding;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
-import net.minecraft.command.ICommand;
-import net.minecraft.util.text.ChatType;
-import net.minecraft.util.text.Style;
-import net.minecraft.util.text.TextComponentString;
-import net.minecraft.util.text.TextComponentTranslation;
-import net.minecraft.util.text.event.ClickEvent;
-import net.minecraft.util.text.event.ClickEvent.Action;
import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.common.config.Configuration;
+import net.minecraftforge.fml.DistExecutor;
+import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod;
-import net.minecraftforge.fml.common.Mod.EventHandler;
-import net.minecraftforge.fml.common.Mod.Instance;
-import net.minecraftforge.fml.common.ProgressManager;
-import net.minecraftforge.fml.common.ProgressManager.ProgressBar;
-import net.minecraftforge.fml.common.SidedProxy;
-import net.minecraftforge.fml.common.event.FMLInitializationEvent;
-import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent;
-import net.minecraftforge.fml.common.event.FMLModDisabledEvent;
-import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
-import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
-import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.fml.config.ModConfig.Type;
+import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
+import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
+import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent;
+import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
+import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
-@SideOnly(Side.CLIENT)
-@Mod(modid = Main.MODID, name = Main.NAME, acceptedMinecraftVersions = "[$compatible,)", version = "$version", canBeDeactivated = true, guiFactory = "exopandora.worldhandler.gui.config.GuiFactoryWorldHandler", updateJSON = "$update_url", clientSideOnly = true, certificateFingerprint = "$certificate")
+@Mod(Main.MODID)
public class WorldHandler
{
- @Instance(Main.MODID)
- private static WorldHandler INSTANCE;
+ public static final Logger LOGGER = LogManager.getLogger();
- public static KeyBinding KEY_WORLD_HANDLER = new KeyBinding(Main.NAME, Keyboard.KEY_V, "key.categories.misc");
- public static KeyBinding KEY_WORLD_HANDLER_POS1 = new KeyBinding(Main.NAME + " Pos1", Keyboard.KEY_O, "key.categories.misc");
- public static KeyBinding KEY_WORLD_HANDLER_POS2 = new KeyBinding(Main.NAME + " Pos2", Keyboard.KEY_P, "key.categories.misc");
+ public static final KeyBinding KEY_WORLD_HANDLER = new KeyBinding(Main.NAME, GLFW.GLFW_KEY_V, "key.categories.misc");
+ public static final KeyBinding KEY_WORLD_HANDLER_POS1 = new KeyBinding(Main.NAME + " Pos1", GLFW.GLFW_KEY_O, "key.categories.misc");
+ public static final KeyBinding KEY_WORLD_HANDLER_POS2 = new KeyBinding(Main.NAME + " Pos2", GLFW.GLFW_KEY_P, "key.categories.misc");
- public static final ICommand COMMAND_WORLD_HANDLER = new CommandWorldHandler();
- public static final ICommand COMMAND_WH = new CommandWH();
-
- public static Configuration CONFIG;
- public static Logger LOGGER;
public static String USERNAME = null;
- @SidedProxy(clientSide = "exopandora.worldhandler.proxy.ClientProxy", serverSide = "exopandora.worldhandler.proxy.CommonProxy")
- private static CommonProxy PROXY;
- private EventListener eventListener = new EventListener();
+ private static CommonProxy SIDEPROXY;
- @EventHandler
- public void preInit(FMLPreInitializationEvent event)
+ public WorldHandler()
{
- LOGGER = event.getModLog();
- LOGGER.info("Pre-Initialization");
- LOGGER.info("First Release on March 28 2013 - 02:29 PM CET by Exopandora");
- LOGGER.info("Latest Version: $url");
- CONFIG = new Configuration(event.getSuggestedConfigurationFile());
+ SIDEPROXY = DistExecutor.runForDist(() -> ClientProxy::new, () -> CommonProxy::new);
+ FMLJavaModLoadingContext.get().getModEventBus().addListener(this::commonSetup);
+ FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);
+ FMLJavaModLoadingContext.get().getModEventBus().addListener(this::loadComplete);
+ FMLJavaModLoadingContext.get().getModEventBus().addListener(Config::configLoad);
+ FMLJavaModLoadingContext.get().getModEventBus().addListener(Config::configReload);
+ ModLoadingContext.get().registerConfig(Type.CLIENT, Config.CLIENT_SPEC, Main.MODID + ".toml");
+ MinecraftForge.EVENT_BUS.addListener(this::serverStarting);
}
- @EventHandler
- public void init(FMLInitializationEvent event)
+ private void commonSetup(FMLCommonSetupEvent event)
{
- LOGGER.info("Initialization");
- USERNAME = Minecraft.getMinecraft().getSession().getUsername();
-
- MinecraftForge.EVENT_BUS.register(this.eventListener);
+ SIDEPROXY.setup();
+ }
+
+ private void clientSetup(FMLClientSetupEvent event)
+ {
+ USERNAME = Minecraft.getInstance().getSession().getUsername();
ClientRegistry.registerKeyBinding(KEY_WORLD_HANDLER);
UtilKeyBinding.updatePosKeys();
}
- @EventHandler
- public void postInit(FMLPostInitializationEvent event)
+ private void loadComplete(FMLLoadCompleteEvent event)
{
- LOGGER.info("Post-Initialization");
- }
-
- @EventHandler
- public void loadComplete(FMLLoadCompleteEvent event)
- {
- LOGGER.info("Load-Complete");
- ProgressBar bar = ProgressManager.push(Main.NAME, 2);
- bar.step("Loading Configuration Files");
-
- ConfigSettings.load(CONFIG);
- ConfigSkin.load(CONFIG);
- ConfigSliders.load(CONFIG);
- ConfigButcher.load(CONFIG);
-
- bar.step("Initializing User Interface");
-
Content.registerContents();
Category.registerCategories();
-
- ProgressManager.pop(bar);
}
- @EventHandler
- public void serverLoad(FMLServerStartingEvent event)
+ private void serverStarting(FMLServerStartingEvent event)
{
- event.registerServerCommand(COMMAND_WORLD_HANDLER);
- event.registerServerCommand(COMMAND_WH);
- }
-
- @EventHandler
- public void disable(FMLModDisabledEvent event)
- {
- MinecraftForge.EVENT_BUS.register(this.eventListener);
- Minecraft.getMinecraft().gameSettings.keyBindings = ArrayUtils.removeElement(Minecraft.getMinecraft().gameSettings.keyBindings, KEY_WORLD_HANDLER);
-
- if(UtilKeyBinding.arePosKeysRegistered() && ConfigSettings.arePosShortcutsEnabled())
- {
- UtilKeyBinding.removePosKeys();
- }
- }
-
- public static void updateConfig()
- {
- ConfigSettings.load(CONFIG);
- ConfigSkin.load(CONFIG);
- ConfigButcher.load(CONFIG);
- ConfigSliders.load(CONFIG);
- UtilKeyBinding.updatePosKeys();
- }
-
- public static void sendCommand(ICommandBuilder builder)
- {
- sendCommand(builder, false);
- }
-
- public static void sendCommand(ICommandBuilder builder, boolean special)
- {
- if(builder != null)
- {
- String command;
-
- if(builder instanceof ICommandBuilderSyntax)
- {
- command = ((ICommandBuilderSyntax) builder).toActualCommand();
- }
- else
- {
- command = builder.toCommand();
- }
-
- LOGGER.info("Command: " + command);
-
- if(builder.needsCommandBlock() || special)
- {
- BlockHelper.setCommandBlockNearPlayer(command);
- }
- else
- {
- Minecraft.getMinecraft().player.sendChatMessage(command);
- }
- }
- }
-
- public static void throwError(Exception exception)
- {
- if(!Minecraft.getMinecraft().inGameHasFocus)
- {
- Minecraft.getMinecraft().displayGuiScreen(null);
- Minecraft.getMinecraft().setIngameFocus();
- }
-
- TextComponentString name = new TextComponentString(Main.NAME);
- name.setStyle(new Style().setUnderlined(true).setClickEvent(new ClickEvent(Action.OPEN_URL, "$url")));
-
- TextComponentTranslation message = new TextComponentTranslation("worldhandler.error.gui", name);
- message.setStyle(new Style().setColor(net.minecraft.util.text.TextFormatting.RED));
-
- Minecraft.getMinecraft().ingameGUI.addChatMessage(ChatType.SYSTEM, message);
- exception.printStackTrace();
+ CommandHelper.registerCommands(event.getCommandDispatcher());
}
}
\ No newline at end of file
diff --git a/src/main/java/exopandora/worldhandler/builder/CommandBuilder.java b/src/main/java/exopandora/worldhandler/builder/CommandBuilder.java
index ed27226..cb72cfd 100644
--- a/src/main/java/exopandora/worldhandler/builder/CommandBuilder.java
+++ b/src/main/java/exopandora/worldhandler/builder/CommandBuilder.java
@@ -9,16 +9,19 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.builder.Syntax.SyntaxEntry;
-import exopandora.worldhandler.builder.types.Coordinate;
-import exopandora.worldhandler.builder.types.Level;
+import exopandora.worldhandler.builder.types.BlockResourceLocation;
+import exopandora.worldhandler.builder.types.CoordinateDouble;
+import exopandora.worldhandler.builder.types.CoordinateInt;
+import exopandora.worldhandler.builder.types.GreedyString;
+import exopandora.worldhandler.builder.types.ItemResourceLocation;
import exopandora.worldhandler.builder.types.TargetSelector;
import exopandora.worldhandler.builder.types.Type;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public abstract class CommandBuilder implements ICommandBuilderSyntax
{
private List> command;
@@ -33,6 +36,11 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
this.set(index, node != null ? (node.isEmpty() ? null : node) : null, Type.STRING);
}
+ protected void setNode(int index, GreedyString node)
+ {
+ this.set(index, node != null ? (node.isEmpty() ? null : node) : null, Type.GREEDY_STRING);
+ }
+
protected void setNode(int index, boolean node)
{
this.set(index, node, Type.BOOLEAN);
@@ -73,14 +81,14 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
this.set(index, node, Type.RESOURCE_LOCATION);
}
- protected void setNode(int index, NBTTagCompound nbt)
+ protected void setNode(int index, CoordinateInt coordinate)
{
- this.set(index, nbt, Type.NBT);
+ this.set(index, coordinate, Type.COORDINATE_INT);
}
- protected void setNode(int index, Coordinate coordinate)
+ protected void setNode(int index, CoordinateDouble coordinate)
{
- this.set(index, coordinate, Type.COORDINATE);
+ this.set(index, coordinate, Type.COORDINATE_DOUBLE);
}
protected void setNode(int index, TargetSelector target)
@@ -88,9 +96,19 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
this.set(index, target, Type.TARGET_SELECTOR);
}
- protected void setNode(int index, Level level)
+ protected void setNode(int index, ItemResourceLocation resource)
{
- this.set(index, level, Type.LEVEL);
+ this.set(index, resource != null ? resource.get() : null, Type.ITEM_RESOURCE_LOCATION);
+ }
+
+ protected void setNode(int index, BlockResourceLocation resource)
+ {
+ this.set(index, resource != null ? resource.get() : null, Type.BLOCK_RESOURCE_LOCATION);
+ }
+
+ protected void setNode(int index, NBTTagCompound nbt)
+ {
+ this.set(index, nbt, Type.NBT);
}
private void set(int index, Object value, Type type)
@@ -127,6 +145,12 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
return this.get(index, Type.STRING);
}
+ @Nullable
+ protected String getNodeAsGreedyString(int index)
+ {
+ return this.get(index, Type.GREEDY_STRING);
+ }
+
protected boolean getNodeAsBoolean(int index)
{
return this.get(index, Type.BOOLEAN);
@@ -162,9 +186,14 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
return this.get(index, Type.LONG);
}
- protected Coordinate getNodeAsCoordinate(int index)
+ protected CoordinateInt getNodeAsCoordinateInt(int index)
{
- return this.get(index, Type.COORDINATE);
+ return this.get(index, Type.COORDINATE_INT);
+ }
+
+ protected CoordinateDouble getNodeAsCoordinateDouble(int index)
+ {
+ return this.get(index, Type.COORDINATE_DOUBLE);
}
@Nullable
@@ -179,9 +208,15 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
}
@Nullable
- protected Level getNodeAsLevel(int index)
+ protected ItemResourceLocation getNodeAsItemResourceLocation(int index)
{
- return this.get(index, Type.LEVEL);
+ return this.get(index, Type.ITEM_RESOURCE_LOCATION);
+ }
+
+ @Nullable
+ protected BlockResourceLocation getNodeAsBlockResourceLocation(int index)
+ {
+ return this.get(index, Type.BLOCK_RESOURCE_LOCATION);
}
@Nullable
diff --git a/src/main/java/exopandora/worldhandler/builder/CommandBuilderNBT.java b/src/main/java/exopandora/worldhandler/builder/CommandBuilderNBT.java
index 053d69f..c38e4a4 100644
--- a/src/main/java/exopandora/worldhandler/builder/CommandBuilderNBT.java
+++ b/src/main/java/exopandora/worldhandler/builder/CommandBuilderNBT.java
@@ -4,12 +4,12 @@ import java.util.ArrayList;
import java.util.List;
import exopandora.worldhandler.builder.component.IBuilderComponent;
-import net.minecraft.nbt.NBTBase;
+import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public abstract class CommandBuilderNBT extends CommandBuilder implements ICommandBuilderNBT
{
private final List TAG_TO_COMPONENT = new ArrayList();
@@ -17,14 +17,32 @@ public abstract class CommandBuilderNBT extends CommandBuilder implements IComma
@Override
public String toCommand()
{
- this.setNBT(this.buildNBT());
+ return this.toCommand(true);
+ }
+
+ public String toCommand(boolean rebuildNBT)
+ {
+ if(rebuildNBT)
+ {
+ this.setNBT(this.buildNBT());
+ }
+
return super.toCommand();
}
@Override
public String toActualCommand()
{
- this.setNBT(this.buildNBT());
+ return this.toActualCommand(true);
+ }
+
+ public String toActualCommand(boolean rebuildNBT)
+ {
+ if(rebuildNBT)
+ {
+ this.setNBT(this.buildNBT());
+ }
+
return super.toActualCommand();
}
@@ -34,7 +52,7 @@ public abstract class CommandBuilderNBT extends CommandBuilder implements IComma
for(IBuilderComponent component : this.TAG_TO_COMPONENT)
{
- NBTBase serialized = component.serialize();
+ INBTBase serialized = component.serialize();
if(serialized != null)
{
@@ -45,7 +63,7 @@ public abstract class CommandBuilderNBT extends CommandBuilder implements IComma
}
}
- if(nbt.hasNoTags())
+ if(nbt.isEmpty())
{
return null;
}
diff --git a/src/main/java/exopandora/worldhandler/builder/CommandString.java b/src/main/java/exopandora/worldhandler/builder/CommandString.java
index c69a1ff..e8f63a4 100644
--- a/src/main/java/exopandora/worldhandler/builder/CommandString.java
+++ b/src/main/java/exopandora/worldhandler/builder/CommandString.java
@@ -2,10 +2,10 @@ package exopandora.worldhandler.builder;
import com.mojang.realmsclient.gui.ChatFormatting;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class CommandString
{
private final StringBuilder command = new StringBuilder("/");
diff --git a/src/main/java/exopandora/worldhandler/builder/ICommandBuilder.java b/src/main/java/exopandora/worldhandler/builder/ICommandBuilder.java
index 41d3038..cd10585 100644
--- a/src/main/java/exopandora/worldhandler/builder/ICommandBuilder.java
+++ b/src/main/java/exopandora/worldhandler/builder/ICommandBuilder.java
@@ -1,9 +1,9 @@
package exopandora.worldhandler.builder;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public interface ICommandBuilder
{
static final int MAX_COMMAND_LENGTH = 256;
diff --git a/src/main/java/exopandora/worldhandler/builder/ICommandBuilderNBT.java b/src/main/java/exopandora/worldhandler/builder/ICommandBuilderNBT.java
index 63476cc..150377d 100644
--- a/src/main/java/exopandora/worldhandler/builder/ICommandBuilderNBT.java
+++ b/src/main/java/exopandora/worldhandler/builder/ICommandBuilderNBT.java
@@ -1,10 +1,10 @@
package exopandora.worldhandler.builder;
import net.minecraft.nbt.NBTTagCompound;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public interface ICommandBuilderNBT extends ICommandBuilder
{
void setNBT(NBTTagCompound nbt);
diff --git a/src/main/java/exopandora/worldhandler/builder/ICommandBuilderSyntax.java b/src/main/java/exopandora/worldhandler/builder/ICommandBuilderSyntax.java
index 8539b65..bc57bf6 100644
--- a/src/main/java/exopandora/worldhandler/builder/ICommandBuilderSyntax.java
+++ b/src/main/java/exopandora/worldhandler/builder/ICommandBuilderSyntax.java
@@ -1,9 +1,9 @@
package exopandora.worldhandler.builder;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public interface ICommandBuilderSyntax extends ICommandBuilder
{
String getCommandName();
diff --git a/src/main/java/exopandora/worldhandler/builder/Syntax.java b/src/main/java/exopandora/worldhandler/builder/Syntax.java
index c08403f..a60d104 100644
--- a/src/main/java/exopandora/worldhandler/builder/Syntax.java
+++ b/src/main/java/exopandora/worldhandler/builder/Syntax.java
@@ -4,10 +4,10 @@ import java.util.ArrayList;
import java.util.List;
import exopandora.worldhandler.builder.types.Type;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class Syntax
{
private List syntax = new ArrayList();
@@ -41,7 +41,7 @@ public class Syntax
return this.syntax;
}
- @SideOnly(Side.CLIENT)
+ @OnlyIn(Dist.CLIENT)
public static class SyntaxEntry
{
private final String key;
diff --git a/src/main/java/exopandora/worldhandler/builder/component/IBuilderComponent.java b/src/main/java/exopandora/worldhandler/builder/component/IBuilderComponent.java
index f5dd611..368dfeb 100644
--- a/src/main/java/exopandora/worldhandler/builder/component/IBuilderComponent.java
+++ b/src/main/java/exopandora/worldhandler/builder/component/IBuilderComponent.java
@@ -2,14 +2,14 @@ package exopandora.worldhandler.builder.component;
import javax.annotation.Nullable;
-import net.minecraft.nbt.NBTBase;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraft.nbt.INBTBase;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public interface IBuilderComponent
{
@Nullable
- NBTBase serialize();
+ INBTBase serialize();
String getTag();
}
diff --git a/src/main/java/exopandora/worldhandler/builder/component/abstr/ComponentAttribute.java b/src/main/java/exopandora/worldhandler/builder/component/abstr/ComponentAttribute.java
index a0b9881..6704da6 100644
--- a/src/main/java/exopandora/worldhandler/builder/component/abstr/ComponentAttribute.java
+++ b/src/main/java/exopandora/worldhandler/builder/component/abstr/ComponentAttribute.java
@@ -7,10 +7,10 @@ import java.util.function.Function;
import exopandora.worldhandler.builder.component.IBuilderComponent;
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public abstract class ComponentAttribute implements IBuilderComponent
{
protected Map attributes = new HashMap();
diff --git a/src/main/java/exopandora/worldhandler/builder/component/abstr/ComponentPotion.java b/src/main/java/exopandora/worldhandler/builder/component/abstr/ComponentPotion.java
index c560040..0ac753e 100644
--- a/src/main/java/exopandora/worldhandler/builder/component/abstr/ComponentPotion.java
+++ b/src/main/java/exopandora/worldhandler/builder/component/abstr/ComponentPotion.java
@@ -1,28 +1,28 @@
package exopandora.worldhandler.builder.component.abstr;
+import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import java.util.stream.Collectors;
import javax.annotation.Nullable;
import exopandora.worldhandler.builder.component.IBuilderComponent;
-import net.minecraft.nbt.NBTBase;
+import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.potion.Potion;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public abstract class ComponentPotion implements IBuilderComponent
{
- protected final Map potions = Potion.REGISTRY.getKeys().stream().collect(Collectors.toMap(Potion.REGISTRY::getObject, key -> new PotionMetadata()));
+ protected final Map potions = new HashMap();
@Override
@Nullable
- public NBTBase serialize()
+ public INBTBase serialize()
{
NBTTagList list = new NBTTagList();
@@ -36,138 +36,95 @@ public abstract class ComponentPotion implements IBuilderComponent
compound.setByte("Id", (byte) Potion.getIdFromPotion(entry.getKey()));
compound.setByte("Amplifier", (byte) (potion.getAmplifier() - 1));
- compound.setInteger("Duration", potion.getDurationTicks() > 0 ? Math.min(potion.getDurationTicks(), 1000000) : 1000000);
+ compound.setInt("Duration", Math.min(potion.toTicks(), 1000000));
compound.setBoolean("Ambient", potion.getAmbient());
compound.setBoolean("ShowParticles", potion.getShowParticles());
- list.appendTag(compound);
+ list.add(compound);
}
}
- if(!list.hasNoTags())
+ if(list.isEmpty())
{
- return list;
+ return null;
}
- return null;
- }
-
- public void set(Potion potion, PotionMetadata metadata)
- {
- this.potions.put(potion, metadata);
- }
-
- public void set(Potion potion, byte amplifier, int seconds, int minutes, int hours, boolean showParticles, boolean ambient)
- {
- this.set(potion, new PotionMetadata(amplifier, seconds, minutes, hours, showParticles, ambient));
+ return list;
}
public void setAmplifier(Potion potion, byte amplifier)
{
- if(this.potions.containsKey(potion))
- {
- this.potions.get(potion).setAmplifier(amplifier);
- }
+ this.getMetadata(potion).setAmplifier(amplifier);
}
public byte getAmplifier(Potion potion)
{
- if(this.potions.containsKey(potion))
- {
- return this.potions.get(potion).getAmplifier();
- }
-
- return 0;
+ return this.getMetadata(potion).getAmplifier();
}
public void setSeconds(Potion potion, int seconds)
{
- if(this.potions.containsKey(potion))
- {
- this.potions.get(potion).setSeconds(seconds);;
- }
+ this.getMetadata(potion).setSeconds(seconds);
}
public int getSeconds(Potion potion)
{
- if(this.potions.containsKey(potion))
- {
- return this.potions.get(potion).getSeconds();
- }
-
- return 0;
+ return this.getMetadata(potion).getSeconds();
}
public void setMinutes(Potion potion, int minutes)
{
- if(this.potions.containsKey(potion))
- {
- this.potions.get(potion).setSeconds(minutes);;
- }
+ this.getMetadata(potion).setMinutes(minutes);
}
public int getMinutes(Potion potion)
{
- if(this.potions.containsKey(potion))
- {
- return this.potions.get(potion).getMinutes();
- }
-
- return 0;
+ return this.getMetadata(potion).getMinutes();
}
public void setHours(Potion potion, int hours)
{
- if(this.potions.containsKey(potion))
- {
- this.potions.get(potion).setSeconds(hours);;
- }
+ this.getMetadata(potion).setHours(hours);
}
public int getHours(Potion potion)
{
- if(this.potions.containsKey(potion))
- {
- return this.potions.get(potion).getHours();
- }
-
- return 0;
+ return this.getMetadata(potion).getHours();
}
public void setShowParticles(Potion potion, boolean showParticles)
{
- if(this.potions.containsKey(potion))
- {
- this.potions.get(potion).setShowParticles(showParticles);
- }
+ this.getMetadata(potion).setShowParticles(showParticles);
}
public boolean getShowParticles(Potion potion)
{
- if(this.potions.containsKey(potion))
- {
- return this.potions.get(potion).getShowParticles();
- }
-
- return true;
+ return this.getMetadata(potion).getShowParticles();
}
public void setAmbient(Potion potion, boolean ambient)
{
- if(this.potions.containsKey(potion))
- {
- this.potions.get(potion).setAmbient(ambient);
- }
+ this.getMetadata(potion).setAmbient(ambient);
}
public boolean getAmbient(Potion potion)
{
- if(this.potions.containsKey(potion))
+ return this.getMetadata(potion).getAmbient();
+ }
+
+ private PotionMetadata getMetadata(Potion potion)
+ {
+ return this.potions.get(this.validate(potion));
+ }
+
+ private Potion validate(Potion potion)
+ {
+ if(!this.potions.containsKey(potion))
{
- return this.potions.get(potion).getAmbient();
+ this.potions.put(potion, new PotionMetadata());
}
- return false;
+ return potion;
}
public Set getPotions()
@@ -175,12 +132,6 @@ public abstract class ComponentPotion implements IBuilderComponent
return this.potions.keySet();
}
- @Nullable
- public PotionMetadata get(Potion potion)
- {
- return this.potions.get(potion);
- }
-
public void remove(Potion potion)
{
this.potions.remove(potion);
diff --git a/src/main/java/exopandora/worldhandler/builder/component/abstr/PotionMetadata.java b/src/main/java/exopandora/worldhandler/builder/component/abstr/PotionMetadata.java
index ab1f7e6..7320646 100644
--- a/src/main/java/exopandora/worldhandler/builder/component/abstr/PotionMetadata.java
+++ b/src/main/java/exopandora/worldhandler/builder/component/abstr/PotionMetadata.java
@@ -1,9 +1,9 @@
package exopandora.worldhandler.builder.component.abstr;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class PotionMetadata
{
private byte amplifier;
@@ -88,22 +88,22 @@ public class PotionMetadata
this.ambient = ambient;
}
- public int getDurationTicks()
+ public int toTicks()
{
- return PotionMetadata.getDurationTicks(this.seconds, this.minutes, this.hours);
+ return PotionMetadata.toTicks(this.seconds, this.minutes, this.hours);
}
- public int getDurationSeconds()
+ public int toSeconds()
{
- return PotionMetadata.getDurationSeconds(this.seconds, this.minutes, this.hours);
+ return PotionMetadata.toSeconds(this.seconds, this.minutes, this.hours);
}
- public static int getDurationTicks(int seconds, int minutes, int hours)
+ public static int toTicks(int seconds, int minutes, int hours)
{
return seconds * 20 + minutes * 1200 + hours * 72000;
}
- public static int getDurationSeconds(int seconds, int minutes, int hours)
+ public static int toSeconds(int seconds, int minutes, int hours)
{
return seconds + minutes * 60 + hours * 3600;
}
@@ -143,5 +143,11 @@ public class PotionMetadata
this.ambient = ambient;
return this;
}
+
+ @Override
+ public String toString()
+ {
+ return "PotionMetadata [amplifier=" + amplifier + ", seconds=" + seconds + ", minutes=" + minutes + ", hours=" + hours + ", showParticles=" + showParticles + ", ambient=" + ambient + "]";
+ }
}
diff --git a/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentAttributeItem.java b/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentAttributeItem.java
index c16b991..a347c6a 100644
--- a/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentAttributeItem.java
+++ b/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentAttributeItem.java
@@ -8,13 +8,13 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.builder.component.abstr.ComponentAttribute;
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
-import net.minecraft.nbt.NBTBase;
+import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class ComponentAttributeItem extends ComponentAttribute
{
public ComponentAttributeItem(Function applyable)
@@ -24,7 +24,7 @@ public class ComponentAttributeItem extends ComponentAttribute
@Override
@Nullable
- public NBTBase serialize()
+ public INBTBase serialize()
{
NBTTagList attributes = new NBTTagList();
@@ -37,20 +37,20 @@ public class ComponentAttributeItem extends ComponentAttribute
attribute.setString("AttributeName", entry.getKey().getAttribute());
attribute.setString("Name", entry.getKey().getAttribute());
attribute.setDouble("Amount", entry.getKey().calculate(entry.getValue()));
- attribute.setInteger("Operation", entry.getKey().getOperation().ordinal());
+ attribute.setInt("Operation", entry.getKey().getOperation().ordinal());
attribute.setLong("UUIDLeast", UUID.nameUUIDFromBytes(entry.getKey().getAttribute().getBytes()).getLeastSignificantBits());
attribute.setLong("UUIDMost", UUID.nameUUIDFromBytes(entry.getKey().getAttribute().getBytes()).getMostSignificantBits());
- attributes.appendTag(attribute);
+ attributes.add(attribute);
}
}
- if(!attributes.hasNoTags())
+ if(attributes.isEmpty())
{
- return attributes;
+ return null;
}
- return null;
+ return attributes;
}
@Override
diff --git a/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentAttributeMob.java b/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentAttributeMob.java
index 1981e55..b951c25 100644
--- a/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentAttributeMob.java
+++ b/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentAttributeMob.java
@@ -7,13 +7,13 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.builder.component.abstr.ComponentAttribute;
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
-import net.minecraft.nbt.NBTBase;
+import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class ComponentAttributeMob extends ComponentAttribute
{
public ComponentAttributeMob(Function applyable)
@@ -23,7 +23,7 @@ public class ComponentAttributeMob extends ComponentAttribute
@Override
@Nullable
- public NBTBase serialize()
+ public INBTBase serialize()
{
NBTTagList attributes = new NBTTagList();
@@ -36,16 +36,16 @@ public class ComponentAttributeMob extends ComponentAttribute
attribute.setString("Name", entry.getKey().getAttribute());
attribute.setDouble("Base", entry.getKey().calculate(entry.getValue()));
- attributes.appendTag(attribute);
+ attributes.add(attribute);
}
}
- if(!attributes.hasNoTags())
+ if(attributes.isEmpty())
{
- return attributes;
+ return null;
}
- return null;
+ return attributes;
}
@Override
diff --git a/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentDisplay.java b/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentDisplay.java
index 1dfcc1c..6dea14b 100644
--- a/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentDisplay.java
+++ b/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentDisplay.java
@@ -2,21 +2,23 @@ package exopandora.worldhandler.builder.component.impl;
import exopandora.worldhandler.builder.component.IBuilderComponent;
import exopandora.worldhandler.format.text.ColoredString;
-import net.minecraft.nbt.NBTBase;
+import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraft.util.text.ITextComponent;
+import net.minecraft.util.text.TextComponentString;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class ComponentDisplay implements IBuilderComponent
{
private ColoredString name = new ColoredString();
private String[] lore = new String[2];
@Override
- public NBTBase serialize()
+ public INBTBase serialize()
{
NBTTagCompound display = new NBTTagCompound();
@@ -24,7 +26,7 @@ public class ComponentDisplay implements IBuilderComponent
if(name != null && !name.isEmpty())
{
- display.setString("Name", this.name.toString());
+ display.setString("Name", ITextComponent.Serializer.toJson(new TextComponentString(this.name.toString())));
}
NBTTagList lore = new NBTTagList();
@@ -33,16 +35,16 @@ public class ComponentDisplay implements IBuilderComponent
{
if(this.lore[x] != null && !this.lore[x].isEmpty())
{
- lore.appendTag(new NBTTagString(this.lore[x]));
+ lore.add(new NBTTagString(this.lore[x]));
}
}
- if(!lore.hasNoTags())
+ if(!lore.isEmpty())
{
display.setTag("Lore", lore);
}
- if(!display.hasNoTags())
+ if(!display.isEmpty())
{
return display;
}
diff --git a/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentEnchantment.java b/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentEnchantment.java
index bede153..84b8c0b 100644
--- a/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentEnchantment.java
+++ b/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentEnchantment.java
@@ -1,28 +1,29 @@
package exopandora.worldhandler.builder.component.impl;
+import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import java.util.stream.Collectors;
import javax.annotation.Nullable;
import exopandora.worldhandler.builder.component.IBuilderComponent;
import net.minecraft.enchantment.Enchantment;
-import net.minecraft.nbt.NBTBase;
+import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+import net.minecraftforge.registries.ForgeRegistries;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class ComponentEnchantment implements IBuilderComponent
{
- private Map enchantments = Enchantment.REGISTRY.getKeys().stream().collect(Collectors.toMap(Enchantment.REGISTRY::getObject, key -> (short) 0));
+ private Map enchantments = new HashMap();
@Override
@Nullable
- public NBTBase serialize()
+ public INBTBase serialize()
{
NBTTagList enchantments = new NBTTagList();
@@ -32,24 +33,31 @@ public class ComponentEnchantment implements IBuilderComponent
{
NBTTagCompound enchantment = new NBTTagCompound();
- enchantment.setShort("id", (short) Enchantment.getEnchantmentID(entry.getKey()));
+ enchantment.setString("id", ForgeRegistries.ENCHANTMENTS.getKey(entry.getKey()).toString());
enchantment.setShort("lvl", entry.getValue());
- enchantments.appendTag(enchantment);
+ enchantments.add(enchantment);
}
}
- if(!enchantments.hasNoTags())
+ if(enchantments.isEmpty())
{
- return enchantments;
+ return null;
}
- return null;
+ return enchantments;
}
public void setLevel(Enchantment enchantment, short level)
{
- this.enchantments.put(enchantment, level);
+ if(level == 0)
+ {
+ this.enchantments.remove(enchantment);
+ }
+ else
+ {
+ this.enchantments.put(enchantment, level);
+ }
}
public short getLevel(Enchantment enchantment)
@@ -65,6 +73,6 @@ public class ComponentEnchantment implements IBuilderComponent
@Override
public String getTag()
{
- return "ench";
+ return "Enchantments";
}
}
diff --git a/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentPotionItem.java b/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentPotionItem.java
index 2a0c609..a95bd6e 100644
--- a/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentPotionItem.java
+++ b/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentPotionItem.java
@@ -1,10 +1,10 @@
package exopandora.worldhandler.builder.component.impl;
import exopandora.worldhandler.builder.component.abstr.ComponentPotion;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class ComponentPotionItem extends ComponentPotion
{
@Override
diff --git a/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentPotionMob.java b/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentPotionMob.java
index c5b0e06..bfa6992 100644
--- a/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentPotionMob.java
+++ b/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentPotionMob.java
@@ -1,10 +1,10 @@
package exopandora.worldhandler.builder.component.impl;
import exopandora.worldhandler.builder.component.abstr.ComponentPotion;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class ComponentPotionMob extends ComponentPotion
{
@Override
diff --git a/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentSummon.java b/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentSummon.java
index cfaf5b5..1cadaee 100644
--- a/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentSummon.java
+++ b/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentSummon.java
@@ -7,45 +7,20 @@ import javax.annotation.Nullable;
import org.apache.commons.lang3.StringUtils;
import exopandora.worldhandler.builder.component.IBuilderComponent;
-import exopandora.worldhandler.helper.EntityHelper;
+import exopandora.worldhandler.helper.ResourceHelper;
import net.minecraft.client.resources.I18n;
-import net.minecraft.entity.EntityList;
-import net.minecraft.entity.boss.EntityDragon;
-import net.minecraft.entity.boss.EntityWither;
-import net.minecraft.entity.item.EntityMinecart;
-import net.minecraft.entity.item.EntityMinecartChest;
-import net.minecraft.entity.item.EntityMinecartCommandBlock;
-import net.minecraft.entity.item.EntityMinecartFurnace;
-import net.minecraft.entity.item.EntityMinecartHopper;
-import net.minecraft.entity.item.EntityMinecartMobSpawner;
-import net.minecraft.entity.item.EntityMinecartTNT;
-import net.minecraft.entity.monster.EntityEvoker;
-import net.minecraft.entity.monster.EntityGhast;
-import net.minecraft.entity.monster.EntityIronGolem;
-import net.minecraft.entity.monster.EntityMagmaCube;
-import net.minecraft.entity.monster.EntityPigZombie;
-import net.minecraft.entity.monster.EntitySkeleton;
-import net.minecraft.entity.monster.EntitySnowman;
-import net.minecraft.entity.monster.EntitySpider;
-import net.minecraft.entity.monster.EntityVindicator;
-import net.minecraft.entity.monster.EntityZombie;
-import net.minecraft.entity.passive.EntityChicken;
-import net.minecraft.entity.passive.EntityHorse;
-import net.minecraft.entity.passive.EntityMooshroom;
-import net.minecraft.entity.passive.EntityOcelot;
-import net.minecraft.entity.passive.EntitySquid;
-import net.minecraft.entity.passive.EntityVillager;
-import net.minecraft.entity.passive.EntityWolf;
-import net.minecraft.nbt.NBTBase;
+import net.minecraft.entity.EntityType;
+import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagByte;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+import net.minecraftforge.registries.ForgeRegistries;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class ComponentSummon implements IBuilderComponent
{
private final Random random = new Random();
@@ -86,7 +61,7 @@ public class ComponentSummon implements IBuilderComponent
}
@Override
- public NBTBase serialize()
+ public INBTBase serialize()
{
if(this.name != null)
{
@@ -128,7 +103,7 @@ public class ComponentSummon implements IBuilderComponent
if(this.entity != null)
{
- if(this.entity.equals(EntityHelper.getResourceLocation(EntityZombie.class)))
+ if(this.entity.equals(EntityType.ZOMBIE.getRegistryName()))
{
if(StringUtils.containsIgnoreCase(this.name, "Baby"))
{
@@ -136,30 +111,30 @@ public class ComponentSummon implements IBuilderComponent
return new NBTTagByte((byte) 1);
}
}
- else if(this.entity.equals(EntityHelper.getResourceLocation(EntityChicken.class)))
+ else if(this.entity.equals(EntityType.CHICKEN.getRegistryName()))
{
if(StringUtils.containsIgnoreCase(this.name, "Jockey") && !this.hasPassenger)
{
NBTTagCompound passenger = new NBTTagCompound();
NBTTagList list = new NBTTagList();
- passenger.setString("id", EntityHelper.getResourceLocation(EntityZombie.class).toString());
+ passenger.setString("id", EntityType.ZOMBIE.getRegistryName().toString());
passenger.setBoolean("IsBaby", true);
- list.appendTag(passenger);
+ list.add(passenger);
this.tag = "Passengers";
return list;
}
}
- else if(this.entity.equals(EntityHelper.getResourceLocation(EntitySpider.class)))
+ else if(this.entity.equals(EntityType.SPIDER.getRegistryName()))
{
if(StringUtils.containsIgnoreCase(this.name, "Jockey") && !this.hasPassenger)
{
NBTTagCompound passenger = new NBTTagCompound();
NBTTagList list = new NBTTagList();
- passenger.setString("id", EntityHelper.getResourceLocation(EntitySkeleton.class).toString());
- list.appendTag(passenger);
+ passenger.setString("id", EntityType.SKELETON.getRegistryName().toString());
+ list.add(passenger);
this.tag = "Passengers";
return list;
@@ -180,116 +155,117 @@ public class ComponentSummon implements IBuilderComponent
@Nullable
public static ResourceLocation resolve(String entityName)
{
- String entity = entityName.replaceAll("_| ", "");
+ String name = ResourceHelper.stripToResourceLocation(entityName);
- for(ResourceLocation location : EntityList.ENTITY_EGGS.keySet())
+ for(EntityType> type : ForgeRegistries.ENTITIES.getValues())
{
- if(entityName.equalsIgnoreCase(I18n.format("entity." + EntityHelper.getEntityName(location) + ".name")))
+ if(type.isSummonable() && entityName.equalsIgnoreCase(I18n.format(type.getTranslationKey())))
{
- entity = location.getResourcePath();
- break;
+ return type.getRegistryName();
}
}
+ String entity = name.replaceAll("_", "");
+
if(entity.equalsIgnoreCase("RedCow"))
{
- return EntityHelper.getResourceLocation(EntityMooshroom.class);
+ return EntityType.MOOSHROOM.getRegistryName();
}
else if(entity.equalsIgnoreCase("ChickenJockey"))
{
- return EntityHelper.getResourceLocation(EntityChicken.class);
+ return EntityType.CHICKEN.getRegistryName();
}
else if(entity.equalsIgnoreCase("Pigman") || entity.equalsIgnoreCase("ZombiePig") || entity.equalsIgnoreCase("ZombiePigman"))
{
- return EntityHelper.getResourceLocation(EntityPigZombie.class);
+ return EntityType.ZOMBIE_PIGMAN.getRegistryName();
}
else if(entity.equalsIgnoreCase("Wither"))
{
- return EntityHelper.getResourceLocation(EntityWither.class);
+ return EntityType.WITHER.getRegistryName();
}
else if(entity.equalsIgnoreCase("Dog"))
{
- return EntityHelper.getResourceLocation(EntityWolf.class);
+ return EntityType.WOLF.getRegistryName();
}
else if(entity.equalsIgnoreCase("Dragon"))
{
- return EntityHelper.getResourceLocation(EntityDragon.class);
+ return EntityType.ENDER_DRAGON.getRegistryName();
}
else if(entity.equalsIgnoreCase("minecraft:SnowGolem"))
{
- return EntityHelper.getResourceLocation(EntitySnowman.class);
+ return EntityType.SNOW_GOLEM.getRegistryName();
}
else if(entity.equalsIgnoreCase("Horse") || entity.equalsIgnoreCase("ZombieHorse") || entity.equalsIgnoreCase("SkeletonHorse"))
{
- return EntityHelper.getResourceLocation(EntityHorse.class);
+ return EntityType.HORSE.getRegistryName();
}
else if(entity.equalsIgnoreCase("LavaCube")|| entity.equalsIgnoreCase("MagmaSlime") || entity.equalsIgnoreCase("MagmaCube"))
{
- return EntityHelper.getResourceLocation(EntityMagmaCube.class);
+ return EntityType.MAGMA_CUBE.getRegistryName();
}
else if(entity.equalsIgnoreCase("SpiderJockey"))
{
- return EntityHelper.getResourceLocation(EntitySpider.class);
+ return EntityType.SPIDER.getRegistryName();
}
else if(entity.equalsIgnoreCase("IronGolem"))
{
- return EntityHelper.getResourceLocation(EntityIronGolem.class);
+ return EntityType.IRON_GOLEM.getRegistryName();
}
else if(entity.equalsIgnoreCase("Ozelot") || entity.equals("Ocelot") || entity.equalsIgnoreCase("Cat") || entity.equalsIgnoreCase("Kitty") || entity.equalsIgnoreCase("Kitten"))
{
- return EntityHelper.getResourceLocation(EntityOcelot.class);
+ return EntityType.OCELOT.getRegistryName();
}
else if(entity.equalsIgnoreCase("TESTIFICATE") || entity.equalsIgnoreCase("Blacksmith") || entity.equalsIgnoreCase("Farmer") || entity.equalsIgnoreCase("Fisherman") || entity.equalsIgnoreCase("Shepherd") || entity.equalsIgnoreCase("Fletcher") || entity.equalsIgnoreCase("Librarian") || entity.equalsIgnoreCase("Cleric") || entity.equalsIgnoreCase("Priest") || entity.equalsIgnoreCase("Armorer") || entity.equalsIgnoreCase("WeaponSmith") || entity.equalsIgnoreCase("ToolSmith") || entity.equalsIgnoreCase("Butcher") || entity.equalsIgnoreCase("Leatherworker") || entity.equalsIgnoreCase("Carthographer") || entity.equalsIgnoreCase("Nitwit"))
{
- return EntityHelper.getResourceLocation(EntityVillager.class);
+ return EntityType.VILLAGER.getRegistryName();
}
else if(entity.equalsIgnoreCase("Octopus") || entity.equalsIgnoreCase("Kraken"))
{
- return EntityHelper.getResourceLocation(EntitySquid.class);
+ return EntityType.SQUID.getRegistryName();
}
else if(entity.equalsIgnoreCase("Exwife"))
{
- return EntityHelper.getResourceLocation(EntityGhast.class);
+ return EntityType.GHAST.getRegistryName();
}
else if(entity.equalsIgnoreCase("TNTMinecart"))
{
- return EntityHelper.getResourceLocation(EntityMinecartTNT.class);
+ return EntityType.TNT_MINECART.getRegistryName();
}
else if(entity.equalsIgnoreCase("Minecart"))
{
- return EntityHelper.getResourceLocation(EntityMinecart.class);
+ return EntityType.MINECART.getRegistryName();
}
else if(entity.equalsIgnoreCase("HopperMinecart"))
{
- return EntityHelper.getResourceLocation(EntityMinecartHopper.class);
+ return EntityType.HOPPER_MINECART.getRegistryName();
}
else if(entity.equalsIgnoreCase("ChestMinecart"))
{
- return EntityHelper.getResourceLocation(EntityMinecartChest.class);
+ return EntityType.CHEST_MINECART.getRegistryName();
}
else if(entity.equalsIgnoreCase("SpawnerMinecart"))
{
- return EntityHelper.getResourceLocation(EntityMinecartMobSpawner.class);
+ return EntityType.SPAWNER_MINECART.getRegistryName();
}
else if(entity.equalsIgnoreCase("FurnaceMinecart"))
{
- return EntityHelper.getResourceLocation(EntityMinecartFurnace.class);
+ return EntityType.FURNACE_MINECART.getRegistryName();
}
else if(entity.equalsIgnoreCase("CommandBlockMinecart") || entity.equalsIgnoreCase("MinecartCommand") || entity.equalsIgnoreCase("CommandMinecart"))
{
- return EntityHelper.getResourceLocation(EntityMinecartCommandBlock.class);
+ return EntityType.COMMAND_BLOCK_MINECART.getRegistryName();
}
else if(entity.equalsIgnoreCase("Wizard"))
{
- return EntityHelper.getResourceLocation(EntityEvoker.class);
+ return EntityType.EVOKER.getRegistryName();
}
else if(entity.equalsIgnoreCase("Johnny"))
{
- return EntityHelper.getResourceLocation(EntityVindicator.class);
+ return EntityType.VINDICATOR.getRegistryName();
}
else if(entity.equalsIgnoreCase("BabyZombie"))
{
- return EntityHelper.getResourceLocation(EntityZombie.class);
+ return EntityType.ZOMBIE.getRegistryName();
}
if(entity == null || entity.isEmpty())
@@ -297,6 +273,6 @@ public class ComponentSummon implements IBuilderComponent
return null;
}
- return new ResourceLocation(entity);
+ return ResourceHelper.stringToResourceLocation(name);
}
}
diff --git a/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentTag.java b/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentTag.java
index 14180d5..43c6c70 100644
--- a/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentTag.java
+++ b/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentTag.java
@@ -1,12 +1,13 @@
package exopandora.worldhandler.builder.component.impl;
+import java.util.Collection;
import java.util.function.Function;
import javax.annotation.Nullable;
import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.builder.component.IBuilderComponent;
-import net.minecraft.nbt.NBTBase;
+import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagByte;
import net.minecraft.nbt.NBTTagByteArray;
import net.minecraft.nbt.NBTTagDouble;
@@ -16,24 +17,24 @@ import net.minecraft.nbt.NBTTagIntArray;
import net.minecraft.nbt.NBTTagLong;
import net.minecraft.nbt.NBTTagLongArray;
import net.minecraft.nbt.NBTTagString;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class ComponentTag implements IBuilderComponent
{
- private final Function serializer;
+ private final Function serializer;
private final String tag;
private T value;
- public ComponentTag(String tag, T value, Function serializer)
+ public ComponentTag(String tag, T value, Function serializer)
{
this.tag = tag;
this.value = value;
this.serializer = serializer;
}
- public ComponentTag(String tag, Function serializer)
+ public ComponentTag(String tag, Function serializer)
{
this(tag, null, serializer);
}
@@ -61,7 +62,7 @@ public class ComponentTag implements IBuilderComponent
@Override
@Nullable
- public NBTBase serialize()
+ public INBTBase serialize()
{
if(this.value != null)
{
@@ -80,16 +81,19 @@ public class ComponentTag implements IBuilderComponent
return new NBTTagString(string);
}
- else if(this.value instanceof NBTBase)
+ else if(this.value instanceof INBTBase)
{
- NBTBase base = (NBTBase) this.value;
-
- if(base.hasNoTags())
+ if(this.value instanceof Collection>)
{
- return null;
+ Collection> collection = (Collection>) this.value;
+
+ if(collection.isEmpty())
+ {
+ return null;
+ }
}
- return (NBTBase) this.value;
+ return (INBTBase) this.value;
}
else if(this.value instanceof Integer)
{
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderAdvancement.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderAdvancement.java
index c6d9a20..036566c 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderAdvancement.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderAdvancement.java
@@ -7,10 +7,10 @@ import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type;
import exopandora.worldhandler.helper.EnumHelper;
import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderAdvancement extends CommandBuilder
{
public BuilderAdvancement(EnumMode mode)
@@ -34,7 +34,7 @@ public class BuilderAdvancement extends CommandBuilder
@Nullable
public EnumActionType getActionType()
{
- return EnumHelper.valueOf(EnumActionType.class, this.getNodeAsString(1));
+ return EnumHelper.valueOf(this.getNodeAsString(1), EnumActionType.class);
}
public void setPlayer(String player)
@@ -56,14 +56,14 @@ public class BuilderAdvancement extends CommandBuilder
@Nullable
public EnumMode getMode()
{
- return EnumHelper.valueOf(EnumMode.class, this.getNodeAsString(2));
+ return EnumHelper.valueOf(this.getNodeAsString(2), EnumMode.class);
}
public void setAdvancement(ResourceLocation advancement)
{
this.setNode(3, advancement);
}
-
+
@Nullable
public ResourceLocation getAdvancement()
{
@@ -98,8 +98,8 @@ public class BuilderAdvancement extends CommandBuilder
return syntax;
}
-
- @SideOnly(Side.CLIENT)
+
+ @OnlyIn(Dist.CLIENT)
public static enum EnumActionType
{
GRANT,
@@ -112,7 +112,7 @@ public class BuilderAdvancement extends CommandBuilder
}
}
- @SideOnly(Side.CLIENT)
+ @OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
ONLY,
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderBlockdata.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderBlockdata.java
deleted file mode 100644
index c7dc1b7..0000000
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderBlockdata.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package exopandora.worldhandler.builder.impl;
-
-import exopandora.worldhandler.builder.Syntax;
-import exopandora.worldhandler.builder.impl.abstr.BuilderBlockPos;
-import exopandora.worldhandler.builder.types.Type;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
-public class BuilderBlockdata extends BuilderBlockPos
-{
- @Override
- public void setNBT(NBTTagCompound nbt)
- {
- this.setNode(3, nbt);
- }
-
- @Override
- public String getCommandName()
- {
- return "blockdata";
- }
-
- @Override
- public final Syntax getSyntax()
- {
- Syntax syntax = new Syntax();
-
- syntax.addRequired("x", Type.COORDINATE);
- syntax.addRequired("y", Type.COORDINATE);
- syntax.addRequired("z", Type.COORDINATE);
- syntax.addRequired("nbt", Type.NBT);
-
- return syntax;
- }
-}
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderButcher.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderButcher.java
index 75a59d4..e6eb211 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderButcher.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderButcher.java
@@ -1,49 +1,60 @@
package exopandora.worldhandler.builder.impl;
import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.TargetSelector;
import exopandora.worldhandler.builder.types.Type;
import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderButcher extends CommandBuilder
{
- private final TargetSelector targetSelector;
+ private final TargetSelector targetSelector = new TargetSelector();
public BuilderButcher()
{
- this(new ResourceLocation(""), 0);
+ this("", 0);
}
- public BuilderButcher(ResourceLocation entity, int radius)
+ public BuilderButcher(ResourceLocation entity, int distance)
+ {
+ this(entity.toString(), distance);
+ }
+
+ private BuilderButcher(String entity, int distance)
{
- this.targetSelector = new TargetSelector();
this.setEntity(entity);
- this.setRadius(radius);
+ this.setDistance(distance);
}
- public void setRadius(int radius)
+ public void setDistance(int distance)
{
- this.targetSelector.set("r", radius);
+ this.targetSelector.set("distance", "0.." + distance);
this.setNode(0, this.targetSelector);
}
-
- @Nonnull
- public int getRadius()
+
+ public int getDistance()
{
- return this.targetSelector.get("r");
+ return Integer.parseInt(this.targetSelector.get("distance").substring(3));
}
-
+
+ private void setEntity(String entity)
+ {
+ if(entity != null)
+ {
+ this.targetSelector.set("type", entity);
+ }
+
+ this.setNode(0, this.targetSelector);
+ }
+
public void setEntity(ResourceLocation entity)
{
- this.targetSelector.set("type", entity.toString());
- this.setNode(0, this.targetSelector);
+ this.setEntity(entity.toString());
}
@Nonnull
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderClone.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderClone.java
index e828fe2..053745f 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderClone.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderClone.java
@@ -2,21 +2,22 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.impl.abstr.BuilderDoubleBlockPos;
-import exopandora.worldhandler.builder.types.Coordinate;
+import exopandora.worldhandler.builder.types.Coordinate.CoordinateType;
+import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.builder.types.Type;
import exopandora.worldhandler.helper.EnumHelper;
import net.minecraft.util.math.BlockPos;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderClone extends BuilderDoubleBlockPos
{
public BuilderClone()
{
- this.setX(new Coordinate());
- this.setY(new Coordinate());
- this.setZ(new Coordinate());
+ this.setX(new CoordinateInt(CoordinateType.GLOBAL));
+ this.setY(new CoordinateInt(CoordinateType.GLOBAL));
+ this.setZ(new CoordinateInt(CoordinateType.GLOBAL));
this.setMask(EnumMask.values()[0]);
this.setNode(10, "force");
}
@@ -28,49 +29,49 @@ public class BuilderClone extends BuilderDoubleBlockPos
this.setZ(pos.getZ());
}
- public void setX(float x)
+ public void setX(int x)
{
- this.setX(new Coordinate(x));
+ this.setX(new CoordinateInt(x));
}
- public void setY(float y)
+ public void setY(int y)
{
- this.setY(new Coordinate(y));
+ this.setY(new CoordinateInt(y));
}
- public void setZ(float z)
+ public void setZ(int z)
{
- this.setZ(new Coordinate(z));
+ this.setZ(new CoordinateInt(z));
}
- public void setX(Coordinate x)
+ public void setX(CoordinateInt x)
{
this.setNode(6, x);
}
- public void setY(Coordinate y)
+ public void setY(CoordinateInt y)
{
this.setNode(7, y);
}
- public void setZ(Coordinate z)
+ public void setZ(CoordinateInt z)
{
this.setNode(8, z);
}
- public Coordinate getXCoordiante()
+ public CoordinateInt getXCoordiante()
{
- return this.getNodeAsCoordinate(6);
+ return this.getNodeAsCoordinateInt(6);
}
- public Coordinate getYCoordiante()
+ public CoordinateInt getYCoordiante()
{
- return this.getNodeAsCoordinate(7);
+ return this.getNodeAsCoordinateInt(7);
}
- public Coordinate getZCoordiante()
+ public CoordinateInt getZCoordiante()
{
- return this.getNodeAsCoordinate(8);
+ return this.getNodeAsCoordinateInt(8);
}
public double getX()
@@ -100,7 +101,7 @@ public class BuilderClone extends BuilderDoubleBlockPos
public EnumMask getMask()
{
- return EnumHelper.valueOf(EnumMask.class, this.getNodeAsString(9));
+ return EnumHelper.valueOf(this.getNodeAsString(9), EnumMask.class);
}
@Override
@@ -114,22 +115,22 @@ public class BuilderClone extends BuilderDoubleBlockPos
{
Syntax syntax = new Syntax();
- syntax.addRequired("x1", Type.COORDINATE);
- syntax.addRequired("y1", Type.COORDINATE);
- syntax.addRequired("z1", Type.COORDINATE);
- syntax.addRequired("x2", Type.COORDINATE);
- syntax.addRequired("y2", Type.COORDINATE);
- syntax.addRequired("z2", Type.COORDINATE);
- syntax.addRequired("x", Type.COORDINATE);
- syntax.addRequired("y", Type.COORDINATE);
- syntax.addRequired("z", Type.COORDINATE);
- syntax.addOptional("mask_mode", Type.STRING);
- syntax.addOptional("clone_mode", Type.STRING);
+ syntax.addRequired("x1", Type.COORDINATE_INT);
+ syntax.addRequired("y1", Type.COORDINATE_INT);
+ syntax.addRequired("z1", Type.COORDINATE_INT);
+ syntax.addRequired("x2", Type.COORDINATE_INT);
+ syntax.addRequired("y2", Type.COORDINATE_INT);
+ syntax.addRequired("z2", Type.COORDINATE_INT);
+ syntax.addRequired("x", Type.COORDINATE_INT);
+ syntax.addRequired("y", Type.COORDINATE_INT);
+ syntax.addRequired("z", Type.COORDINATE_INT);
+ syntax.addOptional("mask", Type.STRING);
+ syntax.addOptional("filter", Type.STRING);
return syntax;
}
- @SideOnly(Side.CLIENT)
+ @OnlyIn(Dist.CLIENT)
public static enum EnumMask
{
REPLACE,
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderCustomItem.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderCustomItem.java
index 1a610d5..3d70cdc 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderCustomItem.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderCustomItem.java
@@ -10,10 +10,10 @@ import exopandora.worldhandler.builder.impl.abstr.EnumAttributes.Applyable;
import exopandora.worldhandler.format.text.ColoredString;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderCustomItem extends BuilderGive
{
private final ComponentAttributeItem attribute;
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderData.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderData.java
new file mode 100644
index 0000000..9e5e783
--- /dev/null
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderData.java
@@ -0,0 +1,323 @@
+package exopandora.worldhandler.builder.impl;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import exopandora.worldhandler.builder.Syntax;
+import exopandora.worldhandler.builder.impl.abstr.BuilderBlockPos;
+import exopandora.worldhandler.builder.types.CoordinateInt;
+import exopandora.worldhandler.builder.types.TargetSelector;
+import exopandora.worldhandler.builder.types.Type;
+import exopandora.worldhandler.helper.EnumHelper;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.math.BlockPos;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+
+@OnlyIn(Dist.CLIENT)
+public class BuilderData extends BuilderBlockPos
+{
+ private final TargetSelector targetSelector = new TargetSelector();
+
+ public BuilderData()
+ {
+ super(2);
+ }
+
+ public BuilderData(EnumMode mode, ResourceLocation entity, NBTTagCompound nbt)
+ {
+ this();
+ this.setMode(mode);
+ this.setEntity(entity);
+ this.setNBT(nbt);
+ }
+
+ public BuilderData(EnumMode mode, BlockPos pos, NBTTagCompound nbt)
+ {
+ this();
+ this.setMode(mode);
+ this.setPosition(pos);
+ this.setNBT(nbt);
+ }
+
+ public void setMode(EnumMode mode)
+ {
+ EnumTarget target = this.getTarget();
+
+ this.updateSyntax(this.getSyntax(mode, target));
+ this.setMode0(mode);
+ this.setTarget0(target);
+ }
+
+ private void setMode0(EnumMode mode)
+ {
+ if(mode != null)
+ {
+ this.setNode(0, mode.toString());
+ }
+ }
+
+ public EnumMode getMode()
+ {
+ return EnumHelper.valueOf(this.getNodeAsString(0), EnumMode.class);
+ }
+
+ public void setTarget(EnumTarget target)
+ {
+ EnumMode mode = this.getMode();
+
+ this.updateSyntax(this.getSyntax(mode, target));
+ this.setMode0(mode);
+ this.setTarget0(target);
+ }
+
+ private void setTarget0(EnumTarget target)
+ {
+ if(target != null)
+ {
+ this.setNode(1, target.toString());
+ }
+ }
+
+ public EnumTarget getTarget()
+ {
+ return EnumHelper.valueOf(this.getNodeAsString(1), EnumTarget.class);
+ }
+
+ private void setEntity(String entity)
+ {
+ this.ensureTarget(EnumTarget.ENTITY);
+
+ if(entity != null)
+ {
+ this.targetSelector.set("type", entity);
+ }
+
+ this.setNode(2, this.targetSelector);
+ }
+
+ public void setEntity(ResourceLocation entity)
+ {
+ this.setEntity(entity.toString());
+ }
+
+ @Nonnull
+ public ResourceLocation getEntity()
+ {
+ return this.targetSelector.get("type");
+ }
+
+ public void setPath(String path)
+ {
+ if(this.getMode() == null || !this.getMode().equals(EnumMode.REMOVE))
+ {
+ this.setMode(EnumMode.REMOVE);
+ }
+
+ switch(this.getTarget())
+ {
+ case BLOCK:
+ this.setNode(5, path);
+ break;
+ case ENTITY:
+ this.setNode(3, path);
+ break;
+ default:
+ break;
+ }
+ }
+
+ @Override
+ public void setNBT(NBTTagCompound nbt)
+ {
+ if(this.getMode() == null || !this.getMode().equals(EnumMode.MERGE))
+ {
+ this.setMode(EnumMode.MERGE);
+ }
+
+ EnumTarget target = this.getTarget();
+
+ if(target != null)
+ {
+ switch(target)
+ {
+ case BLOCK:
+ this.setNode(5, nbt);
+ break;
+ case ENTITY:
+ this.setNode(3, nbt);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ @Nullable
+ public NBTTagCompound getNBT()
+ {
+ if(this.getMode() != null && this.getMode().equals(EnumMode.MERGE))
+ {
+ switch(this.getTarget())
+ {
+ case BLOCK:
+ return this.getNodeAsNBT(5);
+ case ENTITY:
+ return this.getNodeAsNBT(3);
+ default:
+ break;
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public String getCommandName()
+ {
+ return "data";
+ }
+
+ @Nullable
+ private final Syntax getSyntax(EnumMode mode, EnumTarget target)
+ {
+ Syntax syntax = new Syntax();
+
+ syntax.addRequired(mode != null ? mode.toString() : "mode", Type.STRING);
+ syntax.addRequired(target != null ? target.toString() : "target", Type.STRING);
+
+ if(target != null)
+ {
+ switch(target)
+ {
+ case BLOCK:
+ syntax.addRequired("x", Type.COORDINATE_INT);
+ syntax.addRequired("y", Type.COORDINATE_INT);
+ syntax.addRequired("z", Type.COORDINATE_INT);
+ break;
+ case ENTITY:
+ syntax.addRequired("entity", Type.TARGET_SELECTOR);
+ break;
+ default:
+ break;
+ }
+
+ switch(mode)
+ {
+ case GET:
+ break;
+ case MERGE:
+ syntax.addRequired("nbt", Type.NBT);
+ break;
+ case REMOVE:
+ syntax.addRequired("path", Type.STRING);
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ syntax.addOptional("...", Type.STRING);
+ }
+
+ return syntax;
+ }
+
+ private void ensureTarget(EnumTarget target)
+ {
+ if(this.getTarget() == null || !target.equals(this.getTarget()))
+ {
+ this.setTarget(target);
+ }
+ }
+
+ @Override
+ public void setX(CoordinateInt x)
+ {
+ this.ensureTarget(EnumTarget.BLOCK);
+ super.setX(x);
+ }
+
+ @Override
+ public void setY(CoordinateInt y)
+ {
+ this.ensureTarget(EnumTarget.BLOCK);
+ super.setY(y);
+ }
+
+ @Override
+ public void setZ(CoordinateInt z)
+ {
+ this.ensureTarget(EnumTarget.BLOCK);
+ super.setZ(z);
+ }
+
+ @Override
+ public CoordinateInt getXCoordinate()
+ {
+ this.ensureTarget(EnumTarget.BLOCK);
+ return super.getXCoordinate();
+ }
+
+ @Override
+ public CoordinateInt getYCoordinate()
+ {
+ this.ensureTarget(EnumTarget.BLOCK);
+ return super.getYCoordinate();
+ }
+
+ @Override
+ public CoordinateInt getZCoordinate()
+ {
+ this.ensureTarget(EnumTarget.BLOCK);
+ return super.getZCoordinate();
+ }
+
+ @Override
+ public BlockPos getBlockPos()
+ {
+ this.ensureTarget(EnumTarget.BLOCK);
+ return super.getBlockPos();
+ }
+
+ @Override
+ public final Syntax getSyntax()
+ {
+ Syntax syntax = new Syntax();
+
+ syntax.addRequired("get|merge|remove", Type.STRING);
+ syntax.addRequired("block|entity", Type.STRING);
+ syntax.addOptional("...", Type.STRING);
+
+ return syntax;
+ }
+
+ @OnlyIn(Dist.CLIENT)
+ public static enum EnumMode
+ {
+ GET,
+ MERGE,
+ REMOVE;
+
+ @Override
+ public String toString()
+ {
+ return this.name().toLowerCase();
+ }
+ }
+
+ @OnlyIn(Dist.CLIENT)
+ public static enum EnumTarget
+ {
+ BLOCK,
+ ENTITY;
+
+ @Override
+ public String toString()
+ {
+ return this.name().toLowerCase();
+ }
+ }
+}
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderDifficulty.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderDifficulty.java
index aed8464..51fdd16 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderDifficulty.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderDifficulty.java
@@ -3,10 +3,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderDifficulty extends CommandBuilder
{
public BuilderDifficulty()
@@ -21,7 +21,10 @@ public class BuilderDifficulty extends CommandBuilder
public void setDifficulty(EnumDifficulty difficulty)
{
- this.setNode(0, difficulty.toString());
+ if(difficulty != null)
+ {
+ this.setNode(0, difficulty.toString());
+ }
}
@Override
@@ -29,7 +32,7 @@ public class BuilderDifficulty extends CommandBuilder
{
return "difficulty";
}
-
+
@Override
public final Syntax getSyntax()
{
@@ -41,7 +44,7 @@ public class BuilderDifficulty extends CommandBuilder
}
@Deprecated
- @SideOnly(Side.CLIENT)
+ @OnlyIn(Dist.CLIENT)
public static enum EnumDifficulty
{
PEACEFUL,
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderEnchantment.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderEnchantment.java
index d12e3d1..4a83c0c 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderEnchantment.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderEnchantment.java
@@ -3,11 +3,12 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type;
+import net.minecraft.enchantment.Enchantment;
import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderEnchantment extends CommandBuilder
{
public void getPlayer(String player)
@@ -25,6 +26,11 @@ public class BuilderEnchantment extends CommandBuilder
return this.getNodeAsResourceLocation(1);
}
+ public void setEnchantment(Enchantment enchantment)
+ {
+ this.setEnchantment(enchantment.getRegistryName());
+ }
+
public void setEnchantment(ResourceLocation enchantment)
{
this.setNode(1, enchantment);
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderExperience.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderExperience.java
index e4122db..c503a08 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderExperience.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderExperience.java
@@ -1,41 +1,39 @@
package exopandora.worldhandler.builder.impl;
+import javax.annotation.Nullable;
+
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
-import exopandora.worldhandler.builder.types.Level;
import exopandora.worldhandler.builder.types.Type;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import exopandora.worldhandler.helper.EnumHelper;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderExperience extends CommandBuilder
{
public BuilderExperience()
{
-
+ this.setLevel(0);
}
- public BuilderExperience(int level, String player)
+ public BuilderExperience(EnumMode mode, int level, String player, EnumUnit unit)
{
+ this.setMode(mode);
this.setLevel(level);
this.setPlayer(player);
+ this.setUnit(unit);
}
- public void setLevel(int level)
+ public void setMode(EnumMode mode)
{
- this.setNode(0, new Level(level));
+ this.setNode(0, mode.toString());
}
- public int getLevel()
+ @Nullable
+ public EnumMode getMode()
{
- Level level = this.getNodeAsLevel(0);
-
- if(level != null)
- {
- return level.getLevel();
- }
-
- return 0;
+ return EnumHelper.valueOf(this.getNodeAsString(0), EnumMode.class);
}
public void setPlayer(String player)
@@ -48,10 +46,31 @@ public class BuilderExperience extends CommandBuilder
return this.getNodeAsString(1);
}
+ public void setLevel(int level)
+ {
+ this.setNode(2, level);
+ }
+
+ public int getLevel()
+ {
+ return this.getNodeAsInt(2);
+ }
+
+ public void setUnit(EnumUnit unit)
+ {
+ this.setNode(3, unit.toString());
+ }
+
+ @Nullable
+ public EnumUnit getUnit()
+ {
+ return EnumHelper.valueOf(this.getNodeAsString(3), EnumUnit.class);
+ }
+
@Override
public String getCommandName()
{
- return "xp";
+ return "experience";
}
@Override
@@ -59,9 +78,53 @@ public class BuilderExperience extends CommandBuilder
{
Syntax syntax = new Syntax();
- syntax.addRequired("amount", Type.LEVEL, new Level(0));
- syntax.addOptional("player", Type.STRING);
+ syntax.addRequired("add|set|query", Type.STRING);
+ syntax.addRequired("player", Type.STRING);
+ syntax.addRequired("amount", Type.INT);
+ syntax.addOptional("levels|points", Type.STRING);
return syntax;
}
+
+ public BuilderExperience getBuilderForAddLevels()
+ {
+ return new BuilderExperience(EnumMode.ADD, this.getLevel(), this.getPlayer(), EnumUnit.LEVELS);
+ }
+
+ public BuilderExperience getBuilderForRemoveLevels()
+ {
+ return new BuilderExperience(EnumMode.ADD, -this.getLevel(), this.getPlayer(), EnumUnit.LEVELS);
+ }
+
+ public BuilderExperience getBuilderForResetLevels()
+ {
+ return new BuilderExperience(EnumMode.SET, 0, this.getPlayer(), EnumUnit.LEVELS);
+ }
+
+ @OnlyIn(Dist.CLIENT)
+ public static enum EnumMode
+ {
+ ADD,
+ SET,
+ QUERY;
+
+ @Override
+ public String toString()
+ {
+ return this.name().toLowerCase();
+ }
+ }
+
+ @OnlyIn(Dist.CLIENT)
+ public static enum EnumUnit
+ {
+ LEVELS,
+ POINTS;
+
+ @Override
+ public String toString()
+ {
+ return this.name().toLowerCase();
+ }
+ }
}
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderFill.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderFill.java
index a420e09..153f93d 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderFill.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderFill.java
@@ -4,112 +4,89 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.impl.abstr.BuilderDoubleBlockPos;
+import exopandora.worldhandler.builder.types.BlockResourceLocation;
+import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.builder.types.Type;
import exopandora.worldhandler.helper.BlockHelper;
import exopandora.worldhandler.helper.EnumHelper;
-import exopandora.worldhandler.helper.ResourceHelper;
-import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraft.util.math.BlockPos;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderFill extends BuilderDoubleBlockPos
{
- public BuilderFill(ResourceLocation block1, EnumBlockHandling handling, ResourceLocation block2)
+ public BuilderFill()
{
- this.setPosition1(BlockHelper.getPos1());
- this.setPosition2(BlockHelper.getPos2());
+
+ }
+
+ public BuilderFill(BlockResourceLocation block1, EnumBlockFilter filter, BlockResourceLocation block2)
+ {
+ this(BlockHelper.getPos1(), BlockHelper.getPos2(), block1, filter, block2);
+ }
+
+ public BuilderFill(BlockPos pos1, BlockPos pos2, BlockResourceLocation block1, EnumBlockFilter handling, BlockResourceLocation block2)
+ {
+ this.setPosition1(pos1);
+ this.setPosition2(pos2);
this.setBlock1(block1);
- this.setMeta1(0);
this.setBlockHandling(handling);
this.setBlock2(block2);
}
- public BuilderFill()
+ public BuilderFill(CoordinateInt x1, CoordinateInt y1, CoordinateInt z1, CoordinateInt x2, CoordinateInt y2, CoordinateInt z2, BlockResourceLocation block1)
{
- this.init();
- }
-
- private void init()
- {
- this.setMeta1(0);
- }
-
- @Deprecated
- public void setMeta1(int meta)
- {
- this.setNode(7, meta);
- }
-
- @Deprecated
- public void setMeta2(int meta)
- {
- this.setNode(10, meta);
+ this.setX1(x1);
+ this.setY1(y1);
+ this.setZ1(z1);
+ this.setX2(x2);
+ this.setY2(y2);
+ this.setZ2(z2);
+ this.setBlock1(block1);
}
public void setBlock1(String block)
{
- this.setBlock1(ResourceHelper.stringToResourceLocationNullable(block, ResourceHelper::isRegisteredBlock));
+ this.setBlock1(BlockResourceLocation.valueOf(block));
}
- public void setBlock1(ResourceLocation location)
+ public void setBlock1(BlockResourceLocation resource)
{
- this.setNode(6, location);
+ this.setNode(6, resource);
}
- public ResourceLocation getBlock1()
+ @Nullable
+ public BlockResourceLocation getBlock1()
{
- return this.getNodeAsResourceLocation(6);
+ return this.getNodeAsBlockResourceLocation(6);
}
- public String getBlock1String()
+ public void setBlockHandling(EnumBlockFilter filter)
{
- ResourceLocation location = this.getBlock1();
-
- if(location != null)
- {
- return location.toString();
- }
-
- return null;
- }
-
- public void setBlockHandling(EnumBlockHandling blockHandling)
- {
- this.setNode(8, blockHandling != null ? blockHandling.toString() : null);
+ this.setNode(7, filter != null ? filter.toString() : null);
}
public void setBlock2(String block)
{
- this.setBlock2(ResourceHelper.stringToResourceLocationNullable(block, ResourceHelper::isRegisteredBlock));
+ this.setBlock2(BlockResourceLocation.valueOf(block));
}
- public void setBlock2(ResourceLocation location)
+ public void setBlock2(BlockResourceLocation resource)
{
- this.setNode(9, location);
- }
-
- public String getBlock2String()
- {
- ResourceLocation location = this.getBlock2();
-
- if(location != null)
- {
- return location.toString();
- }
-
- return null;
- }
-
- public ResourceLocation getBlock2()
- {
- return this.getNodeAsResourceLocation(9);
+ this.setNode(8, resource);
}
@Nullable
- public EnumBlockHandling getBlockHandling()
+ public BlockResourceLocation getBlock2()
{
- return EnumHelper.valueOf(EnumBlockHandling.class, this.getNodeAsString(8));
+ return this.getNodeAsBlockResourceLocation(8);
+ }
+
+ @Nullable
+ public EnumBlockFilter getBlockFilter()
+ {
+ return EnumHelper.valueOf(this.getNodeAsString(7), EnumBlockFilter.class);
}
public BuilderFill getBuilderForFill()
@@ -119,7 +96,7 @@ public class BuilderFill extends BuilderDoubleBlockPos
public BuilderFill getBuilderForReplace()
{
- return new BuilderFill(this.getBlock2(), EnumBlockHandling.REPLACE, this.getBlock1());
+ return new BuilderFill(this.getBlock2(), EnumBlockFilter.REPLACE, this.getBlock1());
}
@Override
@@ -133,23 +110,21 @@ public class BuilderFill extends BuilderDoubleBlockPos
{
Syntax syntax = new Syntax();
- syntax.addRequired("x1", Type.COORDINATE);
- syntax.addRequired("y1", Type.COORDINATE);
- syntax.addRequired("z1", Type.COORDINATE);
- syntax.addRequired("x2", Type.COORDINATE);
- syntax.addRequired("y2", Type.COORDINATE);
- syntax.addRequired("z2", Type.COORDINATE);
- syntax.addRequired("block", Type.RESOURCE_LOCATION);
- syntax.addOptional("data_value", Type.INT);
- syntax.addOptional("old_block_handling", Type.STRING);
- syntax.addOptional("block_2|nbt", Type.RESOURCE_LOCATION, "block_2|nbt");
- syntax.addOptional("data_value", Type.INT, "data_value");
+ syntax.addRequired("x1", Type.COORDINATE_INT);
+ syntax.addRequired("y1", Type.COORDINATE_INT);
+ syntax.addRequired("z1", Type.COORDINATE_INT);
+ syntax.addRequired("x2", Type.COORDINATE_INT);
+ syntax.addRequired("y2", Type.COORDINATE_INT);
+ syntax.addRequired("z2", Type.COORDINATE_INT);
+ syntax.addRequired("block", Type.BLOCK_RESOURCE_LOCATION);
+ syntax.addOptional("filter", Type.STRING);
+ syntax.addOptional("block", Type.BLOCK_RESOURCE_LOCATION, "block");
return syntax;
}
- @SideOnly(Side.CLIENT)
- public static enum EnumBlockHandling
+ @OnlyIn(Dist.CLIENT)
+ public static enum EnumBlockFilter
{
REPLACE,
DESTROY,
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderGamemode.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderGamemode.java
index 6382650..dae7ebe 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderGamemode.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderGamemode.java
@@ -3,9 +3,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+@OnlyIn(Dist.CLIENT)
public class BuilderGamemode extends CommandBuilder
{
public BuilderGamemode()
@@ -51,7 +52,7 @@ public class BuilderGamemode extends CommandBuilder
return syntax;
}
- @SideOnly(Side.CLIENT)
+ @OnlyIn(Dist.CLIENT)
public static enum EnumGamemode
{
SURVIVAL,
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderGamerule.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderGamerule.java
index 2e138a8..eb7caea 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderGamerule.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderGamerule.java
@@ -3,10 +3,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderGamerule extends CommandBuilder
{
public BuilderGamerule()
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderGeneric.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderGeneric.java
index b27e693..fc1d8a2 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderGeneric.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderGeneric.java
@@ -2,10 +2,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandString;
import exopandora.worldhandler.builder.ICommandBuilder;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderGeneric implements ICommandBuilder
{
private final String command;
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderGive.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderGive.java
index ab2a6c2..b295668 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderGive.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderGive.java
@@ -1,30 +1,35 @@
package exopandora.worldhandler.builder.impl;
+import javax.annotation.Nullable;
+
import exopandora.worldhandler.builder.CommandBuilderNBT;
import exopandora.worldhandler.builder.Syntax;
+import exopandora.worldhandler.builder.types.ItemResourceLocation;
import exopandora.worldhandler.builder.types.Type;
import exopandora.worldhandler.helper.ResourceHelper;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+import net.minecraftforge.registries.ForgeRegistries;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderGive extends CommandBuilderNBT
{
- public BuilderGive(String player, ResourceLocation item)
- {
- this.setPlayer(player);
- this.setItem(item);
- this.setAmount(1);
- this.setMetadata(0);
- }
+ private final ItemResourceLocation itemResourceLocation = new ItemResourceLocation();
public BuilderGive()
{
this(null, null);
}
+ public BuilderGive(String player, ResourceLocation item)
+ {
+ this.setPlayer(player);
+ this.setItem(item);
+ this.setCount(1);
+ }
+
public void setPlayer(String username)
{
this.setNode(0, username);
@@ -37,50 +42,41 @@ public class BuilderGive extends CommandBuilderNBT
public void setItem(String item)
{
- this.setItem(ResourceHelper.stringToResourceLocationNullable(item, ResourceHelper::isRegisteredItem));
+ this.setItem(ResourceHelper.assertRegistered(ResourceHelper.stringToResourceLocation(item), ForgeRegistries.ITEMS));
}
public void setItem(ResourceLocation item)
{
- this.setNode(1, item);
+ this.itemResourceLocation.setResourceLocation(item);
+ this.setNode(1, this.itemResourceLocation);
}
- public ResourceLocation getItem()
+ @Nullable
+ public ItemResourceLocation getItem()
{
- return this.getNodeAsResourceLocation(1);
+ return this.getNodeAsItemResourceLocation(1);
}
- public void setAmount(int ammount)
+ public void setCount(int count)
{
- this.setNode(2, ammount);
+ this.setNode(2, count);
}
- public int getAmount()
+ public int getCount()
{
return this.getNodeAsInt(2);
}
- @Deprecated
- public void setMetadata(int metadata)
- {
- this.setNode(3, metadata);
- }
-
- @Deprecated
- public int getMetadata()
- {
- return this.getNodeAsInt(3);
- }
-
@Override
public void setNBT(NBTTagCompound nbt)
{
- this.setNode(4, nbt);
+ this.itemResourceLocation.setNBT(nbt);
+ this.setNode(1, this.itemResourceLocation);
}
public NBTTagCompound getNBT()
{
- return this.getNodeAsNBT(4);
+ return this.getNodeAsItemResourceLocation(1).getNBT();
}
@Override
@@ -95,10 +91,8 @@ public class BuilderGive extends CommandBuilderNBT
Syntax syntax = new Syntax();
syntax.addRequired("player", Type.STRING);
- syntax.addRequired("item", Type.RESOURCE_LOCATION);
- syntax.addRequired("amount", Type.INT);
- syntax.addRequired("data_value", Type.INT);
- syntax.addOptional("nbt", Type.NBT);
+ syntax.addRequired("item", Type.ITEM_RESOURCE_LOCATION);
+ syntax.addRequired("count", Type.INT);
return syntax;
}
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderMultiCommand.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderMultiCommand.java
index d7a2947..1b9222a 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderMultiCommand.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderMultiCommand.java
@@ -3,10 +3,10 @@ package exopandora.worldhandler.builder.impl;
import java.util.Arrays;
import exopandora.worldhandler.builder.ICommandBuilder;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderMultiCommand implements ICommandBuilder
{
private final ICommandBuilder[] builders;
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderNoteEditor.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderNoteEditor.java
index 5aabd4c..c6ed041 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderNoteEditor.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderNoteEditor.java
@@ -1,38 +1,41 @@
package exopandora.worldhandler.builder.impl;
-import exopandora.worldhandler.builder.component.impl.ComponentTag;
+import net.minecraft.client.Minecraft;
+import net.minecraft.init.Blocks;
+import net.minecraft.state.properties.BlockStateProperties;
+import net.minecraft.state.properties.NoteBlockInstrument;
import net.minecraft.util.math.BlockPos;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
-public class BuilderNoteEditor extends BuilderBlockdata
+@OnlyIn(Dist.CLIENT)
+public class BuilderNoteEditor extends BuilderSetBlock
{
- private final ComponentTag note;
-
public BuilderNoteEditor()
{
- this.note = this.registerNBTComponent(new ComponentTag("note"));
+ this.setBlock(Blocks.NOTE_BLOCK.getRegistryName());
+ this.setMode("replace");
}
- public BuilderNoteEditor(byte note)
+ public BuilderNoteEditor(int note)
{
this();
this.setNote(note);
}
- public BuilderNoteEditor(byte note, BlockPos pos)
+ public BuilderNoteEditor(int note, BlockPos pos)
{
this(note);
this.setPosition(pos);
+ this.withState(BlockStateProperties.NOTE_BLOCK_INSTRUMENT, NoteBlockInstrument.byState(Minecraft.getInstance().world.getBlockState(pos)));
}
- public void setNote(byte note)
+ public void setNote(int note)
{
- this.note.setValue(note);
+ this.withState(BlockStateProperties.NOTE_0_24, note);
}
- public BuilderNoteEditor getBuilderForNote(byte note)
+ public BuilderNoteEditor getBuilderForNote(int note)
{
return new BuilderNoteEditor(note, this.getBlockPos());
}
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderPlayer.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderPlayer.java
index 8edfa5e..45fad76 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderPlayer.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderPlayer.java
@@ -3,10 +3,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderPlayer extends CommandBuilder
{
private final String command;
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderPlayerReason.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderPlayerReason.java
index 2920bcb..f6bf215 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderPlayerReason.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderPlayerReason.java
@@ -3,10 +3,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderPlayerReason extends CommandBuilder
{
private final String command;
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderPotionEffect.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderPotionEffect.java
index 6071ad2..b8e017d 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderPotionEffect.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderPotionEffect.java
@@ -8,10 +8,11 @@ import exopandora.worldhandler.builder.component.abstr.PotionMetadata;
import exopandora.worldhandler.builder.types.Type;
import net.minecraft.potion.Potion;
import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+import net.minecraftforge.registries.ForgeRegistries;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderPotionEffect extends CommandBuilder
{
private int seconds;
@@ -20,16 +21,17 @@ public class BuilderPotionEffect extends CommandBuilder
public BuilderPotionEffect()
{
- this(null, null);
+ this(null, null, null);
}
- public BuilderPotionEffect(String player, ResourceLocation effect)
+ public BuilderPotionEffect(EnumMode mode, String player, ResourceLocation effect)
{
- this(player, effect, 0, (byte) 0, false);
+ this(mode, player, effect, 0, (byte) 0, false);
}
- public BuilderPotionEffect(String player, ResourceLocation effect, int duration, byte amplifier, boolean hideParticles)
+ public BuilderPotionEffect(EnumMode mode, String player, ResourceLocation effect, int duration, byte amplifier, boolean hideParticles)
{
+ this.setMode(mode);
this.setPlayer(player);
this.setEffect(effect);
this.setDuration(duration);
@@ -37,29 +39,42 @@ public class BuilderPotionEffect extends CommandBuilder
this.setHideParticles(hideParticles);
}
+ public void setMode(EnumMode mode)
+ {
+ if(mode != null)
+ {
+ this.setNode(0, mode.toString());
+ }
+ }
+
public void setPlayer(String player)
{
- this.setNode(0, player);
+ this.setNode(1, player);
}
public String getPlayer()
{
- return this.getNodeAsString(0);
+ return this.getNodeAsString(1);
+ }
+
+ public void setEffect(Potion effect)
+ {
+ this.setEffect(effect.getRegistryName());
}
public void setEffect(ResourceLocation effect)
{
- this.setNode(1, effect);
+ this.setNode(2, effect);
}
@Nullable
public Potion getEffectAsPotion()
{
- ResourceLocation location = this.getNodeAsResourceLocation(1);
+ ResourceLocation location = this.getNodeAsResourceLocation(2);
if(location != null)
{
- return Potion.getPotionFromResourceLocation(location.toString());
+ return ForgeRegistries.POTIONS.getValue(location);
}
return null;
@@ -67,37 +82,37 @@ public class BuilderPotionEffect extends CommandBuilder
public ResourceLocation getEffect()
{
- return this.getNodeAsResourceLocation(1);
+ return this.getNodeAsResourceLocation(2);
}
public void setDuration(int duration)
{
- this.setNode(2, Math.min(duration, 1000000));
+ this.setNode(3, Math.min(duration, 1000000));
}
public int getDuration()
{
- return this.getNodeAsInt(2);
+ return this.getNodeAsInt(3);
}
public void setAmplifier(byte amplifier)
{
- this.setNode(3, (byte) (amplifier - 1));
+ this.setNode(4, (byte) (amplifier - 1));
}
public int getAmplifier()
{
- return this.getNodeAsByte(3);
+ return this.getNodeAsByte(4);
}
public void setHideParticles(boolean hideParticles)
{
- this.setNode(4, hideParticles);
+ this.setNode(5, hideParticles);
}
public boolean getHideParticles()
{
- return this.getNodeAsBoolean(4);
+ return this.getNodeAsBoolean(5);
}
public int getSeconds()
@@ -108,7 +123,7 @@ public class BuilderPotionEffect extends CommandBuilder
public void setSeconds(int seconds)
{
this.seconds = seconds;
- this.setDuration(PotionMetadata.getDurationSeconds(this.seconds, this.minutes, this.hours));
+ this.setDuration(PotionMetadata.toSeconds(this.seconds, this.minutes, this.hours));
}
public int getMinutes()
@@ -119,7 +134,7 @@ public class BuilderPotionEffect extends CommandBuilder
public void setMinutes(int minutes)
{
this.minutes = minutes;
- this.setDuration(PotionMetadata.getDurationSeconds(this.seconds, this.minutes, this.hours));
+ this.setDuration(PotionMetadata.toSeconds(this.seconds, this.minutes, this.hours));
}
public int getHours()
@@ -130,17 +145,22 @@ public class BuilderPotionEffect extends CommandBuilder
public void setHours(int hours)
{
this.hours = hours;
- this.setDuration(PotionMetadata.getDurationSeconds(this.seconds, this.minutes, this.hours));
+ this.setDuration(PotionMetadata.toSeconds(this.seconds, this.minutes, this.hours));
+ }
+
+ public BuilderGeneric getGiveCommand()
+ {
+ return new BuilderGeneric(this.getCommandName(), EnumMode.GIVE.toString(), this.getPlayer(), this.getEffect().toString(), String.valueOf(this.getDuration()), String.valueOf(this.getAmplifier()), String.valueOf(this.getHideParticles()));
}
public BuilderGeneric getRemoveCommand()
{
- return new BuilderGeneric(this.getCommandName(), this.getPlayer(), this.getEffect().toString(), "0");
+ return new BuilderGeneric(this.getCommandName(), EnumMode.CLEAR.toString(), this.getPlayer(), this.getEffect().toString());
}
public BuilderGeneric getClearCommand()
{
- return new BuilderGeneric(this.getCommandName(), this.getPlayer(), "clear");
+ return new BuilderGeneric(this.getCommandName(), EnumMode.CLEAR.toString(), this.getPlayer());
}
@Override
@@ -154,6 +174,7 @@ public class BuilderPotionEffect extends CommandBuilder
{
Syntax syntax = new Syntax();
+ syntax.addRequired("give|clear", Type.STRING);
syntax.addRequired("player", Type.STRING);
syntax.addRequired("effect", Type.RESOURCE_LOCATION);
syntax.addOptional("seconds", Type.INT, 0);
@@ -162,4 +183,17 @@ public class BuilderPotionEffect extends CommandBuilder
return syntax;
}
+
+ @OnlyIn(Dist.CLIENT)
+ public static enum EnumMode
+ {
+ GIVE,
+ CLEAR;
+
+ @Override
+ public String toString()
+ {
+ return this.name().toLowerCase();
+ }
+ }
}
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderPotionItem.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderPotionItem.java
index 7587abc..7e992d3 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderPotionItem.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderPotionItem.java
@@ -6,10 +6,10 @@ import exopandora.worldhandler.builder.component.impl.ComponentPotionItem;
import net.minecraft.item.Item;
import net.minecraft.potion.Potion;
import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderPotionItem extends BuilderGive
{
private final ComponentPotionItem potion;
@@ -27,62 +27,62 @@ public class BuilderPotionItem extends BuilderGive
public void setAmplifier(Potion potion, byte amplifier)
{
- this.potion.get(potion).setAmplifier(amplifier);
+ this.potion.setAmplifier(potion, amplifier);
}
public void setSeconds(Potion potion, int seconds)
{
- this.potion.get(potion).setSeconds(seconds);
+ this.potion.setSeconds(potion, seconds);
}
public void setMinutes(Potion potion, int minutes)
{
- this.potion.get(potion).setMinutes(minutes);
+ this.potion.setMinutes(potion, minutes);
}
public void setHours(Potion potion, int hours)
{
- this.potion.get(potion).setHours(hours);
+ this.potion.setHours(potion, hours);
}
public void setShowParticles(Potion potion, boolean showParticles)
{
- this.potion.get(potion).setShowParticles(showParticles);
+ this.potion.setShowParticles(potion, showParticles);
}
public void setAmbient(Potion potion, boolean ambient)
{
- this.potion.get(potion).setAmbient(ambient);
+ this.potion.setAmbient(potion, ambient);
}
public byte getAmplifier(Potion potion)
{
- return this.potion.get(potion).getAmplifier();
+ return this.potion.getAmplifier(potion);
}
public int getSeconds(Potion potion)
{
- return this.potion.get(potion).getSeconds();
+ return this.potion.getSeconds(potion);
}
public int getMinutes(Potion potion)
{
- return this.potion.get(potion).getMinutes();
+ return this.potion.getMinutes(potion);
}
public int getHours(Potion potion)
{
- return this.potion.get(potion).getHours();
+ return this.potion.getHours(potion);
}
public boolean getShowParticles(Potion potion)
{
- return this.potion.get(potion).getShowParticles();
+ return this.potion.getShowParticles(potion);
}
public boolean getAmbient(Potion potion)
{
- return this.potion.get(potion).getAmbient();
+ return this.potion.getAmbient(potion);
}
public Set getPotions()
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderRecipe.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderRecipe.java
index a97899e..755d6ea 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderRecipe.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderRecipe.java
@@ -4,14 +4,14 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
-import exopandora.worldhandler.builder.impl.BuilderAdvancement.EnumActionType;
import exopandora.worldhandler.builder.types.Type;
import exopandora.worldhandler.helper.EnumHelper;
+import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderRecipe extends CommandBuilder
{
public BuilderRecipe()
@@ -34,7 +34,7 @@ public class BuilderRecipe extends CommandBuilder
@Nullable
public EnumMode getMode()
{
- return EnumHelper.valueOf(EnumMode.class, this.getNodeAsString(0));
+ return EnumHelper.valueOf(this.getNodeAsString(0), EnumMode.class);
}
public void setPlayer(String player)
@@ -48,6 +48,11 @@ public class BuilderRecipe extends CommandBuilder
return this.getNodeAsString(1);
}
+ public void setRecipe(IRecipe recipe)
+ {
+ this.setRecipe(recipe.getId());
+ }
+
public void setRecipe(ResourceLocation recipe)
{
this.setNode(2, recipe);
@@ -82,7 +87,7 @@ public class BuilderRecipe extends CommandBuilder
return syntax;
}
- @SideOnly(Side.CLIENT)
+ @OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
GIVE,
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderScoreboardObjectives.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderScoreboardObjectives.java
index 7d8a3d1..ffa07c0 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderScoreboardObjectives.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderScoreboardObjectives.java
@@ -4,11 +4,13 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.impl.abstr.BuilderScoreboard;
+import exopandora.worldhandler.builder.types.GreedyString;
import exopandora.worldhandler.builder.types.Type;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import exopandora.worldhandler.helper.EnumHelper;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderScoreboardObjectives extends BuilderScoreboard
{
public BuilderScoreboardObjectives()
@@ -21,74 +23,74 @@ public class BuilderScoreboardObjectives extends BuilderScoreboard
this.setNode(0, "objectives");
}
- public void setMode(String mode)
+ public void setMode(EnumMode mode)
{
String objective = this.getObjective();
- if(mode.equals("add") || mode.equals("remove") || mode.equals("setdisplay"))
+ this.updateSyntax(this.getSyntax(mode));
+ this.setNode(1, mode.toString());
+
+ if(objective != null)
{
- this.updateSyntax(this.getSyntax(mode));
- this.setNode(1, mode);
-
- if(objective != null)
- {
- this.setObjective(objective);
- }
-
- this.init();
+ this.setObjective(objective);
}
+
+ this.init();
}
- public String getMode()
+ public EnumMode getMode()
{
- return this.getNodeAsString(1);
+ return EnumHelper.valueOf(this.getNodeAsString(1), EnumMode.class);
}
public void setObjective(String name)
{
- String mode = this.getMode();
String objective = name != null ? name.replaceAll(" ", "_") : null;
+ EnumMode mode = this.getMode();
+
if(mode != null)
{
- if(mode.equals("add") || mode.equals("remove"))
+ switch(mode)
{
- this.setNode(2, objective);
-
- if(mode.equals("add"))
- {
- this.setNode(4, name);
- }
- }
- else if(mode.equals("setdisplay"))
- {
- this.setNode(3, objective);
+ case ADD:
+ this.setNode(4, new GreedyString(name));
+ case REMOVE:
+ this.setNode(2, objective);
+ break;
+ case SETDISPLAY:
+ this.setNode(3, objective);
+ break;
+ default:
+ break;
}
}
}
public void setCriteria(String criteria)
{
- if(this.getMode() == null || !this.getMode().equals("add"))
+ if(this.getMode() == null || !this.getMode().equals(EnumMode.ADD))
{
- this.setMode("add");
+ this.setMode(EnumMode.ADD);
}
- this.setNode(3, criteria.replaceAll("[:]", "."));
+
+ this.setNode(3, criteria);
}
public void setSlot(String slot)
{
- if(this.getMode() == null || !this.getMode().equals("setdisplay"))
+ if(this.getMode() == null || !this.getMode().equals(EnumMode.SETDISPLAY))
{
- this.setMode("setdisplay");
+ this.setMode(EnumMode.SETDISPLAY);
}
+
this.setNode(2, slot);
}
@Nullable
public String getSlot()
{
- if(this.getMode() != null && this.getMode().equals("setdisplay"))
+ if(this.getMode() != null && this.getMode().equals(EnumMode.SETDISPLAY))
{
return this.getNodeAsString(2);
}
@@ -99,17 +101,18 @@ public class BuilderScoreboardObjectives extends BuilderScoreboard
@Nullable
public String getObjective()
{
- String mode = this.getMode();
+ EnumMode mode = this.getMode();
if(mode != null)
{
- if(mode.equals("add") || mode.equals("remove"))
+ switch(mode)
{
- return this.getNodeAsString(2);
- }
- else if(mode.equals("setdisplay"))
- {
- return this.getNodeAsString(3);
+ case ADD: case REMOVE:
+ return this.getNodeAsString(2);
+ case SETDISPLAY:
+ return this.getNodeAsString(3);
+ default:
+ break;
}
}
@@ -117,43 +120,33 @@ public class BuilderScoreboardObjectives extends BuilderScoreboard
}
@Nullable
- private Syntax getSyntax(String mode)
+ private Syntax getSyntax(EnumMode mode)
{
- if(mode.equals("add"))
- {
- Syntax syntax = new Syntax();
-
- syntax.addRequired("objectives", Type.STRING);
- syntax.addRequired("add", Type.STRING);
- syntax.addRequired("name", Type.STRING);
- syntax.addRequired("criteria_type", Type.STRING);
- syntax.addOptional("display_name...", Type.STRING);
-
- return syntax;
- }
- else if(mode.equals("remove"))
- {
- Syntax syntax = new Syntax();
-
- syntax.addRequired("objectives", Type.STRING);
- syntax.addRequired("remove", Type.STRING);
- syntax.addRequired("name", Type.STRING);
-
- return syntax;
- }
- else if(mode.equals("setdisplay"))
- {
- Syntax syntax = new Syntax();
-
- syntax.addRequired("objectives", Type.STRING);
- syntax.addRequired("setdisplay", Type.STRING);
- syntax.addRequired("slot", Type.STRING);
- syntax.addOptional("objective", Type.STRING);
-
- return syntax;
- }
+ Syntax syntax = new Syntax();
- return null;
+ switch(mode)
+ {
+ case ADD:
+ syntax.addRequired("objectives", Type.STRING);
+ syntax.addRequired("add", Type.STRING);
+ syntax.addRequired("name", Type.STRING);
+ syntax.addRequired("criteria_type", Type.STRING);
+ syntax.addOptional("display_name...", Type.GREEDY_STRING);
+ return syntax;
+ case REMOVE:
+ syntax.addRequired("objectives", Type.STRING);
+ syntax.addRequired("remove", Type.STRING);
+ syntax.addRequired("name", Type.STRING);
+ return syntax;
+ case SETDISPLAY:
+ syntax.addRequired("objectives", Type.STRING);
+ syntax.addRequired("setdisplay", Type.STRING);
+ syntax.addRequired("slot", Type.STRING);
+ syntax.addOptional("objective", Type.STRING);
+ return syntax;
+ default:
+ return null;
+ }
}
@Override
@@ -167,4 +160,18 @@ public class BuilderScoreboardObjectives extends BuilderScoreboard
return syntax;
}
+
+ @OnlyIn(Dist.CLIENT)
+ public static enum EnumMode
+ {
+ ADD,
+ REMOVE,
+ SETDISPLAY;
+
+ @Override
+ public String toString()
+ {
+ return this.name().toLowerCase();
+ }
+ }
}
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderScoreboardPlayers.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderScoreboardPlayers.java
index d4182f5..768aec9 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderScoreboardPlayers.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderScoreboardPlayers.java
@@ -3,10 +3,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.impl.abstr.BuilderScoreboard;
import exopandora.worldhandler.builder.types.Type;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderScoreboardPlayers extends BuilderScoreboard
{
public BuilderScoreboardPlayers()
@@ -14,6 +14,11 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
this.init();
}
+ private void init()
+ {
+ this.setNode(0, "players");
+ }
+
public String getMode()
{
return this.getNodeAsString(1);
@@ -23,36 +28,19 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
{
String objective = this.getObjective();
String player = this.getPlayer();
- String tag = this.getTag();
int points = this.getPoints();
- if(mode.equals("add|set|remove") || mode.equals("tag") || mode.equals("enable"))
+ this.updateSyntax(this.getSyntax(mode));
+ this.setNode(1, mode);
+ this.setNode(2, player);
+ this.setObjective(objective);
+
+ if(!mode.equals("enable"))
{
- this.updateSyntax(this.getSyntax(mode));
- this.setNode(1, mode);
- this.setNode(2, player);
-
- if(mode.equals("add|set|remove") || mode.equals("enable"))
- {
- this.setObjective(objective);
- }
-
- if(mode.equals("add|set|remove"))
- {
- this.setPoints(points);
- }
- else if(mode.equals("tag"))
- {
- this.setTag(tag);
- }
-
- this.init();
+ this.setPoints(points);
}
- }
-
- private void init()
- {
- this.setNode(0, "players");
+
+ this.init();
}
public void setPlayer(String player)
@@ -72,10 +60,7 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
if(mode != null)
{
- if(mode.equals("add|set|remove") || mode.equals("enable"))
- {
- this.setNode(3, objective);
- }
+ this.setNode(3, objective);
}
}
@@ -85,10 +70,7 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
if(mode != null)
{
- if(mode.equals("add|set|remove") || mode.equals("enable"))
- {
- return this.getNodeAsString(3);
- }
+ return this.getNodeAsString(3);
}
return null;
@@ -96,16 +78,12 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
public void setPoints(int points)
{
- if(this.getMode() == null || !this.getMode().equals("add|set|remove"))
- {
- this.setMode("add|set|remove");
- }
this.setNode(4, points);
}
public int getPoints()
{
- if(this.getMode() != null && this.getMode().equals("add|set|remove"))
+ if(this.getMode() != null && !this.getMode().equals("enable"))
{
return this.getNodeAsInt(4);
}
@@ -113,83 +91,56 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
return 0;
}
- public void setTag(String name)
- {
- String tag = name != null ? name.replaceAll(" ", "_") : null;
-
- if(this.getMode() == null || !this.getMode().equals("tag"))
- {
- this.setMode("tag");
- }
- this.setNode(4, tag);
- }
-
- public String getTag()
- {
- if(this.getMode() != null && this.getMode().equals("tag"))
- {
- return this.getNodeAsString(4);
- }
-
- return null;
- }
-
private Syntax getSyntax(String mode)
{
- if(mode.equals("add|set|remove"))
+ Syntax syntax = new Syntax();
+
+ if(mode.equals("enable"))
{
- Syntax syntax = new Syntax();
-
- syntax.addRequired("players", Type.STRING);
- syntax.addRequired("add|set|remove", Type.STRING, "add|set|remove");
- syntax.addRequired("player", Type.STRING);
- syntax.addRequired("objective", Type.STRING);
- syntax.addRequired("count", Type.INT, 0);
- syntax.addOptional("nbt", Type.NBT);
-
- return syntax;
- }
- else if(mode.equals("tag"))
- {
- Syntax syntax = new Syntax();
-
- syntax.addRequired("players", Type.STRING);
- syntax.addRequired("tag", Type.STRING);
- syntax.addRequired("player", Type.STRING);
- syntax.addRequired("add|remove|list", Type.STRING);
- syntax.addRequired("tag_name", Type.STRING);
- syntax.addOptional("nbt", Type.NBT);
-
- return syntax;
- }
- else if(mode.equals("enable"))
- {
- Syntax syntax = new Syntax();
-
syntax.addRequired("players", Type.STRING);
syntax.addRequired("enable", Type.STRING);
syntax.addRequired("player", Type.STRING);
- syntax.addRequired("trigger", Type.STRING);
+ syntax.addRequired("objective", Type.STRING);
return syntax;
}
- return null;
+ syntax.addRequired("players", Type.STRING);
+ syntax.addRequired("add|set|remove", Type.STRING, "add|set|remove");
+ syntax.addRequired("player", Type.STRING);
+ syntax.addRequired("objective", Type.STRING);
+ syntax.addRequired("score", Type.INT, 0);
+
+ return syntax;
+
}
- public BuilderGeneric getBuilderForTag(EnumTag tag)
- {
- return new BuilderGeneric(this.getCommandName(), "players", this.getMode(), this.getPlayer(), tag.toString(), this.getTag());
- }
-
- public BuilderGeneric getBuilderForPoints(EnumPoints mode)
+ public BuilderScoreboardPlayers getBuilderForPoints(EnumMode mode)
{
return this.getBuilderForPoints(mode, this.getPoints());
}
- public BuilderGeneric getBuilderForPoints(EnumPoints mode, int points)
+ public BuilderScoreboardPlayers getBuilderForPoints(EnumMode mode, int points)
{
- return new BuilderGeneric(this.getCommandName(), "players", mode.toString(), this.getPlayer(), this.getObjective(), String.valueOf(points));
+ BuilderScoreboardPlayers builder = new BuilderScoreboardPlayers();
+
+ builder.setMode(mode.toString());
+ builder.setPlayer(this.getPlayer());
+ builder.setObjective(this.getObjective());
+ builder.setPoints(points);
+
+ return builder;
+ }
+
+ public BuilderScoreboardPlayers getBuilderForEnable()
+ {
+ BuilderScoreboardPlayers builder = new BuilderScoreboardPlayers();
+
+ builder.setMode(EnumMode.ENABLE.toString());
+ builder.setPlayer(this.getPlayer());
+ builder.setObjective(this.getObjective());
+
+ return builder;
}
@Override
@@ -198,30 +149,18 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
Syntax syntax = new Syntax();
syntax.addRequired("players", Type.STRING);
- syntax.addRequired("add|enable|list|operation|remove|reset|set|tag|test", Type.STRING);
+ syntax.addRequired("add|enable|get|list|operation|remove|reset|set", Type.STRING);
syntax.addOptional("...", Type.STRING);
return syntax;
}
- @SideOnly(Side.CLIENT)
- public static enum EnumTag
- {
- ADD,
- REMOVE;
-
- @Override
- public String toString()
- {
- return this.name().toLowerCase();
- }
- }
-
- @SideOnly(Side.CLIENT)
- public static enum EnumPoints
+ @OnlyIn(Dist.CLIENT)
+ public static enum EnumMode
{
ADD,
REMOVE,
+ ENABLE,
SET;
@Override
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderSetblock.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderSetblock.java
index 4ce6f43..0a7f162 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderSetblock.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderSetblock.java
@@ -2,59 +2,66 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.impl.abstr.BuilderBlockPos;
-import exopandora.worldhandler.builder.types.Coordinate;
+import exopandora.worldhandler.builder.types.BlockResourceLocation;
+import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.builder.types.Type;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.state.IProperty;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-public class BuilderSetblock extends BuilderBlockPos
+@OnlyIn(Dist.CLIENT)
+public class BuilderSetBlock extends BuilderBlockPos
{
- @Deprecated
- public BuilderSetblock(BlockPos pos, ResourceLocation block, int meta, String mode)
+ private final BlockResourceLocation blockResourceLocation = new BlockResourceLocation();
+
+ public BuilderSetBlock()
{
+ super(0);
+ }
+
+ public BuilderSetBlock(BlockPos pos, ResourceLocation block, String mode)
+ {
+ this();
this.setPosition(pos);
this.setBlock(block);
- this.setMetadata(meta);
this.setMode(mode);
}
- @Deprecated
- public BuilderSetblock(Coordinate x, Coordinate y, Coordinate z, ResourceLocation block, int meta, String mode)
+ public BuilderSetBlock(CoordinateInt x, CoordinateInt y, CoordinateInt z, ResourceLocation block, String mode)
{
+ this();
this.setX(x);
this.setY(y);
this.setZ(z);
this.setBlock(block);
- this.setMetadata(meta);
this.setMode(mode);
}
- public BuilderSetblock(Coordinate x, Coordinate y, Coordinate z, ResourceLocation block, String mode)
+ public > BuilderSetBlock withState(IProperty property, T value)
{
- this(x, y, z, block, 0, mode);
+ this.blockResourceLocation.withState(property, value);
+ return this;
}
public void setBlock(ResourceLocation block)
{
- this.setNode(3, block);
- }
-
- @Deprecated
- public void setMetadata(int meta)
- {
- this.setNode(4, meta);
+ this.blockResourceLocation.setResourceLocation(block);
+ this.setNode(3, this.blockResourceLocation);
}
public void setMode(String mode)
{
- this.setNode(5, mode);
+ this.setNode(4, mode);
}
@Override
public void setNBT(NBTTagCompound nbt)
{
- this.setNode(6, nbt);
+ this.blockResourceLocation.setNBT(nbt);
+ this.setNode(3, this.blockResourceLocation);
}
@Override
@@ -68,13 +75,11 @@ public class BuilderSetblock extends BuilderBlockPos
{
Syntax syntax = new Syntax();
- syntax.addRequired("x", Type.COORDINATE);
- syntax.addRequired("y", Type.COORDINATE);
- syntax.addRequired("z", Type.COORDINATE);
- syntax.addRequired("block", Type.RESOURCE_LOCATION);
- syntax.addOptional("data_value", Type.INT);
+ syntax.addRequired("x", Type.COORDINATE_INT);
+ syntax.addRequired("y", Type.COORDINATE_INT);
+ syntax.addRequired("z", Type.COORDINATE_INT);
+ syntax.addRequired("block", Type.BLOCK_RESOURCE_LOCATION);
syntax.addOptional("mode", Type.STRING);
- syntax.addOptional("nbt", Type.NBT);
return syntax;
}
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderSignEditor.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderSignEditor.java
index 736d1a7..7a87b6d 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderSignEditor.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderSignEditor.java
@@ -6,16 +6,21 @@ import exopandora.worldhandler.builder.component.impl.ComponentTag;
import exopandora.worldhandler.format.text.ColoredString;
import exopandora.worldhandler.format.text.SignText;
import net.minecraft.nbt.NBTTagString;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
-public class BuilderSignEditor extends BuilderBlockdata
+@OnlyIn(Dist.CLIENT)
+public class BuilderSignEditor extends BuilderData
{
+ @SuppressWarnings("unchecked")
private final ComponentTag[] sign = new ComponentTag[4];
public BuilderSignEditor()
{
+ super();
+ this.setMode(EnumMode.MERGE);
+ this.setTarget(EnumTarget.BLOCK);
+
for(int x = 0; x < 4; x++)
{
this.sign[x] = this.registerNBTComponent(new ComponentTag("Text" + (x + 1), new SignText(x), text -> new NBTTagString(text.toString())));
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderSpawnpoint.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderSpawnpoint.java
index 795066e..37e0509 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderSpawnpoint.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderSpawnpoint.java
@@ -2,19 +2,20 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
-import exopandora.worldhandler.builder.types.Coordinate;
+import exopandora.worldhandler.builder.types.Coordinate.CoordinateType;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.builder.types.Type;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderSpawnpoint extends CommandBuilder
{
public BuilderSpawnpoint(String player)
{
- this.setX(new Coordinate(0, true));
- this.setY(new Coordinate(0, true));
- this.setZ(new Coordinate(0, true));
+ this.setX(new CoordinateInt(CoordinateType.LOCAL));
+ this.setY(new CoordinateInt(CoordinateType.LOCAL));
+ this.setZ(new CoordinateInt(CoordinateType.LOCAL));
}
@Override
@@ -28,17 +29,17 @@ public class BuilderSpawnpoint extends CommandBuilder
this.setNode(0, player);
}
- public void setX(Coordinate x)
+ public void setX(CoordinateInt x)
{
this.setNode(1, x);
}
- public void setY(Coordinate y)
+ public void setY(CoordinateInt y)
{
this.setNode(2, y);
}
- public void setZ(Coordinate z)
+ public void setZ(CoordinateInt z)
{
this.setNode(3, z);
}
@@ -49,9 +50,9 @@ public class BuilderSpawnpoint extends CommandBuilder
Syntax syntax = new Syntax();
syntax.addRequired("player", Type.STRING);
- syntax.addRequired("x", Type.COORDINATE);
- syntax.addRequired("y", Type.COORDINATE);
- syntax.addRequired("z", Type.COORDINATE);
+ syntax.addRequired("x", Type.COORDINATE_INT);
+ syntax.addRequired("y", Type.COORDINATE_INT);
+ syntax.addRequired("z", Type.COORDINATE_INT);
return syntax;
}
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderSummon.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderSummon.java
index e5f7a1b..847c911 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderSummon.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderSummon.java
@@ -14,22 +14,25 @@ import exopandora.worldhandler.builder.component.impl.ComponentSummon;
import exopandora.worldhandler.builder.component.impl.ComponentTag;
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes.Applyable;
-import exopandora.worldhandler.builder.types.Coordinate;
+import exopandora.worldhandler.builder.types.Coordinate.CoordinateType;
+import exopandora.worldhandler.builder.types.CoordinateDouble;
import exopandora.worldhandler.builder.types.Type;
import exopandora.worldhandler.format.text.ColoredString;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
-import net.minecraft.nbt.NBTBase;
+import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.potion.Potion;
import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraft.util.text.ITextComponent;
+import net.minecraft.util.text.TextComponentString;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderSummon extends CommandBuilderNBT
{
private final ComponentAttributeMob attribute;
@@ -51,45 +54,14 @@ public class BuilderSummon extends CommandBuilderNBT
this.handItems = this.registerNBTComponent(new ComponentTag("HandItems", this::itemListSerializer));
this.summon = this.registerNBTComponent(new ComponentSummon(), "summon");
this.potion = this.registerNBTComponent(new ComponentPotionMob());
- }
-
- public BuilderSummon(int direction)
- {
- this();
- this.setDirection(direction);
- }
-
- public void setDirection(int direction)
- {
- if(direction == 0)
- {
- this.setX(new Coordinate(0, true));
- this.setY(new Coordinate(0, true));
- this.setZ(new Coordinate(2, true));
- }
- else if(direction == 1)
- {
- this.setX(new Coordinate(-2, true));
- this.setY(new Coordinate(0, true));
- this.setZ(new Coordinate(0, true));
- }
- else if(direction == 2)
- {
- this.setX(new Coordinate(0, true));
- this.setY(new Coordinate(0, true));
- this.setZ(new Coordinate(-2, true));
- }
- else if(direction == 3)
- {
- this.setX(new Coordinate(2, true));
- this.setY(new Coordinate(0, true));
- this.setZ(new Coordinate(0, true));
- }
+ this.setX(new CoordinateDouble(0.0, CoordinateType.LOCAL));
+ this.setY(new CoordinateDouble(0.0, CoordinateType.LOCAL));
+ this.setZ(new CoordinateDouble(2.0, CoordinateType.LOCAL));
}
public void setEntity(String entityName)
{
- ResourceLocation location = this.summon.resolve(entityName);
+ ResourceLocation location = ComponentSummon.resolve(entityName);
this.summon.setName(entityName);
this.summon.setEntity(location);
@@ -102,34 +74,34 @@ public class BuilderSummon extends CommandBuilderNBT
return this.getNodeAsResourceLocation(0);
}
- public void setX(Coordinate x)
+ public void setX(CoordinateDouble x)
{
this.setNode(1, x);
}
- public Coordinate getX()
+ public CoordinateDouble getX()
{
- return this.getNodeAsCoordinate(1);
+ return this.getNodeAsCoordinateDouble(1);
}
- public void setY(Coordinate y)
+ public void setY(CoordinateDouble y)
{
this.setNode(2, y);
}
- public Coordinate getY()
+ public CoordinateDouble getY()
{
- return this.getNodeAsCoordinate(2);
+ return this.getNodeAsCoordinateDouble(2);
}
- public void setZ(Coordinate z)
+ public void setZ(CoordinateDouble z)
{
this.setNode(3, z);
}
- public Coordinate getZ()
+ public CoordinateDouble getZ()
{
- return this.getNodeAsCoordinate(3);
+ return this.getNodeAsCoordinateDouble(3);
}
public void setAttribute(EnumAttributes attribute, double ammount)
@@ -175,7 +147,7 @@ public class BuilderSummon extends CommandBuilderNBT
public void setPassenger(String entityName)
{
- this.setPassenger(this.summon.resolve(entityName));
+ this.setPassenger(ComponentSummon.resolve(entityName));
}
public void setPassenger(ResourceLocation entityName)
@@ -186,7 +158,7 @@ public class BuilderSummon extends CommandBuilderNBT
passenger.setString("id", entityName.toString());
NBTTagList list = new NBTTagList();
- list.appendTag(passenger);
+ list.add(passenger);
this.passengers.setValue(list);
}
@@ -201,9 +173,9 @@ public class BuilderSummon extends CommandBuilderNBT
{
NBTTagList list = this.passengers.getValue();
- if(list != null && !list.hasNoTags())
+ if(list != null && !list.isEmpty())
{
- return new ResourceLocation(list.getCompoundTagAt(0).getString("id"));
+ return new ResourceLocation(list.getCompound(0).getString("id"));
}
return null;
@@ -232,8 +204,8 @@ public class BuilderSummon extends CommandBuilderNBT
{
NBTTagCompound compound = new NBTTagCompound();
compound.setString("id", item.toString());
- compound.setInteger("Count", 1);
- list.appendTag(compound);
+ compound.setInt("Count", 1);
+ list.add(compound);
}
this.armorItems.setValue(list);
@@ -281,8 +253,8 @@ public class BuilderSummon extends CommandBuilderNBT
{
NBTTagCompound compound = new NBTTagCompound();
compound.setString("id", item.toString());
- compound.setInteger("Count", 1);
- list.appendTag(compound);
+ compound.setInt("Count", 1);
+ list.add(compound);
}
this.handItems.setValue(list);
@@ -300,62 +272,62 @@ public class BuilderSummon extends CommandBuilderNBT
public void setAmplifier(Potion potion, byte amplifier)
{
- this.potion.get(potion).setAmplifier(amplifier);
+ this.potion.setAmplifier(potion, amplifier);
}
public void setSeconds(Potion potion, int seconds)
{
- this.potion.get(potion).setSeconds(seconds);
+ this.potion.setSeconds(potion, seconds);
}
public void setMinutes(Potion potion, int minutes)
{
- this.potion.get(potion).setMinutes(minutes);
+ this.potion.setMinutes(potion, minutes);
}
public void setHours(Potion potion, int hours)
{
- this.potion.get(potion).setHours(hours);
+ this.potion.setHours(potion, hours);
}
public void setShowParticles(Potion potion, boolean showParticles)
{
- this.potion.get(potion).setShowParticles(showParticles);
+ this.potion.setShowParticles(potion, showParticles);
}
public void setAmbient(Potion potion, boolean ambient)
{
- this.potion.get(potion).setAmbient(ambient);
+ this.potion.setAmbient(potion, ambient);
}
public byte getAmplifier(Potion potion)
{
- return this.potion.get(potion).getAmplifier();
+ return this.potion.getAmplifier(potion);
}
public int getSeconds(Potion potion)
{
- return this.potion.get(potion).getSeconds();
+ return this.potion.getSeconds(potion);
}
public int getMinutes(Potion potion)
{
- return this.potion.get(potion).getMinutes();
+ return this.potion.getMinutes(potion);
}
public int getHours(Potion potion)
{
- return this.potion.get(potion).getHours();
+ return this.potion.getHours(potion);
}
public boolean getShowParticles(Potion potion)
{
- return this.potion.get(potion).getShowParticles();
+ return this.potion.getShowParticles(potion);
}
public boolean getAmbient(Potion potion)
{
- return this.potion.get(potion).getAmbient();
+ return this.potion.getAmbient(potion);
}
public Set getPotions()
@@ -363,11 +335,11 @@ public class BuilderSummon extends CommandBuilderNBT
return this.potion.getPotions();
}
- private NBTBase itemListSerializer(NBTTagList list)
+ private INBTBase itemListSerializer(NBTTagList list)
{
- for(int x = 0; x < list.tagCount(); x++)
+ for(int x = 0; x < list.size(); x++)
{
- if(!list.getCompoundTagAt(x).getString("id").equals(Blocks.AIR.getRegistryName().toString()))
+ if(!list.getCompound(x).getString("id").equals(Blocks.AIR.getRegistryName().toString()))
{
return list;
}
@@ -376,11 +348,11 @@ public class BuilderSummon extends CommandBuilderNBT
return null;
}
- private NBTBase colorStringSerializer(ColoredString string)
+ private INBTBase colorStringSerializer(ColoredString string)
{
if(string.getText() != null && !string.getText().isEmpty())
{
- return new NBTTagString(string.toString());
+ return new NBTTagString(ITextComponent.Serializer.toJson(new TextComponentString(string.toString())));
}
return null;
@@ -404,9 +376,9 @@ public class BuilderSummon extends CommandBuilderNBT
Syntax syntax = new Syntax();
syntax.addRequired("entity_name", Type.RESOURCE_LOCATION);
- syntax.addOptional("x", Type.COORDINATE);
- syntax.addOptional("y", Type.COORDINATE);
- syntax.addOptional("z", Type.COORDINATE);
+ syntax.addOptional("x", Type.COORDINATE_DOUBLE);
+ syntax.addOptional("y", Type.COORDINATE_DOUBLE);
+ syntax.addOptional("z", Type.COORDINATE_DOUBLE);
syntax.addOptional("nbt", Type.NBT);
return syntax;
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderTag.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderTag.java
new file mode 100644
index 0000000..759e1f5
--- /dev/null
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderTag.java
@@ -0,0 +1,88 @@
+package exopandora.worldhandler.builder.impl;
+
+import exopandora.worldhandler.builder.CommandBuilder;
+import exopandora.worldhandler.builder.Syntax;
+import exopandora.worldhandler.builder.types.Type;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+
+@OnlyIn(Dist.CLIENT)
+public class BuilderTag extends CommandBuilder
+{
+ public BuilderTag()
+ {
+
+ }
+
+ public BuilderTag(String player, EnumMode mode, String name)
+ {
+ this.setPlayer(player);
+ this.setMode(mode);
+ this.setName(name);
+ }
+
+ public void setPlayer(String player)
+ {
+ this.setNode(0, player);
+ }
+
+ public String getPlayer()
+ {
+ return this.getNodeAsString(0);
+ }
+
+ public void setMode(EnumMode mode)
+ {
+ if(mode != null)
+ {
+ this.setNode(1, mode.toString());
+ }
+ }
+
+ public void setName(String name)
+ {
+ this.setNode(2, name);
+ }
+
+ public String getName()
+ {
+ return this.getNodeAsString(2);
+ }
+
+ @Override
+ public String getCommandName()
+ {
+ return "tag";
+ }
+
+ @Override
+ public Syntax getSyntax()
+ {
+ Syntax syntax = new Syntax();
+
+ syntax.addRequired("player", Type.STRING);
+ syntax.addRequired("add|list|remove", Type.STRING);
+ syntax.addRequired("name", Type.STRING);
+
+ return syntax;
+ }
+
+ public BuilderTag getBuilderForMode(EnumMode mode)
+ {
+ return new BuilderTag(this.getPlayer(), mode, this.getName());
+ }
+
+ @OnlyIn(Dist.CLIENT)
+ public static enum EnumMode
+ {
+ ADD,
+ LIST,
+ REMOVE;
+
+ @Override
+ public String toString()
+ {
+ return this.name().toLowerCase();
+ }
+ }
+}
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderScoreboardTeams.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderTeams.java
similarity index 66%
rename from src/main/java/exopandora/worldhandler/builder/impl/BuilderScoreboardTeams.java
rename to src/main/java/exopandora/worldhandler/builder/impl/BuilderTeams.java
index 5de448a..75a0815 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderScoreboardTeams.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderTeams.java
@@ -2,25 +2,16 @@ package exopandora.worldhandler.builder.impl;
import javax.annotation.Nullable;
+import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
-import exopandora.worldhandler.builder.impl.abstr.BuilderScoreboard;
+import exopandora.worldhandler.builder.types.GreedyString;
import exopandora.worldhandler.builder.types.Type;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
-public class BuilderScoreboardTeams extends BuilderScoreboard
+@OnlyIn(Dist.CLIENT)
+public class BuilderTeams extends CommandBuilder
{
- public BuilderScoreboardTeams()
- {
- this.init();
- }
-
- private void init()
- {
- this.setNode(0, "teams");
- }
-
public void setTeam(String name)
{
String mode = this.getMode();
@@ -30,22 +21,22 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{
if(mode.equals("add"))
{
- this.setNode(3, name);
+ this.setNode(2, new GreedyString(name));
}
}
- this.setNode(2, team);
+ this.setNode(1, team);
}
public String getMode()
{
- return this.getNodeAsString(1);
+ return this.getNodeAsString(0);
}
@Nullable
public String getTeam()
{
- return this.getNodeAsString(2);
+ return this.getNodeAsString(1);
}
public void setMode(String mode)
@@ -53,10 +44,10 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
String team = this.getTeam();
String player = this.getPlayer();
- if(mode.equals("add") || mode.equals("remove|empty") || mode.equals("join|leave") || mode.equals("option"))
+ if(mode.equals("add") || mode.equals("remove|empty") || mode.equals("join|leave") || mode.equals("modify"))
{
this.updateSyntax(this.getSyntax(mode));
- this.setNode(1, mode);
+ this.setNode(0, mode);
if(team != null)
{
@@ -67,8 +58,6 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{
this.setPlayer(player);
}
-
- this.init();
}
}
@@ -80,7 +69,7 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{
if(mode.equals("join|leave"))
{
- this.setNode(3, player);
+ this.setNode(2, player);
}
}
}
@@ -94,7 +83,7 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{
if(mode.equals("join|leave"))
{
- return this.getNodeAsString(3);
+ return this.getNodeAsString(2);
}
}
@@ -103,19 +92,19 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
public void setRule(String rule)
{
- if(this.getMode() == null || !this.getMode().equals("option"))
+ if(this.getMode() == null || !this.getMode().equals("modify"))
{
- this.setMode("option");
+ this.setMode("modify");
}
- this.setNode(3, rule);
+ this.setNode(2, rule);
}
public String getRule()
{
- if(this.getMode() == null || this.getMode().equals("option"))
+ if(this.getMode() == null || this.getMode().equals("modify"))
{
- return this.getNodeAsString(3);
+ return this.getNodeAsString(2);
}
return null;
@@ -123,19 +112,19 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
public void setValue(String value)
{
- if(this.getMode() == null || !this.getMode().equals("option"))
+ if(this.getMode() == null || !this.getMode().equals("modify"))
{
- this.setMode("option");
+ this.setMode("modify");
}
- this.setNode(4, value);
+ this.setNode(3, value);
}
public String getValue()
{
- if(this.getMode() == null || this.getMode().equals("option"))
+ if(this.getMode() == null || this.getMode().equals("modify"))
{
- return this.getNodeAsString(4);
+ return this.getNodeAsString(3);
}
return null;
@@ -148,10 +137,9 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{
Syntax syntax = new Syntax();
- syntax.addRequired("teams", Type.STRING);
syntax.addRequired("add", Type.STRING);
syntax.addRequired("name", Type.STRING);
- syntax.addOptional("display_name...", Type.STRING);
+ syntax.addOptional("display_name...", Type.GREEDY_STRING);
return syntax;
}
@@ -159,7 +147,6 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{
Syntax syntax = new Syntax();
- syntax.addRequired("teams", Type.STRING);
syntax.addRequired("remove|empty", Type.STRING, "remove|empty");
syntax.addRequired("name", Type.STRING);
@@ -169,19 +156,17 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{
Syntax syntax = new Syntax();
- syntax.addRequired("teams", Type.STRING);
syntax.addRequired("join|leave", Type.STRING, "join|leave");
syntax.addRequired("name", Type.STRING);
syntax.addOptional("player", Type.STRING);
return syntax;
}
- else if(mode.equals("option"))
+ else if(mode.equals("modify"))
{
Syntax syntax = new Syntax();
- syntax.addRequired("teams", Type.STRING);
- syntax.addRequired("option", Type.STRING);
+ syntax.addRequired("modify", Type.STRING);
syntax.addRequired("team", Type.STRING);
syntax.addRequired("friendlyfire|color|seeFriendlyInvisibles|nametagVisibility|deathMessageVisibility|collisionRule", Type.STRING);
syntax.addRequired("value", Type.STRING);
@@ -192,28 +177,28 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
return null;
}
- public BuilderScoreboardTeams getBuilderForMode(EnumMode mode)
+ public BuilderTeams getBuilderForMode(EnumMode mode)
{
- BuilderScoreboardTeams builder = new BuilderScoreboardTeams();
+ BuilderTeams builder = new BuilderTeams();
switch(mode)
{
case JOIN:
case LEAVE:
- builder.setNode(1, mode.toString());
+ builder.setNode(0, mode.toString());
builder.setTeam(this.getTeam());
builder.setPlayer(this.getPlayer());
break;
case REMOVE:
case EMPTY:
- builder.setNode(1, mode.toString());
+ builder.setNode(0, mode.toString());
builder.setTeam(this.getTeam());
break;
case ADD:
builder.setMode(mode.toString());
builder.setTeam(this.getTeam());
break;
- case OPTION:
+ case MODIFY:
builder.setMode(mode.toString());
builder.setTeam(this.getTeam());
builder.setRule(this.getRule());
@@ -231,14 +216,19 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{
Syntax syntax = new Syntax();
- syntax.addRequired("teams", Type.STRING);
- syntax.addRequired("list|add|remove|empty|join|leave|option", Type.STRING);
+ syntax.addRequired("list|add|remove|empty|join|leave|modify", Type.STRING);
syntax.addOptional("...", Type.STRING);
return syntax;
}
- @SideOnly(Side.CLIENT)
+ @Override
+ public String getCommandName()
+ {
+ return "team";
+ }
+
+ @OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
JOIN,
@@ -246,7 +236,7 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
REMOVE,
EMPTY,
ADD,
- OPTION;
+ MODIFY;
@Override
public String toString()
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderTime.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderTime.java
index 2bfd052..75d8465 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderTime.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderTime.java
@@ -3,9 +3,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+@OnlyIn(Dist.CLIENT)
public class BuilderTime extends CommandBuilder
{
public BuilderTime()
@@ -51,7 +52,7 @@ public class BuilderTime extends CommandBuilder
return syntax;
}
- @SideOnly(Side.CLIENT)
+ @OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
ADD,
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderTrigger.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderTrigger.java
new file mode 100644
index 0000000..4e1ea6f
--- /dev/null
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderTrigger.java
@@ -0,0 +1,93 @@
+package exopandora.worldhandler.builder.impl;
+
+import exopandora.worldhandler.builder.CommandBuilder;
+import exopandora.worldhandler.builder.Syntax;
+import exopandora.worldhandler.builder.types.Type;
+import exopandora.worldhandler.helper.EnumHelper;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+
+@OnlyIn(Dist.CLIENT)
+public class BuilderTrigger extends CommandBuilder
+{
+ public BuilderTrigger()
+ {
+ this.setValue(0);
+ }
+
+ public BuilderTrigger(String objective, EnumMode mode, int value)
+ {
+ this.setObjective(objective);
+ this.setMode(mode);
+ this.setValue(value);
+ }
+
+ public void setObjective(String name)
+ {
+ this.setNode(0, name != null ? name.replaceAll(" ", "_") : null);
+ }
+
+ public String getObjective()
+ {
+ return this.getNodeAsString(0);
+ }
+
+ public void setMode(EnumMode mode)
+ {
+ if(mode != null)
+ {
+ this.setNode(1, mode.toString());
+ }
+ }
+
+ public EnumMode getMode()
+ {
+ return EnumHelper.valueOf(this.getNodeAsString(1), EnumMode.class);
+ }
+
+ public void setValue(int value)
+ {
+ this.setNode(2, value);
+ }
+
+ public int getValue()
+ {
+ return this.getNodeAsInt(2);
+ }
+
+ @Override
+ public String getCommandName()
+ {
+ return "trigger";
+ }
+
+ @Override
+ public Syntax getSyntax()
+ {
+ Syntax syntax = new Syntax();
+
+ syntax.addRequired("objective", Type.STRING);
+ syntax.addRequired("add|set", Type.STRING);
+ syntax.addRequired("value", Type.INT);
+
+ return syntax;
+ }
+
+ public BuilderTrigger getBuilderForMode(EnumMode mode)
+ {
+ return new BuilderTrigger(this.getObjective(), mode, this.getValue());
+ }
+
+ @OnlyIn(Dist.CLIENT)
+ public static enum EnumMode
+ {
+ ADD,
+ SET;
+
+ @Override
+ public String toString()
+ {
+ return this.name().toLowerCase();
+ }
+ }
+}
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderWH.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderWH.java
index 0183a7c..1d80cba 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderWH.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderWH.java
@@ -3,10 +3,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderWH extends CommandBuilder
{
@Override
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderWeather.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderWeather.java
index 5818299..8a946b1 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderWeather.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderWeather.java
@@ -3,9 +3,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+@OnlyIn(Dist.CLIENT)
public class BuilderWeather extends CommandBuilder
{
public BuilderWeather()
@@ -51,7 +52,7 @@ public class BuilderWeather extends CommandBuilder
return syntax;
}
- @SideOnly(Side.CLIENT)
+ @OnlyIn(Dist.CLIENT)
public static enum EnumWeather
{
CLEAR,
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderWhitelist.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderWhitelist.java
index d0d9ed6..ee5ee36 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderWhitelist.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderWhitelist.java
@@ -5,10 +5,10 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderWhitelist extends CommandBuilder
{
public BuilderWhitelist()
@@ -76,7 +76,7 @@ public class BuilderWhitelist extends CommandBuilder
return syntax;
}
- @SideOnly(Side.CLIENT)
+ @OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
ADD,
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderWorldHandler.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderWorldHandler.java
index 141ea41..4a96fc2 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderWorldHandler.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderWorldHandler.java
@@ -3,10 +3,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class BuilderWorldHandler extends CommandBuilder
{
@Override
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/abstr/BuilderBlockPos.java b/src/main/java/exopandora/worldhandler/builder/impl/abstr/BuilderBlockPos.java
index c0b52c1..0e85e05 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/abstr/BuilderBlockPos.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/abstr/BuilderBlockPos.java
@@ -1,11 +1,21 @@
package exopandora.worldhandler.builder.impl.abstr;
import exopandora.worldhandler.builder.CommandBuilderNBT;
-import exopandora.worldhandler.builder.types.Coordinate;
+import exopandora.worldhandler.builder.types.CoordinateInt;
import net.minecraft.util.math.BlockPos;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+@OnlyIn(Dist.CLIENT)
public abstract class BuilderBlockPos extends CommandBuilderNBT
{
+ private final int offset;
+
+ public BuilderBlockPos(int offset)
+ {
+ this.offset = offset;
+ }
+
public void setPosition(BlockPos pos)
{
this.setX(pos.getX());
@@ -13,64 +23,64 @@ public abstract class BuilderBlockPos extends CommandBuilderNBT
this.setZ(pos.getZ());
}
- public void setX(float x)
+ public void setX(int x)
{
- this.setX(new Coordinate(x));
+ this.setX(new CoordinateInt(x));
}
- public void setY(float y)
+ public void setY(int y)
{
- this.setY(new Coordinate(y));
+ this.setY(new CoordinateInt(y));
}
- public void setZ(float z)
+ public void setZ(int z)
{
- this.setZ(new Coordinate(z));
+ this.setZ(new CoordinateInt(z));
}
- public void setX(Coordinate x)
+ public void setX(CoordinateInt x)
{
- this.setNode(0, x);
+ this.setNode(this.offset, x);
}
- public void setY(Coordinate y)
+ public void setY(CoordinateInt y)
{
- this.setNode(1, y);
+ this.setNode(this.offset + 1, y);
}
- public void setZ(Coordinate z)
+ public void setZ(CoordinateInt z)
{
- this.setNode(2, z);
+ this.setNode(this.offset + 2, z);
}
- public Coordinate getXCoordiante()
+ public CoordinateInt getXCoordinate()
{
- return this.getNodeAsCoordinate(0);
+ return this.getNodeAsCoordinateInt(this.offset);
}
- public Coordinate getYCoordiante()
+ public CoordinateInt getYCoordinate()
{
- return this.getNodeAsCoordinate(1);
+ return this.getNodeAsCoordinateInt(this.offset + 1);
}
- public Coordinate getZCoordiante()
+ public CoordinateInt getZCoordinate()
{
- return this.getNodeAsCoordinate(2);
+ return this.getNodeAsCoordinateInt(this.offset + 2);
}
- public double getX()
+ public int getX()
{
- return this.getXCoordiante().getValue();
+ return this.getXCoordinate().getValue();
}
- public double getY()
+ public int getY()
{
- return this.getYCoordiante().getValue();
+ return this.getYCoordinate().getValue();
}
- public double getZ()
+ public int getZ()
{
- return this.getZCoordiante().getValue();
+ return this.getZCoordinate().getValue();
}
public BlockPos getBlockPos()
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/abstr/BuilderDoubleBlockPos.java b/src/main/java/exopandora/worldhandler/builder/impl/abstr/BuilderDoubleBlockPos.java
index 94d3c50..1f73b0f 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/abstr/BuilderDoubleBlockPos.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/abstr/BuilderDoubleBlockPos.java
@@ -1,13 +1,13 @@
package exopandora.worldhandler.builder.impl.abstr;
import exopandora.worldhandler.builder.CommandBuilder;
-import exopandora.worldhandler.builder.types.Coordinate;
+import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.helper.BlockHelper;
import net.minecraft.util.math.BlockPos;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public abstract class BuilderDoubleBlockPos extends CommandBuilder
{
public BuilderDoubleBlockPos()
@@ -23,52 +23,49 @@ public abstract class BuilderDoubleBlockPos extends CommandBuilder
this.setZ1(pos.getZ());
}
- public void setX1(float x)
+ public void setX1(int x)
{
- this.setX1(new Coordinate(x));
+ this.setX1(new CoordinateInt(x));
}
- public void setY1(float y)
+ public void setY1(int y)
{
- this.setY1(new Coordinate(y));
+ this.setY1(new CoordinateInt(y));
}
- public void setZ1(float z)
+ public void setZ1(int z)
{
- this.setZ1(new Coordinate(z));
+ this.setZ1(new CoordinateInt(z));
}
- public void setX1(Coordinate x)
+ public void setX1(CoordinateInt x)
{
this.setNode(0, x);
- BlockHelper.setPos1(BlockHelper.setX(BlockHelper.getPos1(), x.getValue()));
}
- public void setY1(Coordinate y)
+ public void setY1(CoordinateInt y)
{
this.setNode(1, y);
- BlockHelper.setPos1(BlockHelper.setY(BlockHelper.getPos1(), y.getValue()));
}
- public void setZ1(Coordinate z)
+ public void setZ1(CoordinateInt z)
{
this.setNode(2, z);
- BlockHelper.setPos1(BlockHelper.setZ(BlockHelper.getPos1(), z.getValue()));
}
- public Coordinate getX1Coordiante()
+ public CoordinateInt getX1Coordiante()
{
- return this.getNodeAsCoordinate(0);
+ return this.getNodeAsCoordinateInt(0);
}
- public Coordinate getY1Coordiante()
+ public CoordinateInt getY1Coordiante()
{
- return this.getNodeAsCoordinate(1);
+ return this.getNodeAsCoordinateInt(1);
}
- public Coordinate getZ1Coordiante()
+ public CoordinateInt getZ1Coordiante()
{
- return this.getNodeAsCoordinate(2);
+ return this.getNodeAsCoordinateInt(2);
}
public double getX1()
@@ -98,52 +95,49 @@ public abstract class BuilderDoubleBlockPos extends CommandBuilder
this.setZ2(pos.getZ());
}
- public void setX2(float x)
+ public void setX2(int x)
{
- this.setX2(new Coordinate(x));
+ this.setX2(new CoordinateInt(x));
}
- public void setY2(float y)
+ public void setY2(int y)
{
- this.setY2(new Coordinate(y));
+ this.setY2(new CoordinateInt(y));
}
- public void setZ2(float z)
+ public void setZ2(int z)
{
- this.setZ2(new Coordinate(z));
+ this.setZ2(new CoordinateInt(z));
}
- public void setX2(Coordinate x)
+ public void setX2(CoordinateInt x)
{
this.setNode(3, x);
- BlockHelper.setPos2(BlockHelper.setX(BlockHelper.getPos2(), x.getValue()));
}
- public void setY2(Coordinate y)
+ public void setY2(CoordinateInt y)
{
this.setNode(4, y);
- BlockHelper.setPos2(BlockHelper.setY(BlockHelper.getPos2(), y.getValue()));
}
- public void setZ2(Coordinate z)
+ public void setZ2(CoordinateInt z)
{
this.setNode(5, z);
- BlockHelper.setPos2(BlockHelper.setZ(BlockHelper.getPos2(), z.getValue()));
}
- public Coordinate getX2Coordiante()
+ public CoordinateInt getX2Coordiante()
{
- return this.getNodeAsCoordinate(3);
+ return this.getNodeAsCoordinateInt(3);
}
- public Coordinate getY2Coordiante()
+ public CoordinateInt getY2Coordiante()
{
- return this.getNodeAsCoordinate(4);
+ return this.getNodeAsCoordinateInt(4);
}
- public Coordinate getZ2Coordiante()
+ public CoordinateInt getZ2Coordiante()
{
- return this.getNodeAsCoordinate(5);
+ return this.getNodeAsCoordinateInt(5);
}
public double getX2()
@@ -165,12 +159,4 @@ public abstract class BuilderDoubleBlockPos extends CommandBuilder
{
return new BlockPos(this.getX2(), this.getY2(), this.getZ2());
}
-
- public T addPositionObservers()
- {
- BlockHelper.addPos1Observer(this::setPosition1);
- BlockHelper.addPos2Observer(this::setPosition2);
-
- return (T) this;
- }
}
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/abstr/BuilderScoreboard.java b/src/main/java/exopandora/worldhandler/builder/impl/abstr/BuilderScoreboard.java
index 218b916..6ab306a 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/abstr/BuilderScoreboard.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/abstr/BuilderScoreboard.java
@@ -1,10 +1,10 @@
package exopandora.worldhandler.builder.impl.abstr;
import exopandora.worldhandler.builder.CommandBuilder;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public abstract class BuilderScoreboard extends CommandBuilder
{
@Override
diff --git a/src/main/java/exopandora/worldhandler/builder/impl/abstr/EnumAttributes.java b/src/main/java/exopandora/worldhandler/builder/impl/abstr/EnumAttributes.java
index c07078f..d442cf7 100644
--- a/src/main/java/exopandora/worldhandler/builder/impl/abstr/EnumAttributes.java
+++ b/src/main/java/exopandora/worldhandler/builder/impl/abstr/EnumAttributes.java
@@ -6,10 +6,10 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import net.minecraft.client.resources.I18n;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public enum EnumAttributes
{
MAX_HEALTH("generic.maxHealth", EnumOperation.ADDITIVE, Applyable.BOTH),
@@ -27,8 +27,9 @@ public enum EnumAttributes
private String attribute;
private EnumOperation operation;
private Applyable applyable;
-
- public enum Applyable
+
+ @OnlyIn(Dist.CLIENT)
+ public static enum Applyable
{
BOTH,
PLAYER,
@@ -72,7 +73,8 @@ public enum EnumAttributes
return this.operation.getOperation().apply(value);
}
- public enum EnumOperation
+ @OnlyIn(Dist.CLIENT)
+ public static enum EnumOperation
{
ADDITIVE(value -> value, "(+)"),
PERCENTAGE(value -> value / 100, "%");
diff --git a/src/main/java/exopandora/worldhandler/builder/types/BlockResourceLocation.java b/src/main/java/exopandora/worldhandler/builder/types/BlockResourceLocation.java
new file mode 100644
index 0000000..44e8195
--- /dev/null
+++ b/src/main/java/exopandora/worldhandler/builder/types/BlockResourceLocation.java
@@ -0,0 +1,133 @@
+package exopandora.worldhandler.builder.types;
+
+import javax.annotation.Nullable;
+
+import com.mojang.brigadier.StringReader;
+import com.mojang.brigadier.exceptions.CommandSyntaxException;
+
+import net.minecraft.block.state.IBlockState;
+import net.minecraft.command.arguments.BlockStateParser;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.state.IProperty;
+import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+import net.minecraftforge.registries.ForgeRegistries;
+
+@OnlyIn(Dist.CLIENT)
+public class BlockResourceLocation extends ItemResourceLocation
+{
+ private IBlockState state;
+
+ public BlockResourceLocation()
+ {
+ this(null);
+ }
+
+ public BlockResourceLocation(ResourceLocation resource)
+ {
+ this(resource, null, null);
+ }
+
+ public BlockResourceLocation(ResourceLocation resource, IBlockState state, NBTTagCompound nbt)
+ {
+ super(resource, nbt);
+ this.state = this.findState(state, resource);
+ }
+
+ private IBlockState findState(IBlockState state, ResourceLocation resource)
+ {
+ boolean matchOld = this.state != null && this.state.getBlock().getRegistryName().equals(resource);
+ boolean matchNew = state != null && state.getBlock().getRegistryName().equals(resource);
+
+ if(matchNew)
+ {
+ return state;
+ }
+
+ if(matchOld)
+ {
+ return this.state;
+ }
+
+ if(resource != null && ForgeRegistries.BLOCKS.containsKey(resource))
+ {
+ return ForgeRegistries.BLOCKS.getValue(resource).getDefaultState();
+ }
+
+ return null;
+ }
+
+ @Override
+ public void setResourceLocation(ResourceLocation resource)
+ {
+ super.setResourceLocation(resource);
+ this.state = this.findState(null, resource);
+ }
+
+ public IBlockState getState()
+ {
+ return this.state;
+ }
+
+ public > void withState(IProperty property, T value)
+ {
+ if(this.state != null && this.state.has(property))
+ {
+ this.state = this.state.with(property, value);
+ }
+ }
+
+ @Nullable
+ public static BlockResourceLocation valueOf(String input)
+ {
+ if(input != null)
+ {
+ BlockStateParser parser = new BlockStateParser(new StringReader(input), false);
+
+ try
+ {
+ parser.parse(true);
+ }
+ catch(CommandSyntaxException e)
+ {
+ return null;
+ }
+
+ IBlockState state = parser.getState();
+
+ if(state != null)
+ {
+ return new BlockResourceLocation(state.getBlock().getRegistryName(), state, parser.getNbt());
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public BlockResourceLocation get()
+ {
+ return (BlockResourceLocation) super.get();
+ }
+
+ @Override
+ public String toString()
+ {
+ if(this.resource != null && this.state != null)
+ {
+ StringBuilder builder = new StringBuilder(this.state.toString());
+ String block = this.state.getBlock().toString();
+ builder.replace(0, block.length(), this.resource.toString());
+
+ if(this.nbt != null)
+ {
+ builder.append(this.nbt.toString());
+ }
+
+ return builder.toString();
+ }
+
+ return null;
+ }
+}
diff --git a/src/main/java/exopandora/worldhandler/builder/types/Coordinate.java b/src/main/java/exopandora/worldhandler/builder/types/Coordinate.java
index 64f0be2..557bed2 100644
--- a/src/main/java/exopandora/worldhandler/builder/types/Coordinate.java
+++ b/src/main/java/exopandora/worldhandler/builder/types/Coordinate.java
@@ -1,63 +1,104 @@
package exopandora.worldhandler.builder.types;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import java.util.function.Function;
-@SideOnly(Side.CLIENT)
-public class Coordinate
+import javax.annotation.Nullable;
+
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+
+@OnlyIn(Dist.CLIENT)
+public abstract class Coordinate implements ICoordinate
{
- private double value;
- private boolean relative;
+ protected T value;
+ protected CoordinateType type;
- public Coordinate()
+ public Coordinate(T value)
{
- this(0, true);
+ this(value, CoordinateType.ABSOLUTE);
}
- public Coordinate(double value)
+ public Coordinate(T value, CoordinateType type)
{
- this(value, false);
- }
-
- public Coordinate(double value, boolean relative)
- {
- this.relative = relative;
this.value = value;
+ this.type = type;
}
- public void setValue(double value)
+ public void setValue(T value)
{
this.value = value;
}
- public double getValue()
+ public T getValue()
{
return this.value;
}
- public void setRelative(boolean relative)
+ public void setType(CoordinateType type)
{
- this.relative = relative;
+ this.type = type;
}
- public boolean isRelative()
+ public CoordinateType getType()
{
- return this.relative;
- }
-
- public static Coordinate valueOf(String value)
- {
- if(value.startsWith("~"))
- {
- return new Coordinate(Double.parseDouble(value.substring(1)), true);
- }
-
- return new Coordinate(Double.parseDouble(value), false);
+ return this.type;
}
@Override
public String toString()
{
- return String.valueOf(this.relative ? (this.value != 0 ? "~" + this.value : "~") : this.value);
+ return this.type.format(this.value, this.zero());
+ }
+
+ @Nullable
+ public static > U parse(U coordiante, String input, Function parser)
+ {
+ for(CoordinateType type : CoordinateType.values())
+ {
+ if(!type.prefix.isEmpty() && input.startsWith(type.prefix))
+ {
+ String numbers = input.substring(type.prefix.length());
+
+ coordiante.setType(type);
+ coordiante.setValue(numbers.isEmpty() ? coordiante.zero() : parser.apply(numbers));
+
+ return coordiante;
+ }
+ }
+
+ coordiante.setType(CoordinateType.ABSOLUTE);
+ coordiante.setValue(parser.apply(input));
+
+ return coordiante;
+ }
+
+ @OnlyIn(Dist.CLIENT)
+ public static enum CoordinateType
+ {
+ ABSOLUTE(""),
+ GLOBAL("~"),
+ LOCAL("^");
+
+ private final String prefix;
+
+ private CoordinateType(String prefix)
+ {
+ this.prefix = prefix;
+ }
+
+ public String format(T value, T zero)
+ {
+ if(value == null || value.equals(zero))
+ {
+ if(this.prefix.isEmpty())
+ {
+ return zero.toString();
+ }
+
+ return this.prefix;
+ }
+
+ return this.prefix + value;
+ }
}
}
diff --git a/src/main/java/exopandora/worldhandler/builder/types/CoordinateDouble.java b/src/main/java/exopandora/worldhandler/builder/types/CoordinateDouble.java
new file mode 100644
index 0000000..e274243
--- /dev/null
+++ b/src/main/java/exopandora/worldhandler/builder/types/CoordinateDouble.java
@@ -0,0 +1,39 @@
+package exopandora.worldhandler.builder.types;
+
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+
+@OnlyIn(Dist.CLIENT)
+public class CoordinateDouble extends Coordinate
+{
+ public CoordinateDouble()
+ {
+ super(0.0);
+ }
+
+ public CoordinateDouble(Double value)
+ {
+ super(value);
+ }
+
+ public CoordinateDouble(CoordinateType type)
+ {
+ super(0.0, type);
+ }
+
+ public CoordinateDouble(Double value, CoordinateType type)
+ {
+ super(value, type);
+ }
+
+ public static CoordinateDouble valueOf(String value)
+ {
+ return Coordinate.parse(new CoordinateDouble(), value, Double::parseDouble);
+ }
+
+ @Override
+ public Double zero()
+ {
+ return 0.0;
+ }
+}
diff --git a/src/main/java/exopandora/worldhandler/builder/types/CoordinateInt.java b/src/main/java/exopandora/worldhandler/builder/types/CoordinateInt.java
new file mode 100644
index 0000000..c16c9bb
--- /dev/null
+++ b/src/main/java/exopandora/worldhandler/builder/types/CoordinateInt.java
@@ -0,0 +1,39 @@
+package exopandora.worldhandler.builder.types;
+
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+
+@OnlyIn(Dist.CLIENT)
+public class CoordinateInt extends Coordinate
+{
+ public CoordinateInt()
+ {
+ super(0);
+ }
+
+ public CoordinateInt(Integer value)
+ {
+ super(value);
+ }
+
+ public CoordinateInt(CoordinateType type)
+ {
+ super(0, type);
+ }
+
+ public CoordinateInt(Integer value, CoordinateType type)
+ {
+ super(value, type);
+ }
+
+ public static CoordinateInt valueOf(String value)
+ {
+ return Coordinate.parse(new CoordinateInt(), value, Integer::parseInt);
+ }
+
+ @Override
+ public Integer zero()
+ {
+ return 0;
+ }
+}
diff --git a/src/main/java/exopandora/worldhandler/builder/types/GreedyString.java b/src/main/java/exopandora/worldhandler/builder/types/GreedyString.java
new file mode 100644
index 0000000..812fe21
--- /dev/null
+++ b/src/main/java/exopandora/worldhandler/builder/types/GreedyString.java
@@ -0,0 +1,54 @@
+package exopandora.worldhandler.builder.types;
+
+import javax.annotation.Nullable;
+
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+
+@OnlyIn(Dist.CLIENT)
+public class GreedyString
+{
+ private String string;
+
+ public GreedyString(String string)
+ {
+ this.string = string;
+ }
+
+ public String getString()
+ {
+ return this.string;
+ }
+
+ public void setString(String string)
+ {
+ this.string = string;
+ }
+
+ public boolean isEmpty()
+ {
+ if(this.string == null)
+ {
+ return true;
+ }
+
+ return this.string.isEmpty();
+ }
+
+ @Nullable
+ public static GreedyString valueOf(String string)
+ {
+ if(string != null && string.matches("\"(.*)\""))
+ {
+ return new GreedyString(string.substring(1, string.length() - 1));
+ }
+
+ return null;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "\"" + this.string + "\"";
+ }
+}
diff --git a/src/main/java/exopandora/worldhandler/builder/types/ICoordinate.java b/src/main/java/exopandora/worldhandler/builder/types/ICoordinate.java
new file mode 100644
index 0000000..22ac96b
--- /dev/null
+++ b/src/main/java/exopandora/worldhandler/builder/types/ICoordinate.java
@@ -0,0 +1,10 @@
+package exopandora.worldhandler.builder.types;
+
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+
+@OnlyIn(Dist.CLIENT)
+public interface ICoordinate
+{
+ T zero();
+}
diff --git a/src/main/java/exopandora/worldhandler/builder/types/ItemResourceLocation.java b/src/main/java/exopandora/worldhandler/builder/types/ItemResourceLocation.java
new file mode 100644
index 0000000..c4ab21e
--- /dev/null
+++ b/src/main/java/exopandora/worldhandler/builder/types/ItemResourceLocation.java
@@ -0,0 +1,104 @@
+package exopandora.worldhandler.builder.types;
+
+import javax.annotation.Nullable;
+
+import com.mojang.brigadier.exceptions.CommandSyntaxException;
+
+import net.minecraft.nbt.JsonToNBT;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+
+@OnlyIn(Dist.CLIENT)
+public class ItemResourceLocation
+{
+ protected ResourceLocation resource;
+ protected NBTTagCompound nbt;
+
+ public ItemResourceLocation()
+ {
+ this(null, null);
+ }
+
+ public ItemResourceLocation(ResourceLocation resource)
+ {
+ this(resource, null);
+ }
+
+ public ItemResourceLocation(ResourceLocation resource, NBTTagCompound nbt)
+ {
+ this.resource = resource;
+ this.nbt = nbt;
+ }
+
+ public ResourceLocation getResourceLocation()
+ {
+ return this.resource;
+ }
+
+ public void setResourceLocation(ResourceLocation resource)
+ {
+ this.resource = resource;
+ }
+
+ public NBTTagCompound getNBT()
+ {
+ return this.nbt;
+ }
+
+ public void setNBT(NBTTagCompound nbt)
+ {
+ this.nbt = nbt;
+ }
+
+ public ItemResourceLocation get()
+ {
+ if(this.resource != null)
+ {
+ return this;
+ }
+
+ return null;
+ }
+
+ @Nullable
+ public static ItemResourceLocation valueOf(String input)
+ {
+ int start = input.indexOf("{");
+ ResourceLocation resource = new ResourceLocation(input.substring(0, start));
+ NBTTagCompound nbt = null;
+
+ if(start > 0)
+ {
+ try
+ {
+ nbt = JsonToNBT.getTagFromJson(input.substring(start, input.lastIndexOf("}") + 1));
+ }
+ catch(CommandSyntaxException e)
+ {
+ return null;
+ }
+ }
+
+ return new ItemResourceLocation(resource, nbt);
+ }
+
+ @Override
+ public String toString()
+ {
+ if(this.resource != null)
+ {
+ StringBuilder builder = new StringBuilder(this.resource.toString());
+
+ if(this.nbt != null)
+ {
+ builder.append(this.nbt.toString());
+ }
+
+ return builder.toString();
+ }
+
+ return null;
+ }
+}
diff --git a/src/main/java/exopandora/worldhandler/builder/types/Level.java b/src/main/java/exopandora/worldhandler/builder/types/Level.java
deleted file mode 100644
index 17e1805..0000000
--- a/src/main/java/exopandora/worldhandler/builder/types/Level.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package exopandora.worldhandler.builder.types;
-
-import javax.annotation.Nullable;
-
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
-public class Level
-{
- private int level;
-
- public Level()
- {
- this(0);
- }
-
- public Level(int level)
- {
- this.level = level;
- }
-
- public int getLevel()
- {
- return this.level;
- }
-
- public void setLevel(int level)
- {
- this.level = level;
- }
-
- @Nullable
- public static Level valueOf(String value)
- {
- if(value != null)
- {
- if(value.matches("[-]?[0-9]+[Ll]?"))
- {
- return new Level(Integer.valueOf(value.replaceAll("[lL]$", "")));
- }
- }
-
- return null;
- }
-
- @Override
- public String toString()
- {
- return this.level + "L";
- }
-}
\ No newline at end of file
diff --git a/src/main/java/exopandora/worldhandler/builder/types/TargetSelector.java b/src/main/java/exopandora/worldhandler/builder/types/TargetSelector.java
index c27e711..c1b47f5 100644
--- a/src/main/java/exopandora/worldhandler/builder/types/TargetSelector.java
+++ b/src/main/java/exopandora/worldhandler/builder/types/TargetSelector.java
@@ -7,10 +7,10 @@ import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class TargetSelector
{
private final Map values = new HashMap();
@@ -20,8 +20,9 @@ public class TargetSelector
{
this.values.put(id.toLowerCase(), value);
}
-
+
@Nullable
+ @SuppressWarnings("unchecked")
public T get(String id)
{
return (T) this.values.get(id);
diff --git a/src/main/java/exopandora/worldhandler/builder/types/Type.java b/src/main/java/exopandora/worldhandler/builder/types/Type.java
index 5dba84e..786d956 100644
--- a/src/main/java/exopandora/worldhandler/builder/types/Type.java
+++ b/src/main/java/exopandora/worldhandler/builder/types/Type.java
@@ -4,14 +4,15 @@ import java.util.function.Function;
import javax.annotation.Nullable;
+import com.mojang.brigadier.exceptions.CommandSyntaxException;
+
import net.minecraft.nbt.JsonToNBT;
-import net.minecraft.nbt.NBTException;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public enum Type
{
SHORT(Short::valueOf),
@@ -22,11 +23,14 @@ public enum Type
LONG(Long::valueOf),
BOOLEAN(Boolean::valueOf),
STRING(String::valueOf),
+ GREEDY_STRING(GreedyString::valueOf),
RESOURCE_LOCATION(Type::parseResourceLocation),
+ ITEM_RESOURCE_LOCATION(ItemResourceLocation::valueOf),
+ BLOCK_RESOURCE_LOCATION(BlockResourceLocation::valueOf),
NBT(Type::parseNBTTagCompound),
- COORDINATE(Coordinate::valueOf),
- TARGET_SELECTOR(TargetSelector::valueOf),
- LEVEL(Level::valueOf);
+ COORDINATE_INT(CoordinateInt::valueOf),
+ COORDINATE_DOUBLE(CoordinateDouble::valueOf),
+ TARGET_SELECTOR(TargetSelector::valueOf);
private final Function parser;
@@ -36,6 +40,7 @@ public enum Type
}
@Nullable
+ @SuppressWarnings("unchecked")
public T parse(String object)
{
return (T) this.parser.apply(object);
@@ -56,7 +61,7 @@ public enum Type
{
return JsonToNBT.getTagFromJson(value);
}
- catch(NBTException nbtexception)
+ catch(CommandSyntaxException e)
{
return null;
}
diff --git a/src/main/java/exopandora/worldhandler/command/CommandWH.java b/src/main/java/exopandora/worldhandler/command/CommandWH.java
index aa4ec6e..9b46b31 100644
--- a/src/main/java/exopandora/worldhandler/command/CommandWH.java
+++ b/src/main/java/exopandora/worldhandler/command/CommandWH.java
@@ -1,231 +1,89 @@
package exopandora.worldhandler.command;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.stream.Collectors;
+import com.mojang.brigadier.CommandDispatcher;
+import com.mojang.brigadier.arguments.StringArgumentType;
+import com.mojang.brigadier.exceptions.CommandSyntaxException;
-import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.builder.impl.BuilderClone;
import exopandora.worldhandler.builder.impl.BuilderClone.EnumMask;
import exopandora.worldhandler.builder.impl.BuilderFill;
-import exopandora.worldhandler.builder.impl.BuilderWH;
import exopandora.worldhandler.helper.BlockHelper;
-import exopandora.worldhandler.helper.EnumHelper;
-import exopandora.worldhandler.helper.ResourceHelper;
-import net.minecraft.block.Block;
-import net.minecraft.client.Minecraft;
-import net.minecraft.command.CommandBase;
-import net.minecraft.command.CommandException;
-import net.minecraft.command.ICommandSender;
-import net.minecraft.command.NumberInvalidException;
-import net.minecraft.command.WrongUsageException;
-import net.minecraft.server.MinecraftServer;
+import exopandora.worldhandler.helper.CommandHelper;
+import net.minecraft.command.CommandSource;
+import net.minecraft.command.Commands;
+import net.minecraft.command.arguments.BlockStateArgument;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.text.TextComponentString;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.registries.ForgeRegistries;
-@SideOnly(Side.CLIENT)
-public class CommandWH extends CommandBase
+public class CommandWH
{
- @Override
- public String getName()
+ public static void register(CommandDispatcher dispatcher)
{
- return "wh";
+ dispatcher.register(Commands.literal("wh")
+ .then(Commands.literal("pos1")
+ .executes(context -> pos1(context.getSource())))
+ .then(Commands.literal("pos2")
+ .executes(context -> pos2(context.getSource())))
+ .then(Commands.literal("fill")
+ .then(Commands.argument("block", BlockStateArgument.blockState())
+ .executes(context -> fill(context.getSource(), StringArgumentType.getString(context, "block")))))
+ .then(Commands.literal("replace")
+ .then(Commands.argument("block", BlockStateArgument.blockState())
+ .then(Commands.argument("replace", BlockStateArgument.blockState())
+ .executes(context -> replace(context.getSource(), StringArgumentType.getString(context, "block"), StringArgumentType.getString(context, "replace"))))))
+ .then(Commands.literal("clone")
+ .then(Commands.literal("replace")
+ .executes(context -> clone(context.getSource(), EnumMask.REPLACE)))
+ .then(Commands.literal("masked")
+ .executes(context -> clone(context.getSource(), EnumMask.MASKED)))
+ .then(Commands.literal("filtered")
+ .executes(context -> clone(context.getSource(), EnumMask.FILTERED)))));
}
- @Override
- public int getRequiredPermissionLevel()
+ private static int pos1(CommandSource source) throws CommandSyntaxException
{
- return 0;
+ BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
+ BlockPos pos = BlockHelper.getPos1();
+ ResourceLocation block = ForgeRegistries.BLOCKS.getKey(BlockHelper.getBlock(pos));
+ CommandHelper.sendFeedback(source, "Set first position to " + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + " (" + block + ")");
+ return 1;
}
- @Override
- public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
+ private static int pos2(CommandSource source) throws CommandSyntaxException
{
- if(args.length > 0)
- {
- if(args[0].equals("pos1"))
- {
- BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
- sender.sendMessage(new TextComponentString("Set first position to " + BlockHelper.getPos1().getX() + ", " + BlockHelper.getPos1().getY() + ", " + BlockHelper.getPos1().getZ() + " (" + Block.REGISTRY.getNameForObject(BlockHelper.getFocusedBlock()) + ")"));
- }
- else if(args[0].equals("pos2"))
- {
- BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
- sender.sendMessage(new TextComponentString("Set second position to " + BlockHelper.getPos2().getX() + ", " + BlockHelper.getPos2().getY() + ", " + BlockHelper.getPos2().getZ() + " (" + Block.REGISTRY.getNameForObject(BlockHelper.getFocusedBlock()) + ")"));
- }
- else if(args[0].equals("fill"))
- {
- final String usage = "/wh fill [meta]";
-
- if(args.length > 1)
- {
- ResourceLocation id = new ResourceLocation(args[1]);
- int meta = 0;
-
- if(args.length > 2)
- {
- try
- {
- meta = Integer.parseInt(args[2]);
- }
- catch(Exception e)
- {
- throw new WrongUsageException(usage);
- }
- }
-
- if(!ResourceHelper.isRegisteredBlock(id.toString()))
- {
- throw new NumberInvalidException(usage);
- }
-
- BuilderFill builder = new BuilderFill();
- builder.setBlock1(id);
- builder.setMeta1(meta);
-
- WorldHandler.sendCommand(builder);
- }
- else
- {
- throw new WrongUsageException(usage);
- }
- }
- else if(args[0].equals("replace"))
- {
- final String usage = "/wh replace [meta2]";
-
- if(args.length > 1)
- {
- ResourceLocation id1 = new ResourceLocation(args[1]);
-
- if(args.length > 2)
- {
- ResourceLocation id2 = new ResourceLocation(args[3]);
- int meta1 = 0;
- int meta2 = 0;
-
- try
- {
- meta1 = Integer.parseInt(args[2]);
- }
- catch(Exception e)
- {
- throw new WrongUsageException(usage);
- }
-
- if(args.length > 4)
- {
- try
- {
- meta2 = Integer.parseInt(args[4]);
- }
- catch(Exception e)
- {
- throw new WrongUsageException(usage);
- }
- }
-
- if(!ResourceHelper.isRegisteredBlock(id1.toString()) || !ResourceHelper.isRegisteredBlock(id2.toString()))
- {
- throw new WrongUsageException(usage);
- }
-
- BuilderFill builder = new BuilderFill();
- builder.setPosition1(BlockHelper.getPos1());
- builder.setPosition2(BlockHelper.getPos2());
- builder.setBlock1(id1);
- builder.setMeta1(meta1);
- builder.setBlock2(id2);
- builder.setMeta2(meta2);
-
- Minecraft.getMinecraft().player.sendChatMessage(builder.getBuilderForReplace().toActualCommand());
- }
- else
- {
- throw new WrongUsageException(usage);
- }
- }
- else
- {
- throw new WrongUsageException(usage);
- }
- }
- else if(args[0].equals("clone"))
- {
- final String usage = "/wh clone [" + String.join("|", Arrays.stream(EnumMask.MASKED.values()).map(EnumMask::toString).collect(Collectors.toList())) + "]";
- EnumMask mask = EnumMask.MASKED;
-
- if(args.length > 1)
- {
- mask = EnumHelper.valueOf(EnumMask.class, args[1]);
- }
-
- if(mask == null)
- {
- throw new WrongUsageException(usage);
- }
-
- BuilderClone builder = new BuilderClone();
- builder.setPosition1(BlockHelper.getPos1());
- builder.setPosition2(BlockHelper.getPos2());
- builder.setMask(mask);
-
- Minecraft.getMinecraft().player.sendChatMessage(builder.toActualCommand());
- }
- else
- {
- throw new WrongUsageException(new BuilderWH().toCommand());
- }
- }
- else
- {
- throw new WrongUsageException(new BuilderWH().toCommand());
- }
- }
-
- @Override
- public List getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos)
- {
- if(args.length == 1)
- {
- return this.getListOfStringsMatchingLastWord(args, new String[]{"pos1", "pos2", "fill", "replace", "clone"});
- }
- else if(args.length == 2)
- {
- if(args[0].equals("fill") || args[0].equals("replace"))
- {
- return this.getListOfStringsMatchingLastWord(args, Block.REGISTRY.getKeys());
- }
- else if(args[0].equals("clone"))
- {
- return this.getListOfStringsMatchingLastWord(args, new String[]{"replace", "masked", "filtered"});
- }
- }
- else if(args.length == 3)
- {
- if(args[0].equals("fill") || args[0].equals("replace"))
- {
- return this.getListOfStringsMatchingLastWord(args, new String[] {"0"});
- }
- }
- else if(args.length == 4)
- {
- if(args[0].equals("replace"))
- {
- return this.getListOfStringsMatchingLastWord(args, Block.REGISTRY.getKeys());
- }
- }
-
- return Collections.emptyList();
+ BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
+ BlockPos pos = BlockHelper.getPos2();
+ ResourceLocation block = ForgeRegistries.BLOCKS.getKey(BlockHelper.getBlock(pos));
+ CommandHelper.sendFeedback(source, "Set second position to " + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + " (" + block + ")");
+ return 1;
}
- @Override
- public String getUsage(ICommandSender sender)
+ private static int fill(CommandSource source, String block)
{
- return new BuilderWH().toCommand();
+ BuilderFill builder = new BuilderFill();
+ builder.setBlock1(block);
+ CommandHelper.sendCommand(builder);
+ return 1;
}
-}
\ No newline at end of file
+
+ private static int replace(CommandSource source, String block, String replace)
+ {
+ BuilderFill builder = new BuilderFill();
+ builder.setPosition1(BlockHelper.getPos1());
+ builder.setPosition2(BlockHelper.getPos2());
+ builder.setBlock1(block);
+ builder.setBlock2(replace);
+ CommandHelper.sendCommand(builder);
+ return 1;
+ }
+
+ private static int clone(CommandSource source, EnumMask mask)
+ {
+ BuilderClone builder = new BuilderClone();
+ builder.setPosition1(BlockHelper.getPos1());
+ builder.setPosition2(BlockHelper.getPos2());
+ builder.setMask(mask);
+ return 1;
+ }
+}
diff --git a/src/main/java/exopandora/worldhandler/command/CommandWorldHandler.java b/src/main/java/exopandora/worldhandler/command/CommandWorldHandler.java
index 404efc4..9ec95b1 100644
--- a/src/main/java/exopandora/worldhandler/command/CommandWorldHandler.java
+++ b/src/main/java/exopandora/worldhandler/command/CommandWorldHandler.java
@@ -1,100 +1,51 @@
package exopandora.worldhandler.command;
-import java.util.Collections;
-import java.util.List;
+import org.apache.maven.artifact.versioning.ComparableVersion;
-import com.mojang.realmsclient.gui.ChatFormatting;
+import com.mojang.brigadier.CommandDispatcher;
+import com.mojang.brigadier.exceptions.CommandSyntaxException;
import exopandora.worldhandler.Main;
-import exopandora.worldhandler.WorldHandler;
-import exopandora.worldhandler.builder.impl.BuilderWorldHandler;
-import exopandora.worldhandler.event.EventListener;
+import exopandora.worldhandler.helper.ActionHelper;
+import exopandora.worldhandler.helper.CommandHelper;
import net.minecraft.client.Minecraft;
-import net.minecraft.command.CommandBase;
-import net.minecraft.command.CommandException;
-import net.minecraft.command.ICommandSender;
-import net.minecraft.command.WrongUsageException;
-import net.minecraft.server.MinecraftServer;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.text.TextComponentString;
-import net.minecraftforge.common.ForgeVersion;
-import net.minecraftforge.fml.common.Loader;
-import net.minecraftforge.fml.common.versioning.ComparableVersion;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraft.command.CommandSource;
+import net.minecraft.command.Commands;
+import net.minecraftforge.fml.ModList;
+import net.minecraftforge.fml.VersionChecker;
-@SideOnly(Side.CLIENT)
-public class CommandWorldHandler extends CommandBase
+public class CommandWorldHandler
{
- @Override
- public String getName()
+ public static void register(CommandDispatcher dispatcher)
{
- return "worldhandler";
+ dispatcher.register(Commands.literal("worldhandler")
+ .then(Commands.literal("help")
+ .executes(context -> help(context.getSource())))
+ .then(Commands.literal("display")
+ .executes(context -> display()))
+ .then(Commands.literal("version")
+ .executes(context -> version(context.getSource()))));
}
- @Override
- public int getRequiredPermissionLevel()
+ private static int help(CommandSource source) throws CommandSyntaxException
{
- return 0;
+ CommandHelper.sendFeedback(source, "/worldhandler help");
+ CommandHelper.sendFeedback(source, "/worldhandler display");
+ CommandHelper.sendFeedback(source, "/worldhandler version");
+ return 1;
}
- @Override
- public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
+ private static int display() throws CommandSyntaxException
{
- if(args.length > 0)
- {
- if(args[0].equalsIgnoreCase("help"))
- {
- this.printHelp(sender);
- }
- else if(args[0].equalsIgnoreCase("display"))
- {
- Minecraft.getMinecraft().addScheduledTask(EventListener::displayGui);
- }
- else if(args[0].equalsIgnoreCase("version"))
- {
- sender.sendMessage(new TextComponentString("Installed: $mcversion-$version"));
- ComparableVersion target = ForgeVersion.getResult(Loader.instance().getIndexedModList().get(Main.MODID)).target;
- sender.sendMessage(new TextComponentString("Latest: $mcversion-" + (target != null ? target : "$version")));
- }
- else
- {
- throw new WrongUsageException(this.getUsage(sender));
- }
- }
- else if(args.length == 0)
- {
- this.printHelp(sender);
- }
- else
- {
- throw new WrongUsageException(this.getUsage(sender));
- }
+ Minecraft.getInstance().addScheduledTask(ActionHelper::displayGui);
+ return 1;
}
- private void printHelp(ICommandSender player)
+ private static int version(CommandSource source) throws CommandSyntaxException
{
- player.sendMessage(new TextComponentString(ChatFormatting.DARK_GREEN + "--- Showing help page 1 of 1 (/worldhandler help) ---"));
- player.sendMessage(new TextComponentString("/worldhandler help"));
- player.sendMessage(new TextComponentString("/worldhandler display"));
- player.sendMessage(new TextComponentString("/worldhandler version"));
- player.sendMessage(new TextComponentString(ChatFormatting.GREEN + "Tip: Press '" + WorldHandler.KEY_WORLD_HANDLER.getDisplayName() + "' to open the World Handler"));
+ CommandHelper.sendFeedback(source, "Installed: $mcversion-$version");
+ ComparableVersion target = VersionChecker.getResult(ModList.get().getModContainerById(Main.MODID).get().getModInfo()).target;
+ CommandHelper.sendFeedback(source, "Latest: " + Main.MC_VERSION + "-" + (target != null ? target : Main.MOD_VERSION));
+ return 1;
}
-
- @Override
- public List getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos)
- {
- if(args.length == 1)
- {
- return this.getListOfStringsMatchingLastWord(args, new String[]{"help", "display", "version"});
- }
-
- return Collections.emptyList();
- }
-
- @Override
- public String getUsage(ICommandSender sender)
- {
- return new BuilderWorldHandler().toCommand();
- }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/exopandora/worldhandler/command/FakeCommandHandler.java b/src/main/java/exopandora/worldhandler/command/FakeCommandHandler.java
deleted file mode 100644
index 68580eb..0000000
--- a/src/main/java/exopandora/worldhandler/command/FakeCommandHandler.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package exopandora.worldhandler.command;
-
-import net.minecraft.client.Minecraft;
-import net.minecraft.command.CommandHandler;
-import net.minecraft.command.ICommand;
-import net.minecraft.server.MinecraftServer;
-import net.minecraftforge.client.event.ClientChatEvent;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
-public class FakeCommandHandler extends CommandHandler
-{
- @Override
- protected MinecraftServer getServer()
- {
- return null;
- }
-
- private void fakeCommand(ICommand command, ClientChatEvent event)
- {
- Minecraft.getMinecraft().ingameGUI.getChatGUI().addToSentMessages(event.getMessage());
- this.tryExecute(Minecraft.getMinecraft().player, dropFirstString(event.getMessage().split(" ")), command, event.getMessage());
-
- if(event != null && event.isCancelable())
- {
- event.setCanceled(true);
- }
- }
-
- private static String[] dropFirstString(String[] input)
- {
- String[] string = new String[input.length - 1];
- System.arraycopy(input, 1, string, 0, input.length - 1);
- return string;
- }
-
- public void tryCommand(ICommand command, ClientChatEvent event)
- {
- if(event.getMessage().equals("/" + command.getName()) || event.getMessage().startsWith("/" + command.getName() + " "))
- {
- this.fakeCommand(command, event);
- }
- }
-}
diff --git a/src/main/java/exopandora/worldhandler/config/Config.java b/src/main/java/exopandora/worldhandler/config/Config.java
new file mode 100644
index 0000000..9de0ae8
--- /dev/null
+++ b/src/main/java/exopandora/worldhandler/config/Config.java
@@ -0,0 +1,124 @@
+package exopandora.worldhandler.config;
+
+import java.util.List;
+
+import org.apache.commons.lang3.tuple.Pair;
+
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
+
+import exopandora.worldhandler.util.UtilKeyBinding;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+import net.minecraftforge.common.ForgeConfigSpec;
+import net.minecraftforge.fml.config.ModConfig;
+import net.minecraftforge.fml.config.ModConfig.Type;
+
+public class Config
+{
+ public static final ForgeConfigSpec CLIENT_SPEC;
+ public static final ClientConfig CLIENT;
+
+ private static ModConfig MOD_CONFIG;
+ private static CommentedFileConfig CONFIG_DATA;
+
+ static
+ {
+ Pair pair = new ForgeConfigSpec.Builder().configure(ClientConfig::new);
+ CLIENT_SPEC = pair.getRight();
+ CLIENT = pair.getLeft();
+ }
+
+ @OnlyIn(Dist.CLIENT)
+ public static class ClientConfig
+ {
+ private final ConfigCategorySettings settings;
+ private final ConfigCategoryButcher butcher;
+ private final ConfigCategorySkin skin;
+ private final ConfigCategorySliders sliders;
+
+ public ClientConfig(ForgeConfigSpec.Builder builder)
+ {
+ this.settings = new ConfigCategorySettings(builder);
+ this.butcher = new ConfigCategoryButcher(builder);
+ this.skin = new ConfigCategorySkin(builder);
+ this.sliders = new ConfigCategorySliders(builder);
+ }
+
+ public void read()
+ {
+ this.getSettings().read();
+ this.getButcher().read();
+ this.getSkin().read();
+ this.getSliders().read();
+ }
+
+ public ConfigCategorySettings getSettings()
+ {
+ return this.settings;
+ }
+
+ public ConfigCategoryButcher getButcher()
+ {
+ return this.butcher;
+ }
+
+ public ConfigCategorySkin getSkin()
+ {
+ return this.skin;
+ }
+
+ public ConfigCategorySliders getSliders()
+ {
+ return this.sliders;
+ }
+ }
+
+ public static ConfigCategorySettings getSettings()
+ {
+ return Config.CLIENT.getSettings();
+ }
+
+ public static ConfigCategoryButcher getButcher()
+ {
+ return Config.CLIENT.getButcher();
+ }
+
+ public static ConfigCategorySkin getSkin()
+ {
+ return Config.CLIENT.getSkin();
+ }
+
+ public static ConfigCategorySliders getSliders()
+ {
+ return Config.CLIENT.getSliders();
+ }
+
+ protected static void set(ForgeConfigSpec.ConfigValue configValue, T value)
+ {
+ if(configValue != null && value != null && (!value.equals(configValue.get()) || configValue.get() instanceof List>))
+ {
+ Config.CONFIG_DATA.set(configValue.getPath(), value);
+ }
+ }
+
+ public static void configLoad(ModConfig.Loading event)
+ {
+ if(event.getConfig().getType().equals(Type.CLIENT))
+ {
+ Config.MOD_CONFIG = event.getConfig();
+ Config.CONFIG_DATA = (CommentedFileConfig) Config.MOD_CONFIG.getConfigData();
+ Config.CLIENT.read();
+ }
+ }
+
+ public static void configReload(ModConfig.ConfigReloading event)
+ {
+ if(event.getConfig().getType().equals(Type.CLIENT) && Config.CONFIG_DATA != null)
+ {
+ Config.CONFIG_DATA.load();
+ Config.CLIENT.read();
+
+ UtilKeyBinding.updatePosKeys();
+ }
+ }
+}
diff --git a/src/main/java/exopandora/worldhandler/config/ConfigButcher.java b/src/main/java/exopandora/worldhandler/config/ConfigButcher.java
deleted file mode 100644
index e58dbae..0000000
--- a/src/main/java/exopandora/worldhandler/config/ConfigButcher.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package exopandora.worldhandler.config;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import exopandora.worldhandler.helper.EntityHelper;
-import net.minecraft.client.resources.I18n;
-import net.minecraft.entity.EntityList;
-import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.common.config.Configuration;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
-public class ConfigButcher
-{
- private static Map ENTITIES = new HashMap();
-
- public static final String CATEGORY = "butcher";
-
- public static void load(Configuration config)
- {
- for(ResourceLocation location : EntityList.ENTITY_EGGS.keySet())
- {
- String entity = EntityHelper.getEntityName(location);
- String translationKey = "entity." + entity + ".name";
- String translation = I18n.format(translationKey);
-
- if(!translation.equals(translationKey))
- {
- ENTITIES.put(entity, config.getBoolean(entity, CATEGORY, false, I18n.format("gui.worldhandler.config.comment.butcher", translation), translationKey));
- }
- }
-
- if(config.hasChanged())
- {
- config.save();
- }
- }
-
- public static Map getEntitiyMap()
- {
- return ENTITIES;
- }
-}
diff --git a/src/main/java/exopandora/worldhandler/config/ConfigCategoryButcher.java b/src/main/java/exopandora/worldhandler/config/ConfigCategoryButcher.java
new file mode 100644
index 0000000..5a1ddbc
--- /dev/null
+++ b/src/main/java/exopandora/worldhandler/config/ConfigCategoryButcher.java
@@ -0,0 +1,93 @@
+package exopandora.worldhandler.config;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+import net.minecraftforge.common.ForgeConfigSpec;
+import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
+import net.minecraftforge.registries.ForgeRegistries;
+
+@OnlyIn(Dist.CLIENT)
+public class ConfigCategoryButcher
+{
+ private final List entities = new ArrayList();
+
+ private final ConfigValue> valueEntities;
+
+ public ConfigCategoryButcher(ForgeConfigSpec.Builder builder)
+ {
+ builder.push("butcher");
+
+ this.valueEntities = builder.defineList("entities", Collections.emptyList(), this::isValid);
+
+ builder.pop();
+ }
+
+ public void read()
+ {
+ this.entities.clear();
+ this.entities.addAll(this.valueEntities.get());
+ }
+
+ private void write()
+ {
+ Config.set(this.valueEntities, this.entities);
+ }
+
+ public List getEntities()
+ {
+ List list = new ArrayList();
+
+ for(String entity : this.entities)
+ {
+ ResourceLocation resource = ResourceLocation.makeResourceLocation(entity);
+
+ if(resource != null)
+ {
+ list.add(resource);
+ }
+ }
+
+ return list;
+ }
+
+ public boolean containsEntity(ResourceLocation entity)
+ {
+ return this.entities.contains(entity.toString());
+ }
+
+ public void addEntity(ResourceLocation entity)
+ {
+ if(this.isValid(entity))
+ {
+ this.entities.add(entity.toString());
+ this.write();
+ }
+ }
+
+ public boolean removeEntity(ResourceLocation entity)
+ {
+ boolean removed = this.entities.remove(entity.toString());
+
+ if(removed)
+ {
+ this.write();
+ }
+
+ return removed;
+ }
+
+ private boolean isValid(Object string)
+ {
+ if(string != null)
+ {
+ return ForgeRegistries.ENTITIES.containsKey(ResourceLocation.makeResourceLocation(string.toString()));
+ }
+
+ return false;
+ }
+}
diff --git a/src/main/java/exopandora/worldhandler/config/ConfigCategorySettings.java b/src/main/java/exopandora/worldhandler/config/ConfigCategorySettings.java
new file mode 100644
index 0000000..1772764
--- /dev/null
+++ b/src/main/java/exopandora/worldhandler/config/ConfigCategorySettings.java
@@ -0,0 +1,320 @@
+package exopandora.worldhandler.config;
+
+import java.util.Arrays;
+
+import net.minecraft.client.resources.I18n;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+import net.minecraftforge.common.ForgeConfigSpec;
+import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
+import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
+import net.minecraftforge.common.ForgeConfigSpec.IntValue;
+
+@OnlyIn(Dist.CLIENT)
+public class ConfigCategorySettings
+{
+ private boolean commandSyntax;
+ private boolean shortcuts;
+ private boolean shortcutKeys;
+ private boolean tooltips;
+ private boolean watch;
+ private boolean smoothWatch;
+ private boolean pause;
+ private boolean customTimes;
+ private boolean permissionQuery;
+ private boolean highlightBlocks;
+ private int dawn;
+ private int noon;
+ private int sunset;
+ private int midnight;
+ private String blockPlacingMode;
+
+ private final BooleanValue valueCommandSyntax;
+ private final BooleanValue valueShortcuts;
+ private final BooleanValue valueShortcutKeys;
+ private final BooleanValue valueTooltips;
+ private final BooleanValue valueWatch;
+ private final BooleanValue valueSmoothWatch;
+ private final BooleanValue valuePause;
+ private final BooleanValue valueCustomTimes;
+ private final BooleanValue valuePermissionQuery;
+ private final BooleanValue valueHighlightBlocks;
+ private final IntValue valueDawn;
+ private final IntValue valueNoon;
+ private final IntValue valueSunset;
+ private final IntValue valueMidnight;
+ private final ConfigValue valueBlockPlacingMode;
+
+ public ConfigCategorySettings(ForgeConfigSpec.Builder builder)
+ {
+ builder.push("settings");
+
+ this.valueCommandSyntax = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.settings.command_syntax"))
+ .translation("gui.worldhandler.config.key.settings.command_syntax")
+ .define("command_syntax", false);
+ this.valueShortcuts = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.settings.shortcuts"))
+ .translation("gui.worldhandler.config.key.settings.shortcuts")
+ .define("shortcuts", false);
+ this.valueShortcutKeys = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.settings.key_shortcuts"))
+ .translation("gui.worldhandler.config.key.settings.key_shortcuts")
+ .define("key_shortcuts", false);
+ this.valueTooltips = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.settings.tooltips"))
+ .translation("gui.worldhandler.config.key.settings.tooltips")
+ .define("tooltips", true);
+ this.valueWatch = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.settings.watch"))
+ .translation("gui.worldhandler.config.key.settings.watch")
+ .define("watch", true);
+ this.valueSmoothWatch = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.settings.smooth_watch"))
+ .translation("gui.worldhandler.config.key.settings.smooth_watch")
+ .define("smooth_watch", true);
+ this.valuePause = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.settings.pause_game"))
+ .translation("gui.worldhandler.config.key.settings.pause_game")
+ .define("pause_game", false);
+ this.valueCustomTimes = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.settings.custom_times"))
+ .translation("gui.worldhandler.config.key.settings.custom_times")
+ .define("custom_times", false);
+ this.valuePermissionQuery = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.settings.permission_query"))
+ .translation("gui.worldhandler.config.key.settings.permission_query")
+ .define("permission_query", true);
+ this.valueHighlightBlocks = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.settings.highlight_blocks"))
+ .translation("gui.worldhandler.config.key.settings.highlight_blocks")
+ .define("highlight_blocks", true);
+
+ this.valueDawn = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.settings.custom_time_dawn"))
+ .translation("gui.worldhandler.config.key.settings.custom_time_dawn")
+ .defineInRange("custom_time_dawn", 1000, 0, 24000);
+ this.valueNoon = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.settings.custom_time_noon"))
+ .translation("gui.worldhandler.config.key.settings.custom_time_noon")
+ .defineInRange("custom_time_noon", 6000, 0, 24000);
+ this.valueSunset = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.settings.custom_time_sunset"))
+ .translation("gui.worldhandler.config.key.settings.custom_time_sunset")
+ .defineInRange("custom_time_sunset", 12500, 0, 24000);
+ this.valueMidnight = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.settings.custom_time_midnight"))
+ .translation("gui.worldhandler.config.key.settings.custom_time_midnight")
+ .defineInRange("custom_time_midnight", 18000, 0, 24000);
+
+ this.valueBlockPlacingMode = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.settings.block_placing_mode"))
+ .translation("gui.worldhandler.config.key.settings.block_placing_mode")
+ .defineInList("block_placing_mode", "keep", Arrays.asList("keep", "replace", "destroy"));
+
+ builder.pop();
+ }
+
+ public void read()
+ {
+ this.commandSyntax = this.valueCommandSyntax.get();
+ this.shortcuts = this.valueShortcuts.get();
+ this.shortcutKeys = this.valueShortcutKeys.get();
+ this.tooltips = this.valueTooltips.get();
+ this.watch = this.valueWatch.get();
+ this.smoothWatch = this.valueSmoothWatch.get();
+ this.pause = this.valuePause.get();
+ this.customTimes = this.valueCustomTimes.get();
+ this.permissionQuery = this.valuePermissionQuery.get();
+ this.highlightBlocks = this.valueHighlightBlocks.get();
+ this.dawn = this.valueDawn.get();
+ this.noon = this.valueNoon.get();
+ this.sunset = this.valueSunset.get();
+ this.midnight = this.valueMidnight.get();
+ this.blockPlacingMode = this.valueBlockPlacingMode.get();
+ }
+
+ private void write()
+ {
+ Config.set(this.valueCommandSyntax, this.commandSyntax);
+ Config.set(this.valueShortcuts, this.shortcuts);
+ Config.set(this.valueShortcutKeys, this.shortcutKeys);
+ Config.set(this.valueTooltips, this.tooltips);
+ Config.set(this.valueWatch, this.watch);
+ Config.set(this.valueSmoothWatch, this.smoothWatch);
+ Config.set(this.valuePause, this.pause);
+ Config.set(this.valueCustomTimes, this.customTimes);
+ Config.set(this.valuePermissionQuery, this.permissionQuery);
+ Config.set(this.valueHighlightBlocks, this.highlightBlocks);
+ Config.set(this.valueDawn, this.dawn);
+ Config.set(this.valueNoon, this.noon);
+ Config.set(this.valueSunset, this.sunset);
+ Config.set(this.valueMidnight, this.midnight);
+ Config.set(this.valueBlockPlacingMode, this.blockPlacingMode);
+ }
+
+ public boolean commandSyntax()
+ {
+ return this.commandSyntax;
+ }
+
+ public void setCommandSyntax(boolean enabled)
+ {
+ this.commandSyntax = enabled;
+ this.write();
+ }
+
+ public boolean shortcuts()
+ {
+ return this.shortcuts;
+ }
+
+ public void setShortcuts(boolean enabled)
+ {
+ this.shortcuts = enabled;
+ this.write();
+ }
+
+ public boolean shortcutKeys()
+ {
+ return this.shortcutKeys;
+ }
+
+ public void setShortcutKeys(boolean enabled)
+ {
+ this.shortcutKeys = enabled;
+ this.write();
+ }
+
+ public boolean tooltips()
+ {
+ return this.tooltips;
+ }
+
+ public void setTooltips(boolean enabled)
+ {
+ this.tooltips = enabled;
+ this.write();
+ }
+
+ public boolean watch()
+ {
+ return this.watch;
+ }
+
+ public void setWatch(boolean enabled)
+ {
+ this.watch = enabled;
+ this.write();
+ }
+
+ public boolean smoothWatch()
+ {
+ return this.smoothWatch;
+ }
+
+ public void setSmoothWatch(boolean enabled)
+ {
+ this.smoothWatch = enabled;
+ this.write();
+ }
+
+ public boolean pause()
+ {
+ return this.pause;
+ }
+
+ public void setPause(boolean enabled)
+ {
+ this.pause = enabled;
+ this.write();
+ }
+
+ public boolean customTimes()
+ {
+ return this.customTimes;
+ }
+
+ public void setCustomTimes(boolean enabled)
+ {
+ this.customTimes = enabled;
+ this.write();
+ }
+
+ public boolean permissionQuery()
+ {
+ return this.permissionQuery;
+ }
+
+ public void setPermissionQuery(boolean enabled)
+ {
+ this.permissionQuery = enabled;
+ this.write();
+ }
+
+ public boolean highlightBlocks()
+ {
+ return this.highlightBlocks;
+ }
+
+ public void setHighlightBlocks(boolean enabled)
+ {
+ this.highlightBlocks = enabled;
+ this.write();
+ }
+
+ public int getDawn()
+ {
+ return this.dawn;
+ }
+
+ public void setDawn(int ticks)
+ {
+ this.dawn = ticks;
+ this.write();
+ }
+
+ public int getNoon()
+ {
+ return this.noon;
+ }
+
+ public void setNoon(int ticks)
+ {
+ this.noon = ticks;
+ this.write();
+ }
+
+ public int getSunset()
+ {
+ return this.sunset;
+ }
+
+ public void setSunset(int ticks)
+ {
+ this.sunset = ticks;
+ this.write();
+ }
+
+ public int getMidnight()
+ {
+ return this.midnight;
+ }
+
+ public void setMidnight(int ticks)
+ {
+ this.midnight = ticks;
+ this.write();
+ }
+
+ public String getBlockPlacingMode()
+ {
+ return this.blockPlacingMode;
+ }
+
+ public void setBlockPlacingMode(String mode)
+ {
+ this.blockPlacingMode = mode;
+ this.write();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/exopandora/worldhandler/config/ConfigCategorySkin.java b/src/main/java/exopandora/worldhandler/config/ConfigCategorySkin.java
new file mode 100644
index 0000000..8aa5ca8
--- /dev/null
+++ b/src/main/java/exopandora/worldhandler/config/ConfigCategorySkin.java
@@ -0,0 +1,343 @@
+package exopandora.worldhandler.config;
+
+import java.util.Arrays;
+
+import net.minecraft.client.resources.I18n;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+import net.minecraftforge.common.ForgeConfigSpec;
+import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
+import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
+import net.minecraftforge.common.ForgeConfigSpec.IntValue;
+
+@OnlyIn(Dist.CLIENT)
+public class ConfigCategorySkin
+{
+ private int iconSize;
+ private int labelColor;
+ private int headlineColor;
+ private int backgroundRed;
+ private int backgroundGreen;
+ private int backgroundBlue;
+ private int backgroundAlpha;
+ private int buttonRed;
+ private int buttonGreen;
+ private int buttonBlue;
+ private int buttonAlpha;
+ private String type;
+ private boolean sharpEdges;
+ private boolean drawBackground;
+
+ private final ConfigValue valueIconSize;
+ private final IntValue valueLabelColor;
+ private final IntValue valueHeadlineColor;
+ private final IntValue valueBackgroundRed;
+ private final IntValue valueBackgroundGreen;
+ private final IntValue valueBackgroundBlue;
+ private final IntValue valueBackgroundAlpha;
+ private final IntValue valueButtonRed;
+ private final IntValue valueButtonGreen;
+ private final IntValue valueButtonBlue;
+ private final IntValue valueButtonAlpha;
+ private final ConfigValue valueType;
+ private final BooleanValue valueSharpEdges;
+ private final BooleanValue valueDrawBackground;
+
+ public ConfigCategorySkin(ForgeConfigSpec.Builder builder)
+ {
+ builder.push("skin");
+
+ this.valueIconSize = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.skin.icon_size"))
+ .translation("gui.worldhandler.config.key.skin.icon_size")
+ .defineInList("icon_size", 16, Arrays.asList(16, 32, 64));
+ this.valueLabelColor = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.skin.label_color"))
+ .translation("gui.worldhandler.config.key.skin.label_color")
+ .defineInRange("label_color", 0x1F1F1F, 0x80000000, 0x7FFFFFFF);
+ this.valueHeadlineColor = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.skin.headline_color"))
+ .translation("gui.worldhandler.config.key.skin.headline_color")
+ .defineInRange("headline_color", 0x4F4F4F, 0x80000000, 0x7FFFFFFF);
+
+ this.valueBackgroundRed = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.skin.background_red"))
+ .translation("gui.worldhandler.config.key.skin.background_red")
+ .defineInRange("background_red", 255, 0, 255);
+ this.valueBackgroundGreen = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.skin.background_green"))
+ .translation("gui.worldhandler.config.key.skin.background_green")
+ .defineInRange("background_green", 255, 0, 255);
+ this.valueBackgroundBlue = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.skin.background_blue"))
+ .translation("gui.worldhandler.config.key.skin.background_blue")
+ .defineInRange("background_blue", 255, 0, 255);
+ this.valueBackgroundAlpha = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.skin.background_alpha"))
+ .translation("gui.worldhandler.config.key.skin.background_alpha")
+ .defineInRange("background_alpha", 255, 0, 255);
+
+ this.valueButtonRed = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.skin.button_red"))
+ .translation("gui.worldhandler.config.key.skin.button_red")
+ .defineInRange("button_red", 255, 0, 255);
+ this.valueButtonGreen = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.skin.button_green"))
+ .translation("gui.worldhandler.config.key.skin.button_green")
+ .defineInRange("button_green", 255, 0, 255);
+ this.valueButtonBlue = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.skin.button_blue"))
+ .translation("gui.worldhandler.config.key.skin.button_blue")
+ .defineInRange("button_blue", 255, 0, 255);
+ this.valueButtonAlpha = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.skin.button_alpha"))
+ .translation("gui.worldhandler.config.key.skin.button_alpha")
+ .defineInRange("button_alpha", 255, 0, 255);
+
+ this.valueType = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.skin.textures"))
+ .translation("gui.worldhandler.config.key.skin.textures")
+ .defineInList("textures", "resourcepack", Arrays.asList("resourcepack", "vanilla"));
+
+ this.valueSharpEdges = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.settings.sharp_tab_edges"))
+ .translation("gui.worldhandler.config.key.settings.sharp_tab_edges")
+ .define("sharp_tab_edges", false);
+ this.valueDrawBackground = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.settings.draw_background"))
+ .translation("gui.worldhandler.config.key.settings.draw_background")
+ .define("draw_background", true);
+
+ builder.pop();
+ }
+
+ public void read()
+ {
+ this.iconSize = this.valueIconSize.get();
+ this.labelColor = this.valueLabelColor.get();
+ this.headlineColor = this.valueHeadlineColor.get();
+ this.backgroundRed = this.valueBackgroundRed.get();
+ this.backgroundGreen = this.valueBackgroundGreen.get();
+ this.backgroundBlue = this.valueBackgroundBlue.get();
+ this.backgroundAlpha = this.valueBackgroundAlpha.get();
+ this.buttonRed = this.valueButtonRed.get();
+ this.buttonGreen = this.valueButtonGreen.get();
+ this.buttonBlue = this.valueButtonBlue.get();
+ this.buttonAlpha = this.valueButtonAlpha.get();
+ this.type = this.valueType.get();
+ this.sharpEdges = this.valueSharpEdges.get();
+ this.drawBackground = this.valueDrawBackground.get();
+ }
+
+ private void write()
+ {
+ Config.set(this.valueIconSize, this.iconSize);
+ Config.set(this.valueLabelColor, this.labelColor);
+ Config.set(this.valueHeadlineColor, this.headlineColor);
+ Config.set(this.valueBackgroundRed, this.backgroundRed);
+ Config.set(this.valueBackgroundGreen, this.backgroundGreen);
+ Config.set(this.valueBackgroundBlue, this.backgroundBlue);
+ Config.set(this.valueBackgroundAlpha, this.backgroundAlpha);
+ Config.set(this.valueButtonRed, this.buttonRed);
+ Config.set(this.valueButtonGreen, this.buttonGreen);
+ Config.set(this.valueButtonBlue, this.buttonBlue);
+ Config.set(this.valueButtonAlpha, this.buttonAlpha);
+ Config.set(this.valueType, this.type);
+ Config.set(this.valueSharpEdges, this.sharpEdges);
+ Config.set(this.valueDrawBackground, this.drawBackground);
+ }
+
+ public int getIconSize()
+ {
+ return this.iconSize;
+ }
+
+ public void setIconSize(int size)
+ {
+ this.iconSize = size;
+ this.write();
+ }
+
+ public int getLabelColor()
+ {
+ return this.labelColor;
+ }
+
+ public void setLabelColor(int color)
+ {
+ this.labelColor = color;
+ this.write();
+ }
+
+ public int getHeadlineColor()
+ {
+ return this.headlineColor;
+ }
+
+ public void setHeadlineColor(int color)
+ {
+ this.headlineColor = color;
+ this.write();
+ }
+
+ private int getBackgroundRed()
+ {
+ return this.backgroundRed;
+ }
+
+ public float getBackgroundRedF()
+ {
+ return this.getBackgroundRed() / 255F;
+ }
+
+ public void setBackgroundRed(int red)
+ {
+ this.backgroundRed = red;
+ this.write();
+ }
+
+ private int getBackgroundGreen()
+ {
+ return this.backgroundGreen;
+ }
+
+ public float getBackgroundGreenF()
+ {
+ return this.getBackgroundGreen() / 255F;
+ }
+
+ public void setBackgroundGreen(int green)
+ {
+ this.backgroundGreen = green;
+ this.write();
+ }
+
+ private int getBackgroundBlue()
+ {
+ return this.backgroundBlue;
+ }
+
+ public float getBackgroundBlueF()
+ {
+ return this.getBackgroundBlue() / 255F;
+ }
+
+ public void setBackgroundBlue(int blue)
+ {
+ this.backgroundBlue = blue;
+ this.write();
+ }
+
+ private int getButtonRed()
+ {
+ return this.buttonRed;
+ }
+
+ public float getButtonRedF()
+ {
+ return this.getButtonRed() / 255F;
+ }
+
+ public void setButtonRed(int red)
+ {
+ this.backgroundRed = red;
+ this.write();
+ }
+
+ private int getButtonGreen()
+ {
+ return this.buttonGreen;
+ }
+
+ public float getButtonGreenF()
+ {
+ return this.getButtonGreen() / 255F;
+ }
+
+ public void setButtonGreen(int green)
+ {
+ this.buttonGreen = green;
+ this.write();
+ }
+
+ private int getButtonBlue()
+ {
+ return this.buttonBlue;
+ }
+
+ public float getButtonBlueF()
+ {
+ return this.getButtonBlue() / 255F;
+ }
+
+ public void setButtonBlue(int blue)
+ {
+ this.buttonBlue = blue;
+ this.write();
+ }
+
+ public String getTextureType()
+ {
+ return this.type;
+ }
+
+ public void setTextureType(String type)
+ {
+ this.type = type;
+ this.write();
+ }
+
+ public boolean sharpEdges()
+ {
+ return this.sharpEdges;
+ }
+
+ public void setSharpEdges(boolean enabled)
+ {
+ this.sharpEdges = enabled;
+ this.write();
+ }
+
+ public boolean drawBackground()
+ {
+ return this.drawBackground;
+ }
+
+ public void setDrawBackground(boolean enabled)
+ {
+ this.drawBackground = enabled;
+ this.write();
+ }
+
+ private int getBackgroundAlpha()
+ {
+ return this.backgroundAlpha;
+ }
+
+ public float getBackgroundAlphaF()
+ {
+ return this.getBackgroundAlpha() / 255F;
+ }
+
+ public void setBackgroundAlpha(int alpha)
+ {
+ this.backgroundAlpha = alpha;
+ this.write();
+ }
+
+ private int getButtonAlpha()
+ {
+ return this.buttonAlpha;
+ }
+
+ public float getButtonAlphaF()
+ {
+ return this.getButtonAlpha() / 255F;
+ }
+
+ public void setButtonAlpha(int alpha)
+ {
+ this.buttonAlpha = alpha;
+ this.write();
+ }
+}
diff --git a/src/main/java/exopandora/worldhandler/config/ConfigCategorySliders.java b/src/main/java/exopandora/worldhandler/config/ConfigCategorySliders.java
new file mode 100644
index 0000000..06da5d1
--- /dev/null
+++ b/src/main/java/exopandora/worldhandler/config/ConfigCategorySliders.java
@@ -0,0 +1,203 @@
+package exopandora.worldhandler.config;
+
+import net.minecraft.client.resources.I18n;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+import net.minecraftforge.common.ForgeConfigSpec;
+import net.minecraftforge.common.ForgeConfigSpec.DoubleValue;
+
+@OnlyIn(Dist.CLIENT)
+public class ConfigCategorySliders
+{
+ private double maxPotionAmplifier;
+ private double maxItemEnchantment;
+ private double maxItemAttributes;
+ private double maxSummonPotionAmplifier;
+ private double maxSummonPotionMinutes;
+ private double maxSummonAttributes;
+ private double maxExperience;
+ private double maxPlayerPoints;
+ private double maxTriggerValue;
+
+ private final DoubleValue valueMaxPotionAmplifier;
+ private final DoubleValue valueMaxItemEnchantment;
+ private final DoubleValue valueMaxItemAttributes;
+ private final DoubleValue valueMaxSummonPotionAmplifier;
+ private final DoubleValue valueMaxSummonPotionMinutes;
+ private final DoubleValue valueMaxSummonAttributes;
+ private final DoubleValue valueMaxExperience;
+ private final DoubleValue valueMaxPlayerPoints;
+ private final DoubleValue valueMaxTriggerValue;
+
+ public ConfigCategorySliders(ForgeConfigSpec.Builder builder)
+ {
+ builder.push("sliders");
+
+ this.valueMaxPotionAmplifier = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.sliders.max_potion_amplifier"))
+ .translation("gui.worldhandler.config.key.sliders.max_potion_amplifier")
+ .defineInRange("max_potion_amplifier", 100D, 0D, Byte.MAX_VALUE);
+
+ this.valueMaxItemEnchantment = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.sliders.max_item_enchantment"))
+ .translation("gui.worldhandler.config.key.sliders.max_item_enchantment")
+ .defineInRange("max_item_enchantment", 100D, 0D, Integer.MAX_VALUE);
+ this.valueMaxItemAttributes = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.sliders.max_item_attributes"))
+ .translation("gui.worldhandler.config.key.sliders.max_item_attributes")
+ .defineInRange("max_item_attributes", 100D, 0D, Double.MAX_VALUE);
+
+ this.valueMaxSummonPotionAmplifier = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.sliders.max_summon_potion_amplifier"))
+ .translation("gui.worldhandler.config.key.sliders.max_summon_potion_amplifier")
+ .defineInRange("max_summon_potion_amplifier", 100D, 0D, Byte.MAX_VALUE);
+ this.valueMaxSummonPotionMinutes = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.sliders.max_summon_potion_minutes"))
+ .translation("gui.worldhandler.config.key.sliders.max_summon_potion_minutes")
+ .defineInRange("max_summon_potion_minutes", 100D, 0D, 16000);
+ this.valueMaxSummonAttributes = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.sliders.max_summon_attributes"))
+ .translation("gui.worldhandler.config.key.sliders.max_summon_attributes")
+ .defineInRange("max_summon_attributes", 100D, 0D, Double.MAX_VALUE);
+
+ this.valueMaxExperience = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.sliders.max_experience"))
+ .translation("gui.worldhandler.config.key.sliders.max_experience")
+ .defineInRange("max_experience", 100D, 0D, 100000D);
+ this.valueMaxPlayerPoints = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.sliders.max_player_points"))
+ .translation("gui.worldhandler.config.key.sliders.max_player_points")
+ .defineInRange("max_player_points", 100D, 0D, 100000D);
+ this.valueMaxTriggerValue = builder
+ .comment(I18n.format("gui.worldhandler.config.comment.sliders.max_trigger_value"))
+ .translation("gui.worldhandler.config.key.sliders.max_trigger_value")
+ .defineInRange("max_trigger_value", 100D, 0D, 100000D);
+
+ builder.pop();
+ }
+
+ public void read()
+ {
+ this.maxPotionAmplifier = this.valueMaxPotionAmplifier.get();
+ this.maxItemEnchantment = this.valueMaxItemEnchantment.get();
+ this.maxItemAttributes = this.valueMaxItemAttributes.get();
+ this.maxSummonPotionAmplifier = this.valueMaxSummonPotionAmplifier.get();
+ this.maxSummonPotionMinutes = this.valueMaxSummonPotionMinutes.get();
+ this.maxSummonAttributes = this.valueMaxSummonAttributes.get();
+ this.maxExperience = this.valueMaxExperience.get();
+ this.maxPlayerPoints = this.valueMaxPlayerPoints.get();
+ this.maxTriggerValue = this.valueMaxTriggerValue.get();
+ }
+
+ private void write()
+ {
+ Config.set(this.valueMaxPotionAmplifier, this.maxPotionAmplifier);
+ Config.set(this.valueMaxItemEnchantment, this.maxItemEnchantment);
+ Config.set(this.valueMaxItemAttributes, this.maxItemAttributes);
+ Config.set(this.valueMaxSummonPotionAmplifier, this.maxSummonPotionAmplifier);
+ Config.set(this.valueMaxSummonPotionMinutes, this.maxSummonPotionMinutes);
+ Config.set(this.valueMaxSummonAttributes, this.maxSummonAttributes);
+ Config.set(this.valueMaxExperience, this.maxExperience);
+ Config.set(this.valueMaxPlayerPoints, this.maxPlayerPoints);
+ Config.set(this.valueMaxTriggerValue, this.maxTriggerValue);
+ }
+
+ public double getMaxPotionAmplifier()
+ {
+ return this.maxPotionAmplifier;
+ }
+
+ public void setMaxPotionAmplifier(double max)
+ {
+ this.maxPotionAmplifier = max;
+ this.write();
+ }
+
+ public double getMaxItemEnchantment()
+ {
+ return this.maxItemEnchantment;
+ }
+
+ public void setMaxItemEnchantment(double max)
+ {
+ this.maxItemEnchantment = max;
+ this.write();
+ }
+
+ public double getMaxItemAttributes()
+ {
+ return this.maxItemAttributes;
+ }
+
+ public void setMaxItemAttributes(double max)
+ {
+ this.maxItemAttributes = max;
+ this.write();
+ }
+
+ public double getMaxSummonPotionAmplifier()
+ {
+ return this.maxSummonPotionAmplifier;
+ }
+
+ public void setMaxSummonPotionAmplifier(double max)
+ {
+ this.maxSummonPotionAmplifier = max;
+ this.write();
+ }
+
+ public double getMaxSummonPotionMinutes()
+ {
+ return this.maxSummonPotionMinutes;
+ }
+
+ public void setMaxSummonPotionMinutes(double max)
+ {
+ this.maxSummonPotionMinutes = max;
+ this.write();
+ }
+
+ public double getMaxSummonAttributes()
+ {
+ return this.maxSummonAttributes;
+ }
+
+ public void setMaxSummonAttributes(double max)
+ {
+ this.maxSummonAttributes = max;
+ this.write();
+ }
+
+ public double getMaxExperience()
+ {
+ return this.maxExperience;
+ }
+
+ public void setMaxExperience(double max)
+ {
+ this.maxExperience = max;
+ this.write();
+ }
+
+ public double getMaxPlayerPoints()
+ {
+ return this.maxPlayerPoints;
+ }
+
+ public void setMaxPlayerPoints(double max)
+ {
+ this.maxPlayerPoints = max;
+ this.write();
+ }
+
+ public double getMaxTriggerValue()
+ {
+ return this.maxTriggerValue;
+ }
+
+ public void setMaxTriggerValue(double max)
+ {
+ this.maxTriggerValue = max;
+ this.write();
+ }
+}
diff --git a/src/main/java/exopandora/worldhandler/config/ConfigSettings.java b/src/main/java/exopandora/worldhandler/config/ConfigSettings.java
deleted file mode 100644
index 9f113fe..0000000
--- a/src/main/java/exopandora/worldhandler/config/ConfigSettings.java
+++ /dev/null
@@ -1,136 +0,0 @@
-package exopandora.worldhandler.config;
-
-import net.minecraft.client.resources.I18n;
-import net.minecraftforge.common.config.Configuration;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
-public class ConfigSettings
-{
- private static boolean BIOME_INDICATOR;
- private static boolean COMMAND_SYNTAX;
- private static boolean SHORTCUTS;
- private static boolean SHORTCUT_KEYS;
- private static boolean TOOLTIPS;
- private static boolean WATCH;
- private static boolean SMOOTH_WATCH;
- private static boolean PAUSE;
- private static boolean CUSTOM_TIMES;
- private static boolean PERMISSION_QUERY;
- private static boolean HIGHLIGHT_BLOCKS;
-
- private static int DAWN;
- private static int NOON;
- private static int SUNSET;
- private static int MIDNIGHT;
-
- private static String BLOCK_PLACING_MODE;
-
- public static final String CATEGORY = "settings";
-
- public static void load(Configuration config)
- {
- BIOME_INDICATOR = config.getBoolean("biome_indicator", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.biome_indicator"), "gui.worldhandler.config.key.settings.biome_indicator");
- COMMAND_SYNTAX = config.getBoolean("command_syntax", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.command_syntax"), "gui.worldhandler.config.key.settings.command_syntax");
- SHORTCUTS = config.getBoolean("shortcuts", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.shortcuts"), "gui.worldhandler.config.key.settings.shortcuts");
- SHORTCUT_KEYS = config.getBoolean("key_shortcuts", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.key_shortcuts"), "gui.worldhandler.config.key.settings.key_shortcuts");
- TOOLTIPS = config.getBoolean("tooltips", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.settings.tooltips"), "gui.worldhandler.config.key.settings.tooltips");
- WATCH = config.getBoolean("watch", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.settings.watch"), "gui.worldhandler.config.key.settings.watch");
- SMOOTH_WATCH = config.getBoolean("smooth_watch", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.settings.smooth_watch"), "gui.worldhandler.config.key.settings.smooth_watch");
- PAUSE = config.getBoolean("pause_game", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.pause_game"), "gui.worldhandler.config.key.settings.pause_game");
- CUSTOM_TIMES = config.getBoolean("custom_times", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.custom_times"), "gui.worldhandler.config.key.settings.custom_times");
- PERMISSION_QUERY = config.getBoolean("permission_query", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.settings.permission_query"), "gui.worldhandler.config.key.settings.permission_query");
- HIGHLIGHT_BLOCKS = config.getBoolean("highlight_blocks", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.settings.highlight_blocks"), "gui.worldhandler.config.key.settings.highlight_blocks");
- DAWN = config.getInt("custom_time_dawn", CATEGORY, 1000, 0, 24000, I18n.format("gui.worldhandler.config.comment.settings.custom_time_dawn"), "gui.worldhandler.config.key.settings.custom_time_dawn");
- NOON = config.getInt("custom_time_noon", CATEGORY, 6000, 0, 24000, I18n.format("gui.worldhandler.config.comment.settings.custom_time_noon"), "gui.worldhandler.config.key.settings.custom_time_noon");
- SUNSET = config.getInt("custom_time_sunset", CATEGORY, 12500, 0, 24000, I18n.format("gui.worldhandler.config.comment.settings.custom_time_sunset"), "gui.worldhandler.config.key.settings.custom_time_sunset");
- MIDNIGHT = config.getInt("custom_time_midnight", CATEGORY, 18000, 0, 24000, I18n.format("gui.worldhandler.config.comment.settings.custom_time_midnight"), "gui.worldhandler.config.key.settings.custom_time_midnight");
- BLOCK_PLACING_MODE = config.getString("block_placing_mode", CATEGORY, "keep", I18n.format("gui.worldhandler.config.comment.settings.block_placing_mode"), new String[]{"keep", "replace", "destroy"}, "gui.worldhandler.config.key.settings.block_placing_mode");
-
- if(config.hasChanged())
- {
- config.save();
- }
- }
-
- public static boolean isBiomeIndicatorEnabled()
- {
- return BIOME_INDICATOR;
- }
-
- public static boolean isCommandSyntaxEnabled()
- {
- return COMMAND_SYNTAX;
- }
-
- public static boolean areShortcutsEnabled()
- {
- return SHORTCUTS;
- }
-
- public static boolean arePosShortcutsEnabled()
- {
- return SHORTCUT_KEYS;
- }
-
- public static boolean areTooltipsEnabled()
- {
- return TOOLTIPS;
- }
-
- public static boolean isWatchEnabled()
- {
- return WATCH;
- }
-
- public static boolean isSmoothWatchEnabled()
- {
- return SMOOTH_WATCH;
- }
-
- public static boolean isPauseEnabled()
- {
- return PAUSE;
- }
-
- public static boolean isCustomTimeEnabled()
- {
- return CUSTOM_TIMES;
- }
-
- public static boolean isPermissionQueryEnabled()
- {
- return PERMISSION_QUERY;
- }
-
- public static boolean isHighlightBlocksEnabled()
- {
- return HIGHLIGHT_BLOCKS;
- }
-
- public static int getDawn()
- {
- return DAWN;
- }
-
- public static int getNoon()
- {
- return NOON;
- }
-
- public static int getSunset()
- {
- return SUNSET;
- }
-
- public static int getMidnight()
- {
- return MIDNIGHT;
- }
-
- public static String getMode()
- {
- return BLOCK_PLACING_MODE;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/exopandora/worldhandler/config/ConfigSkin.java b/src/main/java/exopandora/worldhandler/config/ConfigSkin.java
deleted file mode 100644
index 6ec1755..0000000
--- a/src/main/java/exopandora/worldhandler/config/ConfigSkin.java
+++ /dev/null
@@ -1,127 +0,0 @@
-package exopandora.worldhandler.config;
-
-import net.minecraft.client.resources.I18n;
-import net.minecraftforge.common.config.Configuration;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
-public class ConfigSkin
-{
- private static int ICON_SIZE;
- private static int LABEL_COLOR;
- private static int HEADLINE_COLOR;
-
- private static int BACKGROUND_RED;
- private static int BACKGROUND_GREEN;
- private static int BACKGROUND_BLUE;
- private static int BACKGROUND_ALPHA;
-
- private static int BUTTON_RED;
- private static int BUTTON_GREEN;
- private static int BUTTON_BLUE;
- private static int BUTTON_ALPHA;
-
- private static String TYPE;
-
- private static boolean SHARP_EDGES;
- private static boolean DRAW_BACKGROUND;
-
- public static final String CATEGORY = "skin";
-
- public static void load(Configuration config)
- {
- ICON_SIZE = Integer.valueOf(config.getString("icon_size", CATEGORY, "16", I18n.format("gui.worldhandler.config.comment.skin.icons"), new String[]{"16", "32", "64"}, "gui.worldhandler.config.key.skin.icons"));
- LABEL_COLOR = config.getInt("label_color", CATEGORY, 0x1F1F1F, 0x80000000, 0x7FFFFFFF, I18n.format("gui.worldhandler.config.comment.skin.label_color"), "gui.worldhandler.config.key.skin.label_color");
- HEADLINE_COLOR = config.getInt("headline_color", CATEGORY, 0x4F4F4F, 0x80000000, 0x7FFFFFFF, I18n.format("gui.worldhandler.config.comment.skin.headline_color"), "gui.worldhandler.config.key.skin.headline_color");
-
- BACKGROUND_RED = config.getInt("background_red", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.background_red"), "gui.worldhandler.config.key.skin.background_red");
- BACKGROUND_GREEN = config.getInt("background_green", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.background_green"), "gui.worldhandler.config.key.skin.background_green");
- BACKGROUND_BLUE = config.getInt("background_blue", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.background_blue"), "gui.worldhandler.config.key.skin.background_blue");
- BACKGROUND_ALPHA = config.getInt("background_alpha", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.background_alpha"), "gui.worldhandler.config.key.skin.background_alpha");
-
- BUTTON_RED = config.getInt("button_red", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.button_red"), "gui.worldhandler.config.key.skin.button_red");
- BUTTON_GREEN = config.getInt("button_green", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.button_green"), "gui.worldhandler.config.key.skin.button_green");
- BUTTON_BLUE = config.getInt("button_blue", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.button_blue"), "gui.worldhandler.config.key.skin.button_blue");
- BUTTON_ALPHA = config.getInt("button_alpha", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.button_alpha"), "gui.worldhandler.config.key.skin.button_alpha");
-
- TYPE = config.getString("textures", CATEGORY, "resourcepack", I18n.format("gui.worldhandler.config.comment.skin.textures"), new String[]{"resourcepack", "vanilla"}, "gui.worldhandler.config.key.skin.textures");
- SHARP_EDGES = config.getBoolean("sharp_tab_edges", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.skin.sharp_tab_edges"), "gui.worldhandler.config.key.skin.sharp_tab_edges");
- DRAW_BACKGROUND = config.getBoolean("draw_background", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.skin.draw_background"), "gui.worldhandler.config.key.skin.draw_background");
-
- if(config.hasChanged())
- {
- config.save();
- }
- }
-
- public static int getIconSize()
- {
- return ICON_SIZE;
- }
-
- public static int getLabelColor()
- {
- return LABEL_COLOR;
- }
-
- public static int getHeadlineColor()
- {
- return HEADLINE_COLOR;
- }
-
- public static int getBackgroundRed()
- {
- return BACKGROUND_RED;
- }
-
- public static int getBackgroundGreen()
- {
- return BACKGROUND_GREEN;
- }
-
- public static int getBackgroundBlue()
- {
- return BACKGROUND_BLUE;
- }
-
- public static int getButtonRed()
- {
- return BUTTON_RED;
- }
-
- public static int getButtonGreen()
- {
- return BUTTON_GREEN;
- }
-
- public static int getButtonBlue()
- {
- return BUTTON_BLUE;
- }
-
- public static String getTextureType()
- {
- return TYPE;
- }
-
- public static boolean areSharpEdgesEnabled()
- {
- return SHARP_EDGES;
- }
-
- public static boolean isBackgroundDrawingEnabled()
- {
- return DRAW_BACKGROUND;
- }
-
- public static int getBackgroundAlpha()
- {
- return BACKGROUND_ALPHA;
- }
-
- public static int getButtonAlpha()
- {
- return BUTTON_ALPHA;
- }
-}
diff --git a/src/main/java/exopandora/worldhandler/config/ConfigSliders.java b/src/main/java/exopandora/worldhandler/config/ConfigSliders.java
deleted file mode 100644
index 4aacbe4..0000000
--- a/src/main/java/exopandora/worldhandler/config/ConfigSliders.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package exopandora.worldhandler.config;
-
-import net.minecraft.client.resources.I18n;
-import net.minecraftforge.common.config.Configuration;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
-public class ConfigSliders
-{
- private static double MAX_POTION_AMPLIFIER;
-
- private static double MAX_ITEM_ENCHANTENT;
- private static double MAX_ITEM_ATTRIBUTES;
-
- private static double MAX_SUMMON_POTION_AMPLIFIER;
- private static double MAX_SUMMON_POTION_MINUTES;
- private static double MAX_SUMMON_ATTRIBUTES;
-
- private static double MAX_EXPERIENCE;
- private static double MAX_PLAYER_POINTS;
-
- public static final String CATEGORY = "sliders";
-
- public static void load(Configuration config)
- {
- MAX_POTION_AMPLIFIER = config.get(CATEGORY, "max_potion_amplifier", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_potion_amplifier"), 0D, Byte.MAX_VALUE).setLanguageKey("gui.worldhandler.config.key.sliders.max_potion_amplifier").getDouble();
-
- MAX_ITEM_ENCHANTENT = config.get(CATEGORY, "max_item_enchantment", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_item_enchantment"), 0D, Integer.MAX_VALUE).setLanguageKey("gui.worldhandler.config.key.sliders.max_item_enchantment").getDouble();
- MAX_ITEM_ATTRIBUTES = config.get(CATEGORY, "max_item_attributes", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_item_attributes"), 0D, Double.MAX_VALUE).setLanguageKey("gui.worldhandler.config.key.sliders.max_item_attributes").getDouble();
-
- MAX_SUMMON_POTION_AMPLIFIER = config.get(CATEGORY, "max_summon_potion_amplifier", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_summon_potion_amplifier"), 0D, Byte.MAX_VALUE).setLanguageKey("gui.worldhandler.config.key.sliders.max_summon_potion_amplifier").getDouble();
- MAX_SUMMON_POTION_MINUTES = config.get(CATEGORY, "max_summon_potion_minutes", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_summon_potion_minutes"), 0D, 16000).setLanguageKey("gui.worldhandler.config.key.sliders.max_summon_potion_minutes").getDouble();
- MAX_SUMMON_ATTRIBUTES = config.get(CATEGORY, "max_summon_attributes", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_summon_attributes"), 0D, Double.MAX_VALUE).setLanguageKey("gui.worldhandler.config.key.sliders.max_summon_attributes").getDouble();
-
- MAX_EXPERIENCE = config.get(CATEGORY, "max_experience", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_experience"), 0D, 100000D).setLanguageKey("gui.worldhandler.config.key.sliders.max_experience").getDouble();
- MAX_PLAYER_POINTS = config.get(CATEGORY, "max_player_points", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_player_points"), 0D, 100000D).setLanguageKey("gui.worldhandler.config.key.sliders.max_player_points").getDouble();
-
- if(config.hasChanged())
- {
- config.save();
- }
- }
-
- public static double getMaxPotionAmplifier()
- {
- return MAX_POTION_AMPLIFIER;
- }
-
- public static double getMaxItemEnchantment()
- {
- return MAX_ITEM_ENCHANTENT;
- }
-
- public static double getMaxItemAttributes()
- {
- return MAX_ITEM_ATTRIBUTES;
- }
-
- public static double getMaxSummonPotionAmplifier()
- {
- return MAX_SUMMON_POTION_AMPLIFIER;
- }
-
- public static double getMaxSummonPotionMinutes()
- {
- return MAX_SUMMON_POTION_MINUTES;
- }
-
- public static double getMaxSummonAttributes()
- {
- return MAX_SUMMON_ATTRIBUTES;
- }
-
- public static double getMaxExperience()
- {
- return MAX_EXPERIENCE;
- }
-
- public static double getMaxPlayerPoints()
- {
- return MAX_PLAYER_POINTS;
- }
-}
diff --git a/src/main/java/exopandora/worldhandler/event/ClientEventHandler.java b/src/main/java/exopandora/worldhandler/event/ClientEventHandler.java
new file mode 100644
index 0000000..13f16af
--- /dev/null
+++ b/src/main/java/exopandora/worldhandler/event/ClientEventHandler.java
@@ -0,0 +1,121 @@
+package exopandora.worldhandler.event;
+
+import com.mojang.brigadier.CommandDispatcher;
+import com.mojang.brigadier.ParseResults;
+import com.mojang.brigadier.StringReader;
+import com.mojang.brigadier.exceptions.CommandSyntaxException;
+
+import exopandora.worldhandler.config.Config;
+import exopandora.worldhandler.helper.BlockHelper;
+import exopandora.worldhandler.helper.CommandHelper;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.BufferBuilder;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
+import net.minecraft.command.CommandSource;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+import net.minecraftforge.client.event.ClientChatEvent;
+import net.minecraftforge.client.event.RenderWorldLastEvent;
+
+@OnlyIn(Dist.CLIENT)
+public class ClientEventHandler
+{
+ public static void renderWorldLastEvent(RenderWorldLastEvent event)
+ {
+ if(Config.getSettings().highlightBlocks() && Minecraft.getInstance().world != null)
+ {
+ GlStateManager.pushMatrix();
+ GlStateManager.disableAlphaTest();
+ GlStateManager.enableBlend();
+ GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
+ GlStateManager.lineWidth(2.0F);
+ GlStateManager.disableTexture2D();
+ GlStateManager.depthMask(false);
+
+ final double constant = 0.0020000000949949026D;
+ EntityPlayer player = Minecraft.getInstance().player;
+
+ double playerX = player.lastTickPosX + (player.posX - player.lastTickPosX) * Minecraft.getInstance().getRenderPartialTicks();
+ double playerY = player.lastTickPosY + (player.posY - player.lastTickPosY) * Minecraft.getInstance().getRenderPartialTicks();
+ double playerZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * Minecraft.getInstance().getRenderPartialTicks();
+
+ double minX = Math.min(BlockHelper.getPos1().getX(), BlockHelper.getPos2().getX()) - constant - playerX;
+ double minY = Math.min(BlockHelper.getPos1().getY(), BlockHelper.getPos2().getY()) - constant - playerY;
+ double minZ = Math.min(BlockHelper.getPos1().getZ(), BlockHelper.getPos2().getZ()) - constant - playerZ;
+
+ double maxX = Math.max(BlockHelper.getPos1().getX(), BlockHelper.getPos2().getX()) + constant - playerX + 1;
+ double maxY = Math.max(BlockHelper.getPos1().getY(), BlockHelper.getPos2().getY()) + constant - playerY + 1;
+ double maxZ = Math.max(BlockHelper.getPos1().getZ(), BlockHelper.getPos2().getZ()) + constant - playerZ + 1;
+
+ Tessellator tesselator = Tessellator.getInstance();
+ BufferBuilder buffer = tesselator.getBuffer();
+
+ final int alpha = 255;
+ final int color1 = 223;
+ final int color2 = 127;
+
+ GlStateManager.lineWidth(2.0F);
+ buffer.begin(3, DefaultVertexFormats.POSITION_COLOR);
+ buffer.pos(minX, minY, minZ).color((float) color1, (float) color1, (float) color1, 0.0F).endVertex();
+ buffer.pos(minX, minY, minZ).color(color1, color1, color1, alpha).endVertex();
+ buffer.pos(maxX, minY, minZ).color(color1, color2, color2, alpha).endVertex();
+ buffer.pos(maxX, minY, maxZ).color(color1, color1, color1, alpha).endVertex();
+ buffer.pos(minX, minY, maxZ).color(color1, color1, color1, alpha).endVertex();
+ buffer.pos(minX, minY, minZ).color(color2, color2, color1, alpha).endVertex();
+ buffer.pos(minX, maxY, minZ).color(color2, color1, color2, alpha).endVertex();
+ buffer.pos(maxX, maxY, minZ).color(color1, color1, color1, alpha).endVertex();
+ buffer.pos(maxX, maxY, maxZ).color(color1, color1, color1, alpha).endVertex();
+ buffer.pos(minX, maxY, maxZ).color(color1, color1, color1, alpha).endVertex();
+ buffer.pos(minX, maxY, minZ).color(color1, color1, color1, alpha).endVertex();
+ buffer.pos(minX, maxY, maxZ).color(color1, color1, color1, alpha).endVertex();
+ buffer.pos(minX, minY, maxZ).color(color1, color1, color1, alpha).endVertex();
+ buffer.pos(maxX, minY, maxZ).color(color1, color1, color1, alpha).endVertex();
+ buffer.pos(maxX, maxY, maxZ).color(color1, color1, color1, alpha).endVertex();
+ buffer.pos(maxX, maxY, minZ).color(color1, color1, color1, alpha).endVertex();
+ buffer.pos(maxX, minY, minZ).color(color1, color1, color1, alpha).endVertex();
+ buffer.pos(maxX, minY, minZ).color((float) color1, (float) color1, (float) color1, 0.0F).endVertex();
+ tesselator.draw();
+ GlStateManager.lineWidth(1.0F);
+
+ GlStateManager.depthMask(true);
+ GlStateManager.enableTexture2D();
+ GlStateManager.disableBlend();
+ GlStateManager.enableAlphaTest();
+ GlStateManager.popMatrix();
+ }
+ }
+
+ public static void clientChatEvent(ClientChatEvent event)
+ {
+ if(!Minecraft.getInstance().isSingleplayer())
+ {
+ CommandDispatcher dispatcher = new CommandDispatcher();
+ CommandHelper.registerCommands(dispatcher);
+
+ StringReader command = new StringReader(event.getMessage());
+ command.skip();
+
+ ParseResults result = dispatcher.parse(command, Minecraft.getInstance().player.getCommandSource());
+
+ if(result.getContext().getCommand() != null)
+ {
+ try
+ {
+ dispatcher.execute(result);
+ }
+ catch(CommandSyntaxException e)
+ {
+ e.printStackTrace();
+ }
+
+ if(event.isCancelable())
+ {
+ event.setCanceled(true);
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/exopandora/worldhandler/event/EventListener.java b/src/main/java/exopandora/worldhandler/event/EventListener.java
deleted file mode 100644
index f6f6ca3..0000000
--- a/src/main/java/exopandora/worldhandler/event/EventListener.java
+++ /dev/null
@@ -1,172 +0,0 @@
-package exopandora.worldhandler.event;
-
-import com.mojang.realmsclient.gui.ChatFormatting;
-
-import exopandora.worldhandler.Main;
-import exopandora.worldhandler.WorldHandler;
-import exopandora.worldhandler.command.FakeCommandHandler;
-import exopandora.worldhandler.config.ConfigSettings;
-import exopandora.worldhandler.gui.container.impl.GuiWorldHandlerContainer;
-import exopandora.worldhandler.gui.content.Contents;
-import exopandora.worldhandler.helper.BlockHelper;
-import exopandora.worldhandler.hud.BiomeIndicator;
-import exopandora.worldhandler.util.UtilPlayer;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.RenderGlobal;
-import net.minecraft.client.resources.I18n;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.init.Blocks;
-import net.minecraft.util.text.ChatType;
-import net.minecraft.util.text.TextComponentString;
-import net.minecraftforge.client.event.ClientChatEvent;
-import net.minecraftforge.client.event.RenderWorldLastEvent;
-import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent;
-import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
-import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
-public class EventListener
-{
- private final FakeCommandHandler commandHandler = new FakeCommandHandler();
- private final BiomeIndicator biomeIndicator = new BiomeIndicator();
-
- @SubscribeEvent
- public void renderWorldLastEvent(RenderWorldLastEvent event)
- {
- if(ConfigSettings.isHighlightBlocksEnabled() && Minecraft.getMinecraft().world != null)
- {
- GlStateManager.pushMatrix();
- GlStateManager.disableAlpha();
- GlStateManager.enableBlend();
- GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
- GlStateManager.glLineWidth(2.0F);
- GlStateManager.disableTexture2D();
- GlStateManager.depthMask(false);
-
- final double constant = 0.0020000000949949026D;
- EntityPlayer player = Minecraft.getMinecraft().player;
-
- double playerX = player.lastTickPosX + (player.posX - player.lastTickPosX) * Minecraft.getMinecraft().getRenderPartialTicks();
- double playerY = player.lastTickPosY + (player.posY - player.lastTickPosY) * Minecraft.getMinecraft().getRenderPartialTicks();
- double playerZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * Minecraft.getMinecraft().getRenderPartialTicks();
-
- double minX = Math.min(BlockHelper.getPos1().getX(), BlockHelper.getPos2().getX()) - constant - playerX;
- double minY = Math.min(BlockHelper.getPos1().getY(), BlockHelper.getPos2().getY()) - constant - playerY;
- double minZ = Math.min(BlockHelper.getPos1().getZ(), BlockHelper.getPos2().getZ()) - constant - playerZ;
-
- double maxX = Math.max(BlockHelper.getPos1().getX(), BlockHelper.getPos2().getX()) + constant - playerX + 1;
- double maxY = Math.max(BlockHelper.getPos1().getY(), BlockHelper.getPos2().getY()) + constant - playerY + 1;
- double maxZ = Math.max(BlockHelper.getPos1().getZ(), BlockHelper.getPos2().getZ()) + constant - playerZ + 1;
-
- final float opacity = 0.2F;
-
- for(int x = 1; x < maxX - minX; x++)
- {
- RenderGlobal.drawBoundingBox(minX, minY, minZ, minX + x + 2 * constant, maxY, maxZ, 0.0F, 0.0F, 0.0F, opacity);
- }
-
- for(int y = 1; y < maxY - minY; y++)
- {
- RenderGlobal.drawBoundingBox(minX, minY, minZ, maxX, minY + y + 2 * constant, maxZ, 0.0F, 0.0F, 0.0F, opacity);
- }
-
- for(int z = 1; z < maxZ - minZ; z++)
- {
- RenderGlobal.drawBoundingBox(minX, minY, minZ, maxX, maxY, minZ + z + 2 * constant, 0.0F, 0.0F, 0.0F, opacity);
- }
-
- RenderGlobal.renderFilledBox(minX, minY, minZ, maxX, maxY, maxZ, 0.0F, 0.0F, 0.0F, opacity / 2);
- RenderGlobal.renderFilledBox(maxX, maxY, maxZ, minX, minY, minZ, 0.0F, 0.0F, 0.0F, opacity / 2);
-
- GlStateManager.depthMask(true);
- GlStateManager.enableTexture2D();
- GlStateManager.disableBlend();
- GlStateManager.enableAlpha();
- GlStateManager.popMatrix();
- }
- }
-
- @SubscribeEvent
- public void clientTickEvent(ClientTickEvent event)
- {
- if(Minecraft.getMinecraft().inGameHasFocus && event.phase.equals(Phase.START))
- {
- if(ConfigSettings.isBiomeIndicatorEnabled())
- {
- this.biomeIndicator.tick();
- }
- }
- }
-
- @SubscribeEvent
- public void keyInputEvent(KeyInputEvent event)
- {
- if(WorldHandler.KEY_WORLD_HANDLER.isPressed())
- {
- displayGui();
- }
- else if(WorldHandler.KEY_WORLD_HANDLER_POS1.isPressed() && ConfigSettings.arePosShortcutsEnabled())
- {
- BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
- }
- else if(WorldHandler.KEY_WORLD_HANDLER_POS2.isPressed() && ConfigSettings.arePosShortcutsEnabled())
- {
- BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
- }
- }
-
- @SubscribeEvent
- public void onConfigChanged(OnConfigChangedEvent event)
- {
- if(event.getModID().equals(Main.MODID))
- {
- WorldHandler.updateConfig();
- }
- }
-
- @SubscribeEvent
- public void clientChatEvent(ClientChatEvent event)
- {
- if(!Minecraft.getMinecraft().isSingleplayer())
- {
- this.commandHandler.tryCommand(WorldHandler.COMMAND_WORLD_HANDLER, event);
- this.commandHandler.tryCommand(WorldHandler.COMMAND_WH, event);
- }
- }
-
- public static void displayGui()
- {
- if(!UtilPlayer.canIssueCommand() && ConfigSettings.isPermissionQueryEnabled())
- {
- Minecraft.getMinecraft().ingameGUI.addChatMessage(ChatType.GAME_INFO, new TextComponentString(ChatFormatting.RED + I18n.format("worldhandler.permission.refused")));
- Minecraft.getMinecraft().ingameGUI.addChatMessage(ChatType.GAME_INFO, new TextComponentString(ChatFormatting.RED + I18n.format("worldhandler.permission.refused.change", I18n.format("gui.worldhandler.config.key.settings.permission_query"))));
- }
- else
- {
- try
- {
- if(BlockHelper.isFocusedBlockEqualTo(Blocks.STANDING_SIGN) || BlockHelper.isFocusedBlockEqualTo(Blocks.WALL_SIGN))
- {
- Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.SIGN_EDITOR));
- }
- else if(BlockHelper.isFocusedBlockEqualTo(Blocks.NOTEBLOCK))
- {
- Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.NOTE_EDITOR));
- }
- else
- {
- Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.MAIN));
- }
- }
- catch(Exception e)
- {
- WorldHandler.throwError(e);
- }
- }
- }
-}
diff --git a/src/main/java/exopandora/worldhandler/event/KeyHandler.java b/src/main/java/exopandora/worldhandler/event/KeyHandler.java
new file mode 100644
index 0000000..81cf6c8
--- /dev/null
+++ b/src/main/java/exopandora/worldhandler/event/KeyHandler.java
@@ -0,0 +1,34 @@
+package exopandora.worldhandler.event;
+
+import exopandora.worldhandler.WorldHandler;
+import exopandora.worldhandler.config.Config;
+import exopandora.worldhandler.helper.ActionHelper;
+import exopandora.worldhandler.helper.BlockHelper;
+import net.minecraft.client.Minecraft;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
+
+@OnlyIn(Dist.CLIENT)
+public class KeyHandler
+{
+ //TODO FORGE switch to KeyInputEvent
+ public static void keyInputEvent(ClientTickEvent event)
+ {
+ if(Minecraft.getInstance().isGameFocused())
+ {
+ if(WorldHandler.KEY_WORLD_HANDLER.isPressed())
+ {
+ ActionHelper.displayGui();
+ }
+ else if(WorldHandler.KEY_WORLD_HANDLER_POS1.isPressed() && Config.getSettings().shortcutKeys())
+ {
+ BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
+ }
+ else if(WorldHandler.KEY_WORLD_HANDLER_POS2.isPressed() && Config.getSettings().shortcutKeys())
+ {
+ BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
+ }
+ }
+ }
+}
diff --git a/src/main/java/exopandora/worldhandler/format/EnumColor.java b/src/main/java/exopandora/worldhandler/format/EnumColor.java
index e26ed73..f0398f2 100644
--- a/src/main/java/exopandora/worldhandler/format/EnumColor.java
+++ b/src/main/java/exopandora/worldhandler/format/EnumColor.java
@@ -2,11 +2,14 @@ package exopandora.worldhandler.format;
import javax.annotation.Nullable;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+/**
+ * XXX To be replaced with TextFormatting
+ */
@Deprecated
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public enum EnumColor
{
DEFAULT("reset", "r"),
@@ -30,7 +33,7 @@ public enum EnumColor
OBFUSCATED("obfuscated", "k"),
BOLD("bold", "l"),
STRIKETHROUGH("strikethrough", "m"),
- UNDERLINED("underlined", "n"),
+ UNDERLINE("underline", "n"),
ITALIC("italic", "o");
private String format;
diff --git a/src/main/java/exopandora/worldhandler/format/TextFormatting.java b/src/main/java/exopandora/worldhandler/format/TextFormatting.java
index 6e81ba4..f5e2de8 100644
--- a/src/main/java/exopandora/worldhandler/format/TextFormatting.java
+++ b/src/main/java/exopandora/worldhandler/format/TextFormatting.java
@@ -2,10 +2,10 @@ package exopandora.worldhandler.format;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.util.math.MathHelper;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class TextFormatting
{
public static String shortenString(String str, int maxWidth, FontRenderer fontRenderer)
@@ -88,7 +88,7 @@ public class TextFormatting
return minute;
}
- public static String getWorldTime(long tick)
+ public static String formatWorldTime(long tick)
{
int hour = TextFormatting.getHour(tick);
int minute = TextFormatting.getMinute(tick);
diff --git a/src/main/java/exopandora/worldhandler/format/text/ColoredString.java b/src/main/java/exopandora/worldhandler/format/text/ColoredString.java
index b4e74a9..dd2656d 100644
--- a/src/main/java/exopandora/worldhandler/format/text/ColoredString.java
+++ b/src/main/java/exopandora/worldhandler/format/text/ColoredString.java
@@ -3,10 +3,14 @@ package exopandora.worldhandler.format.text;
import com.mojang.realmsclient.gui.ChatFormatting;
import exopandora.worldhandler.format.EnumColor;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+/**
+ * XXX To be replaced with ITextComponent
+ */
+@Deprecated
+@OnlyIn(Dist.CLIENT)
public class ColoredString extends FormattedString
{
private EnumColor color = EnumColor.DEFAULT;
@@ -92,16 +96,6 @@ public class ColoredString extends FormattedString
return result;
}
- public String getTextFieldString()
- {
- if(this.text != null)
- {
- return this.getFormattedString(super.getPreformattedString(this.text));
- }
-
- return null;
- }
-
@Override
public String toString()
{
@@ -124,4 +118,9 @@ public class ColoredString extends FormattedString
return null;
}
+
+ public String textFormatter(String string, Integer integer)
+ {
+ return this.getFormattedString(string);
+ }
}
diff --git a/src/main/java/exopandora/worldhandler/format/text/FormattedString.java b/src/main/java/exopandora/worldhandler/format/text/FormattedString.java
index 411f654..c599275 100644
--- a/src/main/java/exopandora/worldhandler/format/text/FormattedString.java
+++ b/src/main/java/exopandora/worldhandler/format/text/FormattedString.java
@@ -1,9 +1,9 @@
package exopandora.worldhandler.format.text;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public abstract class FormattedString
{
protected String text;
diff --git a/src/main/java/exopandora/worldhandler/format/text/JsonClickEvent.java b/src/main/java/exopandora/worldhandler/format/text/JsonClickEvent.java
index bc140b6..5f487ea 100644
--- a/src/main/java/exopandora/worldhandler/format/text/JsonClickEvent.java
+++ b/src/main/java/exopandora/worldhandler/format/text/JsonClickEvent.java
@@ -1,9 +1,9 @@
package exopandora.worldhandler.format.text;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class JsonClickEvent
{
private String action;
diff --git a/src/main/java/exopandora/worldhandler/format/text/JsonSignLine.java b/src/main/java/exopandora/worldhandler/format/text/JsonSignLine.java
index 929fce9..31cf434 100644
--- a/src/main/java/exopandora/worldhandler/format/text/JsonSignLine.java
+++ b/src/main/java/exopandora/worldhandler/format/text/JsonSignLine.java
@@ -1,9 +1,9 @@
package exopandora.worldhandler.format.text;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class JsonSignLine extends FormattedString
{
private String color;
diff --git a/src/main/java/exopandora/worldhandler/format/text/JsonSignLineSerializer.java b/src/main/java/exopandora/worldhandler/format/text/JsonSignLineSerializer.java
index d318c1e..5d90cb3 100644
--- a/src/main/java/exopandora/worldhandler/format/text/JsonSignLineSerializer.java
+++ b/src/main/java/exopandora/worldhandler/format/text/JsonSignLineSerializer.java
@@ -9,10 +9,10 @@ import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import exopandora.worldhandler.format.EnumColor;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class JsonSignLineSerializer implements JsonSerializer
{
@Override
diff --git a/src/main/java/exopandora/worldhandler/format/text/SignText.java b/src/main/java/exopandora/worldhandler/format/text/SignText.java
index 65c32e5..8527fc2 100644
--- a/src/main/java/exopandora/worldhandler/format/text/SignText.java
+++ b/src/main/java/exopandora/worldhandler/format/text/SignText.java
@@ -3,10 +3,10 @@ package exopandora.worldhandler.format.text;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class SignText
{
private static final Gson GSON = new GsonBuilder().registerTypeAdapter(JsonSignLine.class, new JsonSignLineSerializer()).create();
diff --git a/src/main/java/exopandora/worldhandler/gui/button/EnumIcon.java b/src/main/java/exopandora/worldhandler/gui/button/EnumIcon.java
index 331e063..6a1e63f 100644
--- a/src/main/java/exopandora/worldhandler/gui/button/EnumIcon.java
+++ b/src/main/java/exopandora/worldhandler/gui/button/EnumIcon.java
@@ -1,9 +1,13 @@
package exopandora.worldhandler.gui.button;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+/**
+ * XXX To be replaced by a proper registry object
+ */
+@Deprecated
+@OnlyIn(Dist.CLIENT)
public enum EnumIcon
{
WEATHER_SUN(0, 0),
diff --git a/src/main/java/exopandora/worldhandler/gui/button/EnumTooltip.java b/src/main/java/exopandora/worldhandler/gui/button/EnumTooltip.java
deleted file mode 100644
index 39ea49d..0000000
--- a/src/main/java/exopandora/worldhandler/gui/button/EnumTooltip.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package exopandora.worldhandler.gui.button;
-
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
-public enum EnumTooltip
-{
- TOP_RIGHT,
- TOP_LEFT,
- BOTTOM_RIGHT,
- BOTTOM_LEFT,
- RIGHT,
- LEFT
-}
diff --git a/src/main/java/exopandora/worldhandler/gui/button/GuiButtonBase.java b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonBase.java
new file mode 100644
index 0000000..606c856
--- /dev/null
+++ b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonBase.java
@@ -0,0 +1,91 @@
+package exopandora.worldhandler.gui.button;
+
+import exopandora.worldhandler.config.Config;
+import exopandora.worldhandler.helper.ActionHelper;
+import exopandora.worldhandler.helper.ResourceHelper;
+import exopandora.worldhandler.util.ActionHandler;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+
+@OnlyIn(Dist.CLIENT)
+public class GuiButtonBase extends GuiButton
+{
+ protected ActionHandler actionHandler;
+
+ public GuiButtonBase(int x, int y, int widthIn, int heightIn, String buttonText, ActionHandler actionHandler)
+ {
+ this(0, x, y, widthIn, heightIn, buttonText, actionHandler);
+ }
+
+ public GuiButtonBase(int id, int x, int y, int widthIn, int heightIn, String buttonText, ActionHandler actionHandler)
+ {
+ super(id, x, y, widthIn, heightIn, buttonText);
+ this.actionHandler = actionHandler;
+ }
+
+ protected void drawBackground(int mouseX, int mouseY)
+ {
+ GlStateManager.enableBlend();
+ GlStateManager.color4f(Config.getSkin().getButtonRedF(), Config.getSkin().getButtonGreenF(), Config.getSkin().getButtonBlueF(), Config.getSkin().getButtonAlphaF());
+
+ this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
+ int hovered = this.getHoverState(this.hovered);
+
+ Minecraft.getInstance().getTextureManager().bindTexture(ResourceHelper.getButtonTexture());
+
+ if(Config.getSkin().getTextureType().equals("resourcepack"))
+ {
+ this.drawTexturedModalRect(this.x, this.y, 0, 46 + hovered * 20, this.width / 2, this.height);
+ this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + hovered * 20, this.width / 2, this.height);
+ }
+ else
+ {
+ this.drawTexturedModalRect(this.x, this.y, 0, hovered * 20, this.width / 2, this.height);
+ this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, hovered * 20, this.width / 2, this.height);
+ }
+
+ GlStateManager.disableBlend();
+ GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
+ }
+
+ @Override
+ public void render(int mouseX, int mouseY, float partialTicks)
+ {
+ if(this.visible)
+ {
+ this.drawBackground(mouseX, mouseY);
+ this.renderBg(Minecraft.getInstance(), mouseX, mouseY);
+ this.drawCenteredString(Minecraft.getInstance().fontRenderer, this.displayString, this.x + this.width / 2, this.y + (this.height - 8) / 2, this.getTextColor());
+ }
+ }
+
+ @Override
+ public void onClick(double mouseX, double mouseY)
+ {
+ super.onClick(mouseX, mouseY);
+
+ if(this.actionHandler != null)
+ {
+ ActionHelper.tryRun(this.actionHandler);
+ }
+ }
+
+ protected int getTextColor()
+ {
+ int textColor = 0xE0E0E0;
+
+ if(!this.enabled)
+ {
+ textColor = 0xA0A0A0;
+ }
+ else if(this.hovered)
+ {
+ textColor = 0xFFFFA0;
+ }
+
+ return textColor;
+ }
+}
diff --git a/src/main/java/exopandora/worldhandler/gui/button/GuiButtonIcon.java b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonIcon.java
new file mode 100644
index 0000000..1592664
--- /dev/null
+++ b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonIcon.java
@@ -0,0 +1,59 @@
+package exopandora.worldhandler.gui.button;
+
+import exopandora.worldhandler.helper.ResourceHelper;
+import exopandora.worldhandler.util.ActionHandler;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+
+@OnlyIn(Dist.CLIENT)
+public class GuiButtonIcon extends GuiButtonTooltip
+{
+ private EnumIcon icon;
+
+ public GuiButtonIcon(int x, int y, int widthIn, int heightIn, EnumIcon icon, String tooltip, ActionHandler actionHandler)
+ {
+ this(0, x, y, widthIn, heightIn, icon, tooltip, actionHandler);
+ }
+
+ public GuiButtonIcon(int id, int x, int y, int widthIn, int heightIn, EnumIcon icon, String tooltip, ActionHandler actionHandler)
+ {
+ super(id, x, y, widthIn, heightIn, null, tooltip, actionHandler);
+ this.icon = icon;
+ }
+
+ @Override
+ public void render(int mouseX, int mouseY, float partialTicks)
+ {
+ super.render(mouseX, mouseY, partialTicks);
+
+ if(this.icon != null)
+ {
+ this.renderIcon();
+ }
+ }
+
+ private void renderIcon()
+ {
+ Minecraft.getInstance().getTextureManager().bindTexture(ResourceHelper.getIconTexture());
+
+ if(this.enabled)
+ {
+ if(this.hovered)
+ {
+ GlStateManager.color4f(1.0F, 1.0F, 0.6F, 1.0F);
+ }
+ else
+ {
+ GlStateManager.color4f(0.95F, 0.95F, 0.95F, 1.0F);
+ }
+ }
+ else
+ {
+ GlStateManager.color4f(0.8F, 0.8F, 0.8F, 1.0F);
+ }
+
+ this.drawTexturedModalRect(this.x + this.width / 2 - 4, this.y + 6, this.icon.getX() * 8, this.icon.getY() * 8, 8, 8);
+ }
+}
diff --git a/src/main/java/exopandora/worldhandler/gui/button/GuiButtonItem.java b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonItem.java
index d027b7d..32e81e6 100644
--- a/src/main/java/exopandora/worldhandler/gui/button/GuiButtonItem.java
+++ b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonItem.java
@@ -1,46 +1,55 @@
package exopandora.worldhandler.gui.button;
+import exopandora.worldhandler.util.ActionHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
-public class GuiButtonItem extends GuiButtonWorldHandler
+@OnlyIn(Dist.CLIENT)
+public class GuiButtonItem extends GuiButtonBase
{
- private final ItemStack item;
+ private final ItemStack stack;
- public GuiButtonItem(int id, int x, int y, int width, int height, Item item)
+ public GuiButtonItem(int x, int y, int width, int height, Item item, ActionHandler actionHandler)
{
- this(id, x, y, width, height, new ItemStack(item));
+ this(0, x, y, width, height, item, actionHandler);
}
- public GuiButtonItem(int id, int x, int y, int width, int height, ItemStack item)
+ public GuiButtonItem(int id, int x, int y, int width, int height, Item item, ActionHandler actionHandler)
{
- super(id, x, y, width, height, null);
- this.item = item;
+ this(id, x, y, width, height, new ItemStack(item), actionHandler);
+ }
+
+ public GuiButtonItem(int x, int y, int width, int height, ItemStack stack, ActionHandler actionHandler)
+ {
+ this(0, x, y, width, height, stack, actionHandler);
+ }
+
+ public GuiButtonItem(int id, int x, int y, int width, int height, ItemStack stack, ActionHandler actionHandler)
+ {
+ super(id, x, y, width, height, null, actionHandler);
+ this.stack = stack;
}
@Override
- public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
+ public void render(int mouseX, int mouseY, float partialTicks)
{
if(this.visible)
{
- super.drawBackground(minecraft, mouseX, mouseY);
+ super.drawBackground(mouseX, mouseY);
GlStateManager.enableRescaleNormal();
RenderHelper.enableGUIStandardItemLighting();
- Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(this.item, this.x + this.width / 2 - 8, this.y + 2);
+ Minecraft.getInstance().getItemRenderer().renderItemIntoGUI(this.stack, this.x + this.width / 2 - 8, this.y + 2);
RenderHelper.disableStandardItemLighting();
GlStateManager.disableRescaleNormal();
GlStateManager.disableBlend();
-
- this.isActive = true;
}
}
}
diff --git a/src/main/java/exopandora/worldhandler/gui/button/GuiButtonKeyboard.java b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonKeyboard.java
deleted file mode 100644
index b61b14e..0000000
--- a/src/main/java/exopandora/worldhandler/gui/button/GuiButtonKeyboard.java
+++ /dev/null
@@ -1,181 +0,0 @@
-package exopandora.worldhandler.gui.button;
-
-import org.lwjgl.input.Mouse;
-
-import exopandora.worldhandler.Main;
-import exopandora.worldhandler.WorldHandler;
-import exopandora.worldhandler.config.ConfigSkin;
-import exopandora.worldhandler.gui.container.Container;
-import exopandora.worldhandler.gui.content.Content;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.audio.PositionedSoundRecord;
-import net.minecraft.client.audio.SoundHandler;
-import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.util.ResourceLocation;
-import net.minecraft.util.SoundEvent;
-import net.minecraft.util.math.BlockPos;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
-public class GuiButtonKeyboard extends GuiButtonWorldHandler
-{
- private static final ResourceLocation NOTE = new ResourceLocation(Main.MODID, "textures/misc/note.png");
- private final Orientation orientation;
- private final float pitch;
-
- private boolean lastMousePressed;
-
- private final BlockPos pos;
- private final SoundEvent sound;
- private final Content content;
- private final Container container;
-
- public GuiButtonKeyboard(int id, int x, int y, int width, int height, String displayString, Orientation orientation, float pitch, Container container, Content content, BlockPos pos, SoundEvent sound)
- {
- super(id, x, y, width, height, displayString);
- this.orientation = orientation;
- this.pitch = pitch;
- this.pos = pos;
- this.sound = sound;
- this.content = content;
- this.container = container;
- }
-
- @Override
- public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
- {
- if(this.visible)
- {
- FontRenderer fontRenderer = minecraft.fontRenderer;
- GlStateManager.color(1.0F, 1.0F, 1.0F, (float) ConfigSkin.getButtonAlpha() / 255);
- minecraft.renderEngine.bindTexture(NOTE);
-
- switch(this.orientation)
- {
- case LEFT:
- this.hovered = this.isHoveringLeft(mouseX, mouseY);
- break;
- case NORMAL:
- this.hovered = this.isHoveringNormal(mouseX, mouseY);
- break;
- case RIGHT:
- this.hovered = this.isHoveringRight(mouseX, mouseY);
- break;
- case BLACK:
- this.hovered = this.isHoveringBlack(mouseX, mouseY);
- break;
- default:
- break;
- }
-
- int hoverstate = this.getHoverState(this.hovered);
-
- switch(this.orientation)
- {
- case BLACK:
- this.drawTexturedModalRect(this.x, this.y, 55 + hoverstate * -9 + 18, 0, 9, 58);
- break;
- case LEFT:
- case NORMAL:
- case RIGHT:
- default:
- int textColor = 0x000000;
-
- if(!this.enabled)
- {
- textColor = 0xA0A0A0;
- }
- else if(this.hovered)
- {
- textColor = 0x8B8B8B;
- }
-
- this.drawTexturedModalRect(this.x, this.y, 25 + hoverstate * 15 - 15, 0, 15, 92);
- fontRenderer.drawString(this.displayString, this.x + this.width / 2 - fontRenderer.getStringWidth(this.displayString) / 2, this.y + (this.height - 8) / 2 + 36, textColor);
- break;
- }
- }
-
- this.mouseDragged(minecraft, mouseX, mouseY);
- }
-
- private boolean isHoveringBlack(int mouseX, int mouseY)
- {
- return mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
- }
-
- private boolean isHoveringLeft(int mouseX, int mouseY)
- {
- return (mouseX >= this.x && mouseY >= this.y && mouseX < this.x + 10 && mouseY < this.y + 60) || (mouseX >= this.x && mouseY >= this.y + 58 && mouseX < this.x + 14 && mouseY < this.y + 93);
- }
-
- private boolean isHoveringNormal(int mouseX, int mouseY)
- {
- return (mouseX >= this.x + 4 && mouseY >= this.y && mouseX < this.x + 10 && mouseY < this.y + 60) || (mouseX >= this.x && mouseY >= this.y + 58 && mouseX < this.x + 14 && mouseY < this.y + 93);
- }
-
- private boolean isHoveringRight(int mouseX, int mouseY)
- {
- return (mouseX >= this.x + 4 && mouseY >= this.y && mouseX < this.x + 14 && mouseY < this.y + 60) || (mouseX >= this.x && mouseY >= this.y + 58 && mouseX < this.x + 14 && mouseY < this.y + 93);
- }
-
- @Override
- public boolean mousePressed(Minecraft minecraft, int mouseX, int mouseY)
- {
- switch(this.orientation)
- {
- case LEFT:
- return this.enabled && this.visible && this.isHoveringLeft(mouseX, mouseY);
- case NORMAL:
- return this.enabled && this.visible && this.isHoveringNormal(mouseX, mouseY);
- case RIGHT:
- return this.enabled && this.visible && this.isHoveringRight(mouseX, mouseY);
- case BLACK:
- return this.enabled && this.visible && this.isHoveringBlack(mouseX, mouseY);
- default:
- return false;
- }
- }
-
- @Override
- protected void mouseDragged(Minecraft minecraft, int mouseX, int mouseY)
- {
- if(this.visible)
- {
- if(this.lastMousePressed != mousePressed(minecraft, mouseX, mouseY))
- {
- if(mousePressed(minecraft, mouseX, mouseY) && Mouse.isButtonDown(0))
- {
- this.playPressSound(minecraft.getSoundHandler());
-
- try
- {
- this.content.actionPerformed(this.container, this);
- }
- catch(Exception e)
- {
- WorldHandler.throwError(e);
- }
- }
-
- this.lastMousePressed = mousePressed(minecraft, mouseX, mouseY);
- }
- }
- }
-
- @Override
- public void playPressSound(SoundHandler soundHandlerIn)
- {
- soundHandlerIn.playSound(PositionedSoundRecord.getMasterRecord(this.sound, this.pitch));
- }
-
- public static enum Orientation
- {
- LEFT,
- NORMAL,
- RIGHT,
- BLACK;
- }
-}
diff --git a/src/main/java/exopandora/worldhandler/gui/button/GuiButtonList.java b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonList.java
index 0b5f84d..507441a 100644
--- a/src/main/java/exopandora/worldhandler/gui/button/GuiButtonList.java
+++ b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonList.java
@@ -1,110 +1,80 @@
package exopandora.worldhandler.gui.button;
+import java.util.List;
+
import com.mojang.realmsclient.gui.ChatFormatting;
import exopandora.worldhandler.format.TextFormatting;
-import exopandora.worldhandler.gui.button.logic.IListButtonLogic;
-import exopandora.worldhandler.gui.button.persistence.ButtonValue;
import exopandora.worldhandler.gui.container.Container;
-import exopandora.worldhandler.gui.content.Content;
+import exopandora.worldhandler.gui.logic.ILogicMapped;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
-public class GuiButtonList extends GuiButtonWorldHandler
+@OnlyIn(Dist.CLIENT)
+public class GuiButtonList extends GuiButtonTooltip
{
- private final IListButtonLogic logic;
- private final ButtonValue persistence;
- private int mouseX;
- private int mouseY;
+ private final ILogicMapped logic;
+ private final Persistence persistence;
+ private final List items;
- public GuiButtonList(int id, int x, int y, int width, int height, Content content, IListButtonLogic logic)
+ public GuiButtonList(int x, int y, List items, int widthIn, int heightIn, Container container, ILogicMapped logic)
{
- this(id, x, y, width, height, null, content, logic);
+ this(0, x, y, items, widthIn, heightIn, container, logic);
}
- public GuiButtonList(int id, int x, int y, int width, int height, EnumTooltip tooltipType, Content content, IListButtonLogic logic)
+ public GuiButtonList(int id, int x, int y, List items, int widthIn, int heightIn, Container container, ILogicMapped logic)
{
- super(id, x, y, width, height, null, null, tooltipType);
+ super(id, x, y, widthIn, heightIn, null, null, null);
+ this.items = items;
this.logic = logic;
- this.persistence = content.getPersistence(this.logic.getId());
- this.updatePersistenceObject();
+ this.persistence = container.getContent().getPersistence(this.logic.getId(), Persistence::new);
}
@Override
- public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
+ public void render(int mouseX, int mouseY, float partialTicks)
{
- super.drawBackground(minecraft, mouseX, mouseY);
-
if(this.visible)
{
- FontRenderer fontRenderer = minecraft.fontRenderer;
+ this.drawBackground(mouseX, mouseY);
- this.mouseX = mouseX;
- this.mouseY = mouseY;
+ String displayString = this.logic.translate(this.items.get(this.persistence.getIndex()));
+ FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
- this.displayString = this.logic.getDisplayString(this.persistence);
-
- if(this.displayString != null && !this.displayString.isEmpty())
+ if(displayString != null && !displayString.isEmpty())
{
String leftArrow = this.isHoveringLeft(mouseX, mouseY) ? ChatFormatting.BOLD + "<" + ChatFormatting.RESET : "<";
String rightArrow = this.isHoveringRight(mouseX, mouseY) ? ChatFormatting.BOLD + ">" + ChatFormatting.RESET : ">";
- int leftArrowWidth = fontRenderer.getStringWidth(leftArrow);
- int rightArrowWidth = fontRenderer.getStringWidth(rightArrow);
-
- int maxWidth = Math.max(0, this.width - (fontRenderer.getStringWidth("< >")));
- int spaceWidth = fontRenderer.getCharWidth(' ');
+ int maxWidth = Math.max(0, this.width - fontRenderer.getStringWidth("< >"));
+ int spaceWidth = fontRenderer.getStringWidth(" ");
- String display = TextFormatting.shortenString(this.displayString, maxWidth, fontRenderer);
- int displayWidth = fontRenderer.getStringWidth(display);
+ String display = TextFormatting.shortenString(displayString, maxWidth, fontRenderer);
int yPos = this.y + (this.height - 8) / 2;
this.drawCenteredString(fontRenderer, display, this.x + this.width / 2, yPos, this.getTextColor());
this.drawCenteredString(fontRenderer, leftArrow, this.x + this.width / 2 - maxWidth / 2 - spaceWidth, yPos, this.getTextColor());
this.drawCenteredString(fontRenderer, rightArrow, this.x + this.width / 2 + maxWidth / 2 + spaceWidth, yPos, this.getTextColor());
}
-
- this.isActive = true;
}
}
@Override
- public void drawTooltip(int mouseX, int mouseY, int width, int height)
+ public void renderTooltip(int mouseX, int mouseY)
{
- if(this.tooltipType != null)
- {
- this.displayTooltip = this.logic.getTooltipString(this.persistence);
- }
-
- super.drawTooltip(mouseX, mouseY, width, height);
+ this.tooltip = this.logic.formatTooltip(this.items.get(this.persistence.getIndex()), this.persistence.getIndex() + 1, this.items.size());
+ super.renderTooltip(mouseX, mouseY);
}
- private boolean isHoveringLeft(int mouseX, int mouseY)
+ @Override
+ public void onClick(double mouseX, double mouseY)
{
- return this.isHoveringVertical(mouseY) && mouseX >= this.x && mouseX < this.x + Math.ceil(this.width / 2);
- }
-
- private boolean isHoveringRight(int mouseX, int mouseY)
- {
- return this.isHoveringVertical(mouseY) && mouseX >= this.x + Math.ceil(this.width / 2) && mouseX < this.x + this.width;
- }
-
- private boolean isHoveringVertical(int mouseY)
- {
- return mouseY >= this.y && mouseY < this.y + this.height;
- }
-
- public void actionPerformed(Container container, GuiButton button)
- {
- int max = this.logic.getMax() - 1;
+ int max = this.items.size() - 1;
int index = this.persistence.getIndex();
- if(this.isHoveringLeft(this.mouseX, this.mouseY))
+ if(this.isHoveringLeft(mouseX, mouseY))
{
if(GuiScreen.isShiftKeyDown())
{
@@ -129,7 +99,7 @@ public class GuiButtonList extends GuiButtonWorldHandler
}
}
}
- else if(this.isHoveringRight(this.mouseX, this.mouseY))
+ else if(this.isHoveringRight(mouseX, mouseY))
{
if(GuiScreen.isShiftKeyDown())
{
@@ -155,17 +125,67 @@ public class GuiButtonList extends GuiButtonWorldHandler
}
}
- this.updatePersistenceObject();
- this.logic.actionPerformed(container, button, this.persistence);
+ this.logic.onClick(this.items.get(this.persistence.getIndex()));
}
- private void updatePersistenceObject()
+ private boolean isHoveringLeft(double mouseX, double mouseY)
{
- this.persistence.setObject(this.logic.getObject(this.persistence.getIndex()));
+ return this.isHoveringVertical(mouseY) && mouseX >= this.x && mouseX < this.x + Math.ceil(this.width / 2);
}
- public IListButtonLogic getLogic()
+ private boolean isHoveringRight(double mouseX, double mouseY)
{
- return this.logic;
+ return this.isHoveringVertical(mouseY) && mouseX >= this.x + Math.ceil(this.width / 2) && mouseX < this.x + this.width;
+ }
+
+ private boolean isHoveringVertical(double mouseY)
+ {
+ return mouseY >= this.y && mouseY < this.y + this.height;
+ }
+
+ @OnlyIn(Dist.CLIENT)
+ public static class Persistence
+ {
+ private int index;
+
+ public Persistence()
+ {
+ this(0);
+ }
+
+ public Persistence(int index)
+ {
+ this.index = index;
+ }
+
+ public void setIndex(int index)
+ {
+ this.index = index;
+ }
+
+ public int getIndex()
+ {
+ return this.index;
+ }
+
+ public void incrementIndex()
+ {
+ this.index++;
+ }
+
+ public void incrementIndex(int amount)
+ {
+ this.index += amount;
+ }
+
+ public void decrementIndex()
+ {
+ this.index--;
+ }
+
+ public void decrementIndex(int amount)
+ {
+ this.index -= amount;
+ }
}
}
diff --git a/src/main/java/exopandora/worldhandler/gui/button/GuiButtonPiano.java b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonPiano.java
new file mode 100644
index 0000000..757436b
--- /dev/null
+++ b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonPiano.java
@@ -0,0 +1,162 @@
+package exopandora.worldhandler.gui.button;
+
+import exopandora.worldhandler.Main;
+import exopandora.worldhandler.config.Config;
+import exopandora.worldhandler.util.ActionHandler;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.audio.SimpleSound;
+import net.minecraft.client.audio.SoundHandler;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.SoundEvent;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+
+@OnlyIn(Dist.CLIENT)
+public class GuiButtonPiano extends GuiButtonBase
+{
+ private static final ResourceLocation NOTE = new ResourceLocation(Main.MODID, "textures/misc/note.png");
+ private final Type type;
+ private final SoundEvent sound;
+ private final float pitch;
+
+ public GuiButtonPiano(int x, int y, int widthIn, int heightIn, String buttonText, SoundEvent sound, float pitch, Type type, ActionHandler actionHandler)
+ {
+ this(0, x, y, widthIn, heightIn, buttonText, sound, pitch, type, actionHandler);
+ }
+
+ public GuiButtonPiano(int buttonId, int x, int y, int widthIn, int heightIn, String buttonText, SoundEvent sound, float pitch, Type type, ActionHandler actionHandler)
+ {
+ super(buttonId, x, y, widthIn, heightIn, buttonText, actionHandler);
+ this.sound = sound;
+ this.pitch = pitch;
+ this.type = type;
+ }
+
+ @Override
+ public void render(int mouseX, int mouseY, float partialTicks)
+ {
+ if(this.visible)
+ {
+ switch(this.type)
+ {
+ case LEFT:
+ this.hovered = this.isHoveringLeft(mouseX, mouseY);
+ break;
+ case NORMAL:
+ this.hovered = this.isHoveringNormal(mouseX, mouseY);
+ break;
+ case RIGHT:
+ this.hovered = this.isHoveringRight(mouseX, mouseY);
+ break;
+ case BLACK:
+ this.hovered = this.isHoveringBlack(mouseX, mouseY);
+ break;
+ default:
+ break;
+ }
+
+ int hoverstate = this.getHoverState(this.hovered);
+ GlStateManager.color4f(1.0F, 1.0F, 1.0F, Config.getSkin().getButtonAlphaF());
+ Minecraft.getInstance().getTextureManager().bindTexture(NOTE);
+
+ switch(this.type)
+ {
+ case LEFT:
+ case NORMAL:
+ case RIGHT:
+ this.drawWhiteKey(hoverstate);
+ break;
+ case BLACK:
+ this.drawBlackKey(hoverstate);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ protected void drawWhiteKey(int hoverstate)
+ {
+ int textColor = this.getTextColor();
+ FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
+
+ this.drawTexturedModalRect(this.x, this.y, 25 + hoverstate * 15 - 15, 0, 15, 92);
+ fontRenderer.drawString(this.displayString, this.x + this.width / 2 - fontRenderer.getStringWidth(this.displayString) / 2, this.y + (this.height - 8) / 2 + 36, textColor);
+ }
+
+ protected void drawBlackKey(int hoverstate)
+ {
+ this.drawTexturedModalRect(this.x, this.y, 55 + hoverstate * -9 + 18, 0, 9, 58);
+ }
+
+ protected int getTextColor()
+ {
+ int textColor = 0x000000;
+
+ if(!this.enabled)
+ {
+ textColor = 0xA0A0A0;
+ }
+ else if(this.hovered)
+ {
+ textColor = 0x8B8B8B;
+ }
+
+ return textColor;
+ }
+
+ @Override
+ public void playPressSound(SoundHandler soundHandler)
+ {
+ soundHandler.play(SimpleSound.getMasterRecord(this.sound, this.pitch));
+ }
+
+ private boolean isHoveringBlack(double mouseX, double mouseY)
+ {
+ return mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
+ }
+
+ private boolean isHoveringLeft(double mouseX, double mouseY)
+ {
+ return (mouseX >= this.x && mouseY >= this.y && mouseX < this.x + 10 && mouseY < this.y + 60) || (mouseX >= this.x && mouseY >= this.y + 58 && mouseX < this.x + 14 && mouseY < this.y + 93);
+ }
+
+ private boolean isHoveringNormal(double mouseX, double mouseY)
+ {
+ return (mouseX >= this.x + 4 && mouseY >= this.y && mouseX < this.x + 10 && mouseY < this.y + 60) || (mouseX >= this.x && mouseY >= this.y + 58 && mouseX < this.x + 14 && mouseY < this.y + 93);
+ }
+
+ private boolean isHoveringRight(double mouseX, double mouseY)
+ {
+ return (mouseX >= this.x + 4 && mouseY >= this.y && mouseX < this.x + 14 && mouseY < this.y + 60) || (mouseX >= this.x && mouseY >= this.y + 58 && mouseX < this.x + 14 && mouseY < this.y + 93);
+ }
+
+ @Override
+ protected boolean isPressable(double mouseX, double mouseY)
+ {
+ switch(this.type)
+ {
+ case LEFT:
+ return this.enabled && this.visible && this.isHoveringLeft(mouseX, mouseY);
+ case NORMAL:
+ return this.enabled && this.visible && this.isHoveringNormal(mouseX, mouseY);
+ case RIGHT:
+ return this.enabled && this.visible && this.isHoveringRight(mouseX, mouseY);
+ case BLACK:
+ return this.enabled && this.visible && this.isHoveringBlack(mouseX, mouseY);
+ default:
+ return false;
+ }
+ }
+
+ @OnlyIn(Dist.CLIENT)
+ public static enum Type
+ {
+ LEFT,
+ NORMAL,
+ RIGHT,
+ BLACK;
+ }
+}
diff --git a/src/main/java/exopandora/worldhandler/gui/button/GuiButtonTab.java b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonTab.java
index 2dbf089..05cb644 100644
--- a/src/main/java/exopandora/worldhandler/gui/button/GuiButtonTab.java
+++ b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonTab.java
@@ -1,24 +1,20 @@
package exopandora.worldhandler.gui.button;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.SoundHandler;
import net.minecraft.client.gui.GuiButton;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class GuiButtonTab extends GuiButton
{
- private final int index;
-
- public GuiButtonTab(int buttonId, int x, int y, int widthIn, int heightIn, int index)
+ public GuiButtonTab(int x, int y, int widthIn, int heightIn)
{
- super(buttonId, x, y, widthIn, heightIn, null);
- this.index = index;
+ super(0, x, y, widthIn, heightIn, null);
}
@Override
- public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
+ public void render(int mouseX, int mouseY, float partialTicks)
{
}
@@ -28,9 +24,4 @@ public class GuiButtonTab extends GuiButton
{
}
-
- public int getIndex()
- {
- return this.index;
- }
}
diff --git a/src/main/java/exopandora/worldhandler/gui/button/GuiButtonTooltip.java b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonTooltip.java
new file mode 100644
index 0000000..bbde097
--- /dev/null
+++ b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonTooltip.java
@@ -0,0 +1,44 @@
+package exopandora.worldhandler.gui.button;
+
+import java.util.Arrays;
+import java.util.List;
+
+import exopandora.worldhandler.util.ActionHandler;
+import net.minecraft.client.Minecraft;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+import net.minecraftforge.fml.client.config.GuiUtils;
+
+@OnlyIn(Dist.CLIENT)
+public class GuiButtonTooltip extends GuiButtonBase
+{
+ protected String tooltip;
+
+ public GuiButtonTooltip(int x, int y, int widthIn, int heightIn, String buttonText, String tooltip, ActionHandler actionHandler)
+ {
+ this(0, x, y, widthIn, heightIn, buttonText, tooltip, actionHandler);
+ }
+
+ public GuiButtonTooltip(int id, int x, int y, int widthIn, int heightIn, String buttonText, String tooltip, ActionHandler actionHandler)
+ {
+ super(id, x, y, widthIn, heightIn, buttonText, actionHandler);
+ this.tooltip = tooltip;
+ }
+
+ public void renderTooltip(int mouseX, int mouseY)
+ {
+ if(this.hovered && this.tooltip != null)
+ {
+ List list = Arrays.asList(this.tooltip.split("\n"));
+
+ if(!list.isEmpty())
+ {
+ int tooltipWidth = Minecraft.getInstance().fontRenderer.getStringWidth(this.tooltip) + 9;
+ int width = Minecraft.getInstance().currentScreen.width;
+ int height = Minecraft.getInstance().currentScreen.height;
+
+ GuiUtils.drawHoveringText(list, mouseX, mouseY, width, height, tooltipWidth, Minecraft.getInstance().fontRenderer);
+ }
+ }
+ }
+}
diff --git a/src/main/java/exopandora/worldhandler/gui/button/GuiButtonWorldHandler.java b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonWorldHandler.java
deleted file mode 100644
index 07bc4c3..0000000
--- a/src/main/java/exopandora/worldhandler/gui/button/GuiButtonWorldHandler.java
+++ /dev/null
@@ -1,219 +0,0 @@
-package exopandora.worldhandler.gui.button;
-
-import exopandora.worldhandler.config.ConfigSkin;
-import exopandora.worldhandler.helper.ResourceHelper;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.gui.GuiButton;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraftforge.fml.client.config.GuiUtils;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
-public class GuiButtonWorldHandler extends GuiButton
-{
- protected String displayTooltip;
- protected EnumTooltip tooltipType;
- protected EnumIcon icon;
- protected boolean isActive;
-
- public GuiButtonWorldHandler(int id, int x, int y, int width, int height, String displayString)
- {
- this(id, x, y, width, height, displayString, null, null);
- }
-
- public GuiButtonWorldHandler(int id, int x, int y, int width, int height, String displayString, String tooltip, EnumTooltip tooltipType)
- {
- this(id, x, y, width, height, displayString, tooltip, tooltipType, null);
- }
-
- public GuiButtonWorldHandler(int id, int x, int y, int width, int height, String displayString, EnumIcon icon)
- {
- this(id, x, y, width, height, displayString, null, null, icon);
- }
-
- public GuiButtonWorldHandler(int id, int x, int y, int width, int height, String displayString, String tooltip, EnumTooltip tooltipType, EnumIcon icon)
- {
- super(id, x, y, width, height, displayString);
- this.displayTooltip = tooltip;
- this.tooltipType = tooltipType;
- this.icon = icon;
- }
-
- @Override
- public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
- {
- if(this.visible)
- {
- this.drawBackground(minecraft, mouseX, mouseY);
- this.drawCenteredString(minecraft.fontRenderer, this.displayString, this.x + this.width / 2, this.y + (this.height - 8) / 2, this.getTextColor());
-
- if(this.icon != null)
- {
- this.drawIcons();
- }
-
- this.isActive = true;
- }
- }
-
- protected int getTextColor()
- {
- int textColor = 0xE0E0E0;
-
- if(!this.enabled)
- {
- textColor = 0xA0A0A0;
- }
- else if(this.hovered)
- {
- textColor = 0xFFFFA0;
- }
-
- return textColor;
- }
-
- protected void drawBackground(Minecraft minecraft, int mouseX, int mouseY)
- {
- GlStateManager.enableBlend();
- GlStateManager.color((float) ConfigSkin.getButtonRed() / 255, (float) ConfigSkin.getButtonGreen() / 255, (float) ConfigSkin.getButtonBlue() / 255, (float) ConfigSkin.getButtonAlpha() / 255);
-
- this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
- int hovered = this.getHoverState(this.hovered);
-
- Minecraft.getMinecraft().renderEngine.bindTexture(ResourceHelper.getButtonTexture());
-
- if(ConfigSkin.getTextureType().equals("resourcepack"))
- {
- this.drawTexturedModalRect(this.x, this.y, 0, 46 + hovered * 20, this.width / 2, this.height);
- this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + hovered * 20, this.width / 2, this.height);
- }
- else
- {
- this.drawTexturedModalRect(this.x, this.y, 0, hovered * 20, this.width / 2, this.height);
- this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, hovered * 20, this.width / 2, this.height);
- }
-
- GlStateManager.disableBlend();
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- }
-
- public void drawTooltip(int mouseX, int mouseY, int width, int height)
- {
- if(this.hovered && this.displayTooltip != null)
- {
- int tooltipWidth = Minecraft.getMinecraft().fontRenderer.getStringWidth(this.displayTooltip) + 9;
- int xOffset = 12;
- int yOffset = 12;
- boolean right = mouseX + xOffset + tooltipWidth > width;
- boolean left = mouseX > tooltipWidth + xOffset;
-
- switch(this.tooltipType)
- {
- case TOP_RIGHT:
- this.renderTooltip(mouseX, mouseY, xOffset, -yOffset, right);
- break;
- case TOP_LEFT:
- this.renderTooltip(mouseX, mouseY, xOffset, -yOffset, left);
- break;
- case BOTTOM_RIGHT:
- this.renderTooltip(mouseX, mouseY, xOffset, yOffset, right);
- break;
- case BOTTOM_LEFT:
- this.renderTooltip(mouseX, mouseY, xOffset, yOffset, left);
- break;
- case RIGHT:
- this.renderTooltip(mouseX, mouseY, xOffset, 0, right);
- break;
- case LEFT:
- this.renderTooltip(mouseX, mouseY, xOffset, 0, left);
- break;
- default:
- break;
- }
- }
- }
-
- protected void renderTooltip(int mouseX, int mouseY, int xOffset, int yOffset, boolean left)
- {
- FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
-
- GlStateManager.disableDepth();
-
- String[] text = this.displayTooltip.split("\n");
-
- int tooltipTextWidth = 0;
- int tooltipX = mouseX + xOffset;
- int tooltipY = mouseY + yOffset;
-
- for(String line : text)
- {
- int length = fontRenderer.getStringWidth(line) + 1;
-
- if(length > tooltipTextWidth)
- {
- tooltipTextWidth = length;
- }
- }
-
- if(left)
- {
- tooltipX = mouseX - xOffset - tooltipTextWidth;
- }
-
- int tooltipHeight = fontRenderer.FONT_HEIGHT * text.length;
- int backgroundColor = 0xF0100010;
- int borderColorStart = 0x505000FF;
- int borderColorEnd = (borderColorStart & 0xFEFEFE) >> 1 | borderColorStart & 0xFF000000;
-
- int zLevel = 300;
-
- GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 4, tooltipX + tooltipTextWidth + 3, tooltipY - 3, backgroundColor, backgroundColor);
- GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY + tooltipHeight + 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 4, backgroundColor, backgroundColor);
- GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
- GuiUtils.drawGradientRect(zLevel, tooltipX - 4, tooltipY - 3, tooltipX - 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
- GuiUtils.drawGradientRect(zLevel, tooltipX + tooltipTextWidth + 3, tooltipY - 3, tooltipX + tooltipTextWidth + 4, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
-
- GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3 + 1, tooltipX - 3 + 1, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd);
- GuiUtils.drawGradientRect(zLevel, tooltipX + tooltipTextWidth + 2, tooltipY - 3 + 1, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd);
- GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY - 3 + 1, borderColorStart, borderColorStart);
- GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY + tooltipHeight + 2, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, borderColorEnd, borderColorEnd);
-
- for(int x = 0; x < text.length; x++)
- {
- fontRenderer.drawStringWithShadow(text[x], tooltipX + 1, tooltipY + 1 + fontRenderer.FONT_HEIGHT * x, -1);
- }
-
- GlStateManager.enableDepth();
- }
-
- protected void drawIcons()
- {
- Minecraft.getMinecraft().renderEngine.bindTexture(ResourceHelper.getIconTexture());
-
- if(this.enabled == true)
- {
- if(this.hovered)
- {
- GlStateManager.color(1.0F, 1.0F, 0.6F, 1.0F);
- }
- else
- {
- GlStateManager.color(0.95F, 0.95F, 0.95F, 1.0F);
- }
- }
- else
- {
- GlStateManager.color(0.8F, 0.8F, 0.8F, 1.0F);
- }
-
- this.drawTexturedModalRect(this.x + this.width / 2 - 4, this.y + 6, this.icon.getX() * 8, this.icon.getY() * 8, 8, 8);
- }
-
- @Override
- public boolean mousePressed(Minecraft mc, int mouseX, int mouseY)
- {
- return super.mousePressed(mc, mouseX, mouseY) && this.isActive;
- }
-}
diff --git a/src/main/java/exopandora/worldhandler/gui/button/GuiSlider.java b/src/main/java/exopandora/worldhandler/gui/button/GuiSlider.java
index 62fa5d8..9f6ff07 100644
--- a/src/main/java/exopandora/worldhandler/gui/button/GuiSlider.java
+++ b/src/main/java/exopandora/worldhandler/gui/button/GuiSlider.java
@@ -1,86 +1,80 @@
package exopandora.worldhandler.gui.button;
-import exopandora.worldhandler.config.ConfigSkin;
-import exopandora.worldhandler.gui.button.logic.ISliderResponder;
-import exopandora.worldhandler.gui.button.persistence.ButtonValue;
-import exopandora.worldhandler.gui.button.persistence.SliderValue;
-import exopandora.worldhandler.gui.container.Container;
-import exopandora.worldhandler.gui.content.Content;
-import exopandora.worldhandler.helper.ResourceHelper;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.GuiButton;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.resources.I18n;
-import net.minecraft.util.math.MathHelper;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import java.util.Objects;
-@SideOnly(Side.CLIENT)
-public class GuiSlider extends GuiButton
+import exopandora.worldhandler.config.Config;
+import exopandora.worldhandler.format.TextFormatting;
+import exopandora.worldhandler.gui.container.Container;
+import exopandora.worldhandler.gui.logic.ILogic;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+
+@OnlyIn(Dist.CLIENT)
+public class GuiSlider extends GuiButtonBase
{
- private boolean isMouseDown;
- private boolean isActive;
+ private final Persistence persistence;
+ private final ILogicSlider logic;
+ private final Container container;
- private final Object key;
- private final String name;
- private final ISliderResponder responder;
- private final Container frame;
- private final ButtonValue persistence;
+ private boolean dragging;
- public GuiSlider(Content content, Container frame, Object key, int x, int y, int width, int height, String name, double min, double max, double start, ISliderResponder responder)
+ public GuiSlider(int x, int y, int widthIn, int heightIn, double min, double max, double start, Container container, ILogicSlider logic)
{
- super(Integer.MAX_VALUE, x, y, width, height, null);
- this.frame = frame;
- this.key = key;
- this.name = name;
- this.responder = responder;
- this.persistence = content.getPersistence(key);
- this.initValues(Math.round(min), Math.round(max), Math.round(start));
- this.displayString = this.getDisplayString();
+ this(0, x, y, widthIn, heightIn, min, max, start, container, logic);
}
- private void initValues(double min, double max, double start)
+ public GuiSlider(int id, int x, int y, int widthIn, int heightIn, double min, double max, double start, Container container, ILogicSlider logic)
{
- if(this.persistence.getObject() == null)
+ super(id, x, y, widthIn, heightIn, null, 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))));
+ this.persistence.validate(min, max);
+ this.logic.onChangeSliderValue(this.persistence.getValueInt());
+ this.updateDisplayString();
+ }
+
+ @Override
+ protected void renderBg(Minecraft minecraft, int mouseX, int mouseY)
+ {
+ if(this.visible)
{
- if(min == max)
+ if(this.dragging)
{
- this.persistence.setObject(new SliderValue(min, max, 0.0D));
+ this.persistence.setValue((mouseX - (this.x + 4)) / (float) (this.width - 8));
+ this.updateSlider();
}
- else
- {
- this.persistence.setObject(new SliderValue(min, max, (start - min) / (max - min)));
- }
- }
- else if(this.persistence.getObject().getMin() != min || this.persistence.getObject().getMax() != max)
- {
- this.persistence.setObject(new SliderValue(min, max, (int) MathHelper.clamp(this.getValue(), min, max)));
+
+ int xOffset = Config.getSkin().getTextureType().equals("resourcepack") ? 0 : -46;
+
+ GlStateManager.pushMatrix();
+ GlStateManager.enableBlend();
+ GlStateManager.color4f(Config.getSkin().getButtonRedF(), Config.getSkin().getButtonGreenF(), Config.getSkin().getButtonBlueF(), Config.getSkin().getButtonAlphaF());
+
+ this.drawTexturedModalRect(this.x + (int) (this.persistence.getValue() * (float) (this.width - 8)), this.y, 0, 66 + xOffset, 4, 20);
+ this.drawTexturedModalRect(this.x + (int) (this.persistence.getValue() * (float) (this.width - 8)) + 4, this.y, 196, 66 + xOffset, 4, 20);
+
+ GlStateManager.disableBlend();
+ GlStateManager.popMatrix();
}
}
- private void setPosition(double position)
+ @Override
+ public void onClick(double mouseX, double mouseY)
{
- this.persistence.getObject().setPosition(position);
+ this.persistence.setValue((mouseX - (this.x + 4)) / (this.width - 8));
+ this.updateSlider();
+ this.dragging = true;
}
- private double getPosition()
+ @Override
+ public void onRelease(double mouseX, double mouseY)
{
- return this.persistence.getObject().getPosition();
- }
-
- private void setValue(int value)
- {
- this.persistence.getObject().setValue(value);
- }
-
- private int getValue()
- {
- return this.persistence.getObject().getValue();
- }
-
- private String getDisplayString()
- {
- return this.responder.getText(this.key, I18n.format(this.name), this.getValue());
+ super.onRelease(mouseX, mouseY);
+ this.dragging = false;
}
@Override
@@ -89,114 +83,107 @@ public class GuiSlider extends GuiButton
return 0;
}
- @Override
- public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
- {
- this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
-
- GlStateManager.pushMatrix();
- GlStateManager.enableBlend();
- GlStateManager.color((float) ConfigSkin.getButtonRed() / 255, (float) ConfigSkin.getButtonGreen() / 255, (float) ConfigSkin.getButtonBlue() / 255, (float) ConfigSkin.getButtonAlpha() / 255);
-
- Minecraft.getMinecraft().renderEngine.bindTexture(ResourceHelper.getButtonTexture());
-
- if(ConfigSkin.getTextureType().equals("resourcepack"))
- {
- this.drawTexturedModalRect(this.x, this.y, 0, 46, this.width / 2, this.height);
- this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, 46, this.width / 2, this.height);
- }
- else
- {
- this.drawTexturedModalRect(this.x, this.y, 0, 0, this.width / 2, this.height);
- this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, 0, this.width / 2, this.height);
- }
-
- GlStateManager.disableBlend();
- GlStateManager.popMatrix();
-
- this.mouseDragged(minecraft, mouseX, mouseY);
- }
-
- private void update(int mouseX, int mouseY)
+ private void updateSlider()
{
- float sliderValue = (float) (mouseX - (this.x + 4)) / (float) (this.width - 8);
-
- if(sliderValue < 0.0F)
+ if(this.persistence.getValue() < 0.0F)
{
- sliderValue = 0.0F;
+ this.persistence.setValue(0.0F);
}
- if(sliderValue > 1.0F)
+ if(this.persistence.getValue() > 1.0F)
{
- sliderValue = 1.0F;
+ this.persistence.setValue(1.0F);
}
- this.setPosition(sliderValue);
- this.displayString = this.getDisplayString();
- this.responder.setValue(this.key, this.getValue());
+ this.updateDisplayString();
+ this.logic.onChangeSliderValue(this.persistence.getValueInt());
}
- @Override
- public void mouseDragged(Minecraft mc, int mouseX, int mouseY)
+ private void updateDisplayString()
{
- if(this.visible)
+ int value = this.persistence.getValueInt();
+ String suffix = this.logic.formatValue(value) + this.logic.formatSuffix(value);
+ FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
+
+ this.displayString = TextFormatting.shortenString(this.logic.formatPrefix(value), this.width - fontRenderer.getStringWidth(suffix), fontRenderer) + suffix;
+ }
+
+ @OnlyIn(Dist.CLIENT)
+ public static interface ILogicSlider extends ILogic
+ {
+ String formatPrefix(int value);
+ String formatSuffix(int value);
+ String formatValue(int value);
+
+ void onChangeSliderValue(int value);
+ }
+
+ @OnlyIn(Dist.CLIENT)
+ public class Persistence
+ {
+ private double min;
+ private double max;
+ private double value;
+
+ private Persistence(double min, double max)
{
- if(this.isMouseDown)
+ this.min = min;
+ this.max = max;
+ }
+
+ public Persistence(double min, double max, double value)
+ {
+ this(min, max);
+ this.value = value;
+ }
+
+ public double getMin()
+ {
+ return this.min;
+ }
+
+ public double getMax()
+ {
+ return this.max;
+ }
+
+ public double getValue()
+ {
+ return this.value;
+ }
+
+ public void setValue(double value)
+ {
+ this.value = value;
+ }
+
+ public int getValueInt()
+ {
+ return (int) Math.round(this.min + (this.max - this.min) * this.value);
+ }
+
+ public void setValueInt(int value)
+ {
+ this.value = this.intToValue(value);
+ }
+
+ public void validate(double min, double max)
+ {
+ if(this.getMin() != min || this.getMax() != max)
{
- this.update(mouseX, mouseY);
+ this.min = min;
+ this.max = max;
+ }
+ }
+
+ private double intToValue(int value)
+ {
+ if(this.min == this.max)
+ {
+ return 0;
}
- int textureXOffset = ConfigSkin.getTextureType().equals("resourcepack") ? 0 : -46;
-
- GlStateManager.pushMatrix();
- GlStateManager.enableBlend();
- GlStateManager.color((float) ConfigSkin.getButtonRed() / 255, (float) ConfigSkin.getButtonGreen() / 255, (float) ConfigSkin.getButtonBlue() / 255, (float) ConfigSkin.getButtonAlpha() / 255);
-
- this.drawTexturedModalRect(this.x + (int) (this.getPosition() * (float) (this.width - 8)), this.y, 0, 66 + textureXOffset, 4, 20);
- this.drawTexturedModalRect(this.x + (int) (this.getPosition() * (float) (this.width - 8)) + 4, this.y, 196, 66 + textureXOffset, 4, 20);
-
- GlStateManager.disableBlend();
- GlStateManager.popMatrix();
-
- int color = 0xE0E0E0;
-
- if(!this.enabled)
- {
- color = 0xA0A0A0;
- }
- else if(this.hovered)
- {
- color = 0xFFFFA0;
- }
-
- this.drawCenteredString(mc.fontRenderer, this.displayString, this.x + this.width / 2, this.y + (this.height - 8) / 2, color);
+ return (value - this.min) / (this.max - this.min);
}
-
- this.isActive = true;
}
-
- @Override
- public boolean mousePressed(Minecraft mc, int mouseX, int mouseY)
- {
- if(super.mousePressed(mc, mouseX, mouseY) && this.isActive)
- {
- this.update(mouseX, mouseY);
- this.isMouseDown = true;
-
- return true;
- }
-
- return false;
- }
-
- @Override
- public void mouseReleased(int mouseX, int mouseY)
- {
- this.isMouseDown = false;
-
- if(this.frame != null)
- {
- this.frame.initGui();
- }
- }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/exopandora/worldhandler/gui/button/GuiTextFieldTooltip.java b/src/main/java/exopandora/worldhandler/gui/button/GuiTextFieldTooltip.java
index 358437c..ebb346b 100644
--- a/src/main/java/exopandora/worldhandler/gui/button/GuiTextFieldTooltip.java
+++ b/src/main/java/exopandora/worldhandler/gui/button/GuiTextFieldTooltip.java
@@ -1,261 +1,76 @@
package exopandora.worldhandler.gui.button;
-import com.google.common.base.Predicate;
import com.mojang.realmsclient.gui.ChatFormatting;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.GuiPageButtonList;
import net.minecraft.client.gui.GuiTextField;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
-public class GuiTextFieldTooltip
+@OnlyIn(Dist.CLIENT)
+public class GuiTextFieldTooltip extends GuiTextField
{
- private GuiTextField textfield;
- private String display;
-
- public GuiTextFieldTooltip(int x, int y, int width, int height, String display)
- {
- this.textfield = new GuiTextField(0, Minecraft.getMinecraft().fontRenderer, x, y, width, height);
- this.textfield.setMaxStringLength(Integer.MAX_VALUE);
- this.display = display;
- }
+ private String tooltip;
public GuiTextFieldTooltip(int x, int y, int width, int height)
{
- this(x, y, width, height, null);
+ this(0, x, y, width, height, null);
}
- public void setGuiResponder(GuiPageButtonList.GuiResponder responder)
+ public GuiTextFieldTooltip(int id, int x, int y, int width, int height)
{
- this.textfield.setGuiResponder(responder);
+ this(id, x, y, width, height, null);
}
- public void updateCursorCounter()
+ public GuiTextFieldTooltip(int x, int y, int width, int height, String tooltip)
{
- this.textfield.updateCursorCounter();
+ this(0, x, y, width, height, tooltip);
}
- public void setText(String text)
+ public GuiTextFieldTooltip(int id, int x, int y, int width, int height, String tooltip)
{
- this.textfield.setText(text);
+ super(id, Minecraft.getInstance().fontRenderer, x, y, width, height);
+ this.setMaxStringLength(Integer.MAX_VALUE);
+ this.tooltip = tooltip;
}
- public String getText()
+ @Override
+ public void drawTextField(int x, int y, float partialTicks)
{
- return this.textfield.getText();
- }
-
- public boolean isEmpty()
- {
- if(this.textfield.getText() != null)
- {
- return this.textfield.getText().matches("(\u00A7[a-f0-9k-or])+");
- }
+ super.drawTextField(x, y, partialTicks);
- return true;
- }
-
- public boolean canType(char charTyped)
- {
- return (!this.isEmpty() || charTyped != '\b') && this.textfield.isFocused();
- }
-
- public String getSelectedText()
- {
- return this.textfield.getSelectedText();
- }
-
- public void setValidator(Predicate validator)
- {
- this.textfield.setValidator(validator);;
- }
-
- public void writeText(String text)
- {
- this.textfield.writeText(text);
- }
-
- public void deleteWords(int num)
- {
- this.textfield.deleteWords(num);
- }
-
- public void deleteFromCursor(int num)
- {
- this.textfield.deleteFromCursor(num);
- }
-
- public int getId()
- {
- return this.textfield.getId();
- }
-
- public int getNthWordFromCursor(int numWords)
- {
- return this.textfield.getNthWordFromCursor(numWords);
- }
-
- public int getNthWordFromPos(int n, int pos)
- {
- return this.textfield.getNthWordFromPos(n, pos);
- }
-
- public int getNthWordFromPosWS(int n, int pos, boolean skipWs)
- {
- return this.textfield.getNthWordFromPosWS(n, pos, skipWs);
- }
-
- public void moveCursorBy(int num)
- {
- this.textfield.moveCursorBy(num);
- }
-
- public void setCursorPosition(int pos)
- {
- this.textfield.setCursorPosition(pos);
- }
-
- public void setCursorPositionZero()
- {
- this.textfield.setCursorPositionZero();
- }
-
- public void setCursorPositionEnd()
- {
- this.textfield.setCursorPositionEnd();
- }
-
- public boolean textboxKeyTyped(char typedChar, int keyCode)
- {
- return this.textfield.textboxKeyTyped(typedChar, keyCode);
- }
-
- public void mouseClicked(int mouseX, int mouseY, int mouseButton)
- {
- this.textfield.mouseClicked(mouseX, mouseY, mouseButton);
- }
-
- public void drawTextBox()
- {
- this.textfield.drawTextBox();
-
- if(this.textfield.getVisible())
+ if(this.getVisible() && !this.isFocused() && this.tooltip != null && ChatFormatting.stripFormatting(this.getText()).isEmpty())
{
- int x = this.textfield.getEnableBackgroundDrawing() ? this.textfield.x + 4 : this.textfield.x;
- int y = this.textfield.getEnableBackgroundDrawing() ? this.textfield.y + (this.textfield.height - 8) / 2 : this.textfield.y;
+ int tx = this.getEnableBackgroundDrawing() ? this.x + 4 : this.x;
+ int ty = this.getEnableBackgroundDrawing() ? this.y + (this.height - 8) / 2 : this.y;
- if(ChatFormatting.stripFormatting(this.textfield.getText()).isEmpty() && !this.textfield.isFocused() && this.display != null)
- {
- Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(this.display, (float) x, (float) y, 0x7F7F7F);
- }
+ Minecraft.getInstance().fontRenderer.drawStringWithShadow(this.tooltip, (float) tx, (float) ty, 0x7F7F7F);
}
}
- public void setMaxStringLength(int length)
+ public void setTooltip(String tooltip)
{
- this.textfield.setMaxStringLength(length);
+ this.tooltip = tooltip;
}
- public int getMaxStringLength()
+ public String getTooltip()
{
- return this.textfield.getMaxStringLength();
- }
-
- public int getCursorPosition()
- {
- return this.textfield.getCursorPosition();
- }
-
- public boolean getEnableBackgroundDrawing()
- {
- return this.textfield.getEnableBackgroundDrawing();
- }
-
- public void setEnableBackgroundDrawing(boolean enableBackgroundDrawing)
- {
- this.textfield.setEnableBackgroundDrawing(enableBackgroundDrawing);
- }
-
- public void setTextColor(int color)
- {
- this.textfield.setTextColor(color);
- }
-
- public void setDisabledTextColour(int color)
- {
- this.textfield.setDisabledTextColour(color);
- }
-
- public void setFocused(boolean focused)
- {
- this.textfield.setFocused(focused);
- }
-
- public boolean isFocused()
- {
- return this.textfield.isFocused();
- }
-
- public void setEnabled(boolean enabled)
- {
- this.textfield.setEnabled(enabled);
- }
-
- public int getSelectionEnd()
- {
- return this.textfield.getSelectionEnd();
- }
-
- public int getWidth()
- {
- return this.textfield.getWidth();
- }
-
- public void setSelectionPos(int position)
- {
- this.textfield.setSelectionPos(position);
- }
-
- public void setCanLoseFocus(boolean canLoseFocus)
- {
- this.textfield.setCanLoseFocus(canLoseFocus);
- }
-
- public boolean getVisible()
- {
- return this.textfield.getVisible();
- }
-
- public void setVisible(boolean visible)
- {
- this.textfield.setVisible(visible);
- }
-
- public void setDisplay(String display)
- {
- this.display = display;
- }
-
- public String getDisplay()
- {
- return this.display;
+ return this.tooltip;
}
public void setPosition(int x, int y)
{
- this.textfield.x = x;
- this.textfield.y = y;
+ this.x = x;
+ this.y = y;
}
public void setWidth(int width)
{
- this.textfield.width = width;
+ this.width = width;
}
public void setHeight(int height)
{
- this.textfield.height = height;
+ this.height = height;
}
}
diff --git a/src/main/java/exopandora/worldhandler/gui/button/logic/ColorListButtonLogic.java b/src/main/java/exopandora/worldhandler/gui/button/logic/ColorListButtonLogic.java
deleted file mode 100644
index 126776f..0000000
--- a/src/main/java/exopandora/worldhandler/gui/button/logic/ColorListButtonLogic.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package exopandora.worldhandler.gui.button.logic;
-
-import java.util.Arrays;
-
-import com.mojang.realmsclient.gui.ChatFormatting;
-
-import exopandora.worldhandler.format.EnumColor;
-import exopandora.worldhandler.gui.button.persistence.ButtonValue;
-import net.minecraft.client.resources.I18n;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
-public abstract class ColorListButtonLogic implements IListButtonLogic
-{
- @Override
- public final int getMax()
- {
- return (int) Arrays.stream(ChatFormatting.values()).filter(ChatFormatting::isColor).count();
- }
-
- @Override
- public Integer getObject(int index)
- {
- return index;
- }
-
- @Override
- public String getTooltipString(ButtonValue values)
- {
- return null;
- }
-
- @Override
- public String getDisplayString(ButtonValue values)
- {
- EnumColor color = EnumColor.getColorFromId(values.getIndex());
- return color + I18n.format("gui.worldhandler.color") + ": " + I18n.format("gui.worldhandler.color." + color.getFormat());
- }
-
- @Override
- public String getId()
- {
- return "color";
- }
-}
diff --git a/src/main/java/exopandora/worldhandler/gui/button/logic/IListButtonLogic.java b/src/main/java/exopandora/worldhandler/gui/button/logic/IListButtonLogic.java
deleted file mode 100644
index 47f6b45..0000000
--- a/src/main/java/exopandora/worldhandler/gui/button/logic/IListButtonLogic.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package exopandora.worldhandler.gui.button.logic;
-
-import exopandora.worldhandler.gui.button.persistence.ButtonValue;
-import exopandora.worldhandler.gui.container.Container;
-import net.minecraft.client.gui.GuiButton;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
-public interface IListButtonLogic
-{
- void actionPerformed(Container container, GuiButton button, ButtonValue values);
-
- int getMax();
-
- T getObject(int index);
-
- String getDisplayString(ButtonValue values);
-
- default String getTooltipString(ButtonValue values)
- {
- if(values != null && values.getObject() != null)
- {
- return values.getObject().toString() + " (" + (values.getIndex() + 1) + "/" + this.getMax() + ")";
- }
-
- return null;
- }
-
- String getId();
-}
diff --git a/src/main/java/exopandora/worldhandler/gui/button/logic/ISliderResponder.java b/src/main/java/exopandora/worldhandler/gui/button/logic/ISliderResponder.java
deleted file mode 100644
index 17f8754..0000000
--- a/src/main/java/exopandora/worldhandler/gui/button/logic/ISliderResponder.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package exopandora.worldhandler.gui.button.logic;
-
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
-public interface ISliderResponder
-{
- void setValue(Object id, int value);
- String getText(Object id, String format, int value);
-}
\ No newline at end of file
diff --git a/src/main/java/exopandora/worldhandler/gui/button/persistence/ButtonValue.java b/src/main/java/exopandora/worldhandler/gui/button/persistence/ButtonValue.java
deleted file mode 100644
index 62ac17e..0000000
--- a/src/main/java/exopandora/worldhandler/gui/button/persistence/ButtonValue.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package exopandora.worldhandler.gui.button.persistence;
-
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
-public class ButtonValue
-{
- private int index;
- private T object;
-
- public void setIndex(int index)
- {
- this.index = index;
- }
-
- public int getIndex()
- {
- return this.index;
- }
-
- public void incrementIndex()
- {
- this.index++;
- }
-
- public void incrementIndex(int amount)
- {
- this.index += amount;
- }
-
- public void decrementIndex()
- {
- this.index--;
- }
-
- public void decrementIndex(int amount)
- {
- this.index -= amount;
- }
-
- public T getObject()
- {
- return this.object;
- }
-
- public void setObject(T object)
- {
- this.object = object;
- }
-}
diff --git a/src/main/java/exopandora/worldhandler/gui/button/persistence/SliderValue.java b/src/main/java/exopandora/worldhandler/gui/button/persistence/SliderValue.java
deleted file mode 100644
index 25b16cb..0000000
--- a/src/main/java/exopandora/worldhandler/gui/button/persistence/SliderValue.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package exopandora.worldhandler.gui.button.persistence;
-
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
-public class SliderValue
-{
- private final double min;
- private final double max;
- private double position;
-
- private SliderValue(double min, double max)
- {
- this.min = min;
- this.max = max;
- }
-
- public SliderValue(double min, double max, double position)
- {
- this(min, max);
- this.position = position;
- }
-
- public SliderValue(double min, double max, int value)
- {
- this(min, max);
- this.position = this.valueToPosition(value);
- }
-
- public double getMin()
- {
- return this.min;
- }
-
- public double getMax()
- {
- return this.max;
- }
-
- public double getPosition()
- {
- return this.position;
- }
-
- public void setPosition(double position)
- {
- this.position = position;
- }
-
- public int getValue()
- {
- return (int) (this.min + (this.max - this.min) * this.position);
- }
-
- public void setValue(int value)
- {
- this.position = this.valueToPosition(value);
- }
-
- private double valueToPosition(int value)
- {
- if(this.min == this.max)
- {
- return 0;
- }
-
- return (value - this.min) / (this.max - this.min);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/exopandora/worldhandler/gui/button/responder/AttributeResponder.java b/src/main/java/exopandora/worldhandler/gui/button/responder/AttributeResponder.java
deleted file mode 100644
index 8b8a7a7..0000000
--- a/src/main/java/exopandora/worldhandler/gui/button/responder/AttributeResponder.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package exopandora.worldhandler.gui.button.responder;
-
-import java.util.function.Consumer;
-
-import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
-import exopandora.worldhandler.format.TextFormatting;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.FontRenderer;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
-public class AttributeResponder extends SimpleResponder
-{
- public AttributeResponder(Consumer valueConsumer)
- {
- super(valueConsumer);
- }
-
- @Override
- public String getText(Object id, String format, int value)
- {
- String suffix = ": " + value + " " + ((EnumAttributes) id).getOperation().getDeclaration();
- FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
- return TextFormatting.shortenString(format, 114 - fontRenderer.getStringWidth(suffix), fontRenderer) + suffix;
- }
-}
diff --git a/src/main/java/exopandora/worldhandler/gui/button/responder/SimpleResponder.java b/src/main/java/exopandora/worldhandler/gui/button/responder/SimpleResponder.java
deleted file mode 100644
index 76bd6e5..0000000
--- a/src/main/java/exopandora/worldhandler/gui/button/responder/SimpleResponder.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package exopandora.worldhandler.gui.button.responder;
-
-import java.util.function.Consumer;
-
-import exopandora.worldhandler.format.TextFormatting;
-import exopandora.worldhandler.gui.button.logic.ISliderResponder;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.FontRenderer;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
-public class SimpleResponder implements ISliderResponder
-{
- private final Consumer valueConsumer;
-
- public SimpleResponder(Consumer valueConsumer)
- {
- this.valueConsumer = valueConsumer;
- }
-
- @Override
- public void setValue(Object id, int value)
- {
- this.valueConsumer.accept(value);
- }
-
- @Override
- public String getText(Object id, String format, int value)
- {
- String suffix = ": " + value;
- FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
- return TextFormatting.shortenString(format, 114 - fontRenderer.getStringWidth(suffix), fontRenderer) + suffix;
- }
-}
diff --git a/src/main/java/exopandora/worldhandler/gui/category/Categories.java b/src/main/java/exopandora/worldhandler/gui/category/Categories.java
index ecef943..2266ed1 100644
--- a/src/main/java/exopandora/worldhandler/gui/category/Categories.java
+++ b/src/main/java/exopandora/worldhandler/gui/category/Categories.java
@@ -2,10 +2,10 @@ package exopandora.worldhandler.gui.category;
import exopandora.worldhandler.Main;
import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public class Categories
{
public static final Category MAIN;
@@ -29,7 +29,7 @@ public class Categories
private static Category getRegisteredCategory(String name)
{
- Category category = Category.REGISTRY.getObject(new ResourceLocation(Main.MODID, name));
+ Category category = Category.REGISTRY.get(new ResourceLocation(Main.MODID, name));
if(category == null)
{
diff --git a/src/main/java/exopandora/worldhandler/gui/category/Category.java b/src/main/java/exopandora/worldhandler/gui/category/Category.java
index e9f000e..9898854 100644
--- a/src/main/java/exopandora/worldhandler/gui/category/Category.java
+++ b/src/main/java/exopandora/worldhandler/gui/category/Category.java
@@ -10,14 +10,17 @@ import exopandora.worldhandler.Main;
import exopandora.worldhandler.gui.content.Content;
import exopandora.worldhandler.gui.content.Contents;
import net.minecraft.util.ResourceLocation;
-import net.minecraft.util.registry.RegistryNamespaced;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraft.util.registry.IRegistry;
+import net.minecraft.util.registry.RegistryNamespacedDefaultedByKey;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+import net.minecraftforge.registries.ForgeRegistryEntry;
-@SideOnly(Side.CLIENT)
-public class Category
+@OnlyIn(Dist.CLIENT)
+public class Category extends ForgeRegistryEntry
{
- public static final RegistryNamespaced REGISTRY = new RegistryNamespaced();
+ public static final String NAMESPACE = String.join("_", new String[] {Main.MODID, "category"});
+ public static final IRegistry REGISTRY = IRegistry.func_212610_a(NAMESPACE, new RegistryNamespacedDefaultedByKey(new ResourceLocation(NAMESPACE, "main")));
private final List contents;
diff --git a/src/main/java/exopandora/worldhandler/gui/config/GuiConfigWorldHandler.java b/src/main/java/exopandora/worldhandler/gui/config/GuiConfigWorldHandler.java
deleted file mode 100644
index 15aa168..0000000
--- a/src/main/java/exopandora/worldhandler/gui/config/GuiConfigWorldHandler.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package exopandora.worldhandler.gui.config;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import exopandora.worldhandler.Main;
-import exopandora.worldhandler.WorldHandler;
-import exopandora.worldhandler.config.ConfigButcher;
-import exopandora.worldhandler.config.ConfigSettings;
-import exopandora.worldhandler.config.ConfigSkin;
-import exopandora.worldhandler.config.ConfigSliders;
-import net.minecraft.client.gui.GuiScreen;
-import net.minecraft.client.resources.I18n;
-import net.minecraftforge.common.config.ConfigCategory;
-import net.minecraftforge.common.config.ConfigElement;
-import net.minecraftforge.fml.client.config.DummyConfigElement.DummyCategoryElement;
-import net.minecraftforge.fml.client.config.GuiConfig;
-import net.minecraftforge.fml.client.config.IConfigElement;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
-public class GuiConfigWorldHandler extends GuiConfig
-{
- public GuiConfigWorldHandler(GuiScreen parentScreen, List configElements)
- {
- super(parentScreen, configElements, Main.MODID, false, false, Main.NAME);
- }
-
- public GuiConfigWorldHandler(GuiScreen parentScreen, ConfigCategory category)
- {
- this(parentScreen, new ConfigElement(category).getChildElements());
- }
-
- public GuiConfigWorldHandler(GuiScreen parentScreen, String category)
- {
- this(parentScreen, WorldHandler.CONFIG.getCategory(category));
- }
-
- public GuiConfigWorldHandler(GuiScreen parentScreen)
- {
- this(parentScreen, getConfigElements());
- }
-
- private static List getConfigElements()
- {
- List list = new ArrayList();
-
- list.add(new DummyCategoryElement(I18n.format("gui.worldhandler.config.category.settings"), "gui.worldhandler.config", new ConfigElement(WorldHandler.CONFIG.getCategory(ConfigSettings.CATEGORY)).getChildElements()));
- list.add(new DummyCategoryElement(I18n.format("gui.worldhandler.config.category.skin"), "gui.worldhandler.config", new ConfigElement(WorldHandler.CONFIG.getCategory(ConfigSkin.CATEGORY)).getChildElements()));
- list.add(new DummyCategoryElement(I18n.format("gui.worldhandler.config.category.butcher"), "gui.worldhandler.config", new ConfigElement(WorldHandler.CONFIG.getCategory(ConfigButcher.CATEGORY)).getChildElements()));
- list.add(new DummyCategoryElement(I18n.format("gui.worldhandler.config.category.sliders"), "gui.worldhandler.config", new ConfigElement(WorldHandler.CONFIG.getCategory(ConfigSliders.CATEGORY)).getChildElements()));
-
- return list;
- }
-}
diff --git a/src/main/java/exopandora/worldhandler/gui/config/GuiFactoryWorldHandler.java b/src/main/java/exopandora/worldhandler/gui/config/GuiFactoryWorldHandler.java
deleted file mode 100644
index f347e37..0000000
--- a/src/main/java/exopandora/worldhandler/gui/config/GuiFactoryWorldHandler.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package exopandora.worldhandler.gui.config;
-
-import java.util.Set;
-
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.GuiScreen;
-import net.minecraftforge.fml.client.IModGuiFactory;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
-public class GuiFactoryWorldHandler implements IModGuiFactory
-{
- @Override
- public void initialize(Minecraft minecraft)
- {
-
- }
-
- @Override
- public Set runtimeGuiCategories()
- {
- return null;
- }
-
- @Override
- public boolean hasConfigGui()
- {
- return true;
- }
-
- @Override
- public GuiScreen createConfigGui(GuiScreen parentScreen)
- {
- return new GuiConfigWorldHandler(parentScreen);
- }
-}
diff --git a/src/main/java/exopandora/worldhandler/gui/container/Container.java b/src/main/java/exopandora/worldhandler/gui/container/Container.java
index aff9fe2..4875101 100644
--- a/src/main/java/exopandora/worldhandler/gui/container/Container.java
+++ b/src/main/java/exopandora/worldhandler/gui/container/Container.java
@@ -7,18 +7,31 @@ import exopandora.worldhandler.gui.content.element.Element;
import exopandora.worldhandler.gui.content.element.IElement;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraft.client.gui.GuiTextField;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public abstract class Container extends GuiScreen implements IContainer
{
protected final List elements = new ArrayList();
@Override
- public void add(GuiButton button)
+ public T add(T button)
{
- this.buttonList.add(button);
+ return super.addButton(button);
+ }
+
+ public T add(T textfield)
+ {
+ this.children.add(textfield);
+ return textfield;
+ }
+
+ @Override
+ public void initGui()
+ {
+ super.initGui();
}
@Override
diff --git a/src/main/java/exopandora/worldhandler/gui/container/IContainer.java b/src/main/java/exopandora/worldhandler/gui/container/IContainer.java
index c52f260..a4fe7ed 100644
--- a/src/main/java/exopandora/worldhandler/gui/container/IContainer.java
+++ b/src/main/java/exopandora/worldhandler/gui/container/IContainer.java
@@ -1,16 +1,20 @@
package exopandora.worldhandler.gui.container;
+import exopandora.worldhandler.gui.content.Content;
import exopandora.worldhandler.gui.content.element.Element;
import net.minecraft.client.gui.GuiButton;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
-@SideOnly(Side.CLIENT)
+@OnlyIn(Dist.CLIENT)
public interface IContainer
{
- void add(GuiButton button);
+ T add(T button);
+
void initButtons();
void add(Element element);
String getPlayer();
+
+ Content getContent();
}
diff --git a/src/main/java/exopandora/worldhandler/gui/container/impl/GuiWorldHandlerContainer.java b/src/main/java/exopandora/worldhandler/gui/container/impl/GuiWorldHandler.java
similarity index 50%
rename from src/main/java/exopandora/worldhandler/gui/container/impl/GuiWorldHandlerContainer.java
rename to src/main/java/exopandora/worldhandler/gui/container/impl/GuiWorldHandler.java
index 3a7f08f..3568820 100644
--- a/src/main/java/exopandora/worldhandler/gui/container/impl/GuiWorldHandlerContainer.java
+++ b/src/main/java/exopandora/worldhandler/gui/container/impl/GuiWorldHandler.java
@@ -1,776 +1,658 @@
-package exopandora.worldhandler.gui.container.impl;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.List;
-import java.util.function.BiConsumer;
-
-import javax.annotation.Nullable;
-
-import com.google.common.base.Predicates;
-import com.mojang.realmsclient.gui.ChatFormatting;
-
-import exopandora.worldhandler.WorldHandler;
-import exopandora.worldhandler.builder.impl.BuilderDifficulty;
-import exopandora.worldhandler.builder.impl.BuilderDifficulty.EnumDifficulty;
-import exopandora.worldhandler.builder.impl.BuilderGamemode;
-import exopandora.worldhandler.builder.impl.BuilderGamemode.EnumGamemode;
-import exopandora.worldhandler.builder.impl.BuilderTime;
-import exopandora.worldhandler.builder.impl.BuilderTime.EnumMode;
-import exopandora.worldhandler.builder.impl.BuilderWeather;
-import exopandora.worldhandler.builder.impl.BuilderWeather.EnumWeather;
-import exopandora.worldhandler.builder.impl.BuilderWorldHandler;
-import exopandora.worldhandler.config.ConfigSettings;
-import exopandora.worldhandler.config.ConfigSkin;
-import exopandora.worldhandler.format.TextFormatting;
-import exopandora.worldhandler.gui.button.EnumIcon;
-import exopandora.worldhandler.gui.button.EnumTooltip;
-import exopandora.worldhandler.gui.button.GuiButtonTab;
-import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
-import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
-import exopandora.worldhandler.gui.container.Container;
-import exopandora.worldhandler.gui.content.Content;
-import exopandora.worldhandler.gui.content.IContent;
-import exopandora.worldhandler.gui.content.element.IElement;
-import exopandora.worldhandler.helper.ResourceHelper;
-import exopandora.worldhandler.util.UtilRender;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.GuiButton;
-import net.minecraft.client.gui.GuiScreen;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.RenderHelper;
-import net.minecraft.client.resources.I18n;
-import net.minecraft.util.math.MathHelper;
-import net.minecraftforge.fml.client.config.GuiUtils;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
-public class GuiWorldHandlerContainer extends Container
-{
- private final Content content;
- private final int tabSize;
- private final int bgTextureWidth = 248;
- private final int bgTextureHeight = 166;
- private final int tabDistance = 2;
- private final int tabDistanceTotal;
- private final double tabWidth;
- private final double tabHalf;
- private final double tabEpsilon;
- private final String splash = this.getSplash();
- private final List finalButtons = new ArrayList();
-
- private GuiTextFieldTooltip syntaxField;
- private GuiTextFieldTooltip nameField;
-
- private static final BuilderWorldHandler BUILDER_WORLD_HANDLER = new BuilderWorldHandler();
-
- public GuiWorldHandlerContainer(Content content) throws Exception
- {
- this.content = content;
- this.tabSize = this.content.getCategory().getSize();
- this.tabDistanceTotal = Math.max(this.tabSize - 1, 1) * this.tabDistance;
- this.tabWidth = (this.bgTextureWidth - this.tabDistanceTotal) / Math.max(this.tabSize, 2);
- this.tabHalf = this.tabWidth / 2D;
- this.tabEpsilon = this.bgTextureWidth - (this.tabDistanceTotal + this.tabHalf * Math.max(this.tabSize, 2) * 2D);
- this.content.init(this);
- }
-
- @Override
- public void initGui()
- {
- try
- {
- this.finalButtons.clear();
- this.elements.clear();
-
- //INIT
- this.content.onPlayerNameChanged(this.getPlayer());
- this.content.initGui(this, this.getContentX(), this.getContentY());
-
- //ELEMENTS
-
- for(IElement element : this.elements)
- {
- element.initGui(this);
- }
-
- //SHORTCUTS
-
- final int x = this.width / 2 - 10;
- final int delta = 21;
-
- if(ConfigSettings.areShortcutsEnabled())
- {
- this.finalButtons.add(new GuiButtonWorldHandler(-1, x - delta * 7, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.dawn", ConfigSettings.getDawn())), EnumTooltip.RIGHT, EnumIcon.TIME_DAWN));
- this.finalButtons.add(new GuiButtonWorldHandler(-2, x - delta * 6, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.noon", ConfigSettings.getNoon())), EnumTooltip.RIGHT, EnumIcon.TIME_NOON));
- this.finalButtons.add(new GuiButtonWorldHandler(-3, x - delta * 5, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.sunset", ConfigSettings.getSunset())), EnumTooltip.RIGHT, EnumIcon.TIME_SUNSET));
- this.finalButtons.add(new GuiButtonWorldHandler(-4, x - delta * 4, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.midnight", ConfigSettings.getMidnight())), EnumTooltip.RIGHT, EnumIcon.TIME_MIDNIGHT));
- this.finalButtons.add(new GuiButtonWorldHandler(-5, x - delta * 3, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.clear")), EnumTooltip.RIGHT, EnumIcon.WEATHER_SUN));
- this.finalButtons.add(new GuiButtonWorldHandler(-6, x - delta * 2, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.rainy")), EnumTooltip.RIGHT, EnumIcon.WEATHER_RAIN));
- this.finalButtons.add(new GuiButtonWorldHandler(-7, x - delta * 1, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.thunder")), EnumTooltip.RIGHT, EnumIcon.WEATHER_STORM));
- this.finalButtons.add(new GuiButtonWorldHandler(-8, x - delta * 0, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.peaceful")), EnumTooltip.RIGHT, EnumIcon.DIFFICULTY_PEACEFUL));
- this.finalButtons.add(new GuiButtonWorldHandler(-9, x + delta * 1, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.easy")), EnumTooltip.RIGHT, EnumIcon.DIFFICULTY_EASY));
- this.finalButtons.add(new GuiButtonWorldHandler(-10, x + delta * 2, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.normal")), EnumTooltip.RIGHT, EnumIcon.DIFFICULTY_NORMAL));
- this.finalButtons.add(new GuiButtonWorldHandler(-11, x + delta * 3, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.hard")), EnumTooltip.RIGHT, EnumIcon.DIFFICULTY_HARD));
- this.finalButtons.add(new GuiButtonWorldHandler(-12, x + delta * 4, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.survival")), EnumTooltip.RIGHT, EnumIcon.GAMEMODE_SURVIVAL));
- this.finalButtons.add(new GuiButtonWorldHandler(-13, x + delta * 5, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.creative")), EnumTooltip.RIGHT, EnumIcon.GAMEMODE_CREATIVE));
- this.finalButtons.add(new GuiButtonWorldHandler(-14, x + delta * 6, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.adventure")), EnumTooltip.RIGHT, EnumIcon.GAMEMODE_ADVENTURE));
- this.finalButtons.add(new GuiButtonWorldHandler(-15, x + delta * 7, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.spectator")), EnumTooltip.RIGHT, EnumIcon.GAMEMODE_SPECTATOR));
- }
-
- //SYNTAX
-
- if(ConfigSettings.isCommandSyntaxEnabled())
- {
- this.syntaxField = new GuiTextFieldTooltip(x - delta * 7 + 1, this.height - 22, delta * 15 - 3, 20);
- this.updateSyntax();
- }
-
- //NAME
-
- this.nameField = new GuiTextFieldTooltip(0, 0, 0, 11);
- this.nameField.setMaxStringLength(16);
- this.nameField.setText(this.getPlayer());
- this.updateNameField();
-
- final int backgroundX = this.getBackgroundX();
- final int backgroundY = this.getBackgroundY();
-
- this.forEachTab((index, xOffset) ->
- {
- IContent tab = this.content.getCategory().getContent(index);
-
- if(!this.content.getActiveContent().equals(tab))
- {
- this.finalButtons.add(new GuiButtonTab(-16, (int) (backgroundX + xOffset), backgroundY - 20, (int) this.tabWidth + (int) Math.ceil(this.tabEpsilon / this.tabSize), 21, index));
- }
- });
-
- //BUTTONS
-
- this.initButtons();
- }
- catch(Exception e)
- {
- WorldHandler.throwError(e);
- }
- }
-
- public void initButtons()
- {
- this.buttonList.clear();
-
- this.content.initButtons(this, this.getContentX(), this.getContentY());
-
- if(this.finalButtons != null && !this.finalButtons.isEmpty())
- {
- this.buttonList.addAll(this.finalButtons);
- }
-
- for(IElement element : this.elements)
- {
- element.initButtons(this);
- }
- }
-
- private int getContentX()
- {
- return (this.width - this.bgTextureWidth) / 2 + 8 + this.getXOffset();
- }
-
- private int getContentY()
- {
- return this.height / 2 - 50 + this.getYOffset();
- }
-
- private int getXOffset()
- {
- return 0;
- }
-
- private int getYOffset()
- {
- return ConfigSettings.areShortcutsEnabled() ? 11 : 8;
- }
-
- @Override
- public void updateScreen()
- {
- try
- {
- this.content.updateScreen(this);
- this.updateSyntax();
- }
- catch(Exception e)
- {
- WorldHandler.throwError(e);
- }
- }
-
- private int getBackgroundX()
- {
- return (this.width - this.bgTextureWidth) / 2 + this.getXOffset();
- }
-
- private int getBackgroundY()
- {
- return (this.height - this.bgTextureHeight) / 2 + this.getYOffset();
- }
-
- private int getWatchOffset()
- {
- return ConfigSettings.isWatchEnabled() ? 9 : 0;
- }
-
- private void forEachTab(BiConsumer consumer)
- {
- double xOffset = 0D;
-
- for(int index = 0; index < this.tabSize; index++)
- {
- consumer.accept(index, xOffset);
- xOffset += this.tabWidth + this.tabDistance + this.tabEpsilon / this.tabSize;
- }
- }
-
- private void updateSyntax()
- {
- if(ConfigSettings.isCommandSyntaxEnabled() && this.syntaxField != null)
- {
- if(!this.syntaxField.isFocused())
- {
- this.syntaxField.setValidator(Predicates.alwaysTrue());
-
- if(this.content.getCommandBuilder() != null)
- {
- this.syntaxField.setText(this.content.getCommandBuilder().toCommand());
- }
- else
- {
- this.syntaxField.setText(BUILDER_WORLD_HANDLER.toCommand());
- }
-
- this.syntaxField.setValidator(string -> string.equals(this.syntaxField.getText()));
- this.syntaxField.setCursorPositionZero();
- }
- }
- }
-
- private void updateNameField()
- {
- final int backgroundX = this.getBackgroundX();
- final int backgroundY = this.getBackgroundY();
-
- if(WorldHandler.USERNAME.isEmpty())
- {
- int width = this.fontRenderer.getStringWidth(I18n.format("gui.worldhandler.generic.edit_username")) + 2;
-
- this.nameField.setWidth(width);
- this.nameField.setPosition(backgroundX + this.bgTextureWidth - this.getWatchOffset() - 7 - (this.fontRenderer.getStringWidth(this.content.getTitle()) + 2), backgroundY + 6);
- }
- else
- {
- int width = this.fontRenderer.getStringWidth(WorldHandler.USERNAME) + 2;
-
- this.nameField.setWidth(width);
- this.nameField.setPosition(backgroundX + this.bgTextureWidth - this.getWatchOffset() - 7 - width, backgroundY + 6);
- this.content.onPlayerNameChanged(WorldHandler.USERNAME);
- }
- }
-
- @Override
- protected void actionPerformed(GuiButton button) throws IOException
- {
- try
- {
- buttons:
- switch(button.id)
- {
- case 1:
- Minecraft.getMinecraft().displayGuiScreen((GuiScreen) null);
- Minecraft.getMinecraft().setIngameFocus();
- break;
- case 0:
- if(this.content.getBackContent() != null)
- {
- Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(this.content.getBackContent()));
- }
- break;
- case -1:
- WorldHandler.sendCommand(new BuilderTime(EnumMode.SET, ConfigSettings.getDawn()));
- break;
- case -2:
- WorldHandler.sendCommand(new BuilderTime(EnumMode.SET, ConfigSettings.getNoon()));
- break;
- case -3:
- WorldHandler.sendCommand(new BuilderTime(EnumMode.SET, ConfigSettings.getSunset()));
- break;
- case -4:
- WorldHandler.sendCommand(new BuilderTime(EnumMode.SET, ConfigSettings.getMidnight()));
- break;
- case -5:
- WorldHandler.sendCommand(new BuilderWeather(EnumWeather.CLEAR));
- break;
- case -6:
- WorldHandler.sendCommand(new BuilderWeather(EnumWeather.RAIN));
- break;
- case -7:
- WorldHandler.sendCommand(new BuilderWeather(EnumWeather.THUNDER));
- break;
- case -8:
- WorldHandler.sendCommand(new BuilderDifficulty(EnumDifficulty.PEACEFUL));
- break;
- case -9:
- WorldHandler.sendCommand(new BuilderDifficulty(EnumDifficulty.EASY));
- break;
- case -10:
- WorldHandler.sendCommand(new BuilderDifficulty(EnumDifficulty.NORMAL));
- break;
- case -11:
- WorldHandler.sendCommand(new BuilderDifficulty(EnumDifficulty.HARD));
- break;
- case -12:
- WorldHandler.sendCommand(new BuilderGamemode(EnumGamemode.SURVIVAL));
- break;
- case -13:
- WorldHandler.sendCommand(new BuilderGamemode(EnumGamemode.CREATIVE));
- break;
- case -14:
- WorldHandler.sendCommand(new BuilderGamemode(EnumGamemode.ADVENTURE));
- break;
- case -15:
- WorldHandler.sendCommand(new BuilderGamemode(EnumGamemode.SPECTATOR));
- break;
- case -16:
- if(button instanceof GuiButtonTab)
- {
- Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(this.content.getCategory().getContent(((GuiButtonTab)button).getIndex())));
- }
- break;
- default:
- for(IElement element : this.elements)
- {
- if(element.actionPerformed(this, button))
- {
- break buttons;
- }
- }
- this.content.actionPerformed(this, button);
- break;
- }
- }
- catch(Exception e)
- {
- WorldHandler.throwError(e);
- }
- }
-
- private void defaultColor()
- {
- this.defaultColor(1.0F);
- }
-
- private void defaultColor(float alpha)
- {
- GlStateManager.enableBlend();
- GlStateManager.color((float) ConfigSkin.getBackgroundRed() / 255, (float) ConfigSkin.getBackgroundGreen() / 255, (float) ConfigSkin.getBackgroundBlue() / 255, alpha * (float) ConfigSkin.getBackgroundAlpha() / 255);
- }
-
- private void darkColor()
- {
- GlStateManager.enableBlend();
- GlStateManager.color((float) ConfigSkin.getBackgroundRed() / 255 - 0.3F, (float) ConfigSkin.getBackgroundGreen() / 255 - 0.3F, (float) ConfigSkin.getBackgroundBlue() / 255 - 0.3F, (float) ConfigSkin.getBackgroundAlpha() / 255);
- }
-
- private void bindBackground()
- {
- Minecraft.getMinecraft().renderEngine.bindTexture(ResourceHelper.getBackgroundTexture());
- }
-
- @Nullable
- protected String getSplash()
- {
- Calendar calendar = Calendar.getInstance();
- int day = calendar.get(Calendar.DAY_OF_MONTH);
- int month = calendar.get(Calendar.MONTH) + 1;
-
- if(day == 12 && month == 24)
- {
- return "Merry X-mas!";
- }
- else if(day == 1 && month == 1)
- {
- return "Happy new year!";
- }
- else if(day == 10 && month == 31)
- {
- return "OOoooOOOoooo! Spooky!";
- }
- else if(day == 3 && month == 28)
- {
- return (calendar.get(Calendar.YEAR) - 2013) + " Years of World Handler!";
- }
-
- return null;
- }
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks)
- {
- try
- {
- final int backgroundX = this.getBackgroundX();
- final int backgroundY = this.getBackgroundY();
-
- //DEFAULT BACKGROUND
-
- if(ConfigSkin.isBackgroundDrawingEnabled())
- {
- super.drawDefaultBackground();
- }
-
- //COLOR
-
- this.defaultColor();
-
- //BACKGROUND
-
- this.bindBackground();
- this.drawTexturedModalRect(backgroundX, backgroundY, 0, 0, this.bgTextureWidth, this.bgTextureHeight);
-
- //TABS
-
- this.forEachTab((index, xOffset) ->
- {
- IContent tab = this.content.getCategory().getContent(index);
- int yOffset;
- int fHeight;
- int color;
-
- if(this.content.getActiveContent().equals(tab))
- {
- yOffset = -22;
- fHeight = 25;
- color = 0xFFFFFF;
- this.defaultColor();
- }
- else
- {
- yOffset = -20;
- fHeight = 20;
- color = 0xE0E0E0;
- this.darkColor();
- }
-
- this.bindBackground();
- this.drawTexturedModalRect((int) (backgroundX + xOffset), (int) (backgroundY + yOffset), 0, 0, (int) Math.ceil(this.tabHalf), fHeight);
- this.drawTexturedModalRect((int) (backgroundX + this.tabHalf + xOffset), (int) (backgroundY + yOffset), this.bgTextureWidth - (int) Math.ceil(this.tabHalf), 0, (int) Math.ceil(this.tabHalf), fHeight);
-
- if(!ConfigSkin.areSharpEdgesEnabled())
- {
- if(this.content.getActiveContent().equals(tab))
- {
- //RIGHT TAB CURVATURE
-
- if(index < this.tabSize - 1 || this.tabSize == 1)
- {
- int factor = 2;
-
- for(int x = 0; x < factor; x++)
- {
- this.drawTexturedModalRect((int) (backgroundX + this.tabWidth + xOffset - x - 1), (int) (backgroundY + x + 1), (int) (this.tabWidth - x - 1), x + 1, x + 1, 1);
- }
- }
-
- //LEFT TAB CURVATURE
-
- if(index > 0)
- {
- int factor = 2;
-
- for(int x = 0; x < factor; x++)
- {
- this.drawTexturedModalRect((int) (backgroundX + xOffset), (int) (backgroundY + x + 1), xOffset.intValue(), x + 1, x + 1, 1);
- }
- }
-
- int width = (int)(this.tabWidth - 3);
- int interval = 5;
-
- //LEFT GRADIENT
-
- if(index == 0)
- {
- for(int x = 0; x < width; x += interval)
- {
- this.defaultColor(1.0F - (x / (width + 5.0F * interval)));
- this.drawTexturedModalRect((int) (backgroundX + xOffset), (int) (backgroundY + yOffset + fHeight + x / interval), 0, fHeight, width - x, 1);
- }
- }
-
- //RIGHT GRADIENT
-
- if(index == this.tabSize - 1 && this.tabSize > 1)
- {
- int offset = 3;
-
- for(int x = 0; x < width; x += interval)
- {
- this.defaultColor(1.0F - (x / (width + 5.0F * interval)));
- this.drawTexturedModalRect((int) (backgroundX + Math.ceil(xOffset) + x + offset), (int) (backgroundY + yOffset + fHeight + x / interval), this.bgTextureWidth - width + x, fHeight, width - x, 1);
- }
- }
- }
- else
- {
- //LEFT CORNER FILLER
-
- if(index == 0)
- {
- int factor = 2;
-
- for(int x = 0; x < factor; x++)
- {
- this.drawTexturedModalRect(backgroundX, backgroundY + x, 0, fHeight, factor - x, 1);
- }
- }
-
- //RIGHT CORNER FILLER
-
- if(index == this.tabSize - 1)
- {
- int factor = 3;
-
- for(int x = 0; x < factor + 1; x++)
- {
- this.drawTexturedModalRect(backgroundX + this.bgTextureWidth - x, backgroundY + factor - x, this.bgTextureWidth - x, fHeight, x, 1);
- }
- }
- }
- }
-
- this.drawCenteredString(this.fontRenderer, ChatFormatting.UNDERLINE + tab.getTabTitle(), (int) (backgroundX + this.tabHalf + xOffset), (int) (backgroundY - 13), color);
- });
-
- this.defaultColor();
-
- //VERSION LABEL
-
- final String label = "$mcversion-$version";
- final int hexAlpha = (int) (0xFF * 0.2) << 24;
- final int color = ConfigSkin.getLabelColor() + hexAlpha;
- final int versionWidth = this.width - this.fontRenderer.getStringWidth(label) - 2;
- final int versionHeight = this.height - 10;
-
- this.fontRenderer.drawString(label, versionWidth, versionHeight, color);
-
- //TITLE
-
- final int maxWidth = this.bgTextureWidth - 7 - 2 - this.fontRenderer.getStringWidth(WorldHandler.USERNAME) - 2 - this.getWatchOffset() - 7;
- this.fontRenderer.drawString(TextFormatting.shortenString(this.content.getTitle(), maxWidth, this.fontRenderer), backgroundX + 7, backgroundY + 7, ConfigSkin.getLabelColor());
-
- //HEADLINE
-
- if(this.content.getHeadline() != null)
- {
- if(this.content.getHeadline().length > 0)
- {
- this.fontRenderer.drawString(this.content.getHeadline()[0], backgroundX + 8, backgroundY + 22, ConfigSkin.getHeadlineColor());
- }
-
- if(this.content.getHeadline().length > 1)
- {
- this.fontRenderer.drawString(this.content.getHeadline()[1], backgroundX + 126, backgroundY + 22, ConfigSkin.getHeadlineColor());
- }
- }
-
- //NAME FIELD
-
- final String username = WorldHandler.USERNAME.isEmpty() && !this.nameField.isFocused() ? I18n.format("gui.worldhandler.generic.edit_username") : WorldHandler.USERNAME;
- this.fontRenderer.drawString(username, backgroundX + 232 - this.fontRenderer.getStringWidth(username), backgroundY + 7, ConfigSkin.getLabelColor());
-
- //WATCH
-
- if(ConfigSettings.isWatchEnabled())
- {
- final int watchX = backgroundX + 233;
- final int watchY = backgroundY + 5;
-
- UtilRender.drawWatchIntoGui(this, watchX, watchY, Minecraft.getMinecraft().world.getWorldInfo().getWorldTime(), ConfigSettings.isSmoothWatchEnabled());
-
- if(ConfigSettings.areTooltipsEnabled())
- {
- if(mouseX >= watchX && mouseX <= watchX + 9 && mouseY >= watchY && mouseY <= watchY + 9)
- {
- GuiUtils.drawHoveringText(Arrays.asList(TextFormatting.getWorldTime(Minecraft.getMinecraft().world.getWorldTime())), mouseX, mouseY + 9, this.width, this.height, this.width, this.fontRenderer);
- GlStateManager.disableLighting();
- }
- }
- }
-
- //BUTTONS
-
- for(int x = 0; x < this.buttonList.size(); x++)
- {
- this.buttonList.get(x).drawButton(this.mc, mouseX, mouseY, partialTicks);
- }
-
- for(int x = 0; x < this.labelList.size(); x++)
- {
- this.labelList.get(x).drawLabel(this.mc, mouseX, mouseY);
- }
-
- //CONTAINER
-
- this.content.drawScreen(this, this.getContentX(), this.getContentY(), mouseX, mouseY, partialTicks);
-
- //CONTAINER ELEMENTS
-
- for(IElement element : this.elements)
- {
- element.draw();
- }
-
- //SYNTAX
-
- if(ConfigSettings.isCommandSyntaxEnabled() && this.syntaxField != null)
- {
- this.syntaxField.drawTextBox();
- }
-
- //SPLASHTEXT
-
- if(this.splash != null)
- {
- GlStateManager.pushMatrix();
- RenderHelper.enableGUIStandardItemLighting();
- GlStateManager.disableLighting();
- GlStateManager.translate((float) (backgroundX + 212), backgroundY + 15, 0.0F);
- GlStateManager.rotate(17.0F, 0.0F, 0.0F, 1.0F);
-
- float scale = 1.1F - MathHelper.abs(MathHelper.sin((float) (Minecraft.getSystemTime() % 1000L) / 1000.0F * (float) Math.PI * 2.0F) * 0.1F);
- scale = scale * 100.0F / this.fontRenderer.getStringWidth(this.splash);
- GlStateManager.scale(scale, scale, scale);
-
- this.drawCenteredString(this.fontRenderer, this.splash, 0, (int) scale, 0xFFFF00);
-
- GlStateManager.popMatrix();
- }
-
- //TOOLTIPS
-
- if(ConfigSettings.areTooltipsEnabled())
- {
- for(int x = 0; x < this.buttonList.size(); x++)
- {
- if(this.buttonList.get(x) instanceof GuiButtonWorldHandler)
- {
- ((GuiButtonWorldHandler) this.buttonList.get(x)).drawTooltip(mouseX, mouseY, this.width, this.height);
- }
- }
- }
-
- //VERSION LABEL TOOLTIP
-
- if(mouseX >= versionWidth && mouseY >= versionHeight)
- {
- GuiUtils.drawHoveringText(Arrays.asList(label), versionWidth - 12, versionHeight + 12, this.width + this.fontRenderer.getStringWidth(label), this.height + 10, this.width, this.fontRenderer);
- }
- }
- catch(Exception e)
- {
- WorldHandler.throwError(e);
- }
- }
-
- @Override
- protected void keyTyped(char charTyped, int keyCode) throws IOException
- {
- try
- {
- super.keyTyped(charTyped, keyCode);
-
- this.content.keyTyped(this, charTyped, keyCode);
-
- if(this.nameField.isFocused())
- {
- this.nameField.textboxKeyTyped(charTyped, keyCode);
- WorldHandler.USERNAME = this.nameField.getText();
- this.updateNameField();
- }
-
- if(ConfigSettings.isCommandSyntaxEnabled() && this.syntaxField != null)
- {
- this.syntaxField.textboxKeyTyped(charTyped, keyCode);
- }
-
- for(IElement element : this.elements)
- {
- element.keyTyped(this, charTyped, keyCode);
- }
- }
- catch(Exception e)
- {
- WorldHandler.throwError(e);
- }
- }
-
- @Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
- {
- try
- {
- super.mouseClicked(mouseX, mouseY, mouseButton);
-
- this.content.mouseClicked(mouseX, mouseY, mouseButton);
- this.nameField.mouseClicked(mouseX, mouseY, mouseButton);
-
- if(this.nameField.isFocused())
- {
- this.nameField.setCursorPositionEnd();
- }
-
- if(ConfigSettings.isCommandSyntaxEnabled() && this.syntaxField != null)
- {
- this.syntaxField.mouseClicked(mouseX, mouseY, mouseButton);
- }
-
- for(IElement element : this.elements)
- {
- element.mouseClicked(mouseX, mouseY, mouseButton);
- }
- }
- catch(Exception e)
- {
- WorldHandler.throwError(e);
- }
- }
-
- @Override
- public void onGuiClosed()
- {
- try
- {
- this.content.onGuiClosed();
- }
- catch(Exception e)
- {
- WorldHandler.throwError(e);
- }
- }
-
- @Override
- public boolean doesGuiPauseGame()
- {
- return ConfigSettings.isPauseEnabled();
- }
-
- @Override
- public String getPlayer()
- {
- return WorldHandler.USERNAME;
- }
+package exopandora.worldhandler.gui.container.impl;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.List;
+import java.util.function.BiConsumer;
+
+import javax.annotation.Nullable;
+
+import com.google.common.base.Predicates;
+import com.mojang.realmsclient.gui.ChatFormatting;
+
+import exopandora.worldhandler.Main;
+import exopandora.worldhandler.WorldHandler;
+import exopandora.worldhandler.builder.impl.BuilderWorldHandler;
+import exopandora.worldhandler.config.Config;
+import exopandora.worldhandler.format.TextFormatting;
+import exopandora.worldhandler.gui.button.EnumIcon;
+import exopandora.worldhandler.gui.button.GuiButtonIcon;
+import exopandora.worldhandler.gui.button.GuiButtonTab;
+import exopandora.worldhandler.gui.button.GuiButtonTooltip;
+import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
+import exopandora.worldhandler.gui.container.Container;
+import exopandora.worldhandler.gui.content.Content;
+import exopandora.worldhandler.gui.content.IContent;
+import exopandora.worldhandler.gui.content.element.IElement;
+import exopandora.worldhandler.helper.ActionHelper;
+import exopandora.worldhandler.helper.ResourceHelper;
+import exopandora.worldhandler.util.UtilRender;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.RenderHelper;
+import net.minecraft.client.resources.I18n;
+import net.minecraft.util.math.MathHelper;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+import net.minecraftforge.fml.client.config.GuiUtils;
+
+@OnlyIn(Dist.CLIENT)
+public class GuiWorldHandler extends Container
+{
+ private final Content content;
+ private final int tabSize;
+ private final int bgTextureWidth = 248;
+ private final int bgTextureHeight = 166;
+ private final int tabDistance = 2;
+ private final int tabDistanceTotal;
+ private final double tabWidth;
+ private final double tabHalf;
+ private final double tabEpsilon;
+ private final String splash = this.getSplash();
+ private final List finalButtons = new ArrayList();
+
+ private GuiTextFieldTooltip syntaxField;
+ private GuiTextFieldTooltip nameField;
+
+ private static final BuilderWorldHandler BUILDER_WORLD_HANDLER = new BuilderWorldHandler();
+
+ public GuiWorldHandler(Content content) throws Exception
+ {
+ this.content = content;
+ this.tabSize = this.content.getCategory().getSize();
+ this.tabDistanceTotal = Math.max(this.tabSize - 1, 1) * this.tabDistance;
+ this.tabWidth = (this.bgTextureWidth - this.tabDistanceTotal) / Math.max(this.tabSize, 2);
+ this.tabHalf = this.tabWidth / 2D;
+ this.tabEpsilon = this.bgTextureWidth - (this.tabDistanceTotal + this.tabHalf * Math.max(this.tabSize, 2) * 2D);
+ this.content.init(this);
+ }
+
+ @Override
+ public void initGui()
+ {
+ super.initGui();
+
+ ActionHelper.tryRun(() ->
+ {
+ this.finalButtons.clear();
+ this.elements.clear();
+ this.buttons.clear();
+ this.children.clear();
+
+ //INIT
+ this.content.onPlayerNameChanged(this.getPlayer());
+ this.content.initGui(this, this.getContentX(), this.getContentY());
+
+ //ELEMENTS
+
+ for(IElement element : this.elements)
+ {
+ element.initGui(this);
+ }
+
+ //SHORTCUTS
+
+ final int x = this.width / 2 - 10;
+ final int delta = 21;
+
+ if(Config.getSettings().shortcuts())
+ {
+ this.finalButtons.add(new GuiButtonIcon(x - delta * 7, 0, 20, 20, EnumIcon.TIME_DAWN, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.dawn", Config.getSettings().getDawn())), ActionHelper::timeDawn));
+ this.finalButtons.add(new GuiButtonIcon(x - delta * 6, 0, 20, 20, EnumIcon.TIME_NOON, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.noon", Config.getSettings().getNoon())), ActionHelper::timeNoon));
+ this.finalButtons.add(new GuiButtonIcon(x - delta * 5, 0, 20, 20, EnumIcon.TIME_SUNSET, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.sunset", Config.getSettings().getSunset())), ActionHelper::timeSunset));
+ this.finalButtons.add(new GuiButtonIcon(x - delta * 4, 0, 20, 20, EnumIcon.TIME_MIDNIGHT, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.midnight", Config.getSettings().getMidnight())), ActionHelper::timeMidnight));
+ this.finalButtons.add(new GuiButtonIcon(x - delta * 3, 0, 20, 20, EnumIcon.WEATHER_SUN, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.clear")), ActionHelper::weatherClear));
+ this.finalButtons.add(new GuiButtonIcon(x - delta * 2, 0, 20, 20, EnumIcon.WEATHER_RAIN, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.rainy")), ActionHelper::weatherRain));
+ this.finalButtons.add(new GuiButtonIcon(x - delta * 1, 0, 20, 20, EnumIcon.WEATHER_STORM, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.thunder")), ActionHelper::weatherThunder));
+ this.finalButtons.add(new GuiButtonIcon(x - delta * 0, 0, 20, 20, EnumIcon.DIFFICULTY_PEACEFUL, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.peaceful")), ActionHelper::difficultyPeaceful));
+ this.finalButtons.add(new GuiButtonIcon(x + delta * 1, 0, 20, 20, EnumIcon.DIFFICULTY_EASY, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.easy")), ActionHelper::difficultyEasy));
+ this.finalButtons.add(new GuiButtonIcon(x + delta * 2, 0, 20, 20, EnumIcon.DIFFICULTY_NORMAL, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.normal")), ActionHelper::difficultyNormal));
+ this.finalButtons.add(new GuiButtonIcon(x + delta * 3, 0, 20, 20, EnumIcon.DIFFICULTY_HARD, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.hard")), ActionHelper::difficultyHard));
+ this.finalButtons.add(new GuiButtonIcon(x + delta * 4, 0, 20, 20, EnumIcon.GAMEMODE_SURVIVAL, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.survival")), ActionHelper::gamemodeSurvival));
+ this.finalButtons.add(new GuiButtonIcon(x + delta * 5, 0, 20, 20, EnumIcon.GAMEMODE_CREATIVE, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.creative")), ActionHelper::gamemodeCreative));
+ this.finalButtons.add(new GuiButtonIcon(x + delta * 6, 0, 20, 20, EnumIcon.GAMEMODE_ADVENTURE, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.adventure")), ActionHelper::gamemodeAdventure));
+ this.finalButtons.add(new GuiButtonIcon(x + delta * 7, 0, 20, 20, EnumIcon.GAMEMODE_SPECTATOR, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.spectator")), ActionHelper::gamemodeSpectator));
+ }
+
+ //SYNTAX
+
+ if(Config.getSettings().commandSyntax())
+ {
+ this.syntaxField = new GuiTextFieldTooltip(x - delta * 7 + 1, this.height - 22, delta * 15 - 3, 20);
+ this.updateSyntax();
+ }
+
+ //NAME
+
+ this.nameField = new GuiTextFieldTooltip(0, 0, 0, 11);
+ this.nameField.setMaxStringLength(16);
+ this.nameField.setText(this.getPlayer());
+ this.nameField.setTextAcceptHandler((id, text) ->
+ {
+ WorldHandler.USERNAME = text;
+ this.updateNameField();
+ });
+ this.updateNameField();
+
+ final int backgroundX = this.getBackgroundX();
+ final int backgroundY = this.getBackgroundY();
+
+ this.forEachTab((index, xOffset) ->
+ {
+ IContent tab = this.content.getCategory().getContent(index);
+
+ if(!this.content.getActiveContent().equals(tab))
+ {
+ this.finalButtons.add(new GuiButtonTab((int) (backgroundX + xOffset), backgroundY - 20, (int) this.tabWidth + (int) Math.ceil(this.tabEpsilon / this.tabSize), 21)
+ {
+ @Override
+ public void onClick(double mouseX, double mouseY)
+ {
+ ActionHelper.changeTab(GuiWorldHandler.this.content, index);
+ }
+ });
+ }
+ });
+
+ //BUTTONS
+
+ this.initButtons();
+ });
+ }
+
+ public void initButtons()
+ {
+ this.buttons.clear();
+ this.children.clear();
+ this.content.initButtons(this, this.getContentX(), this.getContentY());
+
+ if(this.finalButtons != null && !this.finalButtons.isEmpty())
+ {
+ this.finalButtons.forEach(this::add);
+ }
+
+ if(Config.getSettings().commandSyntax())
+ {
+ this.add(this.syntaxField);
+ }
+
+ this.add(this.nameField);
+
+ for(IElement element : this.elements)
+ {
+ element.initButtons(this);
+ }
+ }
+
+ private int getContentX()
+ {
+ return (this.width - this.bgTextureWidth) / 2 + 8 + this.getXOffset();
+ }
+
+ private int getContentY()
+ {
+ return this.height / 2 - 50 + this.getYOffset();
+ }
+
+ private int getXOffset()
+ {
+ return 0;
+ }
+
+ private int getYOffset()
+ {
+ return Config.getSettings().shortcuts() ? 11 : 8;
+ }
+
+ @Override
+ public void tick()
+ {
+ ActionHelper.tryRun(this::update);
+ }
+
+ private void update()
+ {
+ this.content.tick(this);
+
+ for(IElement element : this.elements)
+ {
+ element.tick();
+ }
+
+ this.updateSyntax();
+ }
+
+ private int getBackgroundX()
+ {
+ return (this.width - this.bgTextureWidth) / 2 + this.getXOffset();
+ }
+
+ private int getBackgroundY()
+ {
+ return (this.height - this.bgTextureHeight) / 2 + this.getYOffset();
+ }
+
+ private int getWatchOffset()
+ {
+ return Config.getSettings().watch() ? 9 : 0;
+ }
+
+ private void forEachTab(BiConsumer consumer)
+ {
+ double xOffset = 0D;
+
+ for(int index = 0; index < this.tabSize; index++)
+ {
+ consumer.accept(index, xOffset);
+ xOffset += this.tabWidth + this.tabDistance + this.tabEpsilon / this.tabSize;
+ }
+ }
+
+ private void updateSyntax()
+ {
+ if(Config.getSettings().commandSyntax() && this.syntaxField != null)
+ {
+ if(!this.syntaxField.isFocused())
+ {
+ this.syntaxField.setValidator(Predicates.alwaysTrue());
+
+ if(this.content.getCommandBuilder() != null)
+ {
+ this.syntaxField.setText(this.content.getCommandBuilder().toCommand());
+ }
+ else
+ {
+ this.syntaxField.setText(BUILDER_WORLD_HANDLER.toCommand());
+ }
+
+ this.syntaxField.setValidator(string -> string.equals(this.syntaxField.getText()));
+ this.syntaxField.setCursorPositionZero();
+ }
+
+ this.syntaxField.tick();
+ }
+ }
+
+ private void updateNameField()
+ {
+ final int backgroundX = this.getBackgroundX();
+ final int backgroundY = this.getBackgroundY();
+
+ if(WorldHandler.USERNAME.isEmpty())
+ {
+ int width = this.fontRenderer.getStringWidth(I18n.format("gui.worldhandler.generic.edit_username")) + 2;
+ this.nameField.setWidth(width);
+ this.nameField.setPosition(backgroundX + this.bgTextureWidth - this.getWatchOffset() - 7 - (this.fontRenderer.getStringWidth(this.content.getTitle()) + 2), backgroundY + 6);
+ }
+ else
+ {
+ int width = this.fontRenderer.getStringWidth(WorldHandler.USERNAME) + 2;
+ this.nameField.setWidth(width);
+ this.nameField.setPosition(backgroundX + this.bgTextureWidth - this.getWatchOffset() - 7 - width, backgroundY + 6);
+ }
+
+ this.content.onPlayerNameChanged(WorldHandler.USERNAME);
+ }
+
+ private void defaultColor()
+ {
+ this.defaultColor(1.0F);
+ }
+
+ private void defaultColor(float alpha)
+ {
+ GlStateManager.enableBlend();
+ GlStateManager.color4f(Config.getSkin().getBackgroundRedF(), Config.getSkin().getBackgroundGreenF(), Config.getSkin().getBackgroundBlueF(), alpha * Config.getSkin().getBackgroundAlphaF());
+ }
+
+ private void darkColor()
+ {
+ GlStateManager.enableBlend();
+ GlStateManager.color4f(Config.getSkin().getBackgroundRedF() - 0.3F, Config.getSkin().getBackgroundGreenF() - 0.3F, Config.getSkin().getBackgroundBlueF() - 0.3F, Config.getSkin().getBackgroundAlphaF());
+ }
+
+ private void bindBackground()
+ {
+ Minecraft.getInstance().getTextureManager().bindTexture(ResourceHelper.getBackgroundTexture());
+ }
+
+ @Nullable
+ protected String getSplash()
+ {
+ Calendar calendar = Calendar.getInstance();
+ int day = calendar.get(Calendar.DAY_OF_MONTH);
+ int month = calendar.get(Calendar.MONTH) + 1;
+
+ if(day == 12 && month == 24)
+ {
+ return "Merry X-mas!";
+ }
+ else if(day == 1 && month == 1)
+ {
+ return "Happy new year!";
+ }
+ else if(day == 10 && month == 31)
+ {
+ return "OOoooOOOoooo! Spooky!";
+ }
+ else if(day == 3 && month == 28)
+ {
+ return (calendar.get(Calendar.YEAR) - 2013) + " Years of World Handler!";
+ }
+
+ return null;
+ }
+
+ @Override
+ public void render(int mouseX, int mouseY, float partialTicks)
+ {
+ ActionHelper.tryRun(() ->
+ {
+ final int backgroundX = this.getBackgroundX();
+ final int backgroundY = this.getBackgroundY();
+
+ //DEFAULT BACKGROUND
+
+ if(Config.getSkin().drawBackground())
+ {
+ super.drawDefaultBackground();
+ }
+
+ //COLOR
+
+ this.defaultColor();
+
+ //BACKGROUND
+
+ this.bindBackground();
+ this.drawTexturedModalRect(backgroundX, backgroundY, 0, 0, this.bgTextureWidth, this.bgTextureHeight);
+
+ //TABS
+
+ this.forEachTab((index, xOffset) ->
+ {
+ IContent tab = this.content.getCategory().getContent(index);
+ int yOffset;
+ int fHeight;
+ int color;
+
+ if(this.content.getActiveContent().equals(tab))
+ {
+ yOffset = -22;
+ fHeight = 25;
+ color = 0xFFFFFF;
+ this.defaultColor();
+ }
+ else
+ {
+ yOffset = -20;
+ fHeight = 20;
+ color = 0xE0E0E0;
+ this.darkColor();
+ }
+
+ this.bindBackground();
+ this.drawTexturedModalRect((int) (backgroundX + xOffset), (int) (backgroundY + yOffset), 0, 0, (int) Math.ceil(this.tabHalf), fHeight);
+ this.drawTexturedModalRect((int) (backgroundX + this.tabHalf + xOffset), (int) (backgroundY + yOffset), this.bgTextureWidth - (int) Math.ceil(this.tabHalf), 0, (int) Math.ceil(this.tabHalf), fHeight);
+
+ if(!Config.getSkin().sharpEdges())
+ {
+ if(this.content.getActiveContent().equals(tab))
+ {
+ //RIGHT TAB CURVATURE
+
+ if(index < this.tabSize - 1 || this.tabSize == 1)
+ {
+ int factor = 2;
+
+ for(int x = 0; x < factor; x++)
+ {
+ this.drawTexturedModalRect((int) (backgroundX + this.tabWidth + xOffset - x - 1), (int) (backgroundY + x + 1), (int) (this.tabWidth - x - 1), x + 1, x + 1, 1);
+ }
+ }
+
+ //LEFT TAB CURVATURE
+
+ if(index > 0)
+ {
+ int factor = 2;
+
+ for(int x = 0; x < factor; x++)
+ {
+ this.drawTexturedModalRect((int) (backgroundX + xOffset), (int) (backgroundY + x + 1), xOffset.intValue(), x + 1, x + 1, 1);
+ }
+ }
+
+ int width = (int)(this.tabWidth - 3);
+ int interval = 5;
+
+ //LEFT GRADIENT
+
+ if(index == 0)
+ {
+ for(int x = 0; x < width; x += interval)
+ {
+ this.defaultColor(1.0F - (x / (width + 5.0F * interval)));
+ this.drawTexturedModalRect((int) (backgroundX + xOffset), (int) (backgroundY + yOffset + fHeight + x / interval), 0, fHeight, width - x, 1);
+ }
+ }
+
+ //RIGHT GRADIENT
+
+ if(index == this.tabSize - 1 && this.tabSize > 1)
+ {
+ int offset = 3;
+
+ for(int x = 0; x < width; x += interval)
+ {
+ this.defaultColor(1.0F - (x / (width + 5.0F * interval)));
+ this.drawTexturedModalRect((int) (backgroundX + Math.ceil(xOffset) + x + offset), (int) (backgroundY + yOffset + fHeight + x / interval), this.bgTextureWidth - width + x, fHeight, width - x, 1);
+ }
+ }
+ }
+ else
+ {
+ //LEFT CORNER FILLER
+
+ if(index == 0)
+ {
+ int factor = 2;
+
+ for(int x = 0; x < factor; x++)
+ {
+ this.drawTexturedModalRect(backgroundX, backgroundY + x, 0, fHeight, factor - x, 1);
+ }
+ }
+
+ //RIGHT CORNER FILLER
+
+ if(index == this.tabSize - 1)
+ {
+ int factor = 3;
+
+ for(int x = 0; x < factor + 1; x++)
+ {
+ this.drawTexturedModalRect(backgroundX + this.bgTextureWidth - x, backgroundY + factor - x, this.bgTextureWidth - x, fHeight, x, 1);
+ }
+ }
+ }
+ }
+
+ this.drawCenteredString(this.fontRenderer, ChatFormatting.UNDERLINE + tab.getTabTitle(), (int) (backgroundX + this.tabHalf + xOffset), (int) (backgroundY - 13), color);
+ });
+
+ this.defaultColor();
+
+ //VERSION LABEL
+
+ final String label = Main.MC_VERSION + "-" + Main.MOD_VERSION;
+ final int hexAlpha = (int) (0xFF * 0.2) << 24;
+ final int color = Config.getSkin().getLabelColor() + hexAlpha;
+ final int versionWidth = this.width - this.fontRenderer.getStringWidth(label) - 2;
+ final int versionHeight = this.height - 10;
+
+ this.fontRenderer.drawString(label, versionWidth, versionHeight, color);
+
+ //TITLE
+
+ final int maxWidth = this.bgTextureWidth - 7 - 2 - this.fontRenderer.getStringWidth(WorldHandler.USERNAME) - 2 - this.getWatchOffset() - 7;
+ this.fontRenderer.drawString(TextFormatting.shortenString(this.content.getTitle(), maxWidth, this.fontRenderer), backgroundX + 7, backgroundY + 7, Config.getSkin().getLabelColor());
+
+ //HEADLINE
+
+ if(this.content.getHeadline() != null)
+ {
+ if(this.content.getHeadline().length > 0)
+ {
+ this.fontRenderer.drawString(this.content.getHeadline()[0], backgroundX + 8, backgroundY + 22, Config.getSkin().getHeadlineColor());
+ }
+
+ if(this.content.getHeadline().length > 1)
+ {
+ this.fontRenderer.drawString(this.content.getHeadline()[1], backgroundX + 126, backgroundY + 22, Config.getSkin().getHeadlineColor());
+ }
+ }
+
+ //NAME FIELD
+
+ final String username = WorldHandler.USERNAME.isEmpty() && !this.nameField.isFocused() ? I18n.format("gui.worldhandler.generic.edit_username") : WorldHandler.USERNAME;
+ this.fontRenderer.drawString(username, backgroundX + 232 - this.fontRenderer.getStringWidth(username), backgroundY + 7, Config.getSkin().getLabelColor());
+
+ //WATCH
+
+ if(Config.getSettings().watch())
+ {
+ final int watchX = backgroundX + 233;
+ final int watchY = backgroundY + 5;
+
+ UtilRender.drawWatchIntoGui(this, watchX, watchY, Minecraft.getInstance().world.getWorldInfo().getDayTime(), Config.getSettings().smoothWatch());
+
+ if(Config.getSettings().tooltips())
+ {
+ if(mouseX >= watchX && mouseX <= watchX + 9 && mouseY >= watchY && mouseY <= watchY + 9)
+ {
+ GuiUtils.drawHoveringText(Arrays.asList(TextFormatting.formatWorldTime(Minecraft.getInstance().world.getDayTime())), mouseX, mouseY + 9, this.width, this.height, this.width, this.fontRenderer);
+ GlStateManager.disableLighting();
+ }
+ }
+ }
+
+ //BUTTONS
+
+ for(int x = 0; x < this.buttons.size(); x++)
+ {
+ this.buttons.get(x).render(mouseX, mouseY, partialTicks);
+ }
+
+ for(int x = 0; x < this.labels.size(); x++)
+ {
+ this.labels.get(x).render(mouseX, mouseY, partialTicks);
+ }
+
+ //CONTAINER
+
+ this.content.drawScreen(this, this.getContentX(), this.getContentY(), mouseX, mouseY, partialTicks);
+
+ //CONTAINER ELEMENTS
+
+ for(IElement element : this.elements)
+ {
+ element.draw(mouseX, mouseY, partialTicks);
+ }
+
+ //SYNTAX
+
+ if(Config.getSettings().commandSyntax() && this.syntaxField != null)
+ {
+ this.syntaxField.drawTextField(mouseX, mouseY, partialTicks);
+ }
+
+ //SPLASHTEXT
+
+ if(this.splash != null)
+ {
+ GlStateManager.pushMatrix();
+ RenderHelper.enableGUIStandardItemLighting();
+ GlStateManager.disableLighting();
+ GlStateManager.translatef((float) (backgroundX + 212), backgroundY + 15, 0.0F);
+ GlStateManager.rotatef(17.0F, 0.0F, 0.0F, 1.0F);
+
+ float scale = 1.1F - MathHelper.abs(MathHelper.sin((float) (System.currentTimeMillis() % 1000L) / 1000.0F * (float) Math.PI * 2.0F) * 0.1F);
+ scale = scale * 100.0F / this.fontRenderer.getStringWidth(this.splash);
+ GlStateManager.scalef(scale, scale, scale);
+
+ this.drawCenteredString(this.fontRenderer, this.splash, 0, (int) scale, 0xFFFF00);
+
+ GlStateManager.popMatrix();
+ }
+
+ //TOOLTIPS
+
+ if(Config.getSettings().tooltips())
+ {
+ for(GuiButton button : this.buttons)
+ {
+ if(button instanceof GuiButtonTooltip)
+ {
+ ((GuiButtonTooltip) button).renderTooltip(mouseX, mouseY);
+ }
+ }
+ }
+
+ //VERSION LABEL TOOLTIP
+
+ if(mouseX >= versionWidth && mouseY >= versionHeight)
+ {
+ GuiUtils.drawHoveringText(Arrays.asList(label), versionWidth - 12, versionHeight + 12, this.width + this.fontRenderer.getStringWidth(label), this.height + 10, this.width, this.fontRenderer);
+ }
+ });
+ }
+
+ @Override
+ public boolean charTyped(char charTyped, int keyCode)
+ {
+ if(this.nameField.isFocused())
+ {
+ this.nameField.setCursorPositionEnd();
+ }
+
+ return super.charTyped(charTyped, keyCode);
+ }
+
+ @Override
+ public boolean mouseClicked(double mouseX, double mouseY, int keyCode)
+ {
+ if(this.nameField.isFocused())
+ {
+ this.nameField.setCursorPositionEnd();
+ }
+
+ return super.mouseClicked(mouseX, mouseY, keyCode);
+ }
+
+ @Override
+ public void onGuiClosed()
+ {
+ ActionHelper.tryRun(this.content::onGuiClosed);
+ }
+
+ @Override
+ public boolean doesGuiPauseGame()
+ {
+ return Config.getSettings().pause();
+ }
+
+ @Override
+ public String getPlayer()
+ {
+ return WorldHandler.USERNAME;
+ }
+
+ @Override
+ public Content getContent()
+ {
+ return this.content;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/exopandora/worldhandler/gui/content/Content.java b/src/main/java/exopandora/worldhandler/gui/content/Content.java
index c45fd24..58161bf 100644
--- a/src/main/java/exopandora/worldhandler/gui/content/Content.java
+++ b/src/main/java/exopandora/worldhandler/gui/content/Content.java
@@ -2,11 +2,12 @@ package exopandora.worldhandler.gui.content;
import java.util.HashMap;
import java.util.Map;
+import java.util.function.Supplier;
import exopandora.worldhandler.Main;
-import exopandora.worldhandler.gui.button.persistence.ButtonValue;
import exopandora.worldhandler.gui.content.impl.ContentAdvancements;
import exopandora.worldhandler.gui.content.impl.ContentButcher;
+import exopandora.worldhandler.gui.content.impl.ContentButcherSettings;
import exopandora.worldhandler.gui.content.impl.ContentChangeWorld;
import exopandora.worldhandler.gui.content.impl.ContentContainers;
import exopandora.worldhandler.gui.content.impl.ContentContinue;
@@ -18,24 +19,28 @@ import exopandora.worldhandler.gui.content.impl.ContentGamerules;
import exopandora.worldhandler.gui.content.impl.ContentMain;
import exopandora.worldhandler.gui.content.impl.ContentMultiplayer;
import exopandora.worldhandler.gui.content.impl.ContentNoteEditor;
+import exopandora.worldhandler.gui.content.impl.ContentScoreboardObjectives;
import exopandora.worldhandler.gui.content.impl.ContentPlayer;
+import exopandora.worldhandler.gui.content.impl.ContentScoreboardPlayers;
import exopandora.worldhandler.gui.content.impl.ContentPotions;
import exopandora.worldhandler.gui.content.impl.ContentRecipes;
-import exopandora.worldhandler.gui.content.impl.ContentScoreboardObjectives;
-import exopandora.worldhandler.gui.content.impl.ContentScoreboardPlayers;
-import exopandora.worldhandler.gui.content.impl.ContentScoreboardTeams;
+import exopandora.worldhandler.gui.content.impl.ContentSettings;
import exopandora.worldhandler.gui.content.impl.ContentSignEditor;
import exopandora.worldhandler.gui.content.impl.ContentSummon;
+import exopandora.worldhandler.gui.content.impl.ContentScoreboardTeams;
import exopandora.worldhandler.gui.content.impl.ContentWorldInfo;
import net.minecraft.util.ResourceLocation;
-import net.minecraft.util.registry.RegistryNamespaced;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraft.util.registry.IRegistry;
+import net.minecraft.util.registry.RegistryNamespacedDefaultedByKey;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+import net.minecraftforge.registries.ForgeRegistryEntry;
-@SideOnly(Side.CLIENT)
-public abstract class Content implements IContent
+@OnlyIn(Dist.CLIENT)
+public abstract class Content extends ForgeRegistryEntry implements IContent
{
- public static final RegistryNamespaced REGISTRY = new RegistryNamespaced();
+ public static final String NAMESPACE = String.join("_", new String[] {Main.MODID, "content"});
+ public static final IRegistry REGISTRY = IRegistry.func_212610_a(NAMESPACE, new RegistryNamespacedDefaultedByKey(new ResourceLocation(NAMESPACE, "main")));
public static void registerContents()
{
@@ -78,36 +83,38 @@ public abstract class Content implements IContent
//NO CATEGORY
registerContent(20, "potions", new ContentPotions());
registerContent(21, "butcher", new ContentButcher());
+ registerContent(22, "butcher_settings", new ContentButcherSettings());
+ registerContent(23, "settings", new ContentSettings());
}
- private static void registerContent(int id, String textualID, Content content)
- {
- registerContent(id, new ResourceLocation(Main.MODID, textualID), content);
- }
-
- private static void registerContent(int id, ResourceLocation textualID, Content content)
- {
- REGISTRY.register(id, textualID, content);
- }
-
- private Map