diff --git a/.gitignore b/.gitignore index 30c2437..6bb5f66 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,9 @@ # Except !/src/ +!/gradle/ +!gradlew +!gradlew.bat !build.gradle !README.md !version.json \ No newline at end of file diff --git a/README.md b/README.md index 9021bf1..2c37671 100644 --- a/README.md +++ b/README.md @@ -8,42 +8,60 @@ Curseforge: https://minecraft.curseforge.com/projects/world-handler-command-gui # Features # * GUI for Commands - * Client Commands - * /advancement - * /blockdata - * /time - * /difficulty - * /weather - * /kill - * /give - * /effect - * /gamemode - * /setworldspawn - * /spawnpoint - * /clear - * /summon - * /enchant - * /xp - * /scoreboard - * /gamerule - * /fill - * /clone - - * Server Commands - * /kick - * /ban - * /pardon - * /op - * /deop - * /save-all - * /save-on - * /save-off - * /whitelist - * Biome Indicator * World and Player Information * Simplified usage for /fill and /clone + + + + + + + + + +
+ Featured Client Commands
+
+ Featured Server Commands
+
+
    +
  • /advancement
  • +
  • /blockdata
  • +
  • /clear
  • +
  • /clone
  • +
  • /difficulty
  • +
  • /effect
  • +
  • /enchant
  • +
  • /fill
  • +
  • /gamemode
  • +
  • /gamerule
  • +
  • /give
  • +
  • /kill
  • +
  • /recipe
  • +
  • /scoreboard
  • +
  • /setworldspawn
  • +
  • /spawnpoint
  • +
  • /summon
  • +
  • /time
  • +
  • /weather
  • +
  • /xp
  • +
+
+
    +
  • /ban
  • +
  • /deop
  • +
  • /kick
  • +
  • /op
  • +
  • /pardon
  • +
  • /save-all
  • +
  • /save-off
  • +
  • /save-on
  • +
  • /whitelist
  • +
+
+ # Download # Compiled and signed versions: https://minecraft.curseforge.com/projects/world-handler-command-gui/files Requires: Minecraft Forge (http://files.minecraftforge.net/) diff --git a/build.gradle b/build.gradle index 28ca043..38aac18 100644 --- a/build.gradle +++ b/build.gradle @@ -10,9 +10,15 @@ buildscript { 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. +def mcversion = "1.12.2" +def modversion = "2.1.4" +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.12.2-2.0" -group = "src.worldhandler.main.WorldHandler" // http://maven.apache.org/guides/mini/guide-naming-conventions.html +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. @@ -22,12 +28,34 @@ compileJava { jar { manifest { - attributes 'Main-Class': 'exopandora.worldhandler.main.Main' + 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 +} + minecraft { - version = "1.12.2-14.23.2.2611" + version = "1.12.2-14.23.3.2676" runDir = "run" // the mappings can be changed at any time, and must be in the following format. diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..911de12 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,3 @@ +# Sets default memory used for gradle commands. Can be overridden by user or command line properties. +# This is required to provide enough memory for the Minecraft decompilation process. +org.gradle.jvmargs=-Xmx3G \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..30d399d Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..e18cba7 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#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 diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..91a7e26 --- /dev/null +++ b/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# 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" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..8a0b282 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@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 Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz 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. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +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 + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/src/main/java/exopandora/worldhandler/main/Main.java b/src/main/java/exopandora/worldhandler/Main.java similarity index 67% rename from src/main/java/exopandora/worldhandler/main/Main.java rename to src/main/java/exopandora/worldhandler/Main.java index 15f96af..ddb79d8 100644 --- a/src/main/java/exopandora/worldhandler/main/Main.java +++ b/src/main/java/exopandora/worldhandler/Main.java @@ -1,4 +1,4 @@ -package exopandora.worldhandler.main; +package exopandora.worldhandler; import java.awt.EventQueue; import java.io.File; @@ -15,13 +15,6 @@ public class Main { public static final String NAME = "World Handler"; public static final String MODID = "worldhandler"; - public static final String MC_VERSION = "1.12.2"; - public static final String MC_COMPATIBLE = "1.12"; - public static final String VERSION = "2.1"; - public static final String FULL_VERSION = MC_VERSION + "-" + VERSION; - public static final String NAME_AND_VERSION = NAME + " " + FULL_VERSION; - public static final String URL = "https://minecraft.curseforge.com/projects/world-handler-command-gui"; - public static final String UPDATE_URL = "https://raw.githubusercontent.com/Exopandora/worldhandler/master/version.json"; public static void main(String[] args) { diff --git a/src/main/java/exopandora/worldhandler/main/WorldHandler.java b/src/main/java/exopandora/worldhandler/WorldHandler.java similarity index 69% rename from src/main/java/exopandora/worldhandler/main/WorldHandler.java rename to src/main/java/exopandora/worldhandler/WorldHandler.java index fc9cf9a..703de49 100644 --- a/src/main/java/exopandora/worldhandler/main/WorldHandler.java +++ b/src/main/java/exopandora/worldhandler/WorldHandler.java @@ -1,158 +1,171 @@ -package exopandora.worldhandler.main; - -import org.apache.commons.lang3.ArrayUtils; -import org.apache.logging.log4j.Logger; -import org.lwjgl.input.Keyboard; - -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.gui.category.Category; -import exopandora.worldhandler.gui.content.Content; -import exopandora.worldhandler.helper.BlockHelper; -import exopandora.worldhandler.proxy.CommonProxy; -import net.minecraft.client.Minecraft; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.command.ICommand; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.config.Configuration; -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.SidedProxy; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -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; - -@SideOnly(Side.CLIENT) -@Mod(modid = Main.MODID, name = Main.NAME, acceptedMinecraftVersions = "[" + Main.MC_COMPATIBLE + ",)", version = Main.VERSION, canBeDeactivated = false, guiFactory = "exopandora.worldhandler.gui.config.GuiFactoryWorldHandler", updateJSON = Main.UPDATE_URL, clientSideOnly = true) -public class WorldHandler -{ - @Instance(Main.MODID) - public WorldHandler INSTANCE; - - 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 Logger LOGGER; - - public static final ICommand COMMAND_WORLD_HANDLER = new CommandWorldHandler(); - public static final ICommand COMMAND_WH = new CommandWH(); - - public static Configuration CONFIG; - - public static String USERNAME = null; - - @SidedProxy(clientSide = "exopandora.worldhandler.proxy.ClientProxy", serverSide = "exopandora.worldhandler.proxy.CommonProxy") - public static CommonProxy PROXY; - - @EventHandler - public void preInit(FMLPreInitializationEvent event) - { - LOGGER = event.getModLog(); - LOGGER.info("Pre-Initializing " + Main.NAME_AND_VERSION); - LOGGER.info("First Release on March 28 2013 - 02:29 PM CET by Exopandora"); - LOGGER.info("Latest Version: " + Main.URL); - CONFIG = new Configuration(event.getSuggestedConfigurationFile()); - - ConfigSettings.load(CONFIG); - ConfigSkin.load(CONFIG); - ConfigSliders.load(CONFIG); - } - - @EventHandler - public void init(FMLInitializationEvent event) - { - LOGGER.info("Initializing " + Main.NAME_AND_VERSION); - USERNAME = Minecraft.getMinecraft().getSession().getUsername(); - - MinecraftForge.EVENT_BUS.register(new exopandora.worldhandler.event.EventHandler()); - ClientRegistry.registerKeyBinding(KEY_WORLD_HANDLER); - updateKeyBindings(); - } - - @EventHandler - public void postInit(FMLPostInitializationEvent event) - { - LOGGER.info("Post-Initializing " + Main.NAME_AND_VERSION); - LOGGER.info("Every mod that has not been registered to this point may not be fully featured in this mod"); - - ConfigButcher.load(CONFIG); - Content.registerContents(); - Category.registerCategories(); - } - - @EventHandler - public void serverLoad(FMLServerStartingEvent event) - { - event.registerServerCommand(COMMAND_WORLD_HANDLER); - event.registerServerCommand(COMMAND_WH); - } - - public static void updateConfig() - { - ConfigSettings.load(CONFIG); - ConfigSkin.load(CONFIG); - ConfigButcher.load(CONFIG); - ConfigSliders.load(CONFIG); - updateKeyBindings(); - } - - public static void updateKeyBindings() - { - boolean isRegistered = ArrayUtils.contains(Minecraft.getMinecraft().gameSettings.keyBindings, KEY_WORLD_HANDLER_POS1) || ArrayUtils.contains(Minecraft.getMinecraft().gameSettings.keyBindings, KEY_WORLD_HANDLER_POS2); - - if(ConfigSettings.arePosShortcutsEnabled() && !isRegistered) - { - ClientRegistry.registerKeyBinding(KEY_WORLD_HANDLER_POS1); - ClientRegistry.registerKeyBinding(KEY_WORLD_HANDLER_POS2); - } - else if(!ConfigSettings.arePosShortcutsEnabled() && isRegistered) - { - Minecraft.getMinecraft().gameSettings.keyBindings = ArrayUtils.removeElements(Minecraft.getMinecraft().gameSettings.keyBindings, KEY_WORLD_HANDLER_POS1, KEY_WORLD_HANDLER_POS2); - } - } - - 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); - } - } - } +package exopandora.worldhandler; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Keyboard; + +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.gui.category.Category; +import exopandora.worldhandler.gui.content.Content; +import exopandora.worldhandler.helper.BlockHelper; +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.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.config.Configuration; +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; + +@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") +public class WorldHandler +{ + @Instance(Main.MODID) + private static WorldHandler INSTANCE; + + 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 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(); + + @EventHandler + public void preInit(FMLPreInitializationEvent event) + { + 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()); + } + + @EventHandler + public void init(FMLInitializationEvent event) + { + LOGGER.info("Initialization"); + USERNAME = Minecraft.getMinecraft().getSession().getUsername(); + + MinecraftForge.EVENT_BUS.register(this.eventListener); + ClientRegistry.registerKeyBinding(KEY_WORLD_HANDLER); + UtilKeyBinding.updatePosKeys(); + } + + @EventHandler + public void postInit(FMLPostInitializationEvent 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) + { + 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); + } + } + } } \ 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 cc52194..ed27226 100644 --- a/src/main/java/exopandora/worldhandler/builder/CommandBuilder.java +++ b/src/main/java/exopandora/worldhandler/builder/CommandBuilder.java @@ -1,19 +1,18 @@ package exopandora.worldhandler.builder; -import java.util.AbstractMap; -import java.util.ArrayList; +import java.util.AbstractMap.SimpleEntry; import java.util.List; import java.util.Map.Entry; import java.util.stream.Collectors; 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.TargetSelector; import exopandora.worldhandler.builder.types.Type; -import exopandora.worldhandler.main.WorldHandler; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; @@ -232,20 +231,34 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax { if(syntax != null) { - this.command = syntax.getSyntaxEntries().stream().map(entry -> new AbstractMap.SimpleEntry(entry, entry.toString())).collect(Collectors.toList()); + this.command = syntax.getSyntaxEntries().stream().map(entry -> new SimpleEntry(entry, entry.toString())).collect(Collectors.toList()); } } @Override public String toCommand() { - return "/" + this.getCommandName() + " " + String.join(" ", this.command.stream().map(entry -> this.isDefaultEntry(entry) ? entry.getKey().toString() : entry.getValue()).collect(Collectors.toList())); + CommandString command = new CommandString(this.getCommandName()); + + for(Entry entry : this.command) + { + if(this.isDefaultEntry(entry)) + { + command.append(entry.getKey().toString()); + } + else + { + command.append(entry.getValue()); + } + } + + return command.toString(); } @Override public String toActualCommand() { - List command = new ArrayList(); + CommandString command = new CommandString(this.getCommandName()); for(Entry entry : this.command) { @@ -254,9 +267,9 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax break; } - command.add(entry.getValue()); + command.append(entry.getValue()); } - return "/" + this.getCommandName() + " " + String.join(" ", command); + return command.toString(); } } diff --git a/src/main/java/exopandora/worldhandler/builder/CommandString.java b/src/main/java/exopandora/worldhandler/builder/CommandString.java new file mode 100644 index 0000000..c69a1ff --- /dev/null +++ b/src/main/java/exopandora/worldhandler/builder/CommandString.java @@ -0,0 +1,52 @@ +package exopandora.worldhandler.builder; + +import com.mojang.realmsclient.gui.ChatFormatting; + +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class CommandString +{ + private final StringBuilder command = new StringBuilder("/"); + + public CommandString(String name) + { + this.command.append(name); + } + + public CommandString(String name, String... arguments) + { + this(name); + this.append(arguments); + } + + public void append(String argument) + { + if(argument != null && !argument.isEmpty()) + { + this.command.append(" " + argument); + } + else + { + this.command.append(" " + ChatFormatting.RED + "[error]" + ChatFormatting.RESET); + } + } + + public void append(String... arguments) + { + if(arguments != null) + { + for(String argument : arguments) + { + this.append(argument); + } + } + } + + @Override + public String toString() + { + return this.command.toString(); + } +} 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 057e79a..14180d5 100644 --- a/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentTag.java +++ b/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentTag.java @@ -4,8 +4,8 @@ import java.util.function.Function; import javax.annotation.Nullable; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.component.IBuilderComponent; -import exopandora.worldhandler.main.WorldHandler; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagByte; import net.minecraft.nbt.NBTTagByteArray; diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderAdvancement.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderAdvancement.java index 0f9868b..c6d9a20 100644 --- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderAdvancement.java +++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderAdvancement.java @@ -1,5 +1,7 @@ package exopandora.worldhandler.builder.impl; +import javax.annotation.Nullable; + import exopandora.worldhandler.builder.CommandBuilder; import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.types.Type; @@ -28,7 +30,8 @@ public class BuilderAdvancement extends CommandBuilder { this.setNode(0, action != null ? action.toString() : null); } - + + @Nullable public EnumActionType getActionType() { return EnumHelper.valueOf(EnumActionType.class, this.getNodeAsString(1)); @@ -38,7 +41,8 @@ public class BuilderAdvancement extends CommandBuilder { this.setNode(1, player); } - + + @Nullable public String getPlayer() { return this.getNodeAsString(1); @@ -48,7 +52,8 @@ public class BuilderAdvancement extends CommandBuilder { this.setNode(2, mode != null ? mode.toString() : null); } - + + @Nullable public EnumMode getMode() { return EnumHelper.valueOf(EnumMode.class, this.getNodeAsString(2)); @@ -58,7 +63,8 @@ public class BuilderAdvancement extends CommandBuilder { this.setNode(3, advancement); } - + + @Nullable public ResourceLocation getAdvancement() { return this.getNodeAsResourceLocation(3); @@ -92,7 +98,8 @@ public class BuilderAdvancement extends CommandBuilder return syntax; } - + + @SideOnly(Side.CLIENT) public static enum EnumActionType { GRANT, @@ -105,6 +112,7 @@ public class BuilderAdvancement extends CommandBuilder } } + @SideOnly(Side.CLIENT) public static enum EnumMode { ONLY, diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderButcher.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderButcher.java index fd4e1d3..75a59d4 100644 --- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderButcher.java +++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderButcher.java @@ -1,5 +1,8 @@ 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; @@ -30,7 +33,8 @@ public class BuilderButcher extends CommandBuilder this.targetSelector.set("r", radius); this.setNode(0, this.targetSelector); } - + + @Nonnull public int getRadius() { return this.targetSelector.get("r"); @@ -42,6 +46,7 @@ public class BuilderButcher extends CommandBuilder this.setNode(0, this.targetSelector); } + @Nonnull public ResourceLocation getEntity() { return this.targetSelector.get("type"); diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderClone.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderClone.java index 44b6c17..e828fe2 100644 --- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderClone.java +++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderClone.java @@ -129,6 +129,7 @@ public class BuilderClone extends BuilderDoubleBlockPos return syntax; } + @SideOnly(Side.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 a0611a2..1a610d5 100644 --- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderCustomItem.java +++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderCustomItem.java @@ -25,12 +25,9 @@ public class BuilderCustomItem extends BuilderGive this(null, null); } - public BuilderCustomItem(String username, ResourceLocation item) + public BuilderCustomItem(String player, ResourceLocation item) { - this.setPlayer(username); - this.setItem(item); - this.setAmount(1); - this.setMetadata(0); + super(player, item); this.attribute = this.registerNBTComponent(new ComponentAttributeItem(attribute -> attribute.getApplyable().equals(Applyable.BOTH) || attribute.getApplyable().equals(Applyable.PLAYER))); this.display = this.registerNBTComponent(new ComponentDisplay()); this.enchantment = this.registerNBTComponent(new ComponentEnchantment()); diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderDifficulty.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderDifficulty.java index 348a31a..e8fbacd 100644 --- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderDifficulty.java +++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderDifficulty.java @@ -3,6 +3,8 @@ 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; public class BuilderDifficulty extends CommandBuilder { @@ -37,6 +39,7 @@ public class BuilderDifficulty extends CommandBuilder return syntax; } + @SideOnly(Side.CLIENT) public static enum EnumDifficulty { PEACEFUL, diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderFill.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderFill.java index 1fca3af..a420e09 100644 --- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderFill.java +++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderFill.java @@ -148,6 +148,7 @@ public class BuilderFill extends BuilderDoubleBlockPos return syntax; } + @SideOnly(Side.CLIENT) public static enum EnumBlockHandling { REPLACE, diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderGamemode.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderGamemode.java index b2a57e6..6382650 100644 --- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderGamemode.java +++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderGamemode.java @@ -3,6 +3,8 @@ 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; public class BuilderGamemode extends CommandBuilder { @@ -49,6 +51,7 @@ public class BuilderGamemode extends CommandBuilder return syntax; } + @SideOnly(Side.CLIENT) public static enum EnumGamemode { SURVIVAL, diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderGeneric.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderGeneric.java index 739c145..b27e693 100644 --- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderGeneric.java +++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderGeneric.java @@ -1,5 +1,6 @@ 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; @@ -19,7 +20,7 @@ public class BuilderGeneric implements ICommandBuilder @Override public String toCommand() { - return "/" + this.command + " " + String.join(" ", this.arguments); + return new CommandString(this.command, this.arguments).toString(); } public String toActualCommand() diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderGive.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderGive.java index 2c0aa17..ab2a6c2 100644 --- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderGive.java +++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderGive.java @@ -16,6 +16,7 @@ public class BuilderGive extends CommandBuilderNBT { this.setPlayer(player); this.setItem(item); + this.setAmount(1); this.setMetadata(0); } diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderPotionItem.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderPotionItem.java index a1257b6..7587abc 100644 --- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderPotionItem.java +++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderPotionItem.java @@ -21,9 +21,7 @@ public class BuilderPotionItem extends BuilderGive public BuilderPotionItem(ResourceLocation item, String player, ComponentPotionItem potion) { - this.setItem(item); - this.setPlayer(player); - this.setAmount(1); + super(player, item); this.potion = this.registerNBTComponent(potion); } diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderRecipe.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderRecipe.java new file mode 100644 index 0000000..a97899e --- /dev/null +++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderRecipe.java @@ -0,0 +1,97 @@ +package exopandora.worldhandler.builder.impl; + +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.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class BuilderRecipe extends CommandBuilder +{ + public BuilderRecipe() + { + this(null, null, null); + } + + public BuilderRecipe(EnumMode mode, String player, ResourceLocation recipe) + { + this.setMode(mode); + this.setPlayer(player); + this.setRecipe(recipe); + } + + public void setMode(EnumMode mode) + { + this.setNode(0, mode != null ? mode.toString() : null); + } + + @Nullable + public EnumMode getMode() + { + return EnumHelper.valueOf(EnumMode.class, this.getNodeAsString(0)); + } + + public void setPlayer(String player) + { + this.setNode(1, player); + } + + @Nullable + public String getPlayer() + { + return this.getNodeAsString(1); + } + + public void setRecipe(ResourceLocation recipe) + { + this.setNode(2, recipe); + } + + @Nullable + public ResourceLocation getRecipe() + { + return this.getNodeAsResourceLocation(2); + } + + public BuilderRecipe getBuilderForMode(EnumMode mode) + { + return new BuilderRecipe(mode, this.getPlayer(), this.getRecipe()); + } + + @Override + public String getCommandName() + { + return "recipe"; + } + + @Override + public Syntax getSyntax() + { + Syntax syntax = new Syntax(); + + syntax.addRequired("give|take", Type.STRING); + syntax.addOptional("player", Type.STRING); + syntax.addOptional("recipe", Type.RESOURCE_LOCATION); + + return syntax; + } + + @SideOnly(Side.CLIENT) + public static enum EnumMode + { + GIVE, + TAKE; + + @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 61d3877..d4182f5 100644 --- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderScoreboardPlayers.java +++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderScoreboardPlayers.java @@ -204,6 +204,7 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard return syntax; } + @SideOnly(Side.CLIENT) public static enum EnumTag { ADD, @@ -216,6 +217,7 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard } } + @SideOnly(Side.CLIENT) public static enum EnumPoints { ADD, diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderScoreboardTeams.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderScoreboardTeams.java index ba086d8..5de448a 100644 --- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderScoreboardTeams.java +++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderScoreboardTeams.java @@ -238,6 +238,7 @@ public class BuilderScoreboardTeams extends BuilderScoreboard return syntax; } + @SideOnly(Side.CLIENT) public static enum EnumMode { JOIN, diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderTime.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderTime.java index 0eb9ad9..2bfd052 100644 --- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderTime.java +++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderTime.java @@ -3,6 +3,8 @@ 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; public class BuilderTime extends CommandBuilder { @@ -49,6 +51,7 @@ public class BuilderTime extends CommandBuilder return syntax; } + @SideOnly(Side.CLIENT) public static enum EnumMode { ADD, diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderWeather.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderWeather.java index 61d05d4..5818299 100644 --- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderWeather.java +++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderWeather.java @@ -3,6 +3,8 @@ 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; public class BuilderWeather extends CommandBuilder { @@ -49,6 +51,7 @@ public class BuilderWeather extends CommandBuilder return syntax; } + @SideOnly(Side.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 c03eab8..d0d9ed6 100644 --- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderWhitelist.java +++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderWhitelist.java @@ -76,6 +76,7 @@ public class BuilderWhitelist extends CommandBuilder return syntax; } + @SideOnly(Side.CLIENT) public static enum EnumMode { ADD, diff --git a/src/main/java/exopandora/worldhandler/builder/types/Level.java b/src/main/java/exopandora/worldhandler/builder/types/Level.java index c6c580a..17e1805 100644 --- a/src/main/java/exopandora/worldhandler/builder/types/Level.java +++ b/src/main/java/exopandora/worldhandler/builder/types/Level.java @@ -1,5 +1,7 @@ package exopandora.worldhandler.builder.types; +import javax.annotation.Nullable; + import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -28,6 +30,7 @@ public class Level this.level = level; } + @Nullable public static Level valueOf(String value) { if(value != null) diff --git a/src/main/java/exopandora/worldhandler/builder/types/TargetSelector.java b/src/main/java/exopandora/worldhandler/builder/types/TargetSelector.java index d00afbf..c27e711 100644 --- a/src/main/java/exopandora/worldhandler/builder/types/TargetSelector.java +++ b/src/main/java/exopandora/worldhandler/builder/types/TargetSelector.java @@ -4,6 +4,9 @@ import java.util.HashMap; import java.util.Map; 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; @@ -17,7 +20,8 @@ public class TargetSelector { this.values.put(id.toLowerCase(), value); } - + + @Nullable public T get(String id) { return (T) this.values.get(id); @@ -28,6 +32,7 @@ public class TargetSelector return this.values.remove(id.toLowerCase()); } + @Nonnull public static TargetSelector valueOf(String input) { if(input.matches(REGEX)); diff --git a/src/main/java/exopandora/worldhandler/command/CommandWH.java b/src/main/java/exopandora/worldhandler/command/CommandWH.java index 4e10c29..aa4ec6e 100644 --- a/src/main/java/exopandora/worldhandler/command/CommandWH.java +++ b/src/main/java/exopandora/worldhandler/command/CommandWH.java @@ -5,6 +5,7 @@ import java.util.Collections; import java.util.List; import java.util.stream.Collectors; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.impl.BuilderClone; import exopandora.worldhandler.builder.impl.BuilderClone.EnumMask; import exopandora.worldhandler.builder.impl.BuilderFill; @@ -12,7 +13,6 @@ import exopandora.worldhandler.builder.impl.BuilderWH; import exopandora.worldhandler.helper.BlockHelper; import exopandora.worldhandler.helper.EnumHelper; import exopandora.worldhandler.helper.ResourceHelper; -import exopandora.worldhandler.main.WorldHandler; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.command.CommandBase; diff --git a/src/main/java/exopandora/worldhandler/command/CommandWorldHandler.java b/src/main/java/exopandora/worldhandler/command/CommandWorldHandler.java index 5b3eb2b..404efc4 100644 --- a/src/main/java/exopandora/worldhandler/command/CommandWorldHandler.java +++ b/src/main/java/exopandora/worldhandler/command/CommandWorldHandler.java @@ -5,10 +5,10 @@ import java.util.List; import com.mojang.realmsclient.gui.ChatFormatting; +import exopandora.worldhandler.Main; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.impl.BuilderWorldHandler; -import exopandora.worldhandler.event.EventHandler; -import exopandora.worldhandler.main.Main; -import exopandora.worldhandler.main.WorldHandler; +import exopandora.worldhandler.event.EventListener; import net.minecraft.client.Minecraft; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; @@ -49,13 +49,13 @@ public class CommandWorldHandler extends CommandBase } else if(args[0].equalsIgnoreCase("display")) { - new Thread(() -> Minecraft.getMinecraft().addScheduledTask(EventHandler::displayGui)).start(); + Minecraft.getMinecraft().addScheduledTask(EventListener::displayGui); } else if(args[0].equalsIgnoreCase("version")) { - sender.sendMessage(new TextComponentString("Installed: " + Main.MC_VERSION + "-" + Main.VERSION)); + sender.sendMessage(new TextComponentString("Installed: $mcversion-$version")); ComparableVersion target = ForgeVersion.getResult(Loader.instance().getIndexedModList().get(Main.MODID)).target; - sender.sendMessage(new TextComponentString("Latest: " + Main.MC_VERSION + "-" + (target != null ? target : Main.VERSION))); + sender.sendMessage(new TextComponentString("Latest: $mcversion-" + (target != null ? target : "$version"))); } else { diff --git a/src/main/java/exopandora/worldhandler/command/FakeCommandHandler.java b/src/main/java/exopandora/worldhandler/command/FakeCommandHandler.java index 1b0c332..68580eb 100644 --- a/src/main/java/exopandora/worldhandler/command/FakeCommandHandler.java +++ b/src/main/java/exopandora/worldhandler/command/FakeCommandHandler.java @@ -37,7 +37,7 @@ public class FakeCommandHandler extends CommandHandler public void tryCommand(ICommand command, ClientChatEvent event) { - if(event.getMessage().startsWith("/" + command.getName()) || event.getMessage().startsWith("/" + command.getName() + " ")) + if(event.getMessage().equals("/" + command.getName()) || event.getMessage().startsWith("/" + command.getName() + " ")) { this.fakeCommand(command, event); } diff --git a/src/main/java/exopandora/worldhandler/config/ConfigSettings.java b/src/main/java/exopandora/worldhandler/config/ConfigSettings.java index f1b59df..06cc6ff 100644 --- a/src/main/java/exopandora/worldhandler/config/ConfigSettings.java +++ b/src/main/java/exopandora/worldhandler/config/ConfigSettings.java @@ -18,6 +18,7 @@ public class ConfigSettings private static boolean PAUSE; private static boolean CUSTOM_TIMES; private static boolean PERMISSION_QEURY; + private static boolean HIGHLIGHT_BLOCKS; private static int DAWN; private static int NOON; @@ -40,6 +41,7 @@ public class ConfigSettings 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_QEURY = 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"); @@ -101,7 +103,12 @@ public class ConfigSettings { return PERMISSION_QEURY; } - + + public static boolean isHighlightBlocksEnabled() + { + return HIGHLIGHT_BLOCKS; + } + public static int getDawn() { return DAWN; diff --git a/src/main/java/exopandora/worldhandler/event/EventHandler.java b/src/main/java/exopandora/worldhandler/event/EventListener.java similarity index 50% rename from src/main/java/exopandora/worldhandler/event/EventHandler.java rename to src/main/java/exopandora/worldhandler/event/EventListener.java index 81fcf47..02d464b 100644 --- a/src/main/java/exopandora/worldhandler/event/EventHandler.java +++ b/src/main/java/exopandora/worldhandler/event/EventListener.java @@ -2,41 +2,102 @@ 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.main.Main; -import exopandora.worldhandler.main.WorldHandler; 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.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; +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 EventHandler +public class EventListener { private final FakeCommandHandler commandHandler = new FakeCommandHandler(); + private final BiomeIndicator biomeIndicator = new BiomeIndicator(); @SubscribeEvent - public void clientTickEvent(TickEvent.ClientTickEvent event) + 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()) { - BiomeIndicator.tick(); + this.biomeIndicator.tick(); } } } diff --git a/src/main/java/exopandora/worldhandler/gui/button/GuiButtonKeyboard.java b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonKeyboard.java index cd04ba4..6190686 100644 --- a/src/main/java/exopandora/worldhandler/gui/button/GuiButtonKeyboard.java +++ b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonKeyboard.java @@ -2,10 +2,10 @@ package exopandora.worldhandler.gui.button; import org.lwjgl.input.Mouse; +import exopandora.worldhandler.Main; import exopandora.worldhandler.config.ConfigSkin; import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.content.Content; -import exopandora.worldhandler.main.Main; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.audio.SoundHandler; diff --git a/src/main/java/exopandora/worldhandler/gui/button/GuiButtonList.java b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonList.java index e8dd642..7a02174 100644 --- a/src/main/java/exopandora/worldhandler/gui/button/GuiButtonList.java +++ b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonList.java @@ -4,12 +4,13 @@ import com.mojang.realmsclient.gui.ChatFormatting; import exopandora.worldhandler.format.TextFormatting; import exopandora.worldhandler.gui.button.logic.IListButtonLogic; -import exopandora.worldhandler.gui.button.storage.ButtonStorage; +import exopandora.worldhandler.gui.button.persistence.ButtonValues; import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.content.Content; 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; @@ -17,21 +18,21 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class GuiButtonList extends GuiButtonWorldHandler { private final IListButtonLogic logic; - private final ButtonStorage storage; + private final ButtonValues persistence; private int mouseX; private int mouseY; - public GuiButtonList(int id, int x, int y, int width, int height, Content container, IListButtonLogic logic) + public GuiButtonList(int id, int x, int y, int width, int height, Content content, IListButtonLogic logic) { - this(id, x, y, width, height, null, container, logic); + this(id, x, y, width, height, null, content, logic); } - public GuiButtonList(int id, int x, int y, int width, int height, EnumTooltip tooltipType, Content container, IListButtonLogic logic) + public GuiButtonList(int id, int x, int y, int width, int height, EnumTooltip tooltipType, Content content, IListButtonLogic logic) { super(id, x, y, width, height, null, null, tooltipType); this.logic = logic; - this.storage = container.getStorage(this.logic.getId()); - this.updateStorageObject(); + this.persistence = content.getPersistence(this.logic.getId()); + this.updatePersistenceObject(); } @Override @@ -46,7 +47,7 @@ public class GuiButtonList extends GuiButtonWorldHandler this.mouseX = mouseX; this.mouseY = mouseY; - this.displayString = this.logic.getDisplayString(this.storage); + this.displayString = this.logic.getDisplayString(this.persistence); if(this.displayString != null && !this.displayString.isEmpty()) { @@ -77,7 +78,7 @@ public class GuiButtonList extends GuiButtonWorldHandler { if(this.tooltipType != null) { - this.displayTooltip = this.logic.getTooltipString(this.storage); + this.displayTooltip = this.logic.getTooltipString(this.persistence); } super.drawTooltip(mouseX, mouseY, width, height); @@ -100,36 +101,67 @@ public class GuiButtonList extends GuiButtonWorldHandler public void actionPerformed(Container container, GuiButton button) { + int max = this.logic.getMax() - 1; + int index = this.persistence.getIndex(); + if(this.isHoveringLeft(this.mouseX, this.mouseY)) { - if(this.storage.getIndex() > 0) + if(GuiScreen.isShiftKeyDown()) { - this.storage.decrementIndex(); + if(index < 10) + { + this.persistence.setIndex(max - (9 - index)); + } + else + { + this.persistence.decrementIndex(10); + } } else { - this.storage.setIndex(this.logic.getMax() - 1); + if(index > 0) + { + this.persistence.decrementIndex(); + } + else + { + this.persistence.setIndex(max); + } } } else if(this.isHoveringRight(this.mouseX, this.mouseY)) { - if(this.storage.getIndex() < this.logic.getMax() - 1) + if(GuiScreen.isShiftKeyDown()) { - this.storage.incrementIndex(); + if(index > max - 10) + { + this.persistence.setIndex(9 - (max - index)); + } + else + { + this.persistence.incrementIndex(10); + } } else { - this.storage.setIndex(0); + if(index < max) + { + this.persistence.incrementIndex(); + } + else + { + this.persistence.setIndex(0); + } } } - this.updateStorageObject(); - this.logic.actionPerformed(container, button, this.storage); + this.updatePersistenceObject(); + this.logic.actionPerformed(container, button, this.persistence); } - private void updateStorageObject() + private void updatePersistenceObject() { - this.storage.setObject(this.logic.getObject(this.storage.getIndex())); + this.persistence.setObject(this.logic.getObject(this.persistence.getIndex())); } public IListButtonLogic getLogic() diff --git a/src/main/java/exopandora/worldhandler/gui/button/GuiSlider.java b/src/main/java/exopandora/worldhandler/gui/button/GuiSlider.java index 42ca799..835da31 100644 --- a/src/main/java/exopandora/worldhandler/gui/button/GuiSlider.java +++ b/src/main/java/exopandora/worldhandler/gui/button/GuiSlider.java @@ -2,8 +2,8 @@ package exopandora.worldhandler.gui.button; import exopandora.worldhandler.config.ConfigSkin; import exopandora.worldhandler.gui.button.logic.ISliderResponder; -import exopandora.worldhandler.gui.button.storage.ButtonStorage; -import exopandora.worldhandler.gui.button.storage.SliderStorage; +import exopandora.worldhandler.gui.button.persistence.ButtonValues; +import exopandora.worldhandler.gui.button.persistence.SliderValues; import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.content.Content; import exopandora.worldhandler.helper.ResourceHelper; @@ -25,67 +25,64 @@ public class GuiSlider extends GuiButton private final String name; private final ISliderResponder responder; private final Container frame; - private final ButtonStorage storage; + private final ButtonValues persistence; - public GuiSlider(Content container, Container frame, Object key, int x, int y, int width, int height, String name, double min, double max, double start, ISliderResponder responder) + 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) { super(Integer.MAX_VALUE, x, y, width, height, null); this.frame = frame; this.key = key; this.name = name; this.responder = responder; - this.storage = container.getStorage(key); - this.initStorage(Math.round(min), Math.round(max), Math.round(start)); + this.persistence = content.getPersistence(key); + this.initValues(Math.round(min), Math.round(max), Math.round(start)); this.displayString = this.getDisplayString(); } - private void initStorage(double min, double max, double start) + private void initValues(double min, double max, double start) { - if(this.storage.getObject() == null || this.storage.getObject().getMin() != min || this.storage.getObject().getMax() != max) + if(this.persistence.getObject() == null) { - if(this.storage.getObject() == null) + if(min == max) { - if(min == max) - { - this.storage.setObject(new SliderStorage(min, max, 0)); - } - else - { - this.storage.setObject(new SliderStorage(min, max, (start - min) / (max - min))); - } + this.persistence.setObject(new SliderValues(min, max, 0.0D)); } else { - this.storage.setObject(new SliderStorage(min, max, (int) MathHelper.clamp(this.getValue(), min, max))); + this.persistence.setObject(new SliderValues(min, max, (start - min) / (max - min))); } } + else if(this.persistence.getObject().getMin() != min || this.persistence.getObject().getMax() != max) + { + this.persistence.setObject(new SliderValues(min, max, (int) MathHelper.clamp(this.getValue(), min, max))); + } } private void setPosition(double position) { - this.storage.getObject().setPosition(position); + this.persistence.getObject().setPosition(position); } private double getPosition() { - return this.storage.getObject().getPosition(); + return this.persistence.getObject().getPosition(); } private void setValue(int value) { - this.storage.getObject().setValue(value); + this.persistence.getObject().setValue(value); } private int getValue() { - return this.storage.getObject().getValue(); + return this.persistence.getObject().getValue(); } private String getDisplayString() { return this.responder.getText(this.key, I18n.format(this.name), this.getValue()); } - + @Override protected int getHoverState(boolean mouseOver) { @@ -191,7 +188,7 @@ public class GuiSlider extends GuiButton return false; } - + @Override public void mouseReleased(int mouseX, int mouseY) { diff --git a/src/main/java/exopandora/worldhandler/gui/button/logic/ColorListButtonLogic.java b/src/main/java/exopandora/worldhandler/gui/button/logic/ColorListButtonLogic.java index 3711650..a2350b6 100644 --- a/src/main/java/exopandora/worldhandler/gui/button/logic/ColorListButtonLogic.java +++ b/src/main/java/exopandora/worldhandler/gui/button/logic/ColorListButtonLogic.java @@ -5,7 +5,7 @@ import java.util.Arrays; import com.mojang.realmsclient.gui.ChatFormatting; import exopandora.worldhandler.format.EnumColor; -import exopandora.worldhandler.gui.button.storage.ButtonStorage; +import exopandora.worldhandler.gui.button.persistence.ButtonValues; import net.minecraft.client.resources.I18n; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -26,15 +26,15 @@ public abstract class ColorListButtonLogic implements IListButtonLogic } @Override - public String getTooltipString(ButtonStorage storage) + public String getTooltipString(ButtonValues values) { return null; } @Override - public String getDisplayString(ButtonStorage storage) + public String getDisplayString(ButtonValues values) { - EnumColor color = EnumColor.getColorFromId(storage.getIndex()); + EnumColor color = EnumColor.getColorFromId(values.getIndex()); return color + I18n.format("gui.worldhandler.color") + ": " + I18n.format("gui.worldhandler.color." + color.getFormat()); } diff --git a/src/main/java/exopandora/worldhandler/gui/button/logic/IListButtonLogic.java b/src/main/java/exopandora/worldhandler/gui/button/logic/IListButtonLogic.java index a5e1db4..0f3ce55 100644 --- a/src/main/java/exopandora/worldhandler/gui/button/logic/IListButtonLogic.java +++ b/src/main/java/exopandora/worldhandler/gui/button/logic/IListButtonLogic.java @@ -1,6 +1,6 @@ package exopandora.worldhandler.gui.button.logic; -import exopandora.worldhandler.gui.button.storage.ButtonStorage; +import exopandora.worldhandler.gui.button.persistence.ButtonValues; import exopandora.worldhandler.gui.container.Container; import net.minecraft.client.gui.GuiButton; import net.minecraftforge.fml.relauncher.Side; @@ -9,19 +9,19 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public interface IListButtonLogic { - void actionPerformed(Container container, GuiButton button, ButtonStorage storage); + void actionPerformed(Container container, GuiButton button, ButtonValues values); int getMax(); T getObject(int index); - String getDisplayString(ButtonStorage storage); + String getDisplayString(ButtonValues values); - default String getTooltipString(ButtonStorage storage) + default String getTooltipString(ButtonValues values) { - if(storage != null && storage.getObject() != null) + if(values != null && values.getObject() != null) { - return storage.getObject().toString() + " (" + (storage.getIndex() + 1) + "/" + this.getMax() + ")"; + return values.getObject().toString() + " (" + (values.getIndex() + 1) + "/" + this.getMax() + ")"; } return null; diff --git a/src/main/java/exopandora/worldhandler/gui/button/storage/ButtonStorage.java b/src/main/java/exopandora/worldhandler/gui/button/persistence/ButtonValues.java similarity index 68% rename from src/main/java/exopandora/worldhandler/gui/button/storage/ButtonStorage.java rename to src/main/java/exopandora/worldhandler/gui/button/persistence/ButtonValues.java index b8a6dc6..8f9018e 100644 --- a/src/main/java/exopandora/worldhandler/gui/button/storage/ButtonStorage.java +++ b/src/main/java/exopandora/worldhandler/gui/button/persistence/ButtonValues.java @@ -1,10 +1,10 @@ -package exopandora.worldhandler.gui.button.storage; +package exopandora.worldhandler.gui.button.persistence; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class ButtonStorage +public class ButtonValues { private int index; private T object; @@ -24,11 +24,21 @@ public class ButtonStorage 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; diff --git a/src/main/java/exopandora/worldhandler/gui/button/storage/SliderStorage.java b/src/main/java/exopandora/worldhandler/gui/button/persistence/SliderValues.java similarity index 71% rename from src/main/java/exopandora/worldhandler/gui/button/storage/SliderStorage.java rename to src/main/java/exopandora/worldhandler/gui/button/persistence/SliderValues.java index fd38fa8..01b54c3 100644 --- a/src/main/java/exopandora/worldhandler/gui/button/storage/SliderStorage.java +++ b/src/main/java/exopandora/worldhandler/gui/button/persistence/SliderValues.java @@ -1,26 +1,31 @@ -package exopandora.worldhandler.gui.button.storage; +package exopandora.worldhandler.gui.button.persistence; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; + @SideOnly(Side.CLIENT) -public class SliderStorage +public class SliderValues { private final double min; private final double max; private double position; - public SliderStorage(double min, double max, double position) + private SliderValues(double min, double max) { this.min = min; this.max = max; + } + + public SliderValues(double min, double max, double position) + { + this(min, max); this.position = position; } - public SliderStorage(double min, double max, int value) + public SliderValues(double min, double max, int value) { - this.min = min; - this.max = max; + this(min, max); this.position = this.valueToPosition(value); } @@ -56,6 +61,11 @@ public class SliderStorage 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/category/Categories.java b/src/main/java/exopandora/worldhandler/gui/category/Categories.java index d209df7..ecef943 100644 --- a/src/main/java/exopandora/worldhandler/gui/category/Categories.java +++ b/src/main/java/exopandora/worldhandler/gui/category/Categories.java @@ -1,6 +1,6 @@ package exopandora.worldhandler.gui.category; -import exopandora.worldhandler.main.Main; +import exopandora.worldhandler.Main; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; diff --git a/src/main/java/exopandora/worldhandler/gui/category/Category.java b/src/main/java/exopandora/worldhandler/gui/category/Category.java index 9c7338a..4ae1d3f 100644 --- a/src/main/java/exopandora/worldhandler/gui/category/Category.java +++ b/src/main/java/exopandora/worldhandler/gui/category/Category.java @@ -1,81 +1,81 @@ -package exopandora.worldhandler.gui.category; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.annotation.Nullable; - -import exopandora.worldhandler.gui.content.Content; -import exopandora.worldhandler.gui.content.Contents; -import exopandora.worldhandler.main.Main; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.registry.RegistryNamespaced; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class Category -{ - public static final RegistryNamespaced REGISTRY = new RegistryNamespaced(); - - private final List contents; - - public Category() - { - this.contents = new ArrayList(); - } - - public Category(List contents) - { - this.contents = contents; - } - - public Category(Content... contents) - { - this.contents = Arrays.asList(contents); - } - - public Category add(Content content) - { - this.contents.add(content); - return this; - } - - public List getContents() - { - return this.contents; - } - - public int getSize() - { - return this.contents.size(); - } - - @Nullable - public Content getContent(int index) - { - return this.contents.get(index); - } - - public static void registerCategories() - { - registerCategory(0, "main", new Category(Contents.MAIN, Contents.CONTAINERS, Contents.MULTIPLAYER)); - registerCategory(1, "entities", new Category(Contents.SUMMON)); - registerCategory(2, "items", new Category(Contents.CUSTOM_ITEM, Contents.ENCHANTMENT)); - registerCategory(3, "blocks", new Category(Contents.EDIT_BLOCKS, Contents.SIGN_EDITOR, Contents.NOTE_EDITOR)); - registerCategory(4, "world", new Category(Contents.WORLD_INFO, Contents.GAMERULES)); - registerCategory(5, "player", new Category(Contents.PLAYER, Contents.EXPERIENCE, Contents.ADVANCEMENTS)); - registerCategory(6, "scoreboard", new Category(Contents.SCOREBOARD_OBJECTIVES, Contents.SCOREBOARD_TEAMS, Contents.SCOREBOARD_PLAYERS)); - } - - private static void registerCategory(int id, String textualID, Category category) - { - registerCategory(id, new ResourceLocation(Main.MODID, textualID), category); - } - - private static void registerCategory(int id, ResourceLocation textualID, Category category) - { - REGISTRY.register(id, textualID, category); - } -} +package exopandora.worldhandler.gui.category; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.annotation.Nullable; + +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; + +@SideOnly(Side.CLIENT) +public class Category +{ + public static final RegistryNamespaced REGISTRY = new RegistryNamespaced(); + + private final List contents; + + public Category() + { + this.contents = new ArrayList(); + } + + public Category(List contents) + { + this.contents = contents; + } + + public Category(Content... contents) + { + this.contents = Arrays.asList(contents); + } + + public Category add(Content content) + { + this.contents.add(content); + return this; + } + + public List getContents() + { + return this.contents; + } + + public int getSize() + { + return this.contents.size(); + } + + @Nullable + public Content getContent(int index) + { + return this.contents.get(index); + } + + public static void registerCategories() + { + registerCategory(0, "main", new Category(Contents.MAIN, Contents.CONTAINERS, Contents.MULTIPLAYER)); + registerCategory(1, "entities", new Category(Contents.SUMMON)); + registerCategory(2, "items", new Category(Contents.CUSTOM_ITEM, Contents.ENCHANTMENT)); + registerCategory(3, "blocks", new Category(Contents.EDIT_BLOCKS, Contents.SIGN_EDITOR, Contents.NOTE_EDITOR)); + registerCategory(4, "world", new Category(Contents.WORLD_INFO, Contents.GAMERULES, Contents.RECIPES)); + registerCategory(5, "player", new Category(Contents.PLAYER, Contents.EXPERIENCE, Contents.ADVANCEMENTS)); + registerCategory(6, "scoreboard", new Category(Contents.SCOREBOARD_OBJECTIVES, Contents.SCOREBOARD_TEAMS, Contents.SCOREBOARD_PLAYERS)); + } + + private static void registerCategory(int id, String textualID, Category category) + { + registerCategory(id, new ResourceLocation(Main.MODID, textualID), category); + } + + private static void registerCategory(int id, ResourceLocation textualID, Category category) + { + REGISTRY.register(id, textualID, category); + } +} diff --git a/src/main/java/exopandora/worldhandler/gui/config/GuiConfigWorldHandler.java b/src/main/java/exopandora/worldhandler/gui/config/GuiConfigWorldHandler.java index f558c71..15aa168 100644 --- a/src/main/java/exopandora/worldhandler/gui/config/GuiConfigWorldHandler.java +++ b/src/main/java/exopandora/worldhandler/gui/config/GuiConfigWorldHandler.java @@ -3,12 +3,12 @@ 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 exopandora.worldhandler.main.Main; -import exopandora.worldhandler.main.WorldHandler; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.resources.I18n; import net.minecraftforge.common.config.ConfigCategory; diff --git a/src/main/java/exopandora/worldhandler/gui/container/impl/GuiWorldHandlerContainer.java b/src/main/java/exopandora/worldhandler/gui/container/impl/GuiWorldHandlerContainer.java index 6e269ef..665799f 100644 --- a/src/main/java/exopandora/worldhandler/gui/container/impl/GuiWorldHandlerContainer.java +++ b/src/main/java/exopandora/worldhandler/gui/container/impl/GuiWorldHandlerContainer.java @@ -12,6 +12,7 @@ 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; @@ -34,8 +35,6 @@ 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.main.Main; -import exopandora.worldhandler.main.WorldHandler; import exopandora.worldhandler.util.UtilRender; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; @@ -144,7 +143,7 @@ public class GuiWorldHandlerContainer extends Container 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)); + this.finalButtons.add(new GuiButtonTab(-16, (int) (backgroundX + xOffset), backgroundY - 20, (int) this.tabWidth + (int) Math.ceil(this.tabEpsilon / this.tabSize), 21, index)); } }); @@ -343,7 +342,6 @@ public class GuiWorldHandlerContainer extends Container break elements; } } - this.content.actionPerformed(this, button); break; } @@ -351,7 +349,7 @@ public class GuiWorldHandlerContainer extends Container private void defaultColor() { - this.defaultColor(1); + this.defaultColor(1.0F); } private void defaultColor(float alpha) @@ -445,8 +443,8 @@ public class GuiWorldHandlerContainer extends Container } 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); + 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()) { @@ -460,7 +458,7 @@ public class GuiWorldHandlerContainer extends Container 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); + this.drawTexturedModalRect((int) (backgroundX + this.tabWidth + xOffset - x - 1), (int) (backgroundY + x + 1), (int) (this.tabWidth - x - 1), x + 1, x + 1, 1); } } @@ -472,7 +470,7 @@ public class GuiWorldHandlerContainer extends Container for(int x = 0; x < factor; x++) { - this.drawTexturedModalRect((int)(backgroundX + xOffset), (int)(backgroundY + x + 1), xOffset.intValue(), x + 1, x + 1, 1); + this.drawTexturedModalRect((int) (backgroundX + xOffset), (int) (backgroundY + x + 1), xOffset.intValue(), x + 1, x + 1, 1); } } @@ -486,7 +484,7 @@ public class GuiWorldHandlerContainer extends Container 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); + this.drawTexturedModalRect((int) (backgroundX + xOffset), (int) (backgroundY + yOffset + fHeight + x / interval), 0, fHeight, width - x, 1); } } @@ -499,7 +497,7 @@ public class GuiWorldHandlerContainer extends Container 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); + this.drawTexturedModalRect((int) (backgroundX + Math.ceil(xOffset) + x + offset), (int) (backgroundY + yOffset + fHeight + x / interval), this.bgTextureWidth - width + x, fHeight, width - x, 1); } } } @@ -531,17 +529,20 @@ public class GuiWorldHandlerContainer extends Container } } - this.drawCenteredString(this.fontRenderer, ChatFormatting.UNDERLINE + tab.getTabTitle(), (int)(backgroundX + this.tabHalf + xOffset), (int)(backgroundY - 13), color); + 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(Main.MC_VERSION + "-" + Main.VERSION, this.width - this.fontRenderer.getStringWidth(Main.MC_VERSION + "-" + Main.VERSION) - 2, this.height - 10, color); + this.fontRenderer.drawString(label, versionWidth, versionHeight, color); //TITLE @@ -648,6 +649,13 @@ public class GuiWorldHandlerContainer extends Container } } } + + //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 diff --git a/src/main/java/exopandora/worldhandler/gui/content/Content.java b/src/main/java/exopandora/worldhandler/gui/content/Content.java index cd66241..97fadf2 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/Content.java +++ b/src/main/java/exopandora/worldhandler/gui/content/Content.java @@ -1,111 +1,114 @@ -package exopandora.worldhandler.gui.content; - -import java.util.HashMap; -import java.util.Map; - -import exopandora.worldhandler.gui.button.storage.ButtonStorage; -import exopandora.worldhandler.gui.content.impl.ContentAdvancements; -import exopandora.worldhandler.gui.content.impl.ContentButcher; -import exopandora.worldhandler.gui.content.impl.ContentChangeWorld; -import exopandora.worldhandler.gui.content.impl.ContentContainers; -import exopandora.worldhandler.gui.content.impl.ContentContinue; -import exopandora.worldhandler.gui.content.impl.ContentCustomItem; -import exopandora.worldhandler.gui.content.impl.ContentEditBlocks; -import exopandora.worldhandler.gui.content.impl.ContentEnchantment; -import exopandora.worldhandler.gui.content.impl.ContentExperience; -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.ContentPlayer; -import exopandora.worldhandler.gui.content.impl.ContentPotions; -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.ContentSignEditor; -import exopandora.worldhandler.gui.content.impl.ContentSummon; -import exopandora.worldhandler.gui.content.impl.ContentWorldInfo; -import exopandora.worldhandler.main.Main; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.registry.RegistryNamespaced; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public abstract class Content implements IContent -{ - public static final RegistryNamespaced REGISTRY = new RegistryNamespaced(); - - public static void registerContents() - { - //MAIN - registerContent(0, "main", new ContentMain()); - registerContent(1, "containers", new ContentContainers()); - registerContent(2, "multiplayer", new ContentMultiplayer()); - - //ENTITIES - registerContent(3, "summon", new ContentSummon()); - - //ITEMS - registerContent(5, "custom_item", new ContentCustomItem()); - registerContent(4, "enchantment", new ContentEnchantment()); - - //BLOCKS - registerContent(6, "edit_blocks", new ContentEditBlocks()); - registerContent(7, "sign_editor", new ContentSignEditor()); - registerContent(8, "note_editor", new ContentNoteEditor()); - - //WORLD - registerContent(9, "world", new ContentWorldInfo()); - registerContent(10, "gamerules", new ContentGamerules()); - - //PLAYER - registerContent(11, "player", new ContentPlayer()); - registerContent(12, "experience", new ContentExperience()); - registerContent(13, "advancements", new ContentAdvancements()); - - //SCOREBOARD - registerContent(14, "scoreboard_objectives", new ContentScoreboardObjectives()); - registerContent(15, "scoreboard_teams", new ContentScoreboardTeams()); - registerContent(16, "scoreboard_players", new ContentScoreboardPlayers()); - - //MISC - registerContent(17, "change_world", new ContentChangeWorld()); - registerContent(18, "continue", new ContentContinue()); - - //NO CATEGORY - registerContent(19, "potions", new ContentPotions()); - registerContent(20, "butcher", new ContentButcher()); - } - - 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 storage; - - public ButtonStorage getStorage(Object id) - { - if(this.storage == null) - { - this.storage = new HashMap(); - } - - if(this.storage.containsKey(id)) - { - return this.storage.get(id); - } - - ButtonStorage storage = new ButtonStorage(); - - this.storage.put(id, storage); - - return storage; - } -} +package exopandora.worldhandler.gui.content; + +import java.util.HashMap; +import java.util.Map; + +import exopandora.worldhandler.Main; +import exopandora.worldhandler.gui.button.persistence.ButtonValues; +import exopandora.worldhandler.gui.content.impl.ContentAdvancements; +import exopandora.worldhandler.gui.content.impl.ContentButcher; +import exopandora.worldhandler.gui.content.impl.ContentChangeWorld; +import exopandora.worldhandler.gui.content.impl.ContentContainers; +import exopandora.worldhandler.gui.content.impl.ContentContinue; +import exopandora.worldhandler.gui.content.impl.ContentCustomItem; +import exopandora.worldhandler.gui.content.impl.ContentEditBlocks; +import exopandora.worldhandler.gui.content.impl.ContentEnchantment; +import exopandora.worldhandler.gui.content.impl.ContentExperience; +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.ContentPlayer; +import exopandora.worldhandler.gui.content.impl.ContentPlaysound; +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.ContentSignEditor; +import exopandora.worldhandler.gui.content.impl.ContentSummon; +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; + +@SideOnly(Side.CLIENT) +public abstract class Content implements IContent +{ + public static final RegistryNamespaced REGISTRY = new RegistryNamespaced(); + + public static void registerContents() + { + //MAIN + registerContent(0, "main", new ContentMain()); + registerContent(1, "containers", new ContentContainers()); + registerContent(2, "multiplayer", new ContentMultiplayer()); + + //ENTITIES + registerContent(3, "summon", new ContentSummon()); + + //ITEMS + registerContent(5, "custom_item", new ContentCustomItem()); + registerContent(4, "enchantment", new ContentEnchantment()); + + //BLOCKS + registerContent(6, "edit_blocks", new ContentEditBlocks()); + registerContent(7, "sign_editor", new ContentSignEditor()); + registerContent(8, "note_editor", new ContentNoteEditor()); + + //WORLD + registerContent(9, "world", new ContentWorldInfo()); + registerContent(10, "gamerules", new ContentGamerules()); + registerContent(11, "recipes", new ContentRecipes()); + + //PLAYER + registerContent(12, "player", new ContentPlayer()); + registerContent(13, "experience", new ContentExperience()); + registerContent(14, "advancements", new ContentAdvancements()); + + //SCOREBOARD + registerContent(15, "scoreboard_objectives", new ContentScoreboardObjectives()); + registerContent(16, "scoreboard_teams", new ContentScoreboardTeams()); + registerContent(17, "scoreboard_players", new ContentScoreboardPlayers()); + + //MISC + registerContent(18, "change_world", new ContentChangeWorld()); + registerContent(19, "continue", new ContentContinue()); + + //NO CATEGORY + registerContent(20, "potions", new ContentPotions()); + registerContent(21, "butcher", new ContentButcher()); + } + + 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 persistence; + + public ButtonValues getPersistence(Object id) + { + if(this.persistence == null) + { + this.persistence = new HashMap(); + } + + if(this.persistence.containsKey(id)) + { + return this.persistence.get(id); + } + + ButtonValues values = new ButtonValues(); + + this.persistence.put(id, values); + + return values; + } +} diff --git a/src/main/java/exopandora/worldhandler/gui/content/Contents.java b/src/main/java/exopandora/worldhandler/gui/content/Contents.java index 323ce38..c83f674 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/Contents.java +++ b/src/main/java/exopandora/worldhandler/gui/content/Contents.java @@ -1,87 +1,89 @@ -package exopandora.worldhandler.gui.content; - -import exopandora.worldhandler.gui.content.impl.ContentContinue; -import exopandora.worldhandler.gui.content.impl.abstr.ContentChild; -import exopandora.worldhandler.main.Main; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class Contents -{ - public static final Content MAIN; - public static final Content CONTAINERS; - public static final Content MULTIPLAYER; - - public static final Content SUMMON; - - public static final Content CUSTOM_ITEM; - public static final Content ENCHANTMENT; - - public static final Content EDIT_BLOCKS; - public static final Content SIGN_EDITOR; - public static final Content NOTE_EDITOR; - - public static final Content WORLD_INFO; - public static final Content GAMERULES; - - public static final Content PLAYER; - public static final Content EXPERIENCE; - public static final Content ADVANCEMENTS; - - public static final Content SCOREBOARD_OBJECTIVES; - public static final Content SCOREBOARD_TEAMS; - public static final Content SCOREBOARD_PLAYERS; - - public static final ContentChild CHANGE_WORLD; - public static final ContentContinue CONTINUE; - - public static final ContentChild POTIONS; - public static final ContentChild BUTCHER; - - static - { - MAIN = Contents.getRegisteredContainer("main"); - CONTAINERS = Contents.getRegisteredContainer("containers"); - MULTIPLAYER = Contents.getRegisteredContainer("multiplayer"); - - SUMMON = Contents.getRegisteredContainer("summon"); - - CUSTOM_ITEM = Contents.getRegisteredContainer("custom_item"); - ENCHANTMENT = Contents.getRegisteredContainer("enchantment"); - - EDIT_BLOCKS = Contents.getRegisteredContainer("edit_blocks"); - SIGN_EDITOR = Contents.getRegisteredContainer("sign_editor"); - NOTE_EDITOR = Contents.getRegisteredContainer("note_editor"); - - WORLD_INFO = Contents.getRegisteredContainer("world"); - GAMERULES = Contents.getRegisteredContainer("gamerules"); - - PLAYER = Contents.getRegisteredContainer("player"); - EXPERIENCE = Contents.getRegisteredContainer("experience"); - ADVANCEMENTS = Contents.getRegisteredContainer("advancements"); - - SCOREBOARD_OBJECTIVES = Contents.getRegisteredContainer("scoreboard_objectives"); - SCOREBOARD_TEAMS = Contents.getRegisteredContainer("scoreboard_teams"); - SCOREBOARD_PLAYERS = Contents.getRegisteredContainer("scoreboard_players"); - - CHANGE_WORLD = Contents.getRegisteredContainer("change_world"); - CONTINUE = Contents.getRegisteredContainer("continue"); - - POTIONS = Contents.getRegisteredContainer("potions"); - BUTCHER = Contents.getRegisteredContainer("butcher"); - } - - private static T getRegisteredContainer(String name) - { - Content container = Content.REGISTRY.getObject(new ResourceLocation(Main.MODID, name)); - - if(container == null) - { - throw new IllegalStateException("Invalid Container requested: " + name); - } - - return (T) container; - } +package exopandora.worldhandler.gui.content; + +import exopandora.worldhandler.Main; +import exopandora.worldhandler.gui.content.impl.ContentContinue; +import exopandora.worldhandler.gui.content.impl.abstr.ContentChild; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class Contents +{ + public static final Content MAIN; + public static final Content CONTAINERS; + public static final Content MULTIPLAYER; + + public static final Content SUMMON; + + public static final Content CUSTOM_ITEM; + public static final Content ENCHANTMENT; + + public static final Content EDIT_BLOCKS; + public static final Content SIGN_EDITOR; + public static final Content NOTE_EDITOR; + + public static final Content WORLD_INFO; + public static final Content GAMERULES; + public static final Content RECIPES; + + public static final Content PLAYER; + public static final Content EXPERIENCE; + public static final Content ADVANCEMENTS; + + public static final Content SCOREBOARD_OBJECTIVES; + public static final Content SCOREBOARD_TEAMS; + public static final Content SCOREBOARD_PLAYERS; + + public static final ContentChild CHANGE_WORLD; + public static final ContentContinue CONTINUE; + + public static final ContentChild POTIONS; + public static final ContentChild BUTCHER; + + static + { + MAIN = Contents.getRegisteredContainer("main"); + CONTAINERS = Contents.getRegisteredContainer("containers"); + MULTIPLAYER = Contents.getRegisteredContainer("multiplayer"); + + SUMMON = Contents.getRegisteredContainer("summon"); + + CUSTOM_ITEM = Contents.getRegisteredContainer("custom_item"); + ENCHANTMENT = Contents.getRegisteredContainer("enchantment"); + + EDIT_BLOCKS = Contents.getRegisteredContainer("edit_blocks"); + SIGN_EDITOR = Contents.getRegisteredContainer("sign_editor"); + NOTE_EDITOR = Contents.getRegisteredContainer("note_editor"); + + WORLD_INFO = Contents.getRegisteredContainer("world"); + GAMERULES = Contents.getRegisteredContainer("gamerules"); + RECIPES = Contents.getRegisteredContainer("recipes"); + + PLAYER = Contents.getRegisteredContainer("player"); + EXPERIENCE = Contents.getRegisteredContainer("experience"); + ADVANCEMENTS = Contents.getRegisteredContainer("advancements"); + + SCOREBOARD_OBJECTIVES = Contents.getRegisteredContainer("scoreboard_objectives"); + SCOREBOARD_TEAMS = Contents.getRegisteredContainer("scoreboard_teams"); + SCOREBOARD_PLAYERS = Contents.getRegisteredContainer("scoreboard_players"); + + CHANGE_WORLD = Contents.getRegisteredContainer("change_world"); + CONTINUE = Contents.getRegisteredContainer("continue"); + + POTIONS = Contents.getRegisteredContainer("potions"); + BUTCHER = Contents.getRegisteredContainer("butcher"); + } + + private static T getRegisteredContainer(String name) + { + Content content = Content.REGISTRY.getObject(new ResourceLocation(Main.MODID, name)); + + if(content == null) + { + throw new IllegalStateException("Invalid Container requested: " + name); + } + + return (T) content; + } } \ No newline at end of file diff --git a/src/main/java/exopandora/worldhandler/gui/content/element/Element.java b/src/main/java/exopandora/worldhandler/gui/content/element/Element.java index cef184d..216731e 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/element/Element.java +++ b/src/main/java/exopandora/worldhandler/gui/content/element/Element.java @@ -14,10 +14,4 @@ public abstract class Element implements IElement this.x = x; this.y = y; } - - @Override - public void draw() - { - - } } diff --git a/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementClickList.java b/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementClickList.java index b7da6df..05f09ce 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementClickList.java +++ b/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementClickList.java @@ -6,8 +6,9 @@ import javax.annotation.Nullable; import exopandora.worldhandler.gui.button.EnumTooltip; import exopandora.worldhandler.gui.button.GuiButtonList; +import exopandora.worldhandler.gui.button.GuiButtonWorldHandler; import exopandora.worldhandler.gui.button.logic.IListButtonLogic; -import exopandora.worldhandler.gui.button.storage.ButtonStorage; +import exopandora.worldhandler.gui.button.persistence.ButtonValues; import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.content.Content; import exopandora.worldhandler.gui.content.element.Element; @@ -20,22 +21,30 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ElementClickList extends Element { - private final int buttonId1; - private final int buttonId2; + private final int[] buttonIds; private final List list; private final ILogicClickList logic; - private GuiButtonList button1; - private GuiButtonList button2; - private final Content master; + private final Content content; + private final ElementClickList parent; + private final int depth; - public ElementClickList(int x, int y, List list, int buttonId1, int buttonId2, Content container, ILogicClickList logic) + private GuiButtonList button; + private ElementClickList child; + + public ElementClickList(int x, int y, List list, int[] buttonIds, Content content, ILogicClickList logic) + { + this(x, y, list, buttonIds, content, logic, null); + } + + private ElementClickList(int x, int y, List list, int[] buttonIds, Content content, ILogicClickList logic, ElementClickList parent) { super(x, y); this.list = list; - this.buttonId1 = buttonId1; - this.buttonId2 = buttonId2; + this.buttonIds = buttonIds; this.logic = logic; - this.master = container; + this.content = content; + this.parent = parent; + this.depth = this.parent != null ? this.parent.depth + 1 : 1; } @Override @@ -47,12 +56,12 @@ public class ElementClickList extends Element @Override public void initButtons(Container container) { - container.add(this.button1 = new GuiButtonList(this.buttonId1, this.x, this.y, 114, 20, EnumTooltip.TOP_RIGHT, this.master, new IListButtonLogic() + container.add(this.button = new GuiButtonList(this.getButtonId(), this.x, this.y, 114, 20, EnumTooltip.TOP_RIGHT, this.content, new IListButtonLogic() { @Override - public void actionPerformed(Container container, GuiButton button, ButtonStorage storage) + public void actionPerformed(Container container, GuiButton button, ButtonValues values) { - master.getStorage(listButtonLogic2.getId()).setIndex(0); + content.getPersistence(logic.getId() + (depth + 1)).setIndex(0); container.initButtons(); } @@ -67,19 +76,19 @@ public class ElementClickList extends Element { return list.get(index); } - + @Override - public String getDisplayString(ButtonStorage storage) + public String getDisplayString(ButtonValues values) { - return logic.translate1(storage.getObject().getKey()); + return logic.translate(getKeys()); } @Override - public String getTooltipString(ButtonStorage storage) + public String getTooltipString(ButtonValues values) { - if(storage != null && storage.getObject() != null) + if(values != null && values.getObject() != null) { - return storage.getObject().getKey() + " (" + (storage.getIndex() + 1) + "/" + this.getMax() + ")"; + return values.getObject().getKey() + " (" + (values.getIndex() + 1) + "/" + this.getMax() + ")"; } return null; @@ -88,101 +97,32 @@ public class ElementClickList extends Element @Override public String getId() { - return logic.getId() + 1; + return logic.getId() + depth; } })); - final Node node = this.getStorage1().getObject(); - this.logic.consumeKey1(node.getKey()); + Node node = this.getValues().getObject(); + this.logic.consumeKey(this.getKeys()); if(node.getEntries() != null) { - container.add(this.button2 = new GuiButtonList(this.buttonId2, this.x, this.y + 24, 114, 20, EnumTooltip.TOP_RIGHT, this.master, this.listButtonLogic2)); - this.logic.consumeKey2(node.getKey(), node.getEntries().get(this.getStorage2().getIndex()).getKey()); + this.child = new ElementClickList(this.x, this.y + 24, node.getEntries(), this.buttonIds, this.content, this.logic, this); + this.child.initButtons(container); } - else + else if(this.depth < this.buttonIds.length) { - container.add(this.button2 = new GuiButtonList(this.buttonId2, this.x, this.y + 24, 114, 20, EnumTooltip.TOP_RIGHT, this.master, this.listButtonLogic2)); - this.button2.enabled = false; + GuiButtonWorldHandler button = new GuiButtonWorldHandler(this.getButtonId(), this.x, this.y + 24, 114, 20, null); + button.enabled = false; + container.add(button); } } - private final IListButtonLogic listButtonLogic2 = new IListButtonLogic() - { - @Override - public void actionPerformed(Container container, GuiButton button, ButtonStorage storage) - { - container.initButtons(); - } - - @Override - public int getMax() - { - if(getStorage1().getObject() != null) - { - return getStorage1().getObject().getEntries().size(); - } - - return 0; - } - - @Override - public Node getObject(int index) - { - if(getStorage1().getObject().getEntries() != null) - { - return getStorage1().getObject().getEntries().get(index); - } - - return null; - } - - @Override - public String getDisplayString(ButtonStorage storage) - { - if(storage.getObject() != null) - { - return logic.translate2(getStorage1().getObject().getKey(), storage.getObject().getKey()); - } - - return null; - } - - @Override - public String getTooltipString(ButtonStorage storage) - { - if(getStorage1().getObject().getEntries() != null) - { - return storage.getObject().getKey() + " (" + (storage.getIndex() + 1) + "/" + getStorage1().getObject().getEntries().size() + ")"; - } - - return null; - } - - @Override - public String getId() - { - return logic.getId() + 2; - } - }; - @Nullable - private ButtonStorage getStorage1() + private ButtonValues getValues() { - if(this.button1 != null) + if(this.button != null) { - return this.master.getStorage(this.button1.getLogic().getId()); - } - - return null; - } - - @Nullable - private ButtonStorage getStorage2() - { - if(this.button2 != null) - { - return this.master.getStorage(this.button2.getLogic().getId()); + return this.content.getPersistence(this.button.getLogic().getId()); } return null; @@ -191,17 +131,42 @@ public class ElementClickList extends Element @Override public boolean actionPerformed(Container container, GuiButton button) { - if(button.id == this.buttonId1) + if(button.id == this.getButtonId()) { - this.button1.actionPerformed(container, button); + this.button.actionPerformed(container, button); return true; } - else if(button.id == this.buttonId2) + else if(this.child != null) { - this.button2.actionPerformed(container, button); - return true; + return this.child.actionPerformed(container, button); } return false; } + + @Override + public void draw() + { + + } + + private int getButtonId() + { + return this.buttonIds[this.depth - 1]; + } + + private String[] getKeys() + { + return this.getKeys(new String[this.depth]); + } + + private String[] getKeys(String[] keys) + { + if(keys != null && this.depth <= keys.length) + { + keys[this.depth - 1] = this.getValues().getObject().getKey(); + } + + return this.parent != null ? this.parent.getKeys(keys) : keys; + } } diff --git a/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementColorMenu.java b/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementColorMenu.java index 50b3a71..6a8082a 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementColorMenu.java +++ b/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementColorMenu.java @@ -7,7 +7,7 @@ import exopandora.worldhandler.gui.button.GuiButtonList; import exopandora.worldhandler.gui.button.GuiButtonWorldHandler; import exopandora.worldhandler.gui.button.GuiTextFieldTooltip; import exopandora.worldhandler.gui.button.logic.ColorListButtonLogic; -import exopandora.worldhandler.gui.button.storage.ButtonStorage; +import exopandora.worldhandler.gui.button.persistence.ButtonValues; import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.content.Content; import exopandora.worldhandler.gui.content.element.Element; @@ -59,9 +59,9 @@ public class ElementColorMenu extends Element container.add(this.colorList = new GuiButtonList(this.ids[0], this.x + 118, this.y + 24, 114, 20, this.content, new ColorListButtonLogic() { @Override - public void actionPerformed(Container container, GuiButton button, ButtonStorage storage) + public void actionPerformed(Container container, GuiButton button, ButtonValues values) { - string.setColor(storage.getIndex()); + string.setColor(values.getIndex()); } @Override diff --git a/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementPageList.java b/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementPageList.java index b76bd1b..a176279 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementPageList.java +++ b/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementPageList.java @@ -5,13 +5,14 @@ import java.util.List; import exopandora.worldhandler.config.ConfigSkin; import exopandora.worldhandler.format.TextFormatting; import exopandora.worldhandler.gui.button.GuiButtonWorldHandler; -import exopandora.worldhandler.gui.button.storage.ButtonStorage; +import exopandora.worldhandler.gui.button.persistence.ButtonValues; import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.content.Content; import exopandora.worldhandler.gui.content.element.Element; import exopandora.worldhandler.gui.content.element.logic.ILogicPageList; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -24,9 +25,9 @@ public class ElementPageList extends Element private final int width; private final int height; private final int[] ids; - private final ButtonStorage storage; + private final ButtonValues values; - public ElementPageList(int x, int y, List list, K initial, int width, int height, int length, Content container, int[] ids, ILogicPageList logic) + public ElementPageList(int x, int y, List list, K initial, int width, int height, int length, Content content, int[] ids, ILogicPageList logic) { super(x, y); this.list = list; @@ -34,15 +35,15 @@ public class ElementPageList extends Element this.width = width; this.height = height; this.logic = logic; - this.storage = container.getStorage(logic.getId()); + this.values = content.getPersistence(logic.getId()); this.ids = ids; this.list.sort((a, b) -> this.logic.translate(a).compareTo(this.logic.translate(b))); - if(this.storage.getObject() == null) + if(this.values.getObject() == null) { - this.storage.setObject(0); - this.storage.setIndex(Math.max(0, this.list.indexOf(this.logic.convert(initial)))); + this.values.setObject(0); + this.values.setIndex(Math.max(0, this.list.indexOf(this.logic.convert(initial)))); if(initial == null) { @@ -69,8 +70,8 @@ public class ElementPageList extends Element GuiButtonWorldHandler left = new GuiButtonWorldHandler(this.ids[0], this.x, this.y + (this.height + 4) * this.length, buttonWidth + 1, this.height, "<"); GuiButtonWorldHandler right = new GuiButtonWorldHandler(this.ids[1], this.x + 5 + buttonWidth, this.y + (this.height + 4) * this.length, buttonWidth, this.height, ">"); - left.enabled = this.storage.getObject() > 0; - right.enabled = this.storage.getObject() < this.getTotalPages() - 1; + left.enabled = this.values.getObject() > 0; + right.enabled = this.values.getObject() < this.getTotalPages() - 1; container.add(left); container.add(right); @@ -80,12 +81,12 @@ public class ElementPageList extends Element for(int x = 0; x < length; x++) { - int index = this.storage.getObject() * length + x; + int index = this.values.getObject() * length + x; if(index < this.list.size()) { T entry = this.list.get(index); - this.logic.onRegister(this.ids[2], this.x, this.y + (this.height + 4) * x, this.width, this.height, TextFormatting.shortenString(this.logic.translate(entry), this.width, Minecraft.getMinecraft().fontRenderer), this.logic.getRegistryName(entry), this.storage.getIndex() != index, entry, container); + this.logic.onRegister(this.ids[2], this.x, this.y + (this.height + 4) * x, this.width, this.height, TextFormatting.shortenString(this.logic.translate(entry), this.width, Minecraft.getMinecraft().fontRenderer), this.logic.getRegistryName(entry), this.values.getIndex() != index, entry, container); } else { @@ -101,13 +102,33 @@ public class ElementPageList extends Element { if(button.id == this.ids[0]) { - this.storage.setObject(this.storage.getObject() - 1); + int value = this.values.getObject(); + + if(GuiScreen.isShiftKeyDown()) + { + this.values.setObject(value - Math.min(10, value)); + } + else + { + this.values.setObject(value - 1); + } + container.initGui(); return true; } else if(button.id == this.ids[1]) { - this.storage.setObject(this.storage.getObject() + 1); + int value = this.values.getObject(); + + if(GuiScreen.isShiftKeyDown()) + { + this.values.setObject(value + Math.min(10, this.getTotalPages() - 1 - value)); + } + else + { + this.values.setObject(value + 1); + } + container.initGui(); return true; } @@ -119,7 +140,7 @@ public class ElementPageList extends Element if(TextFormatting.shortenString(this.logic.translate(entry), this.width, Minecraft.getMinecraft().fontRenderer).equals(button.displayString)) { - this.storage.setIndex(x); + this.values.setIndex(x); this.logic.onClick(entry); container.initGui(); return true; @@ -133,7 +154,7 @@ public class ElementPageList extends Element @Override public void draw() { - Minecraft.getMinecraft().fontRenderer.drawString((this.storage.getObject() + 1) + "/" + this.getTotalPages(), this.x, this.y - 11, ConfigSkin.getHeadlineColor()); + Minecraft.getMinecraft().fontRenderer.drawString((this.values.getObject() + 1) + "/" + this.getTotalPages(), this.x, this.y - 11, ConfigSkin.getHeadlineColor()); } private int getTotalPages() diff --git a/src/main/java/exopandora/worldhandler/gui/content/element/logic/ILogic.java b/src/main/java/exopandora/worldhandler/gui/content/element/logic/ILogic.java new file mode 100644 index 0000000..0d5851c --- /dev/null +++ b/src/main/java/exopandora/worldhandler/gui/content/element/logic/ILogic.java @@ -0,0 +1,10 @@ +package exopandora.worldhandler.gui.content.element.logic; + +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public interface ILogic +{ + String getId(); +} diff --git a/src/main/java/exopandora/worldhandler/gui/content/element/logic/ILogicClickList.java b/src/main/java/exopandora/worldhandler/gui/content/element/logic/ILogicClickList.java index b08b730..7d6311c 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/element/logic/ILogicClickList.java +++ b/src/main/java/exopandora/worldhandler/gui/content/element/logic/ILogicClickList.java @@ -4,21 +4,13 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public interface ILogicClickList +public interface ILogicClickList extends ILogic { - void consumeKey1(String key); + String translate(String... keys); + void consumeKey(String... keys); - default void consumeKey2(String key1, String key2) + default void consumeKeyImpl(String... keys) { - this.consumeKey1(key1 + "." + key2); + this.consumeKey(keys[0] + "." + keys[1]); } - - String translate1(String key); - - default String translate2(String key1, String key2) - { - return this.translate1(key2); - } - - String getId(); } diff --git a/src/main/java/exopandora/worldhandler/gui/content/element/logic/ILogicColorMenu.java b/src/main/java/exopandora/worldhandler/gui/content/element/logic/ILogicColorMenu.java index 851aff3..3a41108 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/element/logic/ILogicColorMenu.java +++ b/src/main/java/exopandora/worldhandler/gui/content/element/logic/ILogicColorMenu.java @@ -3,7 +3,11 @@ package exopandora.worldhandler.gui.content.element.logic; import com.google.common.base.Predicate; import com.google.common.base.Predicates; -public interface ILogicColorMenu +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public interface ILogicColorMenu extends ILogic { default Predicate getValidator() { @@ -20,6 +24,7 @@ public interface ILogicColorMenu return true; } + @Override default String getId() { return "color"; diff --git a/src/main/java/exopandora/worldhandler/gui/content/element/logic/ILogicPageList.java b/src/main/java/exopandora/worldhandler/gui/content/element/logic/ILogicPageList.java index be5db0a..4062537 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/element/logic/ILogicPageList.java +++ b/src/main/java/exopandora/worldhandler/gui/content/element/logic/ILogicPageList.java @@ -5,7 +5,7 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public interface ILogicPageList +public interface ILogicPageList extends ILogic { String translate(T key); String getRegistryName(T key); @@ -14,6 +14,4 @@ public interface ILogicPageList void onRegister(int id, int x, int y, int width, int height, String display, String registryKey, boolean enabled, T value, Container container); T convert(K object); - - String getId(); } \ No newline at end of file diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentAdvancements.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentAdvancements.java index a2e141e..57be352 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentAdvancements.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentAdvancements.java @@ -3,10 +3,11 @@ package exopandora.worldhandler.gui.content.impl; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; -import java.util.stream.StreamSupport; +import com.google.common.collect.Lists; import com.mojang.realmsclient.gui.ChatFormatting; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.ICommandBuilder; import exopandora.worldhandler.builder.impl.BuilderAdvancement; import exopandora.worldhandler.builder.impl.BuilderAdvancement.EnumActionType; @@ -16,7 +17,7 @@ import exopandora.worldhandler.gui.button.EnumTooltip; import exopandora.worldhandler.gui.button.GuiButtonList; import exopandora.worldhandler.gui.button.GuiButtonWorldHandler; import exopandora.worldhandler.gui.button.logic.IListButtonLogic; -import exopandora.worldhandler.gui.button.storage.ButtonStorage; +import exopandora.worldhandler.gui.button.persistence.ButtonValues; import exopandora.worldhandler.gui.category.Categories; import exopandora.worldhandler.gui.category.Category; import exopandora.worldhandler.gui.container.Container; @@ -26,7 +27,6 @@ import exopandora.worldhandler.gui.content.Contents; import exopandora.worldhandler.gui.content.element.impl.ElementPageList; import exopandora.worldhandler.gui.content.element.logic.ILogicPageList; import exopandora.worldhandler.helper.AdvancementHelper; -import exopandora.worldhandler.main.WorldHandler; import net.minecraft.advancements.Advancement; import net.minecraft.advancements.AdvancementManager; import net.minecraft.client.Minecraft; @@ -43,7 +43,7 @@ public class ContentAdvancements extends Content private GuiButtonList modeButton; - private final List advancements = StreamSupport.stream(new AdvancementManager(null).getAdvancements().spliterator(), true).filter(advancement -> advancement.getDisplay() != null).collect(Collectors.toList()); + private final List advancements = Lists.newArrayList(new AdvancementManager(null).getAdvancements()).parallelStream().filter(advancement -> advancement.getDisplay() != null).collect(Collectors.toList()); @Override public ICommandBuilder getCommandBuilder() @@ -109,9 +109,9 @@ public class ContentAdvancements extends Content private final EnumMode[] values = Arrays.stream(EnumMode.values()).filter(mode -> !mode.equals(EnumMode.EVERYTHING)).toArray(EnumMode[]::new); @Override - public void actionPerformed(Container container, GuiButton button, ButtonStorage storage) + public void actionPerformed(Container container, GuiButton button, ButtonValues values) { - builderAdvancement.setMode(storage.getObject()); + builderAdvancement.setMode(values.getObject()); } @Override @@ -127,9 +127,9 @@ public class ContentAdvancements extends Content } @Override - public String getDisplayString(ButtonStorage storage) + public String getDisplayString(ButtonValues values) { - return I18n.format("gui.worldhandler.advancements." + storage.getObject().toString()); + return I18n.format("gui.worldhandler.advancements." + values.getObject().toString()); } @Override diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentButcher.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentButcher.java index 1e964ac..87fb016 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentButcher.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentButcher.java @@ -1,5 +1,6 @@ package exopandora.worldhandler.gui.content.impl; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.ICommandBuilder; import exopandora.worldhandler.builder.impl.BuilderButcher; import exopandora.worldhandler.config.ConfigButcher; @@ -9,7 +10,6 @@ import exopandora.worldhandler.gui.config.GuiConfigWorldHandler; import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.content.impl.abstr.ContentChild; import exopandora.worldhandler.helper.EntityHelper; -import exopandora.worldhandler.main.WorldHandler; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.I18n; diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentChangeWorld.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentChangeWorld.java index 9b85969..5af55ff 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentChangeWorld.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentChangeWorld.java @@ -5,9 +5,14 @@ import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.content.impl.abstr.ContentChild; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiMainMenu; import net.minecraft.client.gui.GuiMultiplayer; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiWorldSelection; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.resources.I18n; +import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -33,7 +38,43 @@ public class ContentChangeWorld extends ContentChild Minecraft.getMinecraft().displayGuiScreen(new GuiWorldSelection(container)); break; case 3: - Minecraft.getMinecraft().displayGuiScreen(new GuiMultiplayer(container)); + ServerData server = Minecraft.getMinecraft().getCurrentServerData(); + + if(server != null) + { + Minecraft.getMinecraft().world.sendQuittingDisconnectingPacket(); + Minecraft.getMinecraft().loadWorld((WorldClient)null); + + Minecraft.getMinecraft().displayGuiScreen(new GuiMultiplayer(new GuiScreen() + { + @Override + public void initGui() + { + FMLClientHandler.instance().connectToServer(new GuiMultiplayer(new GuiMainMenu()), server); + Minecraft.getMinecraft().displayGuiScreen((GuiScreen) null); + Minecraft.getMinecraft().setIngameFocus(); + } + })); + } + else + { + String worldName = Minecraft.getMinecraft().getIntegratedServer().getWorldName(); + String folderName = Minecraft.getMinecraft().getIntegratedServer().getFolderName(); + + Minecraft.getMinecraft().world.sendQuittingDisconnectingPacket(); + Minecraft.getMinecraft().loadWorld((WorldClient)null); + + Minecraft.getMinecraft().displayGuiScreen(new GuiMultiplayer(new GuiScreen() + { + @Override + public void initGui() + { + Minecraft.getMinecraft().launchIntegratedServer(folderName, worldName, null); + Minecraft.getMinecraft().displayGuiScreen((GuiScreen) null); + Minecraft.getMinecraft().setIngameFocus(); + } + })); + } break; default: break; diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentContainers.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentContainers.java index 605900b..28a4508 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentContainers.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentContainers.java @@ -1,5 +1,6 @@ package exopandora.worldhandler.gui.content.impl; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.impl.BuilderGive; import exopandora.worldhandler.builder.impl.BuilderSetblock; import exopandora.worldhandler.builder.types.Coordinate; @@ -12,7 +13,6 @@ import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.content.Content; import exopandora.worldhandler.gui.content.Contents; import exopandora.worldhandler.helper.BlockHelper; -import exopandora.worldhandler.main.WorldHandler; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentContinue.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentContinue.java index 4aa6885..5b5d94e 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentContinue.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentContinue.java @@ -4,6 +4,7 @@ import org.lwjgl.input.Keyboard; import com.mojang.realmsclient.gui.ChatFormatting; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.ICommandBuilder; import exopandora.worldhandler.builder.ICommandBuilderSyntax; import exopandora.worldhandler.gui.button.GuiButtonWorldHandler; @@ -11,7 +12,6 @@ import exopandora.worldhandler.gui.button.GuiTextFieldTooltip; import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.container.impl.GuiWorldHandlerContainer; import exopandora.worldhandler.gui.content.impl.abstr.ContentChild; -import exopandora.worldhandler.main.WorldHandler; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.I18n; diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentCustomItem.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentCustomItem.java index 7a94c62..3918069 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentCustomItem.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentCustomItem.java @@ -7,6 +7,7 @@ import java.util.stream.Stream; import com.google.common.base.Predicates; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.ICommandBuilder; import exopandora.worldhandler.builder.impl.BuilderCustomItem; import exopandora.worldhandler.builder.impl.abstr.EnumAttributes; @@ -27,7 +28,6 @@ import exopandora.worldhandler.gui.content.element.impl.ElementColorMenu; import exopandora.worldhandler.gui.content.element.impl.ElementPageList; import exopandora.worldhandler.gui.content.element.logic.ILogicPageList; import exopandora.worldhandler.helper.ResourceHelper; -import exopandora.worldhandler.main.WorldHandler; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.I18n; import net.minecraft.enchantment.Enchantment; diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentEditBlocks.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentEditBlocks.java index 731887c..4e26113 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentEditBlocks.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentEditBlocks.java @@ -3,6 +3,7 @@ package exopandora.worldhandler.gui.content.impl; import com.google.common.base.Predicate; import com.google.common.base.Predicates; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.ICommandBuilder; import exopandora.worldhandler.builder.impl.BuilderClone; import exopandora.worldhandler.builder.impl.BuilderClone.EnumMask; @@ -13,7 +14,7 @@ import exopandora.worldhandler.gui.button.GuiButtonList; import exopandora.worldhandler.gui.button.GuiButtonWorldHandler; import exopandora.worldhandler.gui.button.GuiTextFieldTooltip; import exopandora.worldhandler.gui.button.logic.IListButtonLogic; -import exopandora.worldhandler.gui.button.storage.ButtonStorage; +import exopandora.worldhandler.gui.button.persistence.ButtonValues; import exopandora.worldhandler.gui.category.Categories; import exopandora.worldhandler.gui.category.Category; import exopandora.worldhandler.gui.container.Container; @@ -21,7 +22,6 @@ import exopandora.worldhandler.gui.content.Content; import exopandora.worldhandler.gui.content.Contents; import exopandora.worldhandler.helper.BlockHelper; import exopandora.worldhandler.helper.ResourceHelper; -import exopandora.worldhandler.main.WorldHandler; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.I18n; import net.minecraftforge.fml.relauncher.Side; @@ -178,9 +178,9 @@ public class ContentEditBlocks extends Content container.add(this.cloneButton = new GuiButtonList(9, x + 118, y, 114, 20, EnumTooltip.TOP_RIGHT, this, new IListButtonLogic() { @Override - public void actionPerformed(Container container, GuiButton button, ButtonStorage storage) + public void actionPerformed(Container container, GuiButton button, ButtonValues values) { - builderClone.setMask(storage.getObject()); + builderClone.setMask(values.getObject()); } @Override @@ -196,9 +196,9 @@ public class ContentEditBlocks extends Content } @Override - public String getDisplayString(ButtonStorage storage) + public String getDisplayString(ButtonValues values) { - return I18n.format("gui.worldhandler.edit_blocks.clone.mode." + storage.getObject().toString()); + return I18n.format("gui.worldhandler.edit_blocks.clone.mode." + values.getObject().toString()); } @Override diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentEnchantment.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentEnchantment.java index 5c8db65..ab59d04 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentEnchantment.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentEnchantment.java @@ -2,6 +2,7 @@ package exopandora.worldhandler.gui.content.impl; import java.util.ArrayList; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.ICommandBuilder; import exopandora.worldhandler.builder.impl.BuilderEnchantment; import exopandora.worldhandler.builder.types.Type; @@ -16,7 +17,6 @@ import exopandora.worldhandler.gui.content.Content; import exopandora.worldhandler.gui.content.Contents; import exopandora.worldhandler.gui.content.element.impl.ElementPageList; import exopandora.worldhandler.gui.content.element.logic.ILogicPageList; -import exopandora.worldhandler.main.WorldHandler; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.I18n; import net.minecraft.enchantment.Enchantment; diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentExperience.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentExperience.java index c10bba6..7c77a82 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentExperience.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentExperience.java @@ -1,5 +1,6 @@ package exopandora.worldhandler.gui.content.impl; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.ICommandBuilder; import exopandora.worldhandler.builder.impl.BuilderExperience; import exopandora.worldhandler.config.ConfigSliders; @@ -12,7 +13,6 @@ import exopandora.worldhandler.gui.category.Category; import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.content.Content; import exopandora.worldhandler.gui.content.Contents; -import exopandora.worldhandler.main.WorldHandler; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.I18n; diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentGamerules.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentGamerules.java index b1cddff..279ccea 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentGamerules.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentGamerules.java @@ -4,6 +4,7 @@ import java.util.Arrays; import com.google.common.base.Predicates; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.ICommandBuilder; import exopandora.worldhandler.builder.impl.BuilderGamerule; import exopandora.worldhandler.gui.button.EnumTooltip; @@ -16,7 +17,6 @@ import exopandora.worldhandler.gui.content.Content; import exopandora.worldhandler.gui.content.Contents; import exopandora.worldhandler.gui.content.element.impl.ElementPageList; import exopandora.worldhandler.gui.content.element.logic.ILogicPageList; -import exopandora.worldhandler.main.WorldHandler; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.I18n; @@ -53,6 +53,13 @@ public class ContentGamerules extends Content @Override public String translate(String key) { + String translated = I18n.format(key); + + if(!translated.equals(key)) + { + return translated; + } + return I18n.format("gui.worldhandler.gamerules.rule." + key); } diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentMain.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentMain.java index 9db8e11..c775df4 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentMain.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentMain.java @@ -1,5 +1,6 @@ package exopandora.worldhandler.gui.content.impl; +import exopandora.worldhandler.Main; import exopandora.worldhandler.config.ConfigSettings; import exopandora.worldhandler.gui.button.EnumIcon; import exopandora.worldhandler.gui.button.EnumTooltip; @@ -11,7 +12,6 @@ import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.container.impl.GuiWorldHandlerContainer; import exopandora.worldhandler.gui.content.Content; import exopandora.worldhandler.gui.content.Contents; -import exopandora.worldhandler.main.Main; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreenResourcePacks; diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentMultiplayer.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentMultiplayer.java index 1ed41f3..57af421 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentMultiplayer.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentMultiplayer.java @@ -2,6 +2,7 @@ package exopandora.worldhandler.gui.content.impl; import com.google.common.base.Predicates; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.ICommandBuilder; import exopandora.worldhandler.builder.impl.BuilderGeneric; import exopandora.worldhandler.builder.impl.BuilderMultiCommand; @@ -19,7 +20,6 @@ import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.container.impl.GuiWorldHandlerContainer; import exopandora.worldhandler.gui.content.Content; import exopandora.worldhandler.gui.content.Contents; -import exopandora.worldhandler.main.WorldHandler; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.I18n; diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentNoteEditor.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentNoteEditor.java index 66367cd..1f0eb6b 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentNoteEditor.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentNoteEditor.java @@ -2,6 +2,7 @@ package exopandora.worldhandler.gui.content.impl; import org.lwjgl.input.Keyboard; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.ICommandBuilder; import exopandora.worldhandler.builder.impl.BuilderNoteEditor; import exopandora.worldhandler.config.ConfigSkin; @@ -14,7 +15,6 @@ import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.content.Content; import exopandora.worldhandler.gui.content.Contents; import exopandora.worldhandler.helper.BlockHelper; -import exopandora.worldhandler.main.WorldHandler; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentPlayer.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentPlayer.java index 3656ea1..b15c509 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentPlayer.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentPlayer.java @@ -2,6 +2,7 @@ package exopandora.worldhandler.gui.content.impl; import com.mojang.realmsclient.gui.ChatFormatting; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.ICommandBuilder; import exopandora.worldhandler.builder.impl.BuilderGeneric; import exopandora.worldhandler.builder.impl.BuilderMultiCommand; @@ -14,7 +15,6 @@ import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.container.impl.GuiWorldHandlerContainer; import exopandora.worldhandler.gui.content.Content; import exopandora.worldhandler.gui.content.Contents; -import exopandora.worldhandler.main.WorldHandler; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.inventory.GuiInventory; diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentPotions.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentPotions.java index 90169bb..b26ca88 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentPotions.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentPotions.java @@ -2,6 +2,7 @@ package exopandora.worldhandler.gui.content.impl; import java.util.ArrayList; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.ICommandBuilder; import exopandora.worldhandler.builder.impl.BuilderMultiCommand; import exopandora.worldhandler.builder.impl.BuilderPotionEffect; @@ -15,7 +16,6 @@ import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.content.element.impl.ElementPageList; import exopandora.worldhandler.gui.content.element.logic.ILogicPageList; import exopandora.worldhandler.gui.content.impl.abstr.ContentChild; -import exopandora.worldhandler.main.WorldHandler; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.I18n; import net.minecraft.init.Items; diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentRecipes.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentRecipes.java new file mode 100644 index 0000000..fc0b409 --- /dev/null +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentRecipes.java @@ -0,0 +1,158 @@ +package exopandora.worldhandler.gui.content.impl; + +import java.util.ArrayList; +import java.util.List; + +import exopandora.worldhandler.WorldHandler; +import exopandora.worldhandler.builder.ICommandBuilder; +import exopandora.worldhandler.builder.impl.BuilderRecipe; +import exopandora.worldhandler.builder.impl.BuilderRecipe.EnumMode; +import exopandora.worldhandler.builder.types.Type; +import exopandora.worldhandler.gui.button.EnumTooltip; +import exopandora.worldhandler.gui.button.GuiButtonWorldHandler; +import exopandora.worldhandler.gui.category.Categories; +import exopandora.worldhandler.gui.category.Category; +import exopandora.worldhandler.gui.container.Container; +import exopandora.worldhandler.gui.content.Content; +import exopandora.worldhandler.gui.content.Contents; +import exopandora.worldhandler.gui.content.element.impl.ElementPageList; +import exopandora.worldhandler.gui.content.element.logic.ILogicPageList; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ContentRecipes extends Content +{ + private final BuilderRecipe builderRecipe = new BuilderRecipe(); + + @Override + public ICommandBuilder getCommandBuilder() + { + return this.builderRecipe; + } + + @Override + public void initGui(Container container, int x, int y) + { + List recipes = new ArrayList(); + + for(IRecipe recipe : CraftingManager.REGISTRY) + { + if(!recipe.isDynamic()) + { + recipes.add(recipe); + } + } + + ElementPageList list = new ElementPageList(x, y, recipes, null, 114, 20, 3, this, new int[] {4, 5, 6}, new ILogicPageList() + { + @Override + public String translate(IRecipe key) + { + if(!key.getRecipeOutput().equals(ItemStack.EMPTY)) + { + return key.getRecipeOutput().getDisplayName(); + } + + return key.getRegistryName().toString(); + } + + @Override + public void onClick(IRecipe clicked) + { + builderRecipe.setRecipe(clicked.getRegistryName()); + } + + @Override + public String getRegistryName(IRecipe key) + { + return key.getRegistryName().toString(); + } + + @Override + public void onRegister(int id, int x, int y, int width, int height, String display, String registry, boolean enabled, IRecipe value, Container container) + { + GuiButtonWorldHandler button; + container.add(button = new GuiButtonWorldHandler(id, x, y, width, height, display, value.getRegistryName().toString(), EnumTooltip.TOP_RIGHT)); + button.enabled = enabled; + } + + @Override + public IRecipe convert(String object) + { + return CraftingManager.REGISTRY.getObject(Type.parseResourceLocation(object)); + } + + @Override + public String getId() + { + return "recipe"; + } + }); + + container.add(list); + } + + @Override + public void initButtons(Container container, int x, int y) + { + container.add(new GuiButtonWorldHandler(0, x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"))); + container.add(new GuiButtonWorldHandler(1, x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"))); + + container.add(new GuiButtonWorldHandler(2, x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.recipes.give"))); + container.add(new GuiButtonWorldHandler(3, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.recipes.take"))); + } + + @Override + public void actionPerformed(Container container, GuiButton button) + { + switch(button.id) + { + case 2: + WorldHandler.sendCommand(this.builderRecipe.getBuilderForMode(EnumMode.GIVE)); + container.initButtons(); + break; + case 3: + WorldHandler.sendCommand(this.builderRecipe.getBuilderForMode(EnumMode.TAKE)); + container.initButtons(); + break; + default: + break; + } + } + + @Override + public Category getCategory() + { + return Categories.WORLD; + } + + @Override + public String getTitle() + { + return I18n.format("gui.worldhandler.title.world.recipes"); + } + + @Override + public String getTabTitle() + { + return I18n.format("gui.worldhandler.tab.world.recipes"); + } + + @Override + public Content getActiveContent() + { + return Contents.RECIPES; + } + + @Override + public void onPlayerNameChanged(String username) + { + this.builderRecipe.setPlayer(username); + } +} diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentScoreboardObjectives.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentScoreboardObjectives.java index 6295969..c90950e 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentScoreboardObjectives.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentScoreboardObjectives.java @@ -4,6 +4,7 @@ import java.util.Arrays; import com.google.common.base.Predicates; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.ICommandBuilder; import exopandora.worldhandler.builder.impl.BuilderScoreboardObjectives; import exopandora.worldhandler.format.EnumColor; @@ -16,7 +17,6 @@ import exopandora.worldhandler.gui.content.element.impl.ElementClickList; import exopandora.worldhandler.gui.content.element.logic.ILogicClickList; import exopandora.worldhandler.gui.content.impl.abstr.ContentScoreboard; import exopandora.worldhandler.helper.EntityHelper; -import exopandora.worldhandler.main.WorldHandler; import net.minecraft.block.Block; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.I18n; @@ -48,47 +48,61 @@ public class ContentScoreboardObjectives extends ContentScoreboard if(this.selectedObjective.equals("create")) { - ElementClickList objectives = new ElementClickList(x + 118, y + 24, HELPER.getObjectives(), 7, 8, this, new ILogicClickList() + ElementClickList objectives = new ElementClickList(x + 118, y + 24, HELPER.getObjectives(), new int[] {7, 8}, this, new ILogicClickList() { @Override - public void consumeKey1(String key) + public void consumeKey(String... keys) { - builderObjectives.setCriteria(key); + if(keys.length > 1) + { + this.consumeKeyImpl(keys); + } + else + { + builderObjectives.setCriteria(keys[0]); + } } @Override - public String translate1(String key) + public String translate(String... keys) { - String format = "gui.worldhandler.scoreboard.objectives.criteria." + key; - String result = I18n.format(format); - - if(result.equals(format)) + if(keys.length > 1) { - ResourceLocation location = new ResourceLocation(key); - - if(Item.REGISTRY.containsKey(location)) - { - result = I18n.format(Item.REGISTRY.getObject(location).getUnlocalizedName() + ".name"); - } - else if(Block.REGISTRY.containsKey(location)) - { - result = Block.REGISTRY.getObject(location).getLocalizedName(); - } - else if(EntityHelper.doesExist(key)) - { - result = I18n.format("entity." + key + ".name"); - } - else if(Arrays.stream(EnumColor.values()).map(EnumColor::getFormat).anyMatch(Predicates.equalTo(key))) - { - result = I18n.format("gui.worldhandler.color." + key); - } - else - { - result = I18n.format(key); - } + return this.translate(keys[1]); + } + else + { + String format = "gui.worldhandler.scoreboard.objectives.criteria." + keys[0]; + String result = I18n.format(format); + + if(result.equals(format)) + { + ResourceLocation location = new ResourceLocation(keys[0]); + + if(Item.REGISTRY.containsKey(location)) + { + result = I18n.format(Item.REGISTRY.getObject(location).getUnlocalizedName() + ".name"); + } + else if(Block.REGISTRY.containsKey(location)) + { + result = Block.REGISTRY.getObject(location).getLocalizedName(); + } + else if(EntityHelper.doesExist(keys[0])) + { + result = I18n.format("entity." + keys[0] + ".name"); + } + else if(Arrays.stream(EnumColor.values()).map(EnumColor::getFormat).anyMatch(Predicates.equalTo(keys[0]))) + { + result = I18n.format("gui.worldhandler.color." + keys[0]); + } + else + { + result = I18n.format(keys[0]); + } + } + + return result; } - - return result; } @Override @@ -102,24 +116,32 @@ public class ContentScoreboardObjectives extends ContentScoreboard } else if(this.selectedObjective.equals("display") || this.selectedObjective.equals("undisplay")) { - ElementClickList slots = new ElementClickList(x + 118, y + 24 + (this.selectedObjective.equals("undisplay") ? -12 : 0), HELPER.getSlots(), 9, 10, this, new ILogicClickList() + ElementClickList slots = new ElementClickList(x + 118, y + 24 + (this.selectedObjective.equals("undisplay") ? -12 : 0), HELPER.getSlots(), new int[] {9, 10}, this, new ILogicClickList() { @Override - public String translate1(String key) + public String translate(String... keys) { - return I18n.format("gui.worldhandler.scoreboard.slot." + key); + if(keys.length > 1) + { + return I18n.format("gui.worldhandler.color." + keys[1]); + } + else + { + return I18n.format("gui.worldhandler.scoreboard.slot." + keys[0]); + } } @Override - public String translate2(String key1, String key2) + public void consumeKey(String... keys) { - return I18n.format("gui.worldhandler.color." + key2); - } - - @Override - public void consumeKey1(String key) - { - builderObjectives.setSlot(key); + if(keys.length > 1) + { + this.consumeKeyImpl(keys); + } + else + { + builderObjectives.setSlot(keys[0]); + } } @Override diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentScoreboardPlayers.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentScoreboardPlayers.java index 1038054..56a1ea6 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentScoreboardPlayers.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentScoreboardPlayers.java @@ -2,6 +2,7 @@ package exopandora.worldhandler.gui.content.impl; import com.google.common.base.Predicate; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.ICommandBuilder; import exopandora.worldhandler.builder.impl.BuilderScoreboardPlayers; import exopandora.worldhandler.builder.impl.BuilderScoreboardPlayers.EnumPoints; @@ -16,7 +17,6 @@ import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.content.Content; import exopandora.worldhandler.gui.content.Contents; import exopandora.worldhandler.gui.content.impl.abstr.ContentScoreboard; -import exopandora.worldhandler.main.WorldHandler; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.I18n; import net.minecraftforge.fml.relauncher.Side; diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentScoreboardTeams.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentScoreboardTeams.java index 3e9a47e..66514e4 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentScoreboardTeams.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentScoreboardTeams.java @@ -4,6 +4,7 @@ import java.util.Arrays; import com.google.common.base.Predicates; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.ICommandBuilder; import exopandora.worldhandler.builder.impl.BuilderScoreboardTeams; import exopandora.worldhandler.builder.impl.BuilderScoreboardTeams.EnumMode; @@ -16,7 +17,6 @@ import exopandora.worldhandler.gui.content.Contents; import exopandora.worldhandler.gui.content.element.impl.ElementClickList; import exopandora.worldhandler.gui.content.element.logic.ILogicClickList; import exopandora.worldhandler.gui.content.impl.abstr.ContentScoreboard; -import exopandora.worldhandler.main.WorldHandler; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.I18n; import net.minecraftforge.fml.relauncher.Side; @@ -47,37 +47,39 @@ public class ContentScoreboardTeams extends ContentScoreboard if(this.selectedTeam.equals("option")) { - ElementClickList options = new ElementClickList(x + 118, y + 24, HELPER.getOptions(), 6, 7, this, new ILogicClickList() + ElementClickList options = new ElementClickList(x + 118, y + 24, HELPER.getOptions(), new int[] {6, 7}, this, new ILogicClickList() { @Override - public String translate1(String key) + public String translate(String... keys) { - return I18n.format("gui.worldhandler.scoreboard.team.options." + key); - } - - @Override - public String translate2(String key1, String key2) - { - if(Arrays.stream(EnumColor.values()).map(EnumColor::getFormat).anyMatch(Predicates.equalTo(key2))) + if(keys.length > 1) { - return I18n.format("gui.worldhandler.color." + key2); + if(Arrays.stream(EnumColor.values()).map(EnumColor::getFormat).anyMatch(Predicates.equalTo(keys[1]))) + { + return I18n.format("gui.worldhandler.color." + keys[1]); + } + + return I18n.format("gui.worldhandler.scoreboard.team.suboption." + keys[1]); + } + else + { + return I18n.format("gui.worldhandler.scoreboard.team.options." + keys[0]); } - - return I18n.format("gui.worldhandler.scoreboard.team.suboption." + key2); } @Override - public void consumeKey1(String key) + public void consumeKey(String... keys) { - builderTeams.setRule(key); + if(keys.length > 1) + { + builderTeams.setValue(keys[1]); + } + else + { + builderTeams.setRule(keys[0]); + } } - @Override - public void consumeKey2(String key1, String key2) - { - builderTeams.setValue(key2); - } - @Override public String getId() { diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentSignEditor.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentSignEditor.java index 0331603..f84084b 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentSignEditor.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentSignEditor.java @@ -5,6 +5,8 @@ import org.lwjgl.input.Keyboard; import com.google.common.base.Predicate; import com.google.common.base.Predicates; +import exopandora.worldhandler.Main; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.ICommandBuilder; import exopandora.worldhandler.builder.impl.BuilderSignEditor; import exopandora.worldhandler.config.ConfigSkin; @@ -18,7 +20,6 @@ import exopandora.worldhandler.gui.content.Contents; import exopandora.worldhandler.gui.content.element.impl.ElementColorMenu; import exopandora.worldhandler.gui.content.element.logic.ILogicColorMenu; import exopandora.worldhandler.helper.BlockHelper; -import exopandora.worldhandler.main.WorldHandler; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; @@ -35,7 +36,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ContentSignEditor extends Content { - private static final ResourceLocation LOGO = new ResourceLocation("worldhandler:textures/logo.png"); + private static final ResourceLocation LOGO = new ResourceLocation(Main.MODID, "textures/logo.png"); private int selectedLine = 0; private boolean editColor; diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentSummon.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentSummon.java index 56fa1c2..9e39267 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentSummon.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentSummon.java @@ -9,6 +9,7 @@ import org.lwjgl.opengl.GL11; import com.google.common.base.Predicates; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.ICommandBuilder; import exopandora.worldhandler.builder.impl.BuilderSummon; import exopandora.worldhandler.builder.impl.abstr.EnumAttributes; @@ -27,7 +28,6 @@ import exopandora.worldhandler.gui.content.Content; import exopandora.worldhandler.gui.content.Contents; import exopandora.worldhandler.gui.content.element.impl.ElementPageList; import exopandora.worldhandler.gui.content.element.logic.ILogicPageList; -import exopandora.worldhandler.main.WorldHandler; import exopandora.worldhandler.util.UtilPlayer; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; diff --git a/src/main/java/exopandora/worldhandler/helper/BlockHelper.java b/src/main/java/exopandora/worldhandler/helper/BlockHelper.java index 12c996e..831d045 100644 --- a/src/main/java/exopandora/worldhandler/helper/BlockHelper.java +++ b/src/main/java/exopandora/worldhandler/helper/BlockHelper.java @@ -4,12 +4,14 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; +import javax.annotation.Nonnull; + import org.apache.commons.lang3.ArrayUtils; +import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.impl.BuilderSetblock; import exopandora.worldhandler.builder.types.Coordinate; import exopandora.worldhandler.config.ConfigSettings; -import exopandora.worldhandler.main.WorldHandler; import exopandora.worldhandler.util.UtilPlayer; import io.netty.buffer.Unpooled; import net.minecraft.block.Block; @@ -77,6 +79,7 @@ public class BlockHelper return new BlockPos(pos.getX(), pos.getY(), z); } + @Nonnull public static BlockPos getPos1() { return POS_1; @@ -95,6 +98,7 @@ public class BlockHelper } } + @Nonnull public static BlockPos getPos2() { return POS_2; diff --git a/src/main/java/exopandora/worldhandler/helper/EnumHelper.java b/src/main/java/exopandora/worldhandler/helper/EnumHelper.java index 5d5bb4a..92a994c 100644 --- a/src/main/java/exopandora/worldhandler/helper/EnumHelper.java +++ b/src/main/java/exopandora/worldhandler/helper/EnumHelper.java @@ -1,11 +1,14 @@ package exopandora.worldhandler.helper; +import javax.annotation.Nullable; + import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class EnumHelper { + @Nullable public static > T valueOf(Class klass, String name) { try diff --git a/src/main/java/exopandora/worldhandler/helper/ResourceHelper.java b/src/main/java/exopandora/worldhandler/helper/ResourceHelper.java index 77afb55..3221f92 100644 --- a/src/main/java/exopandora/worldhandler/helper/ResourceHelper.java +++ b/src/main/java/exopandora/worldhandler/helper/ResourceHelper.java @@ -4,8 +4,8 @@ import java.util.function.Predicate; import javax.annotation.Nullable; +import exopandora.worldhandler.Main; import exopandora.worldhandler.config.ConfigSkin; -import exopandora.worldhandler.main.Main; import net.minecraft.block.Block; import net.minecraft.entity.EntityList; import net.minecraft.item.Item; diff --git a/src/main/java/exopandora/worldhandler/hud/BiomeIndicator.java b/src/main/java/exopandora/worldhandler/hud/BiomeIndicator.java index cc36077..811d785 100644 --- a/src/main/java/exopandora/worldhandler/hud/BiomeIndicator.java +++ b/src/main/java/exopandora/worldhandler/hud/BiomeIndicator.java @@ -11,77 +11,85 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) public class BiomeIndicator { - private static final Set BIOMES; - private static String CURRENT_BIOME; - private static int TICKS; + private final Set biomes = new HashSet(); + private String currentBiome; + private int ticksRemaining; - static + public BiomeIndicator() { - Set pool = new HashSet(); + this.init(); + } + + private void init() + { + Set biomes = new HashSet(); for(ResourceLocation location : Biome.REGISTRY.getKeys()) { - pool.add(filterName(Biome.REGISTRY.getObject(location).getBiomeName())); + biomes.add(this.filterName(Biome.REGISTRY.getObject(location).getBiomeName())); } - BIOMES = new HashSet(pool); + this.biomes.addAll(biomes); - for(String biome : pool) + for(String biome : biomes) { - for(String index : pool) + for(String index : biomes) { if(index.matches(biome + "([A-Za-z ])+") || index.matches("([A-Za-z ])+ " + biome)) { - BIOMES.remove(index); + this.biomes.remove(index); } } } - BIOMES.remove("River"); - BIOMES.remove("Beach"); + this.biomes.remove("River"); + this.biomes.remove("Beach"); } - public static void tick() + public void tick() { - int posX = MathHelper.floor(Minecraft.getMinecraft().player.posX); - int posY = MathHelper.floor(Minecraft.getMinecraft().player.posY); - int posZ = MathHelper.floor(Minecraft.getMinecraft().player.posZ); - - BlockPos pos = new BlockPos(posX, posY, posZ); - - if(Minecraft.getMinecraft().world != null && Minecraft.getMinecraft().world.isBlockLoaded(pos)) - { - Chunk chunk = Minecraft.getMinecraft().world.getChunkFromBlockCoords(pos); - String biome = getBaseBiome(filterName(chunk.getBiome(pos, Minecraft.getMinecraft().world.getBiomeProvider()).getBiomeName())); - - if(TICKS == 0 && biome != null) - { - if(CURRENT_BIOME == null || !CURRENT_BIOME.equals(biome)) - { - Minecraft.getMinecraft().ingameGUI.displayTitle(biome, null, 20, 60, 20); - TICKS = 100; - CURRENT_BIOME = biome; - } - } - else if(TICKS > 0) - { - TICKS--; - } - } + int posX = MathHelper.floor(Minecraft.getMinecraft().player.posX); + int posY = MathHelper.floor(Minecraft.getMinecraft().player.posY); + int posZ = MathHelper.floor(Minecraft.getMinecraft().player.posZ); + + BlockPos pos = new BlockPos(posX, posY, posZ); + + if(Minecraft.getMinecraft().world != null && Minecraft.getMinecraft().world.isBlockLoaded(pos)) + { + Chunk chunk = Minecraft.getMinecraft().world.getChunkFromBlockCoords(pos); + String biome = this.getBaseBiome(this.filterName(chunk.getBiome(pos, Minecraft.getMinecraft().world.getBiomeProvider()).getBiomeName())); + + if(this.ticksRemaining == 0 && biome != null) + { + if(this.currentBiome == null || !this.currentBiome.equals(biome)) + { + Minecraft.getMinecraft().ingameGUI.displayTitle(biome, null, 20, 60, 20); + this.ticksRemaining = 100; + this.currentBiome = biome; + } + } + else if(this.ticksRemaining > 0) + { + this.ticksRemaining--; + } + } } - private static String filterName(String biome) + private String filterName(String biome) { return biome.replaceAll("([a-z])([A-Z])", "$1 $2").replaceAll("[^A-Za-z ]", "").replaceAll("( [A-Z])$", ""); } @Nullable - private static String getBaseBiome(String input) + private String getBaseBiome(String input) { - for(String biome : BIOMES) + for(String biome : this.biomes) { if(input.matches("([A-Za-z ])*" + biome + "([A-Za-z ])*")) { diff --git a/src/main/java/exopandora/worldhandler/installer/ChangeFolderListener.java b/src/main/java/exopandora/worldhandler/installer/ChangeFolderListener.java index 5555f0e..8f3e625 100644 --- a/src/main/java/exopandora/worldhandler/installer/ChangeFolderListener.java +++ b/src/main/java/exopandora/worldhandler/installer/ChangeFolderListener.java @@ -7,7 +7,7 @@ import java.io.File; import javax.swing.JFileChooser; import javax.swing.JTextField; -import exopandora.worldhandler.main.Main; +import exopandora.worldhandler.Main; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; diff --git a/src/main/java/exopandora/worldhandler/installer/ForumListener.java b/src/main/java/exopandora/worldhandler/installer/ForumListener.java index e038ee2..490bcbd 100644 --- a/src/main/java/exopandora/worldhandler/installer/ForumListener.java +++ b/src/main/java/exopandora/worldhandler/installer/ForumListener.java @@ -5,7 +5,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.net.URI; -import exopandora.worldhandler.main.Main; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -19,7 +18,7 @@ public class ForumListener implements ActionListener { try { - Desktop.getDesktop().browse(new URI(Main.URL)); + Desktop.getDesktop().browse(new URI("$url")); } catch(Exception e) { @@ -27,5 +26,4 @@ public class ForumListener implements ActionListener } } } -} - \ No newline at end of file +} \ No newline at end of file diff --git a/src/main/java/exopandora/worldhandler/installer/InstallListener.java b/src/main/java/exopandora/worldhandler/installer/InstallListener.java index e8e663d..f8d4cab 100644 --- a/src/main/java/exopandora/worldhandler/installer/InstallListener.java +++ b/src/main/java/exopandora/worldhandler/installer/InstallListener.java @@ -11,7 +11,7 @@ import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JTextField; -import exopandora.worldhandler.main.Main; +import exopandora.worldhandler.Main; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -37,7 +37,7 @@ public class InstallListener implements ActionListener File mods = new File(directory, "mods"); File versions = new File(directory, "versions"); - if(!this.isPartialFileNameInFolder(versions, Main.MC_VERSION, "Forge")) + if(!this.isPartialFileNameInFolder(versions, "$mcversion", "Forge")) { JOptionPane.showMessageDialog(null, "Please install Mineceaft Forge", null, JOptionPane.ERROR_MESSAGE); } @@ -54,8 +54,8 @@ public class InstallListener implements ActionListener try { Path path = new File(InstallListener.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()).toPath(); - Files.copy(path, new File(mods, "WorldHandler-" + Main.FULL_VERSION + "-Universal.jar").toPath(), StandardCopyOption.REPLACE_EXISTING); - JOptionPane.showMessageDialog(null, Main.NAME_AND_VERSION + " has been successfully installed", null, JOptionPane.INFORMATION_MESSAGE); + Files.copy(path, new File(mods, "WorldHandler-$mcversion-$version-Universal.jar").toPath(), StandardCopyOption.REPLACE_EXISTING); + JOptionPane.showMessageDialog(null, Main.NAME + " $mcversion-$version has been successfully installed", null, JOptionPane.INFORMATION_MESSAGE); } catch(Exception e) { diff --git a/src/main/java/exopandora/worldhandler/installer/Window.java b/src/main/java/exopandora/worldhandler/installer/Window.java index 4c6d166..31ef12d 100644 --- a/src/main/java/exopandora/worldhandler/installer/Window.java +++ b/src/main/java/exopandora/worldhandler/installer/Window.java @@ -17,21 +17,22 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; -import exopandora.worldhandler.main.Main; +import exopandora.worldhandler.Main; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class Window implements Runnable { - private final String title = Main.NAME_AND_VERSION + " Installer"; private final JFrame frame = new JFrame(); @Override public void run() { + String titleString = Main.NAME + " $mcversion-$version Installer"; + this.frame.setResizable(false); - this.frame.setTitle(this.title); + this.frame.setTitle(titleString); this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); List icons = new ArrayList(); @@ -63,7 +64,7 @@ public class Window implements Runnable gbcPanel.gridy = 0; this.frame.add(panel, gbcPanel); - JLabel title = new JLabel(this.title); + JLabel title = new JLabel(titleString); panel.add(title, this.getButtonConstraints(0, 0)); JTextField textField = new JTextField(Main.getInitialDirectory().getAbsolutePath()); diff --git a/src/main/java/exopandora/worldhandler/util/UtilKeyBinding.java b/src/main/java/exopandora/worldhandler/util/UtilKeyBinding.java new file mode 100644 index 0000000..7ddeda8 --- /dev/null +++ b/src/main/java/exopandora/worldhandler/util/UtilKeyBinding.java @@ -0,0 +1,39 @@ +package exopandora.worldhandler.util; + +import org.apache.commons.lang3.ArrayUtils; + +import exopandora.worldhandler.WorldHandler; +import exopandora.worldhandler.config.ConfigSettings; +import net.minecraft.client.Minecraft; +import net.minecraftforge.fml.client.registry.ClientRegistry; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class UtilKeyBinding +{ + public static void updatePosKeys() + { + boolean isRegistered = arePosKeysRegistered(); + + if(ConfigSettings.arePosShortcutsEnabled() && !isRegistered) + { + ClientRegistry.registerKeyBinding(WorldHandler.KEY_WORLD_HANDLER_POS1); + ClientRegistry.registerKeyBinding(WorldHandler.KEY_WORLD_HANDLER_POS2); + } + else if(!ConfigSettings.arePosShortcutsEnabled() && isRegistered) + { + removePosKeys(); + } + } + + public static boolean arePosKeysRegistered() + { + return ArrayUtils.contains(Minecraft.getMinecraft().gameSettings.keyBindings, WorldHandler.KEY_WORLD_HANDLER_POS1) || ArrayUtils.contains(Minecraft.getMinecraft().gameSettings.keyBindings, WorldHandler.KEY_WORLD_HANDLER_POS2); + } + + public static void removePosKeys() + { + Minecraft.getMinecraft().gameSettings.keyBindings = ArrayUtils.removeElements(Minecraft.getMinecraft().gameSettings.keyBindings, WorldHandler.KEY_WORLD_HANDLER_POS1, WorldHandler.KEY_WORLD_HANDLER_POS2); + } +} \ No newline at end of file diff --git a/src/main/java/exopandora/worldhandler/util/UtilPlayer.java b/src/main/java/exopandora/worldhandler/util/UtilPlayer.java index 4c335c9..d621734 100644 --- a/src/main/java/exopandora/worldhandler/util/UtilPlayer.java +++ b/src/main/java/exopandora/worldhandler/util/UtilPlayer.java @@ -2,7 +2,10 @@ package exopandora.worldhandler.util; import net.minecraft.client.Minecraft; import net.minecraft.util.math.MathHelper; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) public class UtilPlayer { public static boolean canIssueCommand() diff --git a/src/main/resources/assets/worldhandler/installer/icon/icon128.png b/src/main/resources/assets/worldhandler/installer/icon/icon128.png index 6b3e178..73c275a 100644 Binary files a/src/main/resources/assets/worldhandler/installer/icon/icon128.png and b/src/main/resources/assets/worldhandler/installer/icon/icon128.png differ diff --git a/src/main/resources/assets/worldhandler/installer/icon/icon16.png b/src/main/resources/assets/worldhandler/installer/icon/icon16.png index 39458ff..6d19b4e 100644 Binary files a/src/main/resources/assets/worldhandler/installer/icon/icon16.png and b/src/main/resources/assets/worldhandler/installer/icon/icon16.png differ diff --git a/src/main/resources/assets/worldhandler/installer/icon/icon256.png b/src/main/resources/assets/worldhandler/installer/icon/icon256.png index 3296e16..e232255 100644 Binary files a/src/main/resources/assets/worldhandler/installer/icon/icon256.png and b/src/main/resources/assets/worldhandler/installer/icon/icon256.png differ diff --git a/src/main/resources/assets/worldhandler/installer/icon/icon32.png b/src/main/resources/assets/worldhandler/installer/icon/icon32.png index 501e35c..c98457b 100644 Binary files a/src/main/resources/assets/worldhandler/installer/icon/icon32.png and b/src/main/resources/assets/worldhandler/installer/icon/icon32.png differ diff --git a/src/main/resources/assets/worldhandler/installer/icon/icon64.png b/src/main/resources/assets/worldhandler/installer/icon/icon64.png index 4a1b9a3..2ee8100 100644 Binary files a/src/main/resources/assets/worldhandler/installer/icon/icon64.png and b/src/main/resources/assets/worldhandler/installer/icon/icon64.png differ diff --git a/src/main/resources/assets/worldhandler/installer/logo.png b/src/main/resources/assets/worldhandler/installer/logo.png index 7d0e11a..de3c7ed 100644 Binary files a/src/main/resources/assets/worldhandler/installer/logo.png and b/src/main/resources/assets/worldhandler/installer/logo.png differ diff --git a/src/main/resources/assets/worldhandler/lang/de_de.lang b/src/main/resources/assets/worldhandler/lang/de_de.lang index bbf1410..de5a620 100644 --- a/src/main/resources/assets/worldhandler/lang/de_de.lang +++ b/src/main/resources/assets/worldhandler/lang/de_de.lang @@ -15,22 +15,24 @@ gui.worldhandler.config.key.settings.smooth_watch=Geschmeidige Uhr gui.worldhandler.config.key.settings.pause_game=Spiel Pausieren gui.worldhandler.config.key.settings.custom_times=Benutzerdefinierte Zeiten gui.worldhandler.config.key.settings.permission_query=Berechtigungsabfrage +gui.worldhandler.config.key.settings.highlight_blocks=Blöcke Hervorheben gui.worldhandler.config.key.settings.custom_time_dawn=Sonnenaufgangszeit gui.worldhandler.config.key.settings.custom_time_noon=Mittagszeit gui.worldhandler.config.key.settings.custom_time_sunset=Sonnenuntergangszeit gui.worldhandler.config.key.settings.custom_time_midnight=Mitternachtszeit gui.worldhandler.config.key.settings.block_placing_mode=Platziermodus für Blöcke -gui.worldhandler.config.comment.settings.custom_time_dawn=Biome Indikator Aktiviert -gui.worldhandler.config.comment.settings.command_syntax=Befehlssyntax Aktiviert -gui.worldhandler.config.comment.settings.shortcuts=Schnellsteuerleiste Aktiviert -gui.worldhandler.config.comment.settings.key_shortcuts=Tasten Abkürzungen Aktiviert -gui.worldhandler.config.comment.settings.tooltips=Tooltips Aktiviert -gui.worldhandler.config.comment.settings.watch=Uhr Aktiviert -gui.worldhandler.config.comment.settings.smooth_watch=Geschmeidige Uhr Aktiviert +gui.worldhandler.config.comment.settings.custom_time_dawn=Aktiviert Biome Indikator +gui.worldhandler.config.comment.settings.command_syntax=Aktiviert Befehlssyntax +gui.worldhandler.config.comment.settings.shortcuts=Aktiviert Schnellsteuerleiste +gui.worldhandler.config.comment.settings.key_shortcuts=Aktiviert Tasten Abkürzungen +gui.worldhandler.config.comment.settings.tooltips=Aktiviert Tooltips +gui.worldhandler.config.comment.settings.watch=Aktiviert Uhr +gui.worldhandler.config.comment.settings.smooth_watch=Aktiviert Geschmeidige Uhr gui.worldhandler.config.comment.settings.pause_game=Spiel Pausieren -gui.worldhandler.config.comment.settings.custom_times=Benutzerdefinierte Zeiten Aktiviert -gui.worldhandler.config.comment.settings.permission_query=Berechtigungsabfrage Aktiviert +gui.worldhandler.config.comment.settings.custom_times=Aktiviert Benutzerdefinierte Zeiten +gui.worldhandler.config.comment.settings.permission_query=Aktiviert Berechtigungsabfrage +gui.worldhandler.config.comment.settings.highlight_blocks=Hebt ausgewählte Blöcke hervor gui.worldhandler.config.comment.settings.custom_time_dawn=Sonnenaufgangszeit in Ticks gui.worldhandler.config.comment.settings.custom_time_noon=Mittagszeit in Ticks gui.worldhandler.config.comment.settings.custom_time_sunset=Sonnenuntergangszeit in Ticks @@ -99,6 +101,7 @@ gui.worldhandler.tab.entities.summon=Beschwören gui.worldhandler.tab.world.world=Welt gui.worldhandler.tab.world.gamerules=Spielregeln +gui.worldhandler.tab.world.recipes=Rezepte gui.worldhandler.tab.blocks.edit_blocks=Blöcke Ändern gui.worldhandler.tab.blocks.sign_editor=Schilder Ändern @@ -123,6 +126,7 @@ gui.worldhandler.title.scoreboard=Anzeigetafel gui.worldhandler.title.world.world=Welt gui.worldhandler.title.world.gamerules=Gamerules +gui.worldhandler.title.world.recipes=Rezepte gui.worldhandler.title.player.player=Spieler gui.worldhandler.title.player.experience=Erfahrung @@ -281,6 +285,9 @@ gui.worldhandler.edit_blocks.clone.mode.filtered=Gefiltert gui.worldhandler.edit_blocks.pos.set_pos_1=Position 1 gui.worldhandler.edit_blocks.pos.set_pos_2=Position 2 +gui.worldhandler.recipes.give=Geben +gui.worldhandler.recipes.take=Nehmen + gui.worldhandler.scoreboard.slot.list=Liste gui.worldhandler.scoreboard.slot.belowName=Unter Name gui.worldhandler.scoreboard.slot.sidebar=Seitentafel diff --git a/src/main/resources/assets/worldhandler/lang/en_us.lang b/src/main/resources/assets/worldhandler/lang/en_us.lang index 6b1a53e..9464519 100644 --- a/src/main/resources/assets/worldhandler/lang/en_us.lang +++ b/src/main/resources/assets/worldhandler/lang/en_us.lang @@ -15,6 +15,7 @@ gui.worldhandler.config.key.settings.smooth_watch=Smooth Watch gui.worldhandler.config.key.settings.pause_game=Pause Game gui.worldhandler.config.key.settings.custom_times=Custom Times gui.worldhandler.config.key.settings.permission_query=Permission Query +gui.worldhandler.config.key.settings.highlight_blocks=Highlight Blocks gui.worldhandler.config.key.settings.custom_time_dawn=Custom Dawn Ticks gui.worldhandler.config.key.settings.custom_time_noon=Custom Noon Ticks gui.worldhandler.config.key.settings.custom_time_sunset=Custom Sunset Ticks @@ -31,6 +32,7 @@ gui.worldhandler.config.comment.settings.smooth_watch=Whether or not the watch p gui.worldhandler.config.comment.settings.pause_game=Whether or not to pause the game when the gui is opened gui.worldhandler.config.comment.settings.custom_times=Whether or not to use the custom times gui.worldhandler.config.comment.settings.permission_query=Whether or not the permission query is enabled +gui.worldhandler.config.comment.settings.highlight_blocks=Whether or not selected blocks will be highlighted gui.worldhandler.config.comment.settings.custom_time_dawn=Ticks upon dawn gui.worldhandler.config.comment.settings.custom_time_noon=Ticks upon noon gui.worldhandler.config.comment.settings.custom_time_sunset=Ticks upon sunset @@ -99,6 +101,7 @@ gui.worldhandler.tab.entities.summon=Summon gui.worldhandler.tab.world.world=World gui.worldhandler.tab.world.gamerules=Gamerules +gui.worldhandler.tab.world.recipes=Recipes gui.worldhandler.tab.blocks.edit_blocks=Edit Blocks gui.worldhandler.tab.blocks.sign_editor=Sign Editor @@ -123,6 +126,7 @@ gui.worldhandler.title.scoreboard=Scoreboard gui.worldhandler.title.world.world=World gui.worldhandler.title.world.gamerules=Gamerules +gui.worldhandler.title.world.recipes=Recipes gui.worldhandler.title.player.player=Player gui.worldhandler.title.player.experience=Experience @@ -281,6 +285,9 @@ gui.worldhandler.edit_blocks.clone.mode.filtered=Filtered gui.worldhandler.edit_blocks.pos.set_pos_1=Set Pos 1 gui.worldhandler.edit_blocks.pos.set_pos_2=Set Pos 2 +gui.worldhandler.recipes.give=Give +gui.worldhandler.recipes.take=Take + gui.worldhandler.scoreboard.slot.list=List gui.worldhandler.scoreboard.slot.belowName=Below Name gui.worldhandler.scoreboard.slot.sidebar=Sidebar diff --git a/src/main/resources/assets/worldhandler/lang/zh_cn.lang b/src/main/resources/assets/worldhandler/lang/zh_cn.lang index 0def381..c68697d 100644 --- a/src/main/resources/assets/worldhandler/lang/zh_cn.lang +++ b/src/main/resources/assets/worldhandler/lang/zh_cn.lang @@ -15,6 +15,7 @@ gui.worldhandler.config.key.settings.smooth_watch=时钟平滑效果 gui.worldhandler.config.key.settings.pause_game=暂停游戏 gui.worldhandler.config.key.settings.custom_times=自定义时间 gui.worldhandler.config.key.settings.permission_query=权限队列 +gui.worldhandler.config.key.settings.highlight_blocks=Highlight Blocks gui.worldhandler.config.key.settings.custom_time_dawn=自定义日出时间 gui.worldhandler.config.key.settings.custom_time_noon=自定义正午时间 gui.worldhandler.config.key.settings.custom_time_sunset=自定义日落时间 @@ -31,6 +32,7 @@ gui.worldhandler.config.comment.settings.smooth_watch=时钟平滑效果开启 gui.worldhandler.config.comment.settings.pause_game=暂停游戏 gui.worldhandler.config.comment.settings.custom_times=自定义时间开启 gui.worldhandler.config.comment.settings.permission_query=权限队列开启 +gui.worldhandler.config.comment.settings.highlight_blocks=Whether or not selected blocks will be highlighted gui.worldhandler.config.comment.settings.custom_time_dawn=日出的时间 gui.worldhandler.config.comment.settings.custom_time_noon=正午的时间 gui.worldhandler.config.comment.settings.custom_time_sunset=日落的时间 @@ -99,6 +101,7 @@ gui.worldhandler.tab.entities.summon=召唤 gui.worldhandler.tab.world.world=世界 gui.worldhandler.tab.world.gamerules=游戏规则 +gui.worldhandler.tab.world.recipes=Recipes gui.worldhandler.tab.blocks.edit_blocks=编辑方块 gui.worldhandler.tab.blocks.sign_editor=告示牌编辑器 @@ -123,6 +126,7 @@ gui.worldhandler.title.scoreboard=记分板 gui.worldhandler.title.world.world=世界 gui.worldhandler.title.world.gamerules=游戏规则 +gui.worldhandler.title.world.recipes=Recipes gui.worldhandler.title.player.player=玩家 gui.worldhandler.title.player.experience=经验等级 @@ -281,6 +285,9 @@ gui.worldhandler.edit_blocks.clone.mode.filtered=仅指定方块 gui.worldhandler.edit_blocks.pos.set_pos_1=设置位点 1 gui.worldhandler.edit_blocks.pos.set_pos_2=设置位点 2 +gui.worldhandler.recipes.give=Give +gui.worldhandler.recipes.take=Take + gui.worldhandler.scoreboard.slot.list=列表 gui.worldhandler.scoreboard.slot.belowName=名称下方 gui.worldhandler.scoreboard.slot.sidebar=侧边栏 diff --git a/src/main/resources/assets/worldhandler/textures/logo.png b/src/main/resources/assets/worldhandler/textures/logo.png index 84c9e5b..498fb57 100644 Binary files a/src/main/resources/assets/worldhandler/textures/logo.png and b/src/main/resources/assets/worldhandler/textures/logo.png differ diff --git a/version.json b/version.json index e0fda07..897d568 100644 --- a/version.json +++ b/version.json @@ -2,12 +2,12 @@ "homepage": "https://minecraft.curseforge.com/projects/world-handler-command-gui", "promos": { - "1.12.2-latest": "2.0", - "1.12.2-recommended": "2.0", - "1.12.1-latest": "2.0", - "1.12.1-recommended": "2.0", - "1.12-latest": "2.0", - "1.12-recommended": "2.0", + "1.12.2-latest": "2.1.4", + "1.12.2-recommended": "2.1.4", + "1.12.1-latest": "2.1.4", + "1.12.1-recommended": "2.1.4", + "1.12-latest": "2.1.4", + "1.12-recommended": "2.1.4", "1.11.2-latest": "1.46", "1.11.2-recommended": "1.46", "1.11-latest": "1.42", @@ -41,6 +41,11 @@ }, "1.12.2": { + "2.1.4": "- Fixed enchantment level sliders", + "2.1.3": "- Fixed crash when cancelling change to multiplayer server", + "2.1.2": "- Added progress bar\n- Fixed modded gamerule translations\n- Fixed being connected to the old server when changing servers", + "2.1.1": "- Fixed /wh and /worldhandler denying other commands in multiplayer", + "2.1": "- Added option to change the max slider values\n- Fixed Sign Editor showing wrong color\n- Removed Headlines for better visibility\n- Updated Translations", "2.0": "- Recode 2.0\n- Added headline color as a config option\n- Added option tag and trigger for scoreboard players\n- Added reset for advancements\n- Updated config file format\n- Updated translations\n- Updated layout\n- Updated biome indicator (should work better with modded biomes)\n- Changed command syntax display\n- Changed /worldhandler show to /worldhandler display\n- Fixed setworldspawn and spawnpoint\n- Fixed equipment not working for summon\n- Fixed wrong translation for biome indicator settings\n- Fixed translation typo\n- Fixed potential config file issues\n- Fixed custom potions not having an item model\n- Fixed /worldhandler display not showing the mouse cursor\n- /worldhandler and /wh now work in multiplayer\n- Removed custom data from summon\n- Potions can now be combined if given as an item\n- Open source and signed", "1.50": "- Fixed Biome Indicator black screen", "1.49": "- Fixed Bone Block in Note Editor\n- Fixed missing translation", @@ -49,6 +54,11 @@ }, "1.12.1": { + "2.1.4": "- Fixed enchantment level sliders", + "2.1.3": "- Fixed crash when cancelling change to multiplayer server", + "2.1.2": "- Added progress bar\n- Fixed modded gamerule translations\n- Fixed being connected to the old server when changing servers", + "2.1.1": "- Fixed /wh and /worldhandler denying other commands in multiplayer", + "2.1": "- Added option to change the max slider values\n- Fixed Sign Editor showing wrong color\n- Removed Headlines for better visibility\n- Updated Translations", "2.0": "- Recodee 2.0\n- Added headline color as a config option\n- Added option tag and trigger for scoreboard players\n- Added reset for advancements\n- Updated config file format\n- Updated translations\n- Updated layout\n- Updated biome indicator (should work better with modded biomes)\n- Changed command syntax display\n- Changed /worldhandler show to /worldhandler display\n- Fixed setworldspawn and spawnpoint\n- Fixed equipment not working for summon\n- Fixed wrong translation for biome indicator settings\n- Fixed translation typo\n- Fixed potential config file issues\n- Fixed custom potions not having an item model\n- Fixed /worldhandler display not showing the mouse cursor\n- /worldhandler and /wh now work in multiplayer\n- Removed custom data from summon\n- Potions can now be combined if given as an item\n- Open source and signed", "1.50": "- Fixed Biome Indicator black screen", "1.49": "- Fixed Bone Block in Note Editor\n- Fixed missing translation", @@ -57,6 +67,11 @@ }, "1.12": { + "2.1.4": "- Fixed enchantment level sliders", + "2.1.3": "- Fixed crash when cancelling change to multiplayer server", + "2.1.2": "- Added progress bar\n- Fixed modded gamerule translations\n- Fixed being connected to the old server when changing servers", + "2.1.1": "- Fixed /wh and /worldhandler denying other commands in multiplayer", + "2.1": "- Added option to change the max slider values\n- Fixed Sign Editor showing wrong color\n- Removed Headlines for better visibility\n- Updated Translations", "2.0": "- Recodee 2.0\n- Added headline color as a config option\n- Added option tag and trigger for scoreboard players\n- Added reset for advancements\n- Updated config file format\n- Updated translations\n- Updated layout\n- Updated biome indicator (should work better with modded biomes)\n- Changed command syntax display\n- Changed /worldhandler show to /worldhandler display\n- Fixed setworldspawn and spawnpoint\n- Fixed equipment not working for summon\n- Fixed wrong translation for biome indicator settings\n- Fixed translation typo\n- Fixed potential config file issues\n- Fixed custom potions not having an item model\n- Fixed /worldhandler display not showing the mouse cursor\n- /worldhandler and /wh now work in multiplayer\n- Removed custom data from summon\n- Potions can now be combined if given as an item\n- Open source and signed", "1.50": "- Fixed Biome Indicator black screen", "1.49": "- Fixed Bone Block in Note Editor\n- Fixed missing translation",