Update to 1.13.2

This commit is contained in:
Marcel Konrad
2019-04-02 18:17:54 +02:00
parent eafef4ae54
commit e86d4f5c0c
204 changed files with 10130 additions and 9348 deletions

View File

@@ -42,6 +42,7 @@ Curseforge: https://minecraft.curseforge.com/projects/world-handler-command-gui
<li>/spawnpoint</li> <li>/spawnpoint</li>
<li>/summon</li> <li>/summon</li>
<li>/time</li> <li>/time</li>
<li>/trigger</li>
<li>/weather</li> <li>/weather</li>
<li>/xp</li> <li>/xp</li>
</ul> </ul>

View File

@@ -1,110 +1,132 @@
buildscript { buildscript {
repositories { repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
jcenter() jcenter()
maven { url = "http://files.minecraftforge.net/maven" } mavenCentral()
} }
dependencies { dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
} }
} }
apply plugin: 'net.minecraftforge.gradle.forge' apply plugin: 'net.minecraftforge.gradle'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
def mcversion = "1.12.2" version = '1.13.2-2.3'
def modversion = "2.2.1" group = 'exopandora.worldhandler' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
def mccompatible = "1.12" archivesBaseName = 'WorldHandler'
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 = mcversion + "-" + modversion sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
group = "exopandora.worldhandler.WorldHandler" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "WorldHandler"
sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
}
jar {
manifest {
attributes 'Main-Class': 'exopandora.worldhandler.Main'
}
}
task processMetadata(dependsOn: minecraft) {
minecraft.replace '$version', modversion
minecraft.replace '$mcversion', mcversion
minecraft.replace '$compatible', mccompatible
minecraft.replace '$url', url
minecraft.replace '$update_url', update_url
minecraft.replace '$certificate', certificate
}
if(project.hasProperty('keyStore')) {
task signJar(type: SignJar, dependsOn: reobfJar) {
keyStore = project.keyStore
alias = project.keyStoreAlias
storePass = project.keyStorePass
keyPass = project.keyStoreKeyPass
inputFile = jar.archivePath
outputFile = jar.archivePath
}
build.dependsOn signJar
}
minecraft { minecraft {
version = "1.12.2-14.23.4.2705" // The mappings can be changed at any time, and must be in the following format.
runDir = "run" // snapshot_YYYYMMDD Snapshot are built nightly.
// stable_# Stables are built at the discretion of the MCP team.
// the mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD snapshot are built nightly.
// stable_# stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work. // Use non-default mappings at your own risk. they may not always work.
// simply re-run your setup task after changing the mappings to update your workspace. // Simply re-run your setup task after changing the mappings to update your workspace.
mappings = "snapshot_20171003" mappings channel: 'snapshot', version: '20180921-1.13'
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
// accessTransformer = file('build/resources/main/META-INF/accesstransformer.cfg')
// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
client {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
// property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
// property 'forge.logging.console.level', 'debug'
mods {
worldhandler {
source sourceSets.main
}
}
}
server {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
// property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
// property 'forge.logging.console.level', 'debug'
mods {
worldhandler {
source sourceSets.main
}
}
}
}
} }
dependencies { dependencies {
// you may put jars on which you depend on in ./libs // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
// or you may define them like so.. // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
//compile "some.group:artifact:version:classifier" // The userdev artifact is a special name and will get all sorts of transformations applied to it.
//compile "some.group:artifact:version" minecraft 'net.minecraftforge:forge:1.13.2-25.0.100'
// real examples
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
// the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime. // You may put jars on which you depend on in ./libs or you may define them like so..
//provided 'com.mod-buildcraft:buildcraft:6.0.8:dev' // compile "some.group:artifact:version:classifier"
// compile "some.group:artifact:version"
// the deobf configurations: 'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided, // Real examples
// except that these dependencies get remapped to your current MCP mappings // compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
//deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
//deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
// for more info... // The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
// provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
// These dependencies get remapped to your current MCP mappings
// deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'
// For more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html // http://www.gradle.org/docs/current/userguide/dependency_management.html
} }
processResources { // Example for how to get properties into the manifest for reading by the runtime..
// this will ensure that this task is redone when the versions change. jar {
inputs.property "version", project.version manifest {
inputs.property "mcversion", project.minecraft.version attributes([
"Specification-Title": "World Handler",
// replace stuff in mcmod.info, nothing else "Specification-Vendor": "Exopandora",
from(sourceSets.main.resources.srcDirs) { "Specification-Version": "1", // We are version 1 of ourselves
include 'mcmod.info' "Implementation-Title": project.name,
"Implementation-Version": "${version}",
// replace version and mcversion "Implementation-Vendor" :"Exopandora",
expand 'version':project.version, 'mcversion':project.minecraft.version "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
} "Main-Class": "exopandora.worldhandler.Main"
])
// copy everything else except the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
} }
} }
// Example configuration to allow publishing using the maven-publish task
// we define a custom artifact that is sourced from the reobfJar output task
// and then declare that to be published
// Note you'll need to add a repository here
def reobfFile = file("$buildDir/reobfJar/output.jar")
def reobfArtifact = artifacts.add('default', reobfFile) {
type 'jar'
builtBy 'reobfJar'
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact reobfArtifact
}
}
repositories {
maven {
url "file:///${project.projectDir}/mcmodsrepo"
}
}
}

Binary file not shown.

View File

@@ -1,6 +1,5 @@
#Mon Sep 14 12:28:28 PDT 2015
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip

110
gradlew vendored
View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env sh
############################################################################## ##############################################################################
## ##
@@ -6,47 +6,6 @@
## ##
############################################################################## ##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME # Attempt to set APP_HOME
# Resolve links: $0 may be a link # Resolve links: $0 may be a link
PRG="$0" PRG="$0"
@@ -61,9 +20,49 @@ while [ -h "$PRG" ] ; do
fi fi
done done
SAVED="`pwd`" SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&- cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`" APP_HOME="`pwd -P`"
cd "$SAVED" >&- cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@@ -90,7 +89,7 @@ location of your Java installation."
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n` MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -114,6 +113,7 @@ fi
if $cygwin ; then if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"` APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath # We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
@@ -154,11 +154,19 @@ if $cygwin ; then
esac esac
fi fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules # Escape application args
function splitJvmOpts() { save () {
JVM_OPTS=("$@") for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
} }
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS APP_ARGS=$(save "$@")
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" # Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

14
gradlew.bat vendored
View File

@@ -8,14 +8,14 @@
@rem Set local scope for the variables with windows NT shell @rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal 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 set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=. if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe @rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome if defined JAVA_HOME goto findJavaFromJavaHome
@@ -46,10 +46,9 @@ echo location of your Java installation.
goto fail goto fail
:init :init
@rem Get command-line arguments, handling Windowz variants @rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args :win9xME_args
@rem Slurp the command line arguments. @rem Slurp the command line arguments.
@@ -60,11 +59,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%* set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute :execute
@rem Setup the command line @rem Setup the command line

View File

@@ -7,14 +7,14 @@ import java.util.Locale;
import javax.swing.UIManager; import javax.swing.UIManager;
import exopandora.worldhandler.installer.Window; import exopandora.worldhandler.installer.Window;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class Main public class Main
{ {
public static final String NAME = "World Handler"; public static final String NAME = "World Handler";
public static final String MODID = "worldhandler"; public static final String MODID = "worldhandler";
public static final String MC_VERSION = "1.13.2";
public static final String MOD_VERSION = "2.3";
public static final String URL = "https://minecraft.curseforge.com/projects/world-handler-command-gui";
public static void main(String[] args) public static void main(String[] args)
{ {

View File

@@ -1,195 +1,75 @@
package exopandora.worldhandler; package exopandora.worldhandler;
import org.apache.commons.lang3.ArrayUtils; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.lwjgl.input.Keyboard; import org.lwjgl.glfw.GLFW;
import exopandora.worldhandler.builder.ICommandBuilder; import exopandora.worldhandler.config.Config;
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.category.Category;
import exopandora.worldhandler.gui.content.Content; import exopandora.worldhandler.gui.content.Content;
import exopandora.worldhandler.helper.BlockHelper; import exopandora.worldhandler.helper.CommandHelper;
import exopandora.worldhandler.proxy.ClientProxy;
import exopandora.worldhandler.proxy.CommonProxy; import exopandora.worldhandler.proxy.CommonProxy;
import exopandora.worldhandler.util.UtilKeyBinding; import exopandora.worldhandler.util.UtilKeyBinding;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.settings.KeyBinding;
import net.minecraft.command.ICommand;
import net.minecraft.util.text.ChatType;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.event.ClickEvent;
import net.minecraft.util.text.event.ClickEvent.Action;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.config.ModConfig.Type;
import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.common.ProgressManager; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.common.ProgressManager.ProgressBar; import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent;
import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
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(Main.MODID)
@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 public class WorldHandler
{ {
@Instance(Main.MODID) public static final Logger LOGGER = LogManager.getLogger();
private static WorldHandler INSTANCE;
public static KeyBinding KEY_WORLD_HANDLER = new KeyBinding(Main.NAME, Keyboard.KEY_V, "key.categories.misc"); public static final KeyBinding KEY_WORLD_HANDLER = new KeyBinding(Main.NAME, GLFW.GLFW_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 final KeyBinding KEY_WORLD_HANDLER_POS1 = new KeyBinding(Main.NAME + " Pos1", GLFW.GLFW_KEY_O, "key.categories.misc");
public static KeyBinding KEY_WORLD_HANDLER_POS2 = new KeyBinding(Main.NAME + " Pos2", Keyboard.KEY_P, "key.categories.misc"); public static final KeyBinding KEY_WORLD_HANDLER_POS2 = new KeyBinding(Main.NAME + " Pos2", GLFW.GLFW_KEY_P, "key.categories.misc");
public static final ICommand COMMAND_WORLD_HANDLER = new CommandWorldHandler();
public static final ICommand COMMAND_WH = new CommandWH();
public static Configuration CONFIG;
public static Logger LOGGER;
public static String USERNAME = null; public static String USERNAME = null;
@SidedProxy(clientSide = "exopandora.worldhandler.proxy.ClientProxy", serverSide = "exopandora.worldhandler.proxy.CommonProxy") private static CommonProxy SIDEPROXY;
private static CommonProxy PROXY;
private EventListener eventListener = new EventListener();
@EventHandler public WorldHandler()
public void preInit(FMLPreInitializationEvent event)
{ {
LOGGER = event.getModLog(); SIDEPROXY = DistExecutor.runForDist(() -> ClientProxy::new, () -> CommonProxy::new);
LOGGER.info("Pre-Initialization"); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::commonSetup);
LOGGER.info("First Release on March 28 2013 - 02:29 PM CET by Exopandora"); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);
LOGGER.info("Latest Version: $url"); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::loadComplete);
CONFIG = new Configuration(event.getSuggestedConfigurationFile()); FMLJavaModLoadingContext.get().getModEventBus().addListener(Config::configLoad);
FMLJavaModLoadingContext.get().getModEventBus().addListener(Config::configReload);
ModLoadingContext.get().registerConfig(Type.CLIENT, Config.CLIENT_SPEC, Main.MODID + ".toml");
MinecraftForge.EVENT_BUS.addListener(this::serverStarting);
} }
@EventHandler private void commonSetup(FMLCommonSetupEvent event)
public void init(FMLInitializationEvent event)
{ {
LOGGER.info("Initialization"); SIDEPROXY.setup();
USERNAME = Minecraft.getMinecraft().getSession().getUsername(); }
MinecraftForge.EVENT_BUS.register(this.eventListener); private void clientSetup(FMLClientSetupEvent event)
{
USERNAME = Minecraft.getInstance().getSession().getUsername();
ClientRegistry.registerKeyBinding(KEY_WORLD_HANDLER); ClientRegistry.registerKeyBinding(KEY_WORLD_HANDLER);
UtilKeyBinding.updatePosKeys(); UtilKeyBinding.updatePosKeys();
} }
@EventHandler private void loadComplete(FMLLoadCompleteEvent event)
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(); Content.registerContents();
Category.registerCategories(); Category.registerCategories();
ProgressManager.pop(bar);
} }
@EventHandler private void serverStarting(FMLServerStartingEvent event)
public void serverLoad(FMLServerStartingEvent event)
{ {
event.registerServerCommand(COMMAND_WORLD_HANDLER); CommandHelper.registerCommands(event.getCommandDispatcher());
event.registerServerCommand(COMMAND_WH);
}
@EventHandler
public void disable(FMLModDisabledEvent event)
{
MinecraftForge.EVENT_BUS.register(this.eventListener);
Minecraft.getMinecraft().gameSettings.keyBindings = ArrayUtils.removeElement(Minecraft.getMinecraft().gameSettings.keyBindings, KEY_WORLD_HANDLER);
if(UtilKeyBinding.arePosKeysRegistered() && ConfigSettings.arePosShortcutsEnabled())
{
UtilKeyBinding.removePosKeys();
}
}
public static void updateConfig()
{
ConfigSettings.load(CONFIG);
ConfigSkin.load(CONFIG);
ConfigButcher.load(CONFIG);
ConfigSliders.load(CONFIG);
UtilKeyBinding.updatePosKeys();
}
public static void sendCommand(ICommandBuilder builder)
{
sendCommand(builder, false);
}
public static void sendCommand(ICommandBuilder builder, boolean special)
{
if(builder != null)
{
String command;
if(builder instanceof ICommandBuilderSyntax)
{
command = ((ICommandBuilderSyntax) builder).toActualCommand();
}
else
{
command = builder.toCommand();
}
LOGGER.info("Command: " + command);
if(builder.needsCommandBlock() || special)
{
BlockHelper.setCommandBlockNearPlayer(command);
}
else
{
Minecraft.getMinecraft().player.sendChatMessage(command);
}
}
}
public static void throwError(Exception exception)
{
if(!Minecraft.getMinecraft().inGameHasFocus)
{
Minecraft.getMinecraft().displayGuiScreen(null);
Minecraft.getMinecraft().setIngameFocus();
}
TextComponentString name = new TextComponentString(Main.NAME);
name.setStyle(new Style().setUnderlined(true).setClickEvent(new ClickEvent(Action.OPEN_URL, "$url")));
TextComponentTranslation message = new TextComponentTranslation("worldhandler.error.gui", name);
message.setStyle(new Style().setColor(net.minecraft.util.text.TextFormatting.RED));
Minecraft.getMinecraft().ingameGUI.addChatMessage(ChatType.SYSTEM, message);
exception.printStackTrace();
} }
} }

View File

@@ -9,16 +9,19 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.builder.Syntax.SyntaxEntry; import exopandora.worldhandler.builder.Syntax.SyntaxEntry;
import exopandora.worldhandler.builder.types.Coordinate; import exopandora.worldhandler.builder.types.BlockResourceLocation;
import exopandora.worldhandler.builder.types.Level; import exopandora.worldhandler.builder.types.CoordinateDouble;
import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.builder.types.GreedyString;
import exopandora.worldhandler.builder.types.ItemResourceLocation;
import exopandora.worldhandler.builder.types.TargetSelector; import exopandora.worldhandler.builder.types.TargetSelector;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public abstract class CommandBuilder implements ICommandBuilderSyntax public abstract class CommandBuilder implements ICommandBuilderSyntax
{ {
private List<Entry<SyntaxEntry, String>> command; private List<Entry<SyntaxEntry, String>> command;
@@ -33,6 +36,11 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
this.set(index, node != null ? (node.isEmpty() ? null : node) : null, Type.STRING); this.set(index, node != null ? (node.isEmpty() ? null : node) : null, Type.STRING);
} }
protected void setNode(int index, GreedyString node)
{
this.set(index, node != null ? (node.isEmpty() ? null : node) : null, Type.GREEDY_STRING);
}
protected void setNode(int index, boolean node) protected void setNode(int index, boolean node)
{ {
this.set(index, node, Type.BOOLEAN); this.set(index, node, Type.BOOLEAN);
@@ -73,14 +81,14 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
this.set(index, node, Type.RESOURCE_LOCATION); this.set(index, node, Type.RESOURCE_LOCATION);
} }
protected void setNode(int index, NBTTagCompound nbt) protected void setNode(int index, CoordinateInt coordinate)
{ {
this.set(index, nbt, Type.NBT); this.set(index, coordinate, Type.COORDINATE_INT);
} }
protected void setNode(int index, Coordinate coordinate) protected void setNode(int index, CoordinateDouble coordinate)
{ {
this.set(index, coordinate, Type.COORDINATE); this.set(index, coordinate, Type.COORDINATE_DOUBLE);
} }
protected void setNode(int index, TargetSelector target) protected void setNode(int index, TargetSelector target)
@@ -88,9 +96,19 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
this.set(index, target, Type.TARGET_SELECTOR); this.set(index, target, Type.TARGET_SELECTOR);
} }
protected void setNode(int index, Level level) protected void setNode(int index, ItemResourceLocation resource)
{ {
this.set(index, level, Type.LEVEL); this.set(index, resource != null ? resource.get() : null, Type.ITEM_RESOURCE_LOCATION);
}
protected void setNode(int index, BlockResourceLocation resource)
{
this.set(index, resource != null ? resource.get() : null, Type.BLOCK_RESOURCE_LOCATION);
}
protected void setNode(int index, NBTTagCompound nbt)
{
this.set(index, nbt, Type.NBT);
} }
private void set(int index, Object value, Type type) private void set(int index, Object value, Type type)
@@ -127,6 +145,12 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
return this.get(index, Type.STRING); return this.get(index, Type.STRING);
} }
@Nullable
protected String getNodeAsGreedyString(int index)
{
return this.get(index, Type.GREEDY_STRING);
}
protected boolean getNodeAsBoolean(int index) protected boolean getNodeAsBoolean(int index)
{ {
return this.get(index, Type.BOOLEAN); return this.get(index, Type.BOOLEAN);
@@ -162,9 +186,14 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
return this.get(index, Type.LONG); return this.get(index, Type.LONG);
} }
protected Coordinate getNodeAsCoordinate(int index) protected CoordinateInt getNodeAsCoordinateInt(int index)
{ {
return this.get(index, Type.COORDINATE); return this.get(index, Type.COORDINATE_INT);
}
protected CoordinateDouble getNodeAsCoordinateDouble(int index)
{
return this.get(index, Type.COORDINATE_DOUBLE);
} }
@Nullable @Nullable
@@ -179,9 +208,15 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
} }
@Nullable @Nullable
protected Level getNodeAsLevel(int index) protected ItemResourceLocation getNodeAsItemResourceLocation(int index)
{ {
return this.get(index, Type.LEVEL); return this.get(index, Type.ITEM_RESOURCE_LOCATION);
}
@Nullable
protected BlockResourceLocation getNodeAsBlockResourceLocation(int index)
{
return this.get(index, Type.BLOCK_RESOURCE_LOCATION);
} }
@Nullable @Nullable

View File

@@ -4,12 +4,12 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import exopandora.worldhandler.builder.component.IBuilderComponent; import exopandora.worldhandler.builder.component.IBuilderComponent;
import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public abstract class CommandBuilderNBT extends CommandBuilder implements ICommandBuilderNBT public abstract class CommandBuilderNBT extends CommandBuilder implements ICommandBuilderNBT
{ {
private final List<IBuilderComponent> TAG_TO_COMPONENT = new ArrayList<IBuilderComponent>(); private final List<IBuilderComponent> TAG_TO_COMPONENT = new ArrayList<IBuilderComponent>();
@@ -17,14 +17,32 @@ public abstract class CommandBuilderNBT extends CommandBuilder implements IComma
@Override @Override
public String toCommand() public String toCommand()
{ {
this.setNBT(this.buildNBT()); return this.toCommand(true);
}
public String toCommand(boolean rebuildNBT)
{
if(rebuildNBT)
{
this.setNBT(this.buildNBT());
}
return super.toCommand(); return super.toCommand();
} }
@Override @Override
public String toActualCommand() public String toActualCommand()
{ {
this.setNBT(this.buildNBT()); return this.toActualCommand(true);
}
public String toActualCommand(boolean rebuildNBT)
{
if(rebuildNBT)
{
this.setNBT(this.buildNBT());
}
return super.toActualCommand(); return super.toActualCommand();
} }
@@ -34,7 +52,7 @@ public abstract class CommandBuilderNBT extends CommandBuilder implements IComma
for(IBuilderComponent component : this.TAG_TO_COMPONENT) for(IBuilderComponent component : this.TAG_TO_COMPONENT)
{ {
NBTBase serialized = component.serialize(); INBTBase serialized = component.serialize();
if(serialized != null) if(serialized != null)
{ {
@@ -45,7 +63,7 @@ public abstract class CommandBuilderNBT extends CommandBuilder implements IComma
} }
} }
if(nbt.hasNoTags()) if(nbt.isEmpty())
{ {
return null; return null;
} }

View File

@@ -2,10 +2,10 @@ package exopandora.worldhandler.builder;
import com.mojang.realmsclient.gui.ChatFormatting; import com.mojang.realmsclient.gui.ChatFormatting;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class CommandString public class CommandString
{ {
private final StringBuilder command = new StringBuilder("/"); private final StringBuilder command = new StringBuilder("/");

View File

@@ -1,9 +1,9 @@
package exopandora.worldhandler.builder; package exopandora.worldhandler.builder;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public interface ICommandBuilder public interface ICommandBuilder
{ {
static final int MAX_COMMAND_LENGTH = 256; static final int MAX_COMMAND_LENGTH = 256;

View File

@@ -1,10 +1,10 @@
package exopandora.worldhandler.builder; package exopandora.worldhandler.builder;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public interface ICommandBuilderNBT extends ICommandBuilder public interface ICommandBuilderNBT extends ICommandBuilder
{ {
void setNBT(NBTTagCompound nbt); void setNBT(NBTTagCompound nbt);

View File

@@ -1,9 +1,9 @@
package exopandora.worldhandler.builder; package exopandora.worldhandler.builder;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public interface ICommandBuilderSyntax extends ICommandBuilder public interface ICommandBuilderSyntax extends ICommandBuilder
{ {
String getCommandName(); String getCommandName();

View File

@@ -4,10 +4,10 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class Syntax public class Syntax
{ {
private List<SyntaxEntry> syntax = new ArrayList<SyntaxEntry>(); private List<SyntaxEntry> syntax = new ArrayList<SyntaxEntry>();
@@ -41,7 +41,7 @@ public class Syntax
return this.syntax; return this.syntax;
} }
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public static class SyntaxEntry public static class SyntaxEntry
{ {
private final String key; private final String key;

View File

@@ -2,14 +2,14 @@ package exopandora.worldhandler.builder.component;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.INBTBase;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public interface IBuilderComponent public interface IBuilderComponent
{ {
@Nullable @Nullable
NBTBase serialize(); INBTBase serialize();
String getTag(); String getTag();
} }

View File

@@ -7,10 +7,10 @@ import java.util.function.Function;
import exopandora.worldhandler.builder.component.IBuilderComponent; import exopandora.worldhandler.builder.component.IBuilderComponent;
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes; import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public abstract class ComponentAttribute implements IBuilderComponent public abstract class ComponentAttribute implements IBuilderComponent
{ {
protected Map<EnumAttributes, Double> attributes = new HashMap<EnumAttributes, Double>(); protected Map<EnumAttributes, Double> attributes = new HashMap<EnumAttributes, Double>();

View File

@@ -1,28 +1,28 @@
package exopandora.worldhandler.builder.component.abstr; package exopandora.worldhandler.builder.component.abstr;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import exopandora.worldhandler.builder.component.IBuilderComponent; import exopandora.worldhandler.builder.component.IBuilderComponent;
import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.potion.Potion; import net.minecraft.potion.Potion;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public abstract class ComponentPotion implements IBuilderComponent public abstract class ComponentPotion implements IBuilderComponent
{ {
protected final Map<Potion, PotionMetadata> potions = Potion.REGISTRY.getKeys().stream().collect(Collectors.toMap(Potion.REGISTRY::getObject, key -> new PotionMetadata())); protected final Map<Potion, PotionMetadata> potions = new HashMap<Potion, PotionMetadata>();
@Override @Override
@Nullable @Nullable
public NBTBase serialize() public INBTBase serialize()
{ {
NBTTagList list = new NBTTagList(); NBTTagList list = new NBTTagList();
@@ -36,138 +36,95 @@ public abstract class ComponentPotion implements IBuilderComponent
compound.setByte("Id", (byte) Potion.getIdFromPotion(entry.getKey())); compound.setByte("Id", (byte) Potion.getIdFromPotion(entry.getKey()));
compound.setByte("Amplifier", (byte) (potion.getAmplifier() - 1)); compound.setByte("Amplifier", (byte) (potion.getAmplifier() - 1));
compound.setInteger("Duration", potion.getDurationTicks() > 0 ? Math.min(potion.getDurationTicks(), 1000000) : 1000000); compound.setInt("Duration", Math.min(potion.toTicks(), 1000000));
compound.setBoolean("Ambient", potion.getAmbient()); compound.setBoolean("Ambient", potion.getAmbient());
compound.setBoolean("ShowParticles", potion.getShowParticles()); compound.setBoolean("ShowParticles", potion.getShowParticles());
list.appendTag(compound); list.add(compound);
} }
} }
if(!list.hasNoTags()) if(list.isEmpty())
{ {
return list; return null;
} }
return null; return list;
}
public void set(Potion potion, PotionMetadata metadata)
{
this.potions.put(potion, metadata);
}
public void set(Potion potion, byte amplifier, int seconds, int minutes, int hours, boolean showParticles, boolean ambient)
{
this.set(potion, new PotionMetadata(amplifier, seconds, minutes, hours, showParticles, ambient));
} }
public void setAmplifier(Potion potion, byte amplifier) public void setAmplifier(Potion potion, byte amplifier)
{ {
if(this.potions.containsKey(potion)) this.getMetadata(potion).setAmplifier(amplifier);
{
this.potions.get(potion).setAmplifier(amplifier);
}
} }
public byte getAmplifier(Potion potion) public byte getAmplifier(Potion potion)
{ {
if(this.potions.containsKey(potion)) return this.getMetadata(potion).getAmplifier();
{
return this.potions.get(potion).getAmplifier();
}
return 0;
} }
public void setSeconds(Potion potion, int seconds) public void setSeconds(Potion potion, int seconds)
{ {
if(this.potions.containsKey(potion)) this.getMetadata(potion).setSeconds(seconds);
{
this.potions.get(potion).setSeconds(seconds);;
}
} }
public int getSeconds(Potion potion) public int getSeconds(Potion potion)
{ {
if(this.potions.containsKey(potion)) return this.getMetadata(potion).getSeconds();
{
return this.potions.get(potion).getSeconds();
}
return 0;
} }
public void setMinutes(Potion potion, int minutes) public void setMinutes(Potion potion, int minutes)
{ {
if(this.potions.containsKey(potion)) this.getMetadata(potion).setMinutes(minutes);
{
this.potions.get(potion).setSeconds(minutes);;
}
} }
public int getMinutes(Potion potion) public int getMinutes(Potion potion)
{ {
if(this.potions.containsKey(potion)) return this.getMetadata(potion).getMinutes();
{
return this.potions.get(potion).getMinutes();
}
return 0;
} }
public void setHours(Potion potion, int hours) public void setHours(Potion potion, int hours)
{ {
if(this.potions.containsKey(potion)) this.getMetadata(potion).setHours(hours);
{
this.potions.get(potion).setSeconds(hours);;
}
} }
public int getHours(Potion potion) public int getHours(Potion potion)
{ {
if(this.potions.containsKey(potion)) return this.getMetadata(potion).getHours();
{
return this.potions.get(potion).getHours();
}
return 0;
} }
public void setShowParticles(Potion potion, boolean showParticles) public void setShowParticles(Potion potion, boolean showParticles)
{ {
if(this.potions.containsKey(potion)) this.getMetadata(potion).setShowParticles(showParticles);
{
this.potions.get(potion).setShowParticles(showParticles);
}
} }
public boolean getShowParticles(Potion potion) public boolean getShowParticles(Potion potion)
{ {
if(this.potions.containsKey(potion)) return this.getMetadata(potion).getShowParticles();
{
return this.potions.get(potion).getShowParticles();
}
return true;
} }
public void setAmbient(Potion potion, boolean ambient) public void setAmbient(Potion potion, boolean ambient)
{ {
if(this.potions.containsKey(potion)) this.getMetadata(potion).setAmbient(ambient);
{
this.potions.get(potion).setAmbient(ambient);
}
} }
public boolean getAmbient(Potion potion) public boolean getAmbient(Potion potion)
{ {
if(this.potions.containsKey(potion)) return this.getMetadata(potion).getAmbient();
}
private PotionMetadata getMetadata(Potion potion)
{
return this.potions.get(this.validate(potion));
}
private Potion validate(Potion potion)
{
if(!this.potions.containsKey(potion))
{ {
return this.potions.get(potion).getAmbient(); this.potions.put(potion, new PotionMetadata());
} }
return false; return potion;
} }
public Set<Potion> getPotions() public Set<Potion> getPotions()
@@ -175,12 +132,6 @@ public abstract class ComponentPotion implements IBuilderComponent
return this.potions.keySet(); return this.potions.keySet();
} }
@Nullable
public PotionMetadata get(Potion potion)
{
return this.potions.get(potion);
}
public void remove(Potion potion) public void remove(Potion potion)
{ {
this.potions.remove(potion); this.potions.remove(potion);

View File

@@ -1,9 +1,9 @@
package exopandora.worldhandler.builder.component.abstr; package exopandora.worldhandler.builder.component.abstr;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class PotionMetadata public class PotionMetadata
{ {
private byte amplifier; private byte amplifier;
@@ -88,22 +88,22 @@ public class PotionMetadata
this.ambient = ambient; this.ambient = ambient;
} }
public int getDurationTicks() public int toTicks()
{ {
return PotionMetadata.getDurationTicks(this.seconds, this.minutes, this.hours); return PotionMetadata.toTicks(this.seconds, this.minutes, this.hours);
} }
public int getDurationSeconds() public int toSeconds()
{ {
return PotionMetadata.getDurationSeconds(this.seconds, this.minutes, this.hours); return PotionMetadata.toSeconds(this.seconds, this.minutes, this.hours);
} }
public static int getDurationTicks(int seconds, int minutes, int hours) public static int toTicks(int seconds, int minutes, int hours)
{ {
return seconds * 20 + minutes * 1200 + hours * 72000; return seconds * 20 + minutes * 1200 + hours * 72000;
} }
public static int getDurationSeconds(int seconds, int minutes, int hours) public static int toSeconds(int seconds, int minutes, int hours)
{ {
return seconds + minutes * 60 + hours * 3600; return seconds + minutes * 60 + hours * 3600;
} }
@@ -143,5 +143,11 @@ public class PotionMetadata
this.ambient = ambient; this.ambient = ambient;
return this; return this;
} }
@Override
public String toString()
{
return "PotionMetadata [amplifier=" + amplifier + ", seconds=" + seconds + ", minutes=" + minutes + ", hours=" + hours + ", showParticles=" + showParticles + ", ambient=" + ambient + "]";
}
} }

View File

@@ -8,13 +8,13 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.builder.component.abstr.ComponentAttribute; import exopandora.worldhandler.builder.component.abstr.ComponentAttribute;
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes; import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class ComponentAttributeItem extends ComponentAttribute public class ComponentAttributeItem extends ComponentAttribute
{ {
public ComponentAttributeItem(Function<EnumAttributes, Boolean> applyable) public ComponentAttributeItem(Function<EnumAttributes, Boolean> applyable)
@@ -24,7 +24,7 @@ public class ComponentAttributeItem extends ComponentAttribute
@Override @Override
@Nullable @Nullable
public NBTBase serialize() public INBTBase serialize()
{ {
NBTTagList attributes = new NBTTagList(); NBTTagList attributes = new NBTTagList();
@@ -37,20 +37,20 @@ public class ComponentAttributeItem extends ComponentAttribute
attribute.setString("AttributeName", entry.getKey().getAttribute()); attribute.setString("AttributeName", entry.getKey().getAttribute());
attribute.setString("Name", entry.getKey().getAttribute()); attribute.setString("Name", entry.getKey().getAttribute());
attribute.setDouble("Amount", entry.getKey().calculate(entry.getValue())); attribute.setDouble("Amount", entry.getKey().calculate(entry.getValue()));
attribute.setInteger("Operation", entry.getKey().getOperation().ordinal()); attribute.setInt("Operation", entry.getKey().getOperation().ordinal());
attribute.setLong("UUIDLeast", UUID.nameUUIDFromBytes(entry.getKey().getAttribute().getBytes()).getLeastSignificantBits()); attribute.setLong("UUIDLeast", UUID.nameUUIDFromBytes(entry.getKey().getAttribute().getBytes()).getLeastSignificantBits());
attribute.setLong("UUIDMost", UUID.nameUUIDFromBytes(entry.getKey().getAttribute().getBytes()).getMostSignificantBits()); attribute.setLong("UUIDMost", UUID.nameUUIDFromBytes(entry.getKey().getAttribute().getBytes()).getMostSignificantBits());
attributes.appendTag(attribute); attributes.add(attribute);
} }
} }
if(!attributes.hasNoTags()) if(attributes.isEmpty())
{ {
return attributes; return null;
} }
return null; return attributes;
} }
@Override @Override

View File

@@ -7,13 +7,13 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.builder.component.abstr.ComponentAttribute; import exopandora.worldhandler.builder.component.abstr.ComponentAttribute;
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes; import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class ComponentAttributeMob extends ComponentAttribute public class ComponentAttributeMob extends ComponentAttribute
{ {
public ComponentAttributeMob(Function<EnumAttributes, Boolean> applyable) public ComponentAttributeMob(Function<EnumAttributes, Boolean> applyable)
@@ -23,7 +23,7 @@ public class ComponentAttributeMob extends ComponentAttribute
@Override @Override
@Nullable @Nullable
public NBTBase serialize() public INBTBase serialize()
{ {
NBTTagList attributes = new NBTTagList(); NBTTagList attributes = new NBTTagList();
@@ -36,16 +36,16 @@ public class ComponentAttributeMob extends ComponentAttribute
attribute.setString("Name", entry.getKey().getAttribute()); attribute.setString("Name", entry.getKey().getAttribute());
attribute.setDouble("Base", entry.getKey().calculate(entry.getValue())); attribute.setDouble("Base", entry.getKey().calculate(entry.getValue()));
attributes.appendTag(attribute); attributes.add(attribute);
} }
} }
if(!attributes.hasNoTags()) if(attributes.isEmpty())
{ {
return attributes; return null;
} }
return null; return attributes;
} }
@Override @Override

View File

@@ -2,21 +2,23 @@ package exopandora.worldhandler.builder.component.impl;
import exopandora.worldhandler.builder.component.IBuilderComponent; import exopandora.worldhandler.builder.component.IBuilderComponent;
import exopandora.worldhandler.format.text.ColoredString; import exopandora.worldhandler.format.text.ColoredString;
import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString; import net.minecraft.nbt.NBTTagString;
import net.minecraftforge.fml.relauncher.Side; import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class ComponentDisplay implements IBuilderComponent public class ComponentDisplay implements IBuilderComponent
{ {
private ColoredString name = new ColoredString(); private ColoredString name = new ColoredString();
private String[] lore = new String[2]; private String[] lore = new String[2];
@Override @Override
public NBTBase serialize() public INBTBase serialize()
{ {
NBTTagCompound display = new NBTTagCompound(); NBTTagCompound display = new NBTTagCompound();
@@ -24,7 +26,7 @@ public class ComponentDisplay implements IBuilderComponent
if(name != null && !name.isEmpty()) if(name != null && !name.isEmpty())
{ {
display.setString("Name", this.name.toString()); display.setString("Name", ITextComponent.Serializer.toJson(new TextComponentString(this.name.toString())));
} }
NBTTagList lore = new NBTTagList(); NBTTagList lore = new NBTTagList();
@@ -33,16 +35,16 @@ public class ComponentDisplay implements IBuilderComponent
{ {
if(this.lore[x] != null && !this.lore[x].isEmpty()) if(this.lore[x] != null && !this.lore[x].isEmpty())
{ {
lore.appendTag(new NBTTagString(this.lore[x])); lore.add(new NBTTagString(this.lore[x]));
} }
} }
if(!lore.hasNoTags()) if(!lore.isEmpty())
{ {
display.setTag("Lore", lore); display.setTag("Lore", lore);
} }
if(!display.hasNoTags()) if(!display.isEmpty())
{ {
return display; return display;
} }

View File

@@ -1,28 +1,29 @@
package exopandora.worldhandler.builder.component.impl; package exopandora.worldhandler.builder.component.impl;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import exopandora.worldhandler.builder.component.IBuilderComponent; import exopandora.worldhandler.builder.component.IBuilderComponent;
import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.Enchantment;
import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistries;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class ComponentEnchantment implements IBuilderComponent public class ComponentEnchantment implements IBuilderComponent
{ {
private Map<Enchantment, Short> enchantments = Enchantment.REGISTRY.getKeys().stream().collect(Collectors.toMap(Enchantment.REGISTRY::getObject, key -> (short) 0)); private Map<Enchantment, Short> enchantments = new HashMap<Enchantment, Short>();
@Override @Override
@Nullable @Nullable
public NBTBase serialize() public INBTBase serialize()
{ {
NBTTagList enchantments = new NBTTagList(); NBTTagList enchantments = new NBTTagList();
@@ -32,24 +33,31 @@ public class ComponentEnchantment implements IBuilderComponent
{ {
NBTTagCompound enchantment = new NBTTagCompound(); NBTTagCompound enchantment = new NBTTagCompound();
enchantment.setShort("id", (short) Enchantment.getEnchantmentID(entry.getKey())); enchantment.setString("id", ForgeRegistries.ENCHANTMENTS.getKey(entry.getKey()).toString());
enchantment.setShort("lvl", entry.getValue()); enchantment.setShort("lvl", entry.getValue());
enchantments.appendTag(enchantment); enchantments.add(enchantment);
} }
} }
if(!enchantments.hasNoTags()) if(enchantments.isEmpty())
{ {
return enchantments; return null;
} }
return null; return enchantments;
} }
public void setLevel(Enchantment enchantment, short level) public void setLevel(Enchantment enchantment, short level)
{ {
this.enchantments.put(enchantment, level); if(level == 0)
{
this.enchantments.remove(enchantment);
}
else
{
this.enchantments.put(enchantment, level);
}
} }
public short getLevel(Enchantment enchantment) public short getLevel(Enchantment enchantment)
@@ -65,6 +73,6 @@ public class ComponentEnchantment implements IBuilderComponent
@Override @Override
public String getTag() public String getTag()
{ {
return "ench"; return "Enchantments";
} }
} }

View File

@@ -1,10 +1,10 @@
package exopandora.worldhandler.builder.component.impl; package exopandora.worldhandler.builder.component.impl;
import exopandora.worldhandler.builder.component.abstr.ComponentPotion; import exopandora.worldhandler.builder.component.abstr.ComponentPotion;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class ComponentPotionItem extends ComponentPotion public class ComponentPotionItem extends ComponentPotion
{ {
@Override @Override

View File

@@ -1,10 +1,10 @@
package exopandora.worldhandler.builder.component.impl; package exopandora.worldhandler.builder.component.impl;
import exopandora.worldhandler.builder.component.abstr.ComponentPotion; import exopandora.worldhandler.builder.component.abstr.ComponentPotion;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class ComponentPotionMob extends ComponentPotion public class ComponentPotionMob extends ComponentPotion
{ {
@Override @Override

View File

@@ -7,45 +7,20 @@ import javax.annotation.Nullable;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import exopandora.worldhandler.builder.component.IBuilderComponent; import exopandora.worldhandler.builder.component.IBuilderComponent;
import exopandora.worldhandler.helper.EntityHelper; import exopandora.worldhandler.helper.ResourceHelper;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityType;
import net.minecraft.entity.boss.EntityDragon; import net.minecraft.nbt.INBTBase;
import net.minecraft.entity.boss.EntityWither;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.item.EntityMinecartChest;
import net.minecraft.entity.item.EntityMinecartCommandBlock;
import net.minecraft.entity.item.EntityMinecartFurnace;
import net.minecraft.entity.item.EntityMinecartHopper;
import net.minecraft.entity.item.EntityMinecartMobSpawner;
import net.minecraft.entity.item.EntityMinecartTNT;
import net.minecraft.entity.monster.EntityEvoker;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.monster.EntityIronGolem;
import net.minecraft.entity.monster.EntityMagmaCube;
import net.minecraft.entity.monster.EntityPigZombie;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntitySnowman;
import net.minecraft.entity.monster.EntitySpider;
import net.minecraft.entity.monster.EntityVindicator;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntityMooshroom;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.entity.passive.EntitySquid;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagByte; import net.minecraft.nbt.NBTTagByte;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt; import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistries;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class ComponentSummon implements IBuilderComponent public class ComponentSummon implements IBuilderComponent
{ {
private final Random random = new Random(); private final Random random = new Random();
@@ -86,7 +61,7 @@ public class ComponentSummon implements IBuilderComponent
} }
@Override @Override
public NBTBase serialize() public INBTBase serialize()
{ {
if(this.name != null) if(this.name != null)
{ {
@@ -128,7 +103,7 @@ public class ComponentSummon implements IBuilderComponent
if(this.entity != null) if(this.entity != null)
{ {
if(this.entity.equals(EntityHelper.getResourceLocation(EntityZombie.class))) if(this.entity.equals(EntityType.ZOMBIE.getRegistryName()))
{ {
if(StringUtils.containsIgnoreCase(this.name, "Baby")) if(StringUtils.containsIgnoreCase(this.name, "Baby"))
{ {
@@ -136,30 +111,30 @@ public class ComponentSummon implements IBuilderComponent
return new NBTTagByte((byte) 1); return new NBTTagByte((byte) 1);
} }
} }
else if(this.entity.equals(EntityHelper.getResourceLocation(EntityChicken.class))) else if(this.entity.equals(EntityType.CHICKEN.getRegistryName()))
{ {
if(StringUtils.containsIgnoreCase(this.name, "Jockey") && !this.hasPassenger) if(StringUtils.containsIgnoreCase(this.name, "Jockey") && !this.hasPassenger)
{ {
NBTTagCompound passenger = new NBTTagCompound(); NBTTagCompound passenger = new NBTTagCompound();
NBTTagList list = new NBTTagList(); NBTTagList list = new NBTTagList();
passenger.setString("id", EntityHelper.getResourceLocation(EntityZombie.class).toString()); passenger.setString("id", EntityType.ZOMBIE.getRegistryName().toString());
passenger.setBoolean("IsBaby", true); passenger.setBoolean("IsBaby", true);
list.appendTag(passenger); list.add(passenger);
this.tag = "Passengers"; this.tag = "Passengers";
return list; return list;
} }
} }
else if(this.entity.equals(EntityHelper.getResourceLocation(EntitySpider.class))) else if(this.entity.equals(EntityType.SPIDER.getRegistryName()))
{ {
if(StringUtils.containsIgnoreCase(this.name, "Jockey") && !this.hasPassenger) if(StringUtils.containsIgnoreCase(this.name, "Jockey") && !this.hasPassenger)
{ {
NBTTagCompound passenger = new NBTTagCompound(); NBTTagCompound passenger = new NBTTagCompound();
NBTTagList list = new NBTTagList(); NBTTagList list = new NBTTagList();
passenger.setString("id", EntityHelper.getResourceLocation(EntitySkeleton.class).toString()); passenger.setString("id", EntityType.SKELETON.getRegistryName().toString());
list.appendTag(passenger); list.add(passenger);
this.tag = "Passengers"; this.tag = "Passengers";
return list; return list;
@@ -180,116 +155,117 @@ public class ComponentSummon implements IBuilderComponent
@Nullable @Nullable
public static ResourceLocation resolve(String entityName) public static ResourceLocation resolve(String entityName)
{ {
String entity = entityName.replaceAll("_| ", ""); String name = ResourceHelper.stripToResourceLocation(entityName);
for(ResourceLocation location : EntityList.ENTITY_EGGS.keySet()) for(EntityType<?> type : ForgeRegistries.ENTITIES.getValues())
{ {
if(entityName.equalsIgnoreCase(I18n.format("entity." + EntityHelper.getEntityName(location) + ".name"))) if(type.isSummonable() && entityName.equalsIgnoreCase(I18n.format(type.getTranslationKey())))
{ {
entity = location.getResourcePath(); return type.getRegistryName();
break;
} }
} }
String entity = name.replaceAll("_", "");
if(entity.equalsIgnoreCase("RedCow")) if(entity.equalsIgnoreCase("RedCow"))
{ {
return EntityHelper.getResourceLocation(EntityMooshroom.class); return EntityType.MOOSHROOM.getRegistryName();
} }
else if(entity.equalsIgnoreCase("ChickenJockey")) else if(entity.equalsIgnoreCase("ChickenJockey"))
{ {
return EntityHelper.getResourceLocation(EntityChicken.class); return EntityType.CHICKEN.getRegistryName();
} }
else if(entity.equalsIgnoreCase("Pigman") || entity.equalsIgnoreCase("ZombiePig") || entity.equalsIgnoreCase("ZombiePigman")) else if(entity.equalsIgnoreCase("Pigman") || entity.equalsIgnoreCase("ZombiePig") || entity.equalsIgnoreCase("ZombiePigman"))
{ {
return EntityHelper.getResourceLocation(EntityPigZombie.class); return EntityType.ZOMBIE_PIGMAN.getRegistryName();
} }
else if(entity.equalsIgnoreCase("Wither")) else if(entity.equalsIgnoreCase("Wither"))
{ {
return EntityHelper.getResourceLocation(EntityWither.class); return EntityType.WITHER.getRegistryName();
} }
else if(entity.equalsIgnoreCase("Dog")) else if(entity.equalsIgnoreCase("Dog"))
{ {
return EntityHelper.getResourceLocation(EntityWolf.class); return EntityType.WOLF.getRegistryName();
} }
else if(entity.equalsIgnoreCase("Dragon")) else if(entity.equalsIgnoreCase("Dragon"))
{ {
return EntityHelper.getResourceLocation(EntityDragon.class); return EntityType.ENDER_DRAGON.getRegistryName();
} }
else if(entity.equalsIgnoreCase("minecraft:SnowGolem")) else if(entity.equalsIgnoreCase("minecraft:SnowGolem"))
{ {
return EntityHelper.getResourceLocation(EntitySnowman.class); return EntityType.SNOW_GOLEM.getRegistryName();
} }
else if(entity.equalsIgnoreCase("Horse") || entity.equalsIgnoreCase("ZombieHorse") || entity.equalsIgnoreCase("SkeletonHorse")) else if(entity.equalsIgnoreCase("Horse") || entity.equalsIgnoreCase("ZombieHorse") || entity.equalsIgnoreCase("SkeletonHorse"))
{ {
return EntityHelper.getResourceLocation(EntityHorse.class); return EntityType.HORSE.getRegistryName();
} }
else if(entity.equalsIgnoreCase("LavaCube")|| entity.equalsIgnoreCase("MagmaSlime") || entity.equalsIgnoreCase("MagmaCube")) else if(entity.equalsIgnoreCase("LavaCube")|| entity.equalsIgnoreCase("MagmaSlime") || entity.equalsIgnoreCase("MagmaCube"))
{ {
return EntityHelper.getResourceLocation(EntityMagmaCube.class); return EntityType.MAGMA_CUBE.getRegistryName();
} }
else if(entity.equalsIgnoreCase("SpiderJockey")) else if(entity.equalsIgnoreCase("SpiderJockey"))
{ {
return EntityHelper.getResourceLocation(EntitySpider.class); return EntityType.SPIDER.getRegistryName();
} }
else if(entity.equalsIgnoreCase("IronGolem")) else if(entity.equalsIgnoreCase("IronGolem"))
{ {
return EntityHelper.getResourceLocation(EntityIronGolem.class); return EntityType.IRON_GOLEM.getRegistryName();
} }
else if(entity.equalsIgnoreCase("Ozelot") || entity.equals("Ocelot") || entity.equalsIgnoreCase("Cat") || entity.equalsIgnoreCase("Kitty") || entity.equalsIgnoreCase("Kitten")) else if(entity.equalsIgnoreCase("Ozelot") || entity.equals("Ocelot") || entity.equalsIgnoreCase("Cat") || entity.equalsIgnoreCase("Kitty") || entity.equalsIgnoreCase("Kitten"))
{ {
return EntityHelper.getResourceLocation(EntityOcelot.class); return EntityType.OCELOT.getRegistryName();
} }
else if(entity.equalsIgnoreCase("TESTIFICATE") || entity.equalsIgnoreCase("Blacksmith") || entity.equalsIgnoreCase("Farmer") || entity.equalsIgnoreCase("Fisherman") || entity.equalsIgnoreCase("Shepherd") || entity.equalsIgnoreCase("Fletcher") || entity.equalsIgnoreCase("Librarian") || entity.equalsIgnoreCase("Cleric") || entity.equalsIgnoreCase("Priest") || entity.equalsIgnoreCase("Armorer") || entity.equalsIgnoreCase("WeaponSmith") || entity.equalsIgnoreCase("ToolSmith") || entity.equalsIgnoreCase("Butcher") || entity.equalsIgnoreCase("Leatherworker") || entity.equalsIgnoreCase("Carthographer") || entity.equalsIgnoreCase("Nitwit")) else if(entity.equalsIgnoreCase("TESTIFICATE") || entity.equalsIgnoreCase("Blacksmith") || entity.equalsIgnoreCase("Farmer") || entity.equalsIgnoreCase("Fisherman") || entity.equalsIgnoreCase("Shepherd") || entity.equalsIgnoreCase("Fletcher") || entity.equalsIgnoreCase("Librarian") || entity.equalsIgnoreCase("Cleric") || entity.equalsIgnoreCase("Priest") || entity.equalsIgnoreCase("Armorer") || entity.equalsIgnoreCase("WeaponSmith") || entity.equalsIgnoreCase("ToolSmith") || entity.equalsIgnoreCase("Butcher") || entity.equalsIgnoreCase("Leatherworker") || entity.equalsIgnoreCase("Carthographer") || entity.equalsIgnoreCase("Nitwit"))
{ {
return EntityHelper.getResourceLocation(EntityVillager.class); return EntityType.VILLAGER.getRegistryName();
} }
else if(entity.equalsIgnoreCase("Octopus") || entity.equalsIgnoreCase("Kraken")) else if(entity.equalsIgnoreCase("Octopus") || entity.equalsIgnoreCase("Kraken"))
{ {
return EntityHelper.getResourceLocation(EntitySquid.class); return EntityType.SQUID.getRegistryName();
} }
else if(entity.equalsIgnoreCase("Exwife")) else if(entity.equalsIgnoreCase("Exwife"))
{ {
return EntityHelper.getResourceLocation(EntityGhast.class); return EntityType.GHAST.getRegistryName();
} }
else if(entity.equalsIgnoreCase("TNTMinecart")) else if(entity.equalsIgnoreCase("TNTMinecart"))
{ {
return EntityHelper.getResourceLocation(EntityMinecartTNT.class); return EntityType.TNT_MINECART.getRegistryName();
} }
else if(entity.equalsIgnoreCase("Minecart")) else if(entity.equalsIgnoreCase("Minecart"))
{ {
return EntityHelper.getResourceLocation(EntityMinecart.class); return EntityType.MINECART.getRegistryName();
} }
else if(entity.equalsIgnoreCase("HopperMinecart")) else if(entity.equalsIgnoreCase("HopperMinecart"))
{ {
return EntityHelper.getResourceLocation(EntityMinecartHopper.class); return EntityType.HOPPER_MINECART.getRegistryName();
} }
else if(entity.equalsIgnoreCase("ChestMinecart")) else if(entity.equalsIgnoreCase("ChestMinecart"))
{ {
return EntityHelper.getResourceLocation(EntityMinecartChest.class); return EntityType.CHEST_MINECART.getRegistryName();
} }
else if(entity.equalsIgnoreCase("SpawnerMinecart")) else if(entity.equalsIgnoreCase("SpawnerMinecart"))
{ {
return EntityHelper.getResourceLocation(EntityMinecartMobSpawner.class); return EntityType.SPAWNER_MINECART.getRegistryName();
} }
else if(entity.equalsIgnoreCase("FurnaceMinecart")) else if(entity.equalsIgnoreCase("FurnaceMinecart"))
{ {
return EntityHelper.getResourceLocation(EntityMinecartFurnace.class); return EntityType.FURNACE_MINECART.getRegistryName();
} }
else if(entity.equalsIgnoreCase("CommandBlockMinecart") || entity.equalsIgnoreCase("MinecartCommand") || entity.equalsIgnoreCase("CommandMinecart")) else if(entity.equalsIgnoreCase("CommandBlockMinecart") || entity.equalsIgnoreCase("MinecartCommand") || entity.equalsIgnoreCase("CommandMinecart"))
{ {
return EntityHelper.getResourceLocation(EntityMinecartCommandBlock.class); return EntityType.COMMAND_BLOCK_MINECART.getRegistryName();
} }
else if(entity.equalsIgnoreCase("Wizard")) else if(entity.equalsIgnoreCase("Wizard"))
{ {
return EntityHelper.getResourceLocation(EntityEvoker.class); return EntityType.EVOKER.getRegistryName();
} }
else if(entity.equalsIgnoreCase("Johnny")) else if(entity.equalsIgnoreCase("Johnny"))
{ {
return EntityHelper.getResourceLocation(EntityVindicator.class); return EntityType.VINDICATOR.getRegistryName();
} }
else if(entity.equalsIgnoreCase("BabyZombie")) else if(entity.equalsIgnoreCase("BabyZombie"))
{ {
return EntityHelper.getResourceLocation(EntityZombie.class); return EntityType.ZOMBIE.getRegistryName();
} }
if(entity == null || entity.isEmpty()) if(entity == null || entity.isEmpty())
@@ -297,6 +273,6 @@ public class ComponentSummon implements IBuilderComponent
return null; return null;
} }
return new ResourceLocation(entity); return ResourceHelper.stringToResourceLocation(name);
} }
} }

View File

@@ -1,12 +1,13 @@
package exopandora.worldhandler.builder.component.impl; package exopandora.worldhandler.builder.component.impl;
import java.util.Collection;
import java.util.function.Function; import java.util.function.Function;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.builder.component.IBuilderComponent; import exopandora.worldhandler.builder.component.IBuilderComponent;
import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagByte; import net.minecraft.nbt.NBTTagByte;
import net.minecraft.nbt.NBTTagByteArray; import net.minecraft.nbt.NBTTagByteArray;
import net.minecraft.nbt.NBTTagDouble; import net.minecraft.nbt.NBTTagDouble;
@@ -16,24 +17,24 @@ import net.minecraft.nbt.NBTTagIntArray;
import net.minecraft.nbt.NBTTagLong; import net.minecraft.nbt.NBTTagLong;
import net.minecraft.nbt.NBTTagLongArray; import net.minecraft.nbt.NBTTagLongArray;
import net.minecraft.nbt.NBTTagString; import net.minecraft.nbt.NBTTagString;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class ComponentTag<T> implements IBuilderComponent public class ComponentTag<T> implements IBuilderComponent
{ {
private final Function<T, NBTBase> serializer; private final Function<T, INBTBase> serializer;
private final String tag; private final String tag;
private T value; private T value;
public ComponentTag(String tag, T value, Function<T, NBTBase> serializer) public ComponentTag(String tag, T value, Function<T, INBTBase> serializer)
{ {
this.tag = tag; this.tag = tag;
this.value = value; this.value = value;
this.serializer = serializer; this.serializer = serializer;
} }
public ComponentTag(String tag, Function<T, NBTBase> serializer) public ComponentTag(String tag, Function<T, INBTBase> serializer)
{ {
this(tag, null, serializer); this(tag, null, serializer);
} }
@@ -61,7 +62,7 @@ public class ComponentTag<T> implements IBuilderComponent
@Override @Override
@Nullable @Nullable
public NBTBase serialize() public INBTBase serialize()
{ {
if(this.value != null) if(this.value != null)
{ {
@@ -80,16 +81,19 @@ public class ComponentTag<T> implements IBuilderComponent
return new NBTTagString(string); return new NBTTagString(string);
} }
else if(this.value instanceof NBTBase) else if(this.value instanceof INBTBase)
{ {
NBTBase base = (NBTBase) this.value; if(this.value instanceof Collection<?>)
if(base.hasNoTags())
{ {
return null; Collection<?> collection = (Collection<?>) this.value;
if(collection.isEmpty())
{
return null;
}
} }
return (NBTBase) this.value; return (INBTBase) this.value;
} }
else if(this.value instanceof Integer) else if(this.value instanceof Integer)
{ {

View File

@@ -7,10 +7,10 @@ import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import exopandora.worldhandler.helper.EnumHelper; import exopandora.worldhandler.helper.EnumHelper;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderAdvancement extends CommandBuilder public class BuilderAdvancement extends CommandBuilder
{ {
public BuilderAdvancement(EnumMode mode) public BuilderAdvancement(EnumMode mode)
@@ -34,7 +34,7 @@ public class BuilderAdvancement extends CommandBuilder
@Nullable @Nullable
public EnumActionType getActionType() public EnumActionType getActionType()
{ {
return EnumHelper.valueOf(EnumActionType.class, this.getNodeAsString(1)); return EnumHelper.valueOf(this.getNodeAsString(1), EnumActionType.class);
} }
public void setPlayer(String player) public void setPlayer(String player)
@@ -56,14 +56,14 @@ public class BuilderAdvancement extends CommandBuilder
@Nullable @Nullable
public EnumMode getMode() public EnumMode getMode()
{ {
return EnumHelper.valueOf(EnumMode.class, this.getNodeAsString(2)); return EnumHelper.valueOf(this.getNodeAsString(2), EnumMode.class);
} }
public void setAdvancement(ResourceLocation advancement) public void setAdvancement(ResourceLocation advancement)
{ {
this.setNode(3, advancement); this.setNode(3, advancement);
} }
@Nullable @Nullable
public ResourceLocation getAdvancement() public ResourceLocation getAdvancement()
{ {
@@ -98,8 +98,8 @@ public class BuilderAdvancement extends CommandBuilder
return syntax; return syntax;
} }
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public static enum EnumActionType public static enum EnumActionType
{ {
GRANT, GRANT,
@@ -112,7 +112,7 @@ public class BuilderAdvancement extends CommandBuilder
} }
} }
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public static enum EnumMode public static enum EnumMode
{ {
ONLY, ONLY,

View File

@@ -1,37 +0,0 @@
package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.impl.abstr.BuilderBlockPos;
import exopandora.worldhandler.builder.types.Type;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class BuilderBlockdata extends BuilderBlockPos
{
@Override
public void setNBT(NBTTagCompound nbt)
{
this.setNode(3, nbt);
}
@Override
public String getCommandName()
{
return "blockdata";
}
@Override
public final Syntax getSyntax()
{
Syntax syntax = new Syntax();
syntax.addRequired("x", Type.COORDINATE);
syntax.addRequired("y", Type.COORDINATE);
syntax.addRequired("z", Type.COORDINATE);
syntax.addRequired("nbt", Type.NBT);
return syntax;
}
}

View File

@@ -1,49 +1,60 @@
package exopandora.worldhandler.builder.impl; package exopandora.worldhandler.builder.impl;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import exopandora.worldhandler.builder.CommandBuilder; import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.TargetSelector; import exopandora.worldhandler.builder.types.TargetSelector;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderButcher extends CommandBuilder public class BuilderButcher extends CommandBuilder
{ {
private final TargetSelector targetSelector; private final TargetSelector targetSelector = new TargetSelector();
public BuilderButcher() public BuilderButcher()
{ {
this(new ResourceLocation("<entity_name>"), 0); this("<entity_name>", 0);
} }
public BuilderButcher(ResourceLocation entity, int radius) public BuilderButcher(ResourceLocation entity, int distance)
{
this(entity.toString(), distance);
}
private BuilderButcher(String entity, int distance)
{ {
this.targetSelector = new TargetSelector();
this.setEntity(entity); this.setEntity(entity);
this.setRadius(radius); this.setDistance(distance);
} }
public void setRadius(int radius) public void setDistance(int distance)
{ {
this.targetSelector.set("r", radius); this.targetSelector.set("distance", "0.." + distance);
this.setNode(0, this.targetSelector); this.setNode(0, this.targetSelector);
} }
@Nonnull public int getDistance()
public int getRadius()
{ {
return this.targetSelector.<Integer>get("r"); return Integer.parseInt(this.targetSelector.<String>get("distance").substring(3));
} }
private void setEntity(String entity)
{
if(entity != null)
{
this.targetSelector.set("type", entity);
}
this.setNode(0, this.targetSelector);
}
public void setEntity(ResourceLocation entity) public void setEntity(ResourceLocation entity)
{ {
this.targetSelector.set("type", entity.toString()); this.setEntity(entity.toString());
this.setNode(0, this.targetSelector);
} }
@Nonnull @Nonnull

View File

@@ -2,21 +2,22 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.impl.abstr.BuilderDoubleBlockPos; import exopandora.worldhandler.builder.impl.abstr.BuilderDoubleBlockPos;
import exopandora.worldhandler.builder.types.Coordinate; import exopandora.worldhandler.builder.types.Coordinate.CoordinateType;
import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import exopandora.worldhandler.helper.EnumHelper; import exopandora.worldhandler.helper.EnumHelper;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderClone extends BuilderDoubleBlockPos public class BuilderClone extends BuilderDoubleBlockPos
{ {
public BuilderClone() public BuilderClone()
{ {
this.setX(new Coordinate()); this.setX(new CoordinateInt(CoordinateType.GLOBAL));
this.setY(new Coordinate()); this.setY(new CoordinateInt(CoordinateType.GLOBAL));
this.setZ(new Coordinate()); this.setZ(new CoordinateInt(CoordinateType.GLOBAL));
this.setMask(EnumMask.values()[0]); this.setMask(EnumMask.values()[0]);
this.setNode(10, "force"); this.setNode(10, "force");
} }
@@ -28,49 +29,49 @@ public class BuilderClone extends BuilderDoubleBlockPos
this.setZ(pos.getZ()); this.setZ(pos.getZ());
} }
public void setX(float x) public void setX(int x)
{ {
this.setX(new Coordinate(x)); this.setX(new CoordinateInt(x));
} }
public void setY(float y) public void setY(int y)
{ {
this.setY(new Coordinate(y)); this.setY(new CoordinateInt(y));
} }
public void setZ(float z) public void setZ(int z)
{ {
this.setZ(new Coordinate(z)); this.setZ(new CoordinateInt(z));
} }
public void setX(Coordinate x) public void setX(CoordinateInt x)
{ {
this.setNode(6, x); this.setNode(6, x);
} }
public void setY(Coordinate y) public void setY(CoordinateInt y)
{ {
this.setNode(7, y); this.setNode(7, y);
} }
public void setZ(Coordinate z) public void setZ(CoordinateInt z)
{ {
this.setNode(8, z); this.setNode(8, z);
} }
public Coordinate getXCoordiante() public CoordinateInt getXCoordiante()
{ {
return this.getNodeAsCoordinate(6); return this.getNodeAsCoordinateInt(6);
} }
public Coordinate getYCoordiante() public CoordinateInt getYCoordiante()
{ {
return this.getNodeAsCoordinate(7); return this.getNodeAsCoordinateInt(7);
} }
public Coordinate getZCoordiante() public CoordinateInt getZCoordiante()
{ {
return this.getNodeAsCoordinate(8); return this.getNodeAsCoordinateInt(8);
} }
public double getX() public double getX()
@@ -100,7 +101,7 @@ public class BuilderClone extends BuilderDoubleBlockPos
public EnumMask getMask() public EnumMask getMask()
{ {
return EnumHelper.valueOf(EnumMask.class, this.getNodeAsString(9)); return EnumHelper.valueOf(this.getNodeAsString(9), EnumMask.class);
} }
@Override @Override
@@ -114,22 +115,22 @@ public class BuilderClone extends BuilderDoubleBlockPos
{ {
Syntax syntax = new Syntax(); Syntax syntax = new Syntax();
syntax.addRequired("x1", Type.COORDINATE); syntax.addRequired("x1", Type.COORDINATE_INT);
syntax.addRequired("y1", Type.COORDINATE); syntax.addRequired("y1", Type.COORDINATE_INT);
syntax.addRequired("z1", Type.COORDINATE); syntax.addRequired("z1", Type.COORDINATE_INT);
syntax.addRequired("x2", Type.COORDINATE); syntax.addRequired("x2", Type.COORDINATE_INT);
syntax.addRequired("y2", Type.COORDINATE); syntax.addRequired("y2", Type.COORDINATE_INT);
syntax.addRequired("z2", Type.COORDINATE); syntax.addRequired("z2", Type.COORDINATE_INT);
syntax.addRequired("x", Type.COORDINATE); syntax.addRequired("x", Type.COORDINATE_INT);
syntax.addRequired("y", Type.COORDINATE); syntax.addRequired("y", Type.COORDINATE_INT);
syntax.addRequired("z", Type.COORDINATE); syntax.addRequired("z", Type.COORDINATE_INT);
syntax.addOptional("mask_mode", Type.STRING); syntax.addOptional("mask", Type.STRING);
syntax.addOptional("clone_mode", Type.STRING); syntax.addOptional("filter", Type.STRING);
return syntax; return syntax;
} }
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public static enum EnumMask public static enum EnumMask
{ {
REPLACE, REPLACE,

View File

@@ -10,10 +10,10 @@ import exopandora.worldhandler.builder.impl.abstr.EnumAttributes.Applyable;
import exopandora.worldhandler.format.text.ColoredString; import exopandora.worldhandler.format.text.ColoredString;
import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.Enchantment;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderCustomItem extends BuilderGive public class BuilderCustomItem extends BuilderGive
{ {
private final ComponentAttributeItem attribute; private final ComponentAttributeItem attribute;

View File

@@ -0,0 +1,323 @@
package exopandora.worldhandler.builder.impl;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.impl.abstr.BuilderBlockPos;
import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.builder.types.TargetSelector;
import exopandora.worldhandler.builder.types.Type;
import exopandora.worldhandler.helper.EnumHelper;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class BuilderData extends BuilderBlockPos
{
private final TargetSelector targetSelector = new TargetSelector();
public BuilderData()
{
super(2);
}
public BuilderData(EnumMode mode, ResourceLocation entity, NBTTagCompound nbt)
{
this();
this.setMode(mode);
this.setEntity(entity);
this.setNBT(nbt);
}
public BuilderData(EnumMode mode, BlockPos pos, NBTTagCompound nbt)
{
this();
this.setMode(mode);
this.setPosition(pos);
this.setNBT(nbt);
}
public void setMode(EnumMode mode)
{
EnumTarget target = this.getTarget();
this.updateSyntax(this.getSyntax(mode, target));
this.setMode0(mode);
this.setTarget0(target);
}
private void setMode0(EnumMode mode)
{
if(mode != null)
{
this.setNode(0, mode.toString());
}
}
public EnumMode getMode()
{
return EnumHelper.valueOf(this.getNodeAsString(0), EnumMode.class);
}
public void setTarget(EnumTarget target)
{
EnumMode mode = this.getMode();
this.updateSyntax(this.getSyntax(mode, target));
this.setMode0(mode);
this.setTarget0(target);
}
private void setTarget0(EnumTarget target)
{
if(target != null)
{
this.setNode(1, target.toString());
}
}
public EnumTarget getTarget()
{
return EnumHelper.valueOf(this.getNodeAsString(1), EnumTarget.class);
}
private void setEntity(String entity)
{
this.ensureTarget(EnumTarget.ENTITY);
if(entity != null)
{
this.targetSelector.set("type", entity);
}
this.setNode(2, this.targetSelector);
}
public void setEntity(ResourceLocation entity)
{
this.setEntity(entity.toString());
}
@Nonnull
public ResourceLocation getEntity()
{
return this.targetSelector.<ResourceLocation>get("type");
}
public void setPath(String path)
{
if(this.getMode() == null || !this.getMode().equals(EnumMode.REMOVE))
{
this.setMode(EnumMode.REMOVE);
}
switch(this.getTarget())
{
case BLOCK:
this.setNode(5, path);
break;
case ENTITY:
this.setNode(3, path);
break;
default:
break;
}
}
@Override
public void setNBT(NBTTagCompound nbt)
{
if(this.getMode() == null || !this.getMode().equals(EnumMode.MERGE))
{
this.setMode(EnumMode.MERGE);
}
EnumTarget target = this.getTarget();
if(target != null)
{
switch(target)
{
case BLOCK:
this.setNode(5, nbt);
break;
case ENTITY:
this.setNode(3, nbt);
break;
default:
break;
}
}
}
@Nullable
public NBTTagCompound getNBT()
{
if(this.getMode() != null && this.getMode().equals(EnumMode.MERGE))
{
switch(this.getTarget())
{
case BLOCK:
return this.getNodeAsNBT(5);
case ENTITY:
return this.getNodeAsNBT(3);
default:
break;
}
}
return null;
}
@Override
public String getCommandName()
{
return "data";
}
@Nullable
private final Syntax getSyntax(EnumMode mode, EnumTarget target)
{
Syntax syntax = new Syntax();
syntax.addRequired(mode != null ? mode.toString() : "mode", Type.STRING);
syntax.addRequired(target != null ? target.toString() : "target", Type.STRING);
if(target != null)
{
switch(target)
{
case BLOCK:
syntax.addRequired("x", Type.COORDINATE_INT);
syntax.addRequired("y", Type.COORDINATE_INT);
syntax.addRequired("z", Type.COORDINATE_INT);
break;
case ENTITY:
syntax.addRequired("entity", Type.TARGET_SELECTOR);
break;
default:
break;
}
switch(mode)
{
case GET:
break;
case MERGE:
syntax.addRequired("nbt", Type.NBT);
break;
case REMOVE:
syntax.addRequired("path", Type.STRING);
break;
default:
break;
}
}
else
{
syntax.addOptional("...", Type.STRING);
}
return syntax;
}
private void ensureTarget(EnumTarget target)
{
if(this.getTarget() == null || !target.equals(this.getTarget()))
{
this.setTarget(target);
}
}
@Override
public void setX(CoordinateInt x)
{
this.ensureTarget(EnumTarget.BLOCK);
super.setX(x);
}
@Override
public void setY(CoordinateInt y)
{
this.ensureTarget(EnumTarget.BLOCK);
super.setY(y);
}
@Override
public void setZ(CoordinateInt z)
{
this.ensureTarget(EnumTarget.BLOCK);
super.setZ(z);
}
@Override
public CoordinateInt getXCoordinate()
{
this.ensureTarget(EnumTarget.BLOCK);
return super.getXCoordinate();
}
@Override
public CoordinateInt getYCoordinate()
{
this.ensureTarget(EnumTarget.BLOCK);
return super.getYCoordinate();
}
@Override
public CoordinateInt getZCoordinate()
{
this.ensureTarget(EnumTarget.BLOCK);
return super.getZCoordinate();
}
@Override
public BlockPos getBlockPos()
{
this.ensureTarget(EnumTarget.BLOCK);
return super.getBlockPos();
}
@Override
public final Syntax getSyntax()
{
Syntax syntax = new Syntax();
syntax.addRequired("get|merge|remove", Type.STRING);
syntax.addRequired("block|entity", Type.STRING);
syntax.addOptional("...", Type.STRING);
return syntax;
}
@OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
GET,
MERGE,
REMOVE;
@Override
public String toString()
{
return this.name().toLowerCase();
}
}
@OnlyIn(Dist.CLIENT)
public static enum EnumTarget
{
BLOCK,
ENTITY;
@Override
public String toString()
{
return this.name().toLowerCase();
}
}
}

View File

@@ -3,10 +3,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder; import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderDifficulty extends CommandBuilder public class BuilderDifficulty extends CommandBuilder
{ {
public BuilderDifficulty() public BuilderDifficulty()
@@ -21,7 +21,10 @@ public class BuilderDifficulty extends CommandBuilder
public void setDifficulty(EnumDifficulty difficulty) public void setDifficulty(EnumDifficulty difficulty)
{ {
this.setNode(0, difficulty.toString()); if(difficulty != null)
{
this.setNode(0, difficulty.toString());
}
} }
@Override @Override
@@ -29,7 +32,7 @@ public class BuilderDifficulty extends CommandBuilder
{ {
return "difficulty"; return "difficulty";
} }
@Override @Override
public final Syntax getSyntax() public final Syntax getSyntax()
{ {
@@ -41,7 +44,7 @@ public class BuilderDifficulty extends CommandBuilder
} }
@Deprecated @Deprecated
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public static enum EnumDifficulty public static enum EnumDifficulty
{ {
PEACEFUL, PEACEFUL,

View File

@@ -3,11 +3,12 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder; import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderEnchantment extends CommandBuilder public class BuilderEnchantment extends CommandBuilder
{ {
public void getPlayer(String player) public void getPlayer(String player)
@@ -25,6 +26,11 @@ public class BuilderEnchantment extends CommandBuilder
return this.getNodeAsResourceLocation(1); return this.getNodeAsResourceLocation(1);
} }
public void setEnchantment(Enchantment enchantment)
{
this.setEnchantment(enchantment.getRegistryName());
}
public void setEnchantment(ResourceLocation enchantment) public void setEnchantment(ResourceLocation enchantment)
{ {
this.setNode(1, enchantment); this.setNode(1, enchantment);

View File

@@ -1,41 +1,39 @@
package exopandora.worldhandler.builder.impl; package exopandora.worldhandler.builder.impl;
import javax.annotation.Nullable;
import exopandora.worldhandler.builder.CommandBuilder; import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Level;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import net.minecraftforge.fml.relauncher.Side; import exopandora.worldhandler.helper.EnumHelper;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderExperience extends CommandBuilder public class BuilderExperience extends CommandBuilder
{ {
public BuilderExperience() public BuilderExperience()
{ {
this.setLevel(0);
} }
public BuilderExperience(int level, String player) public BuilderExperience(EnumMode mode, int level, String player, EnumUnit unit)
{ {
this.setMode(mode);
this.setLevel(level); this.setLevel(level);
this.setPlayer(player); this.setPlayer(player);
this.setUnit(unit);
} }
public void setLevel(int level) public void setMode(EnumMode mode)
{ {
this.setNode(0, new Level(level)); this.setNode(0, mode.toString());
} }
public int getLevel() @Nullable
public EnumMode getMode()
{ {
Level level = this.getNodeAsLevel(0); return EnumHelper.valueOf(this.getNodeAsString(0), EnumMode.class);
if(level != null)
{
return level.getLevel();
}
return 0;
} }
public void setPlayer(String player) public void setPlayer(String player)
@@ -48,10 +46,31 @@ public class BuilderExperience extends CommandBuilder
return this.getNodeAsString(1); return this.getNodeAsString(1);
} }
public void setLevel(int level)
{
this.setNode(2, level);
}
public int getLevel()
{
return this.getNodeAsInt(2);
}
public void setUnit(EnumUnit unit)
{
this.setNode(3, unit.toString());
}
@Nullable
public EnumUnit getUnit()
{
return EnumHelper.valueOf(this.getNodeAsString(3), EnumUnit.class);
}
@Override @Override
public String getCommandName() public String getCommandName()
{ {
return "xp"; return "experience";
} }
@Override @Override
@@ -59,9 +78,53 @@ public class BuilderExperience extends CommandBuilder
{ {
Syntax syntax = new Syntax(); Syntax syntax = new Syntax();
syntax.addRequired("amount", Type.LEVEL, new Level(0)); syntax.addRequired("add|set|query", Type.STRING);
syntax.addOptional("player", Type.STRING); syntax.addRequired("player", Type.STRING);
syntax.addRequired("amount", Type.INT);
syntax.addOptional("levels|points", Type.STRING);
return syntax; return syntax;
} }
public BuilderExperience getBuilderForAddLevels()
{
return new BuilderExperience(EnumMode.ADD, this.getLevel(), this.getPlayer(), EnumUnit.LEVELS);
}
public BuilderExperience getBuilderForRemoveLevels()
{
return new BuilderExperience(EnumMode.ADD, -this.getLevel(), this.getPlayer(), EnumUnit.LEVELS);
}
public BuilderExperience getBuilderForResetLevels()
{
return new BuilderExperience(EnumMode.SET, 0, this.getPlayer(), EnumUnit.LEVELS);
}
@OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
ADD,
SET,
QUERY;
@Override
public String toString()
{
return this.name().toLowerCase();
}
}
@OnlyIn(Dist.CLIENT)
public static enum EnumUnit
{
LEVELS,
POINTS;
@Override
public String toString()
{
return this.name().toLowerCase();
}
}
} }

View File

@@ -4,112 +4,89 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.impl.abstr.BuilderDoubleBlockPos; import exopandora.worldhandler.builder.impl.abstr.BuilderDoubleBlockPos;
import exopandora.worldhandler.builder.types.BlockResourceLocation;
import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import exopandora.worldhandler.helper.BlockHelper; import exopandora.worldhandler.helper.BlockHelper;
import exopandora.worldhandler.helper.EnumHelper; import exopandora.worldhandler.helper.EnumHelper;
import exopandora.worldhandler.helper.ResourceHelper; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderFill extends BuilderDoubleBlockPos public class BuilderFill extends BuilderDoubleBlockPos
{ {
public BuilderFill(ResourceLocation block1, EnumBlockHandling handling, ResourceLocation block2) public BuilderFill()
{ {
this.setPosition1(BlockHelper.getPos1());
this.setPosition2(BlockHelper.getPos2()); }
public BuilderFill(BlockResourceLocation block1, EnumBlockFilter filter, BlockResourceLocation block2)
{
this(BlockHelper.getPos1(), BlockHelper.getPos2(), block1, filter, block2);
}
public BuilderFill(BlockPos pos1, BlockPos pos2, BlockResourceLocation block1, EnumBlockFilter handling, BlockResourceLocation block2)
{
this.setPosition1(pos1);
this.setPosition2(pos2);
this.setBlock1(block1); this.setBlock1(block1);
this.setMeta1(0);
this.setBlockHandling(handling); this.setBlockHandling(handling);
this.setBlock2(block2); this.setBlock2(block2);
} }
public BuilderFill() public BuilderFill(CoordinateInt x1, CoordinateInt y1, CoordinateInt z1, CoordinateInt x2, CoordinateInt y2, CoordinateInt z2, BlockResourceLocation block1)
{ {
this.init(); this.setX1(x1);
} this.setY1(y1);
this.setZ1(z1);
private void init() this.setX2(x2);
{ this.setY2(y2);
this.setMeta1(0); this.setZ2(z2);
} this.setBlock1(block1);
@Deprecated
public void setMeta1(int meta)
{
this.setNode(7, meta);
}
@Deprecated
public void setMeta2(int meta)
{
this.setNode(10, meta);
} }
public void setBlock1(String block) public void setBlock1(String block)
{ {
this.setBlock1(ResourceHelper.stringToResourceLocationNullable(block, ResourceHelper::isRegisteredBlock)); this.setBlock1(BlockResourceLocation.valueOf(block));
} }
public void setBlock1(ResourceLocation location) public void setBlock1(BlockResourceLocation resource)
{ {
this.setNode(6, location); this.setNode(6, resource);
} }
public ResourceLocation getBlock1() @Nullable
public BlockResourceLocation getBlock1()
{ {
return this.getNodeAsResourceLocation(6); return this.getNodeAsBlockResourceLocation(6);
} }
public String getBlock1String() public void setBlockHandling(EnumBlockFilter filter)
{ {
ResourceLocation location = this.getBlock1(); this.setNode(7, filter != null ? filter.toString() : null);
if(location != null)
{
return location.toString();
}
return null;
}
public void setBlockHandling(EnumBlockHandling blockHandling)
{
this.setNode(8, blockHandling != null ? blockHandling.toString() : null);
} }
public void setBlock2(String block) public void setBlock2(String block)
{ {
this.setBlock2(ResourceHelper.stringToResourceLocationNullable(block, ResourceHelper::isRegisteredBlock)); this.setBlock2(BlockResourceLocation.valueOf(block));
} }
public void setBlock2(ResourceLocation location) public void setBlock2(BlockResourceLocation resource)
{ {
this.setNode(9, location); this.setNode(8, resource);
}
public String getBlock2String()
{
ResourceLocation location = this.getBlock2();
if(location != null)
{
return location.toString();
}
return null;
}
public ResourceLocation getBlock2()
{
return this.getNodeAsResourceLocation(9);
} }
@Nullable @Nullable
public EnumBlockHandling getBlockHandling() public BlockResourceLocation getBlock2()
{ {
return EnumHelper.valueOf(EnumBlockHandling.class, this.getNodeAsString(8)); return this.getNodeAsBlockResourceLocation(8);
}
@Nullable
public EnumBlockFilter getBlockFilter()
{
return EnumHelper.valueOf(this.getNodeAsString(7), EnumBlockFilter.class);
} }
public BuilderFill getBuilderForFill() public BuilderFill getBuilderForFill()
@@ -119,7 +96,7 @@ public class BuilderFill extends BuilderDoubleBlockPos
public BuilderFill getBuilderForReplace() public BuilderFill getBuilderForReplace()
{ {
return new BuilderFill(this.getBlock2(), EnumBlockHandling.REPLACE, this.getBlock1()); return new BuilderFill(this.getBlock2(), EnumBlockFilter.REPLACE, this.getBlock1());
} }
@Override @Override
@@ -133,23 +110,21 @@ public class BuilderFill extends BuilderDoubleBlockPos
{ {
Syntax syntax = new Syntax(); Syntax syntax = new Syntax();
syntax.addRequired("x1", Type.COORDINATE); syntax.addRequired("x1", Type.COORDINATE_INT);
syntax.addRequired("y1", Type.COORDINATE); syntax.addRequired("y1", Type.COORDINATE_INT);
syntax.addRequired("z1", Type.COORDINATE); syntax.addRequired("z1", Type.COORDINATE_INT);
syntax.addRequired("x2", Type.COORDINATE); syntax.addRequired("x2", Type.COORDINATE_INT);
syntax.addRequired("y2", Type.COORDINATE); syntax.addRequired("y2", Type.COORDINATE_INT);
syntax.addRequired("z2", Type.COORDINATE); syntax.addRequired("z2", Type.COORDINATE_INT);
syntax.addRequired("block", Type.RESOURCE_LOCATION); syntax.addRequired("block", Type.BLOCK_RESOURCE_LOCATION);
syntax.addOptional("data_value", Type.INT); syntax.addOptional("filter", Type.STRING);
syntax.addOptional("old_block_handling", Type.STRING); syntax.addOptional("block", Type.BLOCK_RESOURCE_LOCATION, "block");
syntax.addOptional("block_2|nbt", Type.RESOURCE_LOCATION, "block_2|nbt");
syntax.addOptional("data_value", Type.INT, "data_value");
return syntax; return syntax;
} }
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public static enum EnumBlockHandling public static enum EnumBlockFilter
{ {
REPLACE, REPLACE,
DESTROY, DESTROY,

View File

@@ -3,9 +3,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder; import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class BuilderGamemode extends CommandBuilder public class BuilderGamemode extends CommandBuilder
{ {
public BuilderGamemode() public BuilderGamemode()
@@ -51,7 +52,7 @@ public class BuilderGamemode extends CommandBuilder
return syntax; return syntax;
} }
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public static enum EnumGamemode public static enum EnumGamemode
{ {
SURVIVAL, SURVIVAL,

View File

@@ -3,10 +3,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder; import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderGamerule extends CommandBuilder public class BuilderGamerule extends CommandBuilder
{ {
public BuilderGamerule() public BuilderGamerule()

View File

@@ -2,10 +2,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandString; import exopandora.worldhandler.builder.CommandString;
import exopandora.worldhandler.builder.ICommandBuilder; import exopandora.worldhandler.builder.ICommandBuilder;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderGeneric implements ICommandBuilder public class BuilderGeneric implements ICommandBuilder
{ {
private final String command; private final String command;

View File

@@ -1,30 +1,35 @@
package exopandora.worldhandler.builder.impl; package exopandora.worldhandler.builder.impl;
import javax.annotation.Nullable;
import exopandora.worldhandler.builder.CommandBuilderNBT; import exopandora.worldhandler.builder.CommandBuilderNBT;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.ItemResourceLocation;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import exopandora.worldhandler.helper.ResourceHelper; import exopandora.worldhandler.helper.ResourceHelper;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistries;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderGive extends CommandBuilderNBT public class BuilderGive extends CommandBuilderNBT
{ {
public BuilderGive(String player, ResourceLocation item) private final ItemResourceLocation itemResourceLocation = new ItemResourceLocation();
{
this.setPlayer(player);
this.setItem(item);
this.setAmount(1);
this.setMetadata(0);
}
public BuilderGive() public BuilderGive()
{ {
this(null, null); this(null, null);
} }
public BuilderGive(String player, ResourceLocation item)
{
this.setPlayer(player);
this.setItem(item);
this.setCount(1);
}
public void setPlayer(String username) public void setPlayer(String username)
{ {
this.setNode(0, username); this.setNode(0, username);
@@ -37,50 +42,41 @@ public class BuilderGive extends CommandBuilderNBT
public void setItem(String item) public void setItem(String item)
{ {
this.setItem(ResourceHelper.stringToResourceLocationNullable(item, ResourceHelper::isRegisteredItem)); this.setItem(ResourceHelper.assertRegistered(ResourceHelper.stringToResourceLocation(item), ForgeRegistries.ITEMS));
} }
public void setItem(ResourceLocation item) public void setItem(ResourceLocation item)
{ {
this.setNode(1, item); this.itemResourceLocation.setResourceLocation(item);
this.setNode(1, this.itemResourceLocation);
} }
public ResourceLocation getItem() @Nullable
public ItemResourceLocation getItem()
{ {
return this.getNodeAsResourceLocation(1); return this.getNodeAsItemResourceLocation(1);
} }
public void setAmount(int ammount) public void setCount(int count)
{ {
this.setNode(2, ammount); this.setNode(2, count);
} }
public int getAmount() public int getCount()
{ {
return this.getNodeAsInt(2); return this.getNodeAsInt(2);
} }
@Deprecated
public void setMetadata(int metadata)
{
this.setNode(3, metadata);
}
@Deprecated
public int getMetadata()
{
return this.getNodeAsInt(3);
}
@Override @Override
public void setNBT(NBTTagCompound nbt) public void setNBT(NBTTagCompound nbt)
{ {
this.setNode(4, nbt); this.itemResourceLocation.setNBT(nbt);
this.setNode(1, this.itemResourceLocation);
} }
public NBTTagCompound getNBT() public NBTTagCompound getNBT()
{ {
return this.getNodeAsNBT(4); return this.getNodeAsItemResourceLocation(1).getNBT();
} }
@Override @Override
@@ -95,10 +91,8 @@ public class BuilderGive extends CommandBuilderNBT
Syntax syntax = new Syntax(); Syntax syntax = new Syntax();
syntax.addRequired("player", Type.STRING); syntax.addRequired("player", Type.STRING);
syntax.addRequired("item", Type.RESOURCE_LOCATION); syntax.addRequired("item", Type.ITEM_RESOURCE_LOCATION);
syntax.addRequired("amount", Type.INT); syntax.addRequired("count", Type.INT);
syntax.addRequired("data_value", Type.INT);
syntax.addOptional("nbt", Type.NBT);
return syntax; return syntax;
} }

View File

@@ -3,10 +3,10 @@ package exopandora.worldhandler.builder.impl;
import java.util.Arrays; import java.util.Arrays;
import exopandora.worldhandler.builder.ICommandBuilder; import exopandora.worldhandler.builder.ICommandBuilder;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderMultiCommand implements ICommandBuilder public class BuilderMultiCommand implements ICommandBuilder
{ {
private final ICommandBuilder[] builders; private final ICommandBuilder[] builders;

View File

@@ -1,38 +1,41 @@
package exopandora.worldhandler.builder.impl; package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.component.impl.ComponentTag; import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.state.properties.NoteBlockInstrument;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderNoteEditor extends BuilderBlockdata public class BuilderNoteEditor extends BuilderSetBlock
{ {
private final ComponentTag<Byte> note;
public BuilderNoteEditor() public BuilderNoteEditor()
{ {
this.note = this.registerNBTComponent(new ComponentTag<Byte>("note")); this.setBlock(Blocks.NOTE_BLOCK.getRegistryName());
this.setMode("replace");
} }
public BuilderNoteEditor(byte note) public BuilderNoteEditor(int note)
{ {
this(); this();
this.setNote(note); this.setNote(note);
} }
public BuilderNoteEditor(byte note, BlockPos pos) public BuilderNoteEditor(int note, BlockPos pos)
{ {
this(note); this(note);
this.setPosition(pos); this.setPosition(pos);
this.withState(BlockStateProperties.NOTE_BLOCK_INSTRUMENT, NoteBlockInstrument.byState(Minecraft.getInstance().world.getBlockState(pos)));
} }
public void setNote(byte note) public void setNote(int note)
{ {
this.note.setValue(note); this.withState(BlockStateProperties.NOTE_0_24, note);
} }
public BuilderNoteEditor getBuilderForNote(byte note) public BuilderNoteEditor getBuilderForNote(int note)
{ {
return new BuilderNoteEditor(note, this.getBlockPos()); return new BuilderNoteEditor(note, this.getBlockPos());
} }

View File

@@ -3,10 +3,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder; import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderPlayer extends CommandBuilder public class BuilderPlayer extends CommandBuilder
{ {
private final String command; private final String command;

View File

@@ -3,10 +3,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder; import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderPlayerReason extends CommandBuilder public class BuilderPlayerReason extends CommandBuilder
{ {
private final String command; private final String command;

View File

@@ -8,10 +8,11 @@ import exopandora.worldhandler.builder.component.abstr.PotionMetadata;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import net.minecraft.potion.Potion; import net.minecraft.potion.Potion;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistries;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderPotionEffect extends CommandBuilder public class BuilderPotionEffect extends CommandBuilder
{ {
private int seconds; private int seconds;
@@ -20,16 +21,17 @@ public class BuilderPotionEffect extends CommandBuilder
public BuilderPotionEffect() public BuilderPotionEffect()
{ {
this(null, null); this(null, null, null);
} }
public BuilderPotionEffect(String player, ResourceLocation effect) public BuilderPotionEffect(EnumMode mode, String player, ResourceLocation effect)
{ {
this(player, effect, 0, (byte) 0, false); this(mode, player, effect, 0, (byte) 0, false);
} }
public BuilderPotionEffect(String player, ResourceLocation effect, int duration, byte amplifier, boolean hideParticles) public BuilderPotionEffect(EnumMode mode, String player, ResourceLocation effect, int duration, byte amplifier, boolean hideParticles)
{ {
this.setMode(mode);
this.setPlayer(player); this.setPlayer(player);
this.setEffect(effect); this.setEffect(effect);
this.setDuration(duration); this.setDuration(duration);
@@ -37,29 +39,42 @@ public class BuilderPotionEffect extends CommandBuilder
this.setHideParticles(hideParticles); this.setHideParticles(hideParticles);
} }
public void setMode(EnumMode mode)
{
if(mode != null)
{
this.setNode(0, mode.toString());
}
}
public void setPlayer(String player) public void setPlayer(String player)
{ {
this.setNode(0, player); this.setNode(1, player);
} }
public String getPlayer() public String getPlayer()
{ {
return this.getNodeAsString(0); return this.getNodeAsString(1);
}
public void setEffect(Potion effect)
{
this.setEffect(effect.getRegistryName());
} }
public void setEffect(ResourceLocation effect) public void setEffect(ResourceLocation effect)
{ {
this.setNode(1, effect); this.setNode(2, effect);
} }
@Nullable @Nullable
public Potion getEffectAsPotion() public Potion getEffectAsPotion()
{ {
ResourceLocation location = this.getNodeAsResourceLocation(1); ResourceLocation location = this.getNodeAsResourceLocation(2);
if(location != null) if(location != null)
{ {
return Potion.getPotionFromResourceLocation(location.toString()); return ForgeRegistries.POTIONS.getValue(location);
} }
return null; return null;
@@ -67,37 +82,37 @@ public class BuilderPotionEffect extends CommandBuilder
public ResourceLocation getEffect() public ResourceLocation getEffect()
{ {
return this.getNodeAsResourceLocation(1); return this.getNodeAsResourceLocation(2);
} }
public void setDuration(int duration) public void setDuration(int duration)
{ {
this.setNode(2, Math.min(duration, 1000000)); this.setNode(3, Math.min(duration, 1000000));
} }
public int getDuration() public int getDuration()
{ {
return this.getNodeAsInt(2); return this.getNodeAsInt(3);
} }
public void setAmplifier(byte amplifier) public void setAmplifier(byte amplifier)
{ {
this.setNode(3, (byte) (amplifier - 1)); this.setNode(4, (byte) (amplifier - 1));
} }
public int getAmplifier() public int getAmplifier()
{ {
return this.getNodeAsByte(3); return this.getNodeAsByte(4);
} }
public void setHideParticles(boolean hideParticles) public void setHideParticles(boolean hideParticles)
{ {
this.setNode(4, hideParticles); this.setNode(5, hideParticles);
} }
public boolean getHideParticles() public boolean getHideParticles()
{ {
return this.getNodeAsBoolean(4); return this.getNodeAsBoolean(5);
} }
public int getSeconds() public int getSeconds()
@@ -108,7 +123,7 @@ public class BuilderPotionEffect extends CommandBuilder
public void setSeconds(int seconds) public void setSeconds(int seconds)
{ {
this.seconds = seconds; this.seconds = seconds;
this.setDuration(PotionMetadata.getDurationSeconds(this.seconds, this.minutes, this.hours)); this.setDuration(PotionMetadata.toSeconds(this.seconds, this.minutes, this.hours));
} }
public int getMinutes() public int getMinutes()
@@ -119,7 +134,7 @@ public class BuilderPotionEffect extends CommandBuilder
public void setMinutes(int minutes) public void setMinutes(int minutes)
{ {
this.minutes = minutes; this.minutes = minutes;
this.setDuration(PotionMetadata.getDurationSeconds(this.seconds, this.minutes, this.hours)); this.setDuration(PotionMetadata.toSeconds(this.seconds, this.minutes, this.hours));
} }
public int getHours() public int getHours()
@@ -130,17 +145,22 @@ public class BuilderPotionEffect extends CommandBuilder
public void setHours(int hours) public void setHours(int hours)
{ {
this.hours = hours; this.hours = hours;
this.setDuration(PotionMetadata.getDurationSeconds(this.seconds, this.minutes, this.hours)); this.setDuration(PotionMetadata.toSeconds(this.seconds, this.minutes, this.hours));
}
public BuilderGeneric getGiveCommand()
{
return new BuilderGeneric(this.getCommandName(), EnumMode.GIVE.toString(), this.getPlayer(), this.getEffect().toString(), String.valueOf(this.getDuration()), String.valueOf(this.getAmplifier()), String.valueOf(this.getHideParticles()));
} }
public BuilderGeneric getRemoveCommand() public BuilderGeneric getRemoveCommand()
{ {
return new BuilderGeneric(this.getCommandName(), this.getPlayer(), this.getEffect().toString(), "0"); return new BuilderGeneric(this.getCommandName(), EnumMode.CLEAR.toString(), this.getPlayer(), this.getEffect().toString());
} }
public BuilderGeneric getClearCommand() public BuilderGeneric getClearCommand()
{ {
return new BuilderGeneric(this.getCommandName(), this.getPlayer(), "clear"); return new BuilderGeneric(this.getCommandName(), EnumMode.CLEAR.toString(), this.getPlayer());
} }
@Override @Override
@@ -154,6 +174,7 @@ public class BuilderPotionEffect extends CommandBuilder
{ {
Syntax syntax = new Syntax(); Syntax syntax = new Syntax();
syntax.addRequired("give|clear", Type.STRING);
syntax.addRequired("player", Type.STRING); syntax.addRequired("player", Type.STRING);
syntax.addRequired("effect", Type.RESOURCE_LOCATION); syntax.addRequired("effect", Type.RESOURCE_LOCATION);
syntax.addOptional("seconds", Type.INT, 0); syntax.addOptional("seconds", Type.INT, 0);
@@ -162,4 +183,17 @@ public class BuilderPotionEffect extends CommandBuilder
return syntax; return syntax;
} }
@OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
GIVE,
CLEAR;
@Override
public String toString()
{
return this.name().toLowerCase();
}
}
} }

View File

@@ -6,10 +6,10 @@ import exopandora.worldhandler.builder.component.impl.ComponentPotionItem;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.potion.Potion; import net.minecraft.potion.Potion;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderPotionItem extends BuilderGive public class BuilderPotionItem extends BuilderGive
{ {
private final ComponentPotionItem potion; private final ComponentPotionItem potion;
@@ -27,62 +27,62 @@ public class BuilderPotionItem extends BuilderGive
public void setAmplifier(Potion potion, byte amplifier) public void setAmplifier(Potion potion, byte amplifier)
{ {
this.potion.get(potion).setAmplifier(amplifier); this.potion.setAmplifier(potion, amplifier);
} }
public void setSeconds(Potion potion, int seconds) public void setSeconds(Potion potion, int seconds)
{ {
this.potion.get(potion).setSeconds(seconds); this.potion.setSeconds(potion, seconds);
} }
public void setMinutes(Potion potion, int minutes) public void setMinutes(Potion potion, int minutes)
{ {
this.potion.get(potion).setMinutes(minutes); this.potion.setMinutes(potion, minutes);
} }
public void setHours(Potion potion, int hours) public void setHours(Potion potion, int hours)
{ {
this.potion.get(potion).setHours(hours); this.potion.setHours(potion, hours);
} }
public void setShowParticles(Potion potion, boolean showParticles) public void setShowParticles(Potion potion, boolean showParticles)
{ {
this.potion.get(potion).setShowParticles(showParticles); this.potion.setShowParticles(potion, showParticles);
} }
public void setAmbient(Potion potion, boolean ambient) public void setAmbient(Potion potion, boolean ambient)
{ {
this.potion.get(potion).setAmbient(ambient); this.potion.setAmbient(potion, ambient);
} }
public byte getAmplifier(Potion potion) public byte getAmplifier(Potion potion)
{ {
return this.potion.get(potion).getAmplifier(); return this.potion.getAmplifier(potion);
} }
public int getSeconds(Potion potion) public int getSeconds(Potion potion)
{ {
return this.potion.get(potion).getSeconds(); return this.potion.getSeconds(potion);
} }
public int getMinutes(Potion potion) public int getMinutes(Potion potion)
{ {
return this.potion.get(potion).getMinutes(); return this.potion.getMinutes(potion);
} }
public int getHours(Potion potion) public int getHours(Potion potion)
{ {
return this.potion.get(potion).getHours(); return this.potion.getHours(potion);
} }
public boolean getShowParticles(Potion potion) public boolean getShowParticles(Potion potion)
{ {
return this.potion.get(potion).getShowParticles(); return this.potion.getShowParticles(potion);
} }
public boolean getAmbient(Potion potion) public boolean getAmbient(Potion potion)
{ {
return this.potion.get(potion).getAmbient(); return this.potion.getAmbient(potion);
} }
public Set<Potion> getPotions() public Set<Potion> getPotions()

View File

@@ -4,14 +4,14 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.builder.CommandBuilder; import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.impl.BuilderAdvancement.EnumActionType;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import exopandora.worldhandler.helper.EnumHelper; import exopandora.worldhandler.helper.EnumHelper;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderRecipe extends CommandBuilder public class BuilderRecipe extends CommandBuilder
{ {
public BuilderRecipe() public BuilderRecipe()
@@ -34,7 +34,7 @@ public class BuilderRecipe extends CommandBuilder
@Nullable @Nullable
public EnumMode getMode() public EnumMode getMode()
{ {
return EnumHelper.valueOf(EnumMode.class, this.getNodeAsString(0)); return EnumHelper.valueOf(this.getNodeAsString(0), EnumMode.class);
} }
public void setPlayer(String player) public void setPlayer(String player)
@@ -48,6 +48,11 @@ public class BuilderRecipe extends CommandBuilder
return this.getNodeAsString(1); return this.getNodeAsString(1);
} }
public void setRecipe(IRecipe recipe)
{
this.setRecipe(recipe.getId());
}
public void setRecipe(ResourceLocation recipe) public void setRecipe(ResourceLocation recipe)
{ {
this.setNode(2, recipe); this.setNode(2, recipe);
@@ -82,7 +87,7 @@ public class BuilderRecipe extends CommandBuilder
return syntax; return syntax;
} }
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public static enum EnumMode public static enum EnumMode
{ {
GIVE, GIVE,

View File

@@ -4,11 +4,13 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.impl.abstr.BuilderScoreboard; import exopandora.worldhandler.builder.impl.abstr.BuilderScoreboard;
import exopandora.worldhandler.builder.types.GreedyString;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import net.minecraftforge.fml.relauncher.Side; import exopandora.worldhandler.helper.EnumHelper;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderScoreboardObjectives extends BuilderScoreboard public class BuilderScoreboardObjectives extends BuilderScoreboard
{ {
public BuilderScoreboardObjectives() public BuilderScoreboardObjectives()
@@ -21,74 +23,74 @@ public class BuilderScoreboardObjectives extends BuilderScoreboard
this.setNode(0, "objectives"); this.setNode(0, "objectives");
} }
public void setMode(String mode) public void setMode(EnumMode mode)
{ {
String objective = this.getObjective(); String objective = this.getObjective();
if(mode.equals("add") || mode.equals("remove") || mode.equals("setdisplay")) this.updateSyntax(this.getSyntax(mode));
this.setNode(1, mode.toString());
if(objective != null)
{ {
this.updateSyntax(this.getSyntax(mode)); this.setObjective(objective);
this.setNode(1, mode);
if(objective != null)
{
this.setObjective(objective);
}
this.init();
} }
this.init();
} }
public String getMode() public EnumMode getMode()
{ {
return this.getNodeAsString(1); return EnumHelper.valueOf(this.getNodeAsString(1), EnumMode.class);
} }
public void setObjective(String name) public void setObjective(String name)
{ {
String mode = this.getMode();
String objective = name != null ? name.replaceAll(" ", "_") : null; String objective = name != null ? name.replaceAll(" ", "_") : null;
EnumMode mode = this.getMode();
if(mode != null) if(mode != null)
{ {
if(mode.equals("add") || mode.equals("remove")) switch(mode)
{ {
this.setNode(2, objective); case ADD:
this.setNode(4, new GreedyString(name));
if(mode.equals("add")) case REMOVE:
{ this.setNode(2, objective);
this.setNode(4, name); break;
} case SETDISPLAY:
} this.setNode(3, objective);
else if(mode.equals("setdisplay")) break;
{ default:
this.setNode(3, objective); break;
} }
} }
} }
public void setCriteria(String criteria) public void setCriteria(String criteria)
{ {
if(this.getMode() == null || !this.getMode().equals("add")) if(this.getMode() == null || !this.getMode().equals(EnumMode.ADD))
{ {
this.setMode("add"); this.setMode(EnumMode.ADD);
} }
this.setNode(3, criteria.replaceAll("[:]", "."));
this.setNode(3, criteria);
} }
public void setSlot(String slot) public void setSlot(String slot)
{ {
if(this.getMode() == null || !this.getMode().equals("setdisplay")) if(this.getMode() == null || !this.getMode().equals(EnumMode.SETDISPLAY))
{ {
this.setMode("setdisplay"); this.setMode(EnumMode.SETDISPLAY);
} }
this.setNode(2, slot); this.setNode(2, slot);
} }
@Nullable @Nullable
public String getSlot() public String getSlot()
{ {
if(this.getMode() != null && this.getMode().equals("setdisplay")) if(this.getMode() != null && this.getMode().equals(EnumMode.SETDISPLAY))
{ {
return this.getNodeAsString(2); return this.getNodeAsString(2);
} }
@@ -99,17 +101,18 @@ public class BuilderScoreboardObjectives extends BuilderScoreboard
@Nullable @Nullable
public String getObjective() public String getObjective()
{ {
String mode = this.getMode(); EnumMode mode = this.getMode();
if(mode != null) if(mode != null)
{ {
if(mode.equals("add") || mode.equals("remove")) switch(mode)
{ {
return this.getNodeAsString(2); case ADD: case REMOVE:
} return this.getNodeAsString(2);
else if(mode.equals("setdisplay")) case SETDISPLAY:
{ return this.getNodeAsString(3);
return this.getNodeAsString(3); default:
break;
} }
} }
@@ -117,43 +120,33 @@ public class BuilderScoreboardObjectives extends BuilderScoreboard
} }
@Nullable @Nullable
private Syntax getSyntax(String mode) private Syntax getSyntax(EnumMode mode)
{ {
if(mode.equals("add")) Syntax syntax = new Syntax();
{
Syntax syntax = new Syntax();
syntax.addRequired("objectives", Type.STRING);
syntax.addRequired("add", Type.STRING);
syntax.addRequired("name", Type.STRING);
syntax.addRequired("criteria_type", Type.STRING);
syntax.addOptional("display_name...", Type.STRING);
return syntax;
}
else if(mode.equals("remove"))
{
Syntax syntax = new Syntax();
syntax.addRequired("objectives", Type.STRING);
syntax.addRequired("remove", Type.STRING);
syntax.addRequired("name", Type.STRING);
return syntax;
}
else if(mode.equals("setdisplay"))
{
Syntax syntax = new Syntax();
syntax.addRequired("objectives", Type.STRING);
syntax.addRequired("setdisplay", Type.STRING);
syntax.addRequired("slot", Type.STRING);
syntax.addOptional("objective", Type.STRING);
return syntax;
}
return null; switch(mode)
{
case ADD:
syntax.addRequired("objectives", Type.STRING);
syntax.addRequired("add", Type.STRING);
syntax.addRequired("name", Type.STRING);
syntax.addRequired("criteria_type", Type.STRING);
syntax.addOptional("display_name...", Type.GREEDY_STRING);
return syntax;
case REMOVE:
syntax.addRequired("objectives", Type.STRING);
syntax.addRequired("remove", Type.STRING);
syntax.addRequired("name", Type.STRING);
return syntax;
case SETDISPLAY:
syntax.addRequired("objectives", Type.STRING);
syntax.addRequired("setdisplay", Type.STRING);
syntax.addRequired("slot", Type.STRING);
syntax.addOptional("objective", Type.STRING);
return syntax;
default:
return null;
}
} }
@Override @Override
@@ -167,4 +160,18 @@ public class BuilderScoreboardObjectives extends BuilderScoreboard
return syntax; return syntax;
} }
@OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
ADD,
REMOVE,
SETDISPLAY;
@Override
public String toString()
{
return this.name().toLowerCase();
}
}
} }

View File

@@ -3,10 +3,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.impl.abstr.BuilderScoreboard; import exopandora.worldhandler.builder.impl.abstr.BuilderScoreboard;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderScoreboardPlayers extends BuilderScoreboard public class BuilderScoreboardPlayers extends BuilderScoreboard
{ {
public BuilderScoreboardPlayers() public BuilderScoreboardPlayers()
@@ -14,6 +14,11 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
this.init(); this.init();
} }
private void init()
{
this.setNode(0, "players");
}
public String getMode() public String getMode()
{ {
return this.getNodeAsString(1); return this.getNodeAsString(1);
@@ -23,36 +28,19 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
{ {
String objective = this.getObjective(); String objective = this.getObjective();
String player = this.getPlayer(); String player = this.getPlayer();
String tag = this.getTag();
int points = this.getPoints(); int points = this.getPoints();
if(mode.equals("add|set|remove") || mode.equals("tag") || mode.equals("enable")) this.updateSyntax(this.getSyntax(mode));
this.setNode(1, mode);
this.setNode(2, player);
this.setObjective(objective);
if(!mode.equals("enable"))
{ {
this.updateSyntax(this.getSyntax(mode)); this.setPoints(points);
this.setNode(1, mode);
this.setNode(2, player);
if(mode.equals("add|set|remove") || mode.equals("enable"))
{
this.setObjective(objective);
}
if(mode.equals("add|set|remove"))
{
this.setPoints(points);
}
else if(mode.equals("tag"))
{
this.setTag(tag);
}
this.init();
} }
}
this.init();
private void init()
{
this.setNode(0, "players");
} }
public void setPlayer(String player) public void setPlayer(String player)
@@ -72,10 +60,7 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
if(mode != null) if(mode != null)
{ {
if(mode.equals("add|set|remove") || mode.equals("enable")) this.setNode(3, objective);
{
this.setNode(3, objective);
}
} }
} }
@@ -85,10 +70,7 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
if(mode != null) if(mode != null)
{ {
if(mode.equals("add|set|remove") || mode.equals("enable")) return this.getNodeAsString(3);
{
return this.getNodeAsString(3);
}
} }
return null; return null;
@@ -96,16 +78,12 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
public void setPoints(int points) public void setPoints(int points)
{ {
if(this.getMode() == null || !this.getMode().equals("add|set|remove"))
{
this.setMode("add|set|remove");
}
this.setNode(4, points); this.setNode(4, points);
} }
public int getPoints() public int getPoints()
{ {
if(this.getMode() != null && this.getMode().equals("add|set|remove")) if(this.getMode() != null && !this.getMode().equals("enable"))
{ {
return this.getNodeAsInt(4); return this.getNodeAsInt(4);
} }
@@ -113,83 +91,56 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
return 0; return 0;
} }
public void setTag(String name)
{
String tag = name != null ? name.replaceAll(" ", "_") : null;
if(this.getMode() == null || !this.getMode().equals("tag"))
{
this.setMode("tag");
}
this.setNode(4, tag);
}
public String getTag()
{
if(this.getMode() != null && this.getMode().equals("tag"))
{
return this.getNodeAsString(4);
}
return null;
}
private Syntax getSyntax(String mode) private Syntax getSyntax(String mode)
{ {
if(mode.equals("add|set|remove")) Syntax syntax = new Syntax();
if(mode.equals("enable"))
{ {
Syntax syntax = new Syntax();
syntax.addRequired("players", Type.STRING);
syntax.addRequired("add|set|remove", Type.STRING, "add|set|remove");
syntax.addRequired("player", Type.STRING);
syntax.addRequired("objective", Type.STRING);
syntax.addRequired("count", Type.INT, 0);
syntax.addOptional("nbt", Type.NBT);
return syntax;
}
else if(mode.equals("tag"))
{
Syntax syntax = new Syntax();
syntax.addRequired("players", Type.STRING);
syntax.addRequired("tag", Type.STRING);
syntax.addRequired("player", Type.STRING);
syntax.addRequired("add|remove|list", Type.STRING);
syntax.addRequired("tag_name", Type.STRING);
syntax.addOptional("nbt", Type.NBT);
return syntax;
}
else if(mode.equals("enable"))
{
Syntax syntax = new Syntax();
syntax.addRequired("players", Type.STRING); syntax.addRequired("players", Type.STRING);
syntax.addRequired("enable", Type.STRING); syntax.addRequired("enable", Type.STRING);
syntax.addRequired("player", Type.STRING); syntax.addRequired("player", Type.STRING);
syntax.addRequired("trigger", Type.STRING); syntax.addRequired("objective", Type.STRING);
return syntax; return syntax;
} }
return null; syntax.addRequired("players", Type.STRING);
syntax.addRequired("add|set|remove", Type.STRING, "add|set|remove");
syntax.addRequired("player", Type.STRING);
syntax.addRequired("objective", Type.STRING);
syntax.addRequired("score", Type.INT, 0);
return syntax;
} }
public BuilderGeneric getBuilderForTag(EnumTag tag) public BuilderScoreboardPlayers getBuilderForPoints(EnumMode mode)
{
return new BuilderGeneric(this.getCommandName(), "players", this.getMode(), this.getPlayer(), tag.toString(), this.getTag());
}
public BuilderGeneric getBuilderForPoints(EnumPoints mode)
{ {
return this.getBuilderForPoints(mode, this.getPoints()); return this.getBuilderForPoints(mode, this.getPoints());
} }
public BuilderGeneric getBuilderForPoints(EnumPoints mode, int points) public BuilderScoreboardPlayers getBuilderForPoints(EnumMode mode, int points)
{ {
return new BuilderGeneric(this.getCommandName(), "players", mode.toString(), this.getPlayer(), this.getObjective(), String.valueOf(points)); BuilderScoreboardPlayers builder = new BuilderScoreboardPlayers();
builder.setMode(mode.toString());
builder.setPlayer(this.getPlayer());
builder.setObjective(this.getObjective());
builder.setPoints(points);
return builder;
}
public BuilderScoreboardPlayers getBuilderForEnable()
{
BuilderScoreboardPlayers builder = new BuilderScoreboardPlayers();
builder.setMode(EnumMode.ENABLE.toString());
builder.setPlayer(this.getPlayer());
builder.setObjective(this.getObjective());
return builder;
} }
@Override @Override
@@ -198,30 +149,18 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
Syntax syntax = new Syntax(); Syntax syntax = new Syntax();
syntax.addRequired("players", Type.STRING); syntax.addRequired("players", Type.STRING);
syntax.addRequired("add|enable|list|operation|remove|reset|set|tag|test", Type.STRING); syntax.addRequired("add|enable|get|list|operation|remove|reset|set", Type.STRING);
syntax.addOptional("...", Type.STRING); syntax.addOptional("...", Type.STRING);
return syntax; return syntax;
} }
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public static enum EnumTag public static enum EnumMode
{
ADD,
REMOVE;
@Override
public String toString()
{
return this.name().toLowerCase();
}
}
@SideOnly(Side.CLIENT)
public static enum EnumPoints
{ {
ADD, ADD,
REMOVE, REMOVE,
ENABLE,
SET; SET;
@Override @Override

View File

@@ -2,59 +2,66 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.impl.abstr.BuilderBlockPos; import exopandora.worldhandler.builder.impl.abstr.BuilderBlockPos;
import exopandora.worldhandler.builder.types.Coordinate; import exopandora.worldhandler.builder.types.BlockResourceLocation;
import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.state.IProperty;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class BuilderSetblock extends BuilderBlockPos @OnlyIn(Dist.CLIENT)
public class BuilderSetBlock extends BuilderBlockPos
{ {
@Deprecated private final BlockResourceLocation blockResourceLocation = new BlockResourceLocation();
public BuilderSetblock(BlockPos pos, ResourceLocation block, int meta, String mode)
public BuilderSetBlock()
{ {
super(0);
}
public BuilderSetBlock(BlockPos pos, ResourceLocation block, String mode)
{
this();
this.setPosition(pos); this.setPosition(pos);
this.setBlock(block); this.setBlock(block);
this.setMetadata(meta);
this.setMode(mode); this.setMode(mode);
} }
@Deprecated public BuilderSetBlock(CoordinateInt x, CoordinateInt y, CoordinateInt z, ResourceLocation block, String mode)
public BuilderSetblock(Coordinate x, Coordinate y, Coordinate z, ResourceLocation block, int meta, String mode)
{ {
this();
this.setX(x); this.setX(x);
this.setY(y); this.setY(y);
this.setZ(z); this.setZ(z);
this.setBlock(block); this.setBlock(block);
this.setMetadata(meta);
this.setMode(mode); this.setMode(mode);
} }
public BuilderSetblock(Coordinate x, Coordinate y, Coordinate z, ResourceLocation block, String mode) public <T extends Comparable<T>> BuilderSetBlock withState(IProperty<T> property, T value)
{ {
this(x, y, z, block, 0, mode); this.blockResourceLocation.withState(property, value);
return this;
} }
public void setBlock(ResourceLocation block) public void setBlock(ResourceLocation block)
{ {
this.setNode(3, block); this.blockResourceLocation.setResourceLocation(block);
} this.setNode(3, this.blockResourceLocation);
@Deprecated
public void setMetadata(int meta)
{
this.setNode(4, meta);
} }
public void setMode(String mode) public void setMode(String mode)
{ {
this.setNode(5, mode); this.setNode(4, mode);
} }
@Override @Override
public void setNBT(NBTTagCompound nbt) public void setNBT(NBTTagCompound nbt)
{ {
this.setNode(6, nbt); this.blockResourceLocation.setNBT(nbt);
this.setNode(3, this.blockResourceLocation);
} }
@Override @Override
@@ -68,13 +75,11 @@ public class BuilderSetblock extends BuilderBlockPos
{ {
Syntax syntax = new Syntax(); Syntax syntax = new Syntax();
syntax.addRequired("x", Type.COORDINATE); syntax.addRequired("x", Type.COORDINATE_INT);
syntax.addRequired("y", Type.COORDINATE); syntax.addRequired("y", Type.COORDINATE_INT);
syntax.addRequired("z", Type.COORDINATE); syntax.addRequired("z", Type.COORDINATE_INT);
syntax.addRequired("block", Type.RESOURCE_LOCATION); syntax.addRequired("block", Type.BLOCK_RESOURCE_LOCATION);
syntax.addOptional("data_value", Type.INT);
syntax.addOptional("mode", Type.STRING); syntax.addOptional("mode", Type.STRING);
syntax.addOptional("nbt", Type.NBT);
return syntax; return syntax;
} }

View File

@@ -6,16 +6,21 @@ import exopandora.worldhandler.builder.component.impl.ComponentTag;
import exopandora.worldhandler.format.text.ColoredString; import exopandora.worldhandler.format.text.ColoredString;
import exopandora.worldhandler.format.text.SignText; import exopandora.worldhandler.format.text.SignText;
import net.minecraft.nbt.NBTTagString; import net.minecraft.nbt.NBTTagString;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderSignEditor extends BuilderBlockdata public class BuilderSignEditor extends BuilderData
{ {
@SuppressWarnings("unchecked")
private final ComponentTag<SignText>[] sign = new ComponentTag[4]; private final ComponentTag<SignText>[] sign = new ComponentTag[4];
public BuilderSignEditor() public BuilderSignEditor()
{ {
super();
this.setMode(EnumMode.MERGE);
this.setTarget(EnumTarget.BLOCK);
for(int x = 0; x < 4; x++) for(int x = 0; x < 4; x++)
{ {
this.sign[x] = this.registerNBTComponent(new ComponentTag<SignText>("Text" + (x + 1), new SignText(x), text -> new NBTTagString(text.toString()))); this.sign[x] = this.registerNBTComponent(new ComponentTag<SignText>("Text" + (x + 1), new SignText(x), text -> new NBTTagString(text.toString())));

View File

@@ -2,19 +2,20 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder; import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Coordinate; import exopandora.worldhandler.builder.types.Coordinate.CoordinateType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderSpawnpoint extends CommandBuilder public class BuilderSpawnpoint extends CommandBuilder
{ {
public BuilderSpawnpoint(String player) public BuilderSpawnpoint(String player)
{ {
this.setX(new Coordinate(0, true)); this.setX(new CoordinateInt(CoordinateType.LOCAL));
this.setY(new Coordinate(0, true)); this.setY(new CoordinateInt(CoordinateType.LOCAL));
this.setZ(new Coordinate(0, true)); this.setZ(new CoordinateInt(CoordinateType.LOCAL));
} }
@Override @Override
@@ -28,17 +29,17 @@ public class BuilderSpawnpoint extends CommandBuilder
this.setNode(0, player); this.setNode(0, player);
} }
public void setX(Coordinate x) public void setX(CoordinateInt x)
{ {
this.setNode(1, x); this.setNode(1, x);
} }
public void setY(Coordinate y) public void setY(CoordinateInt y)
{ {
this.setNode(2, y); this.setNode(2, y);
} }
public void setZ(Coordinate z) public void setZ(CoordinateInt z)
{ {
this.setNode(3, z); this.setNode(3, z);
} }
@@ -49,9 +50,9 @@ public class BuilderSpawnpoint extends CommandBuilder
Syntax syntax = new Syntax(); Syntax syntax = new Syntax();
syntax.addRequired("player", Type.STRING); syntax.addRequired("player", Type.STRING);
syntax.addRequired("x", Type.COORDINATE); syntax.addRequired("x", Type.COORDINATE_INT);
syntax.addRequired("y", Type.COORDINATE); syntax.addRequired("y", Type.COORDINATE_INT);
syntax.addRequired("z", Type.COORDINATE); syntax.addRequired("z", Type.COORDINATE_INT);
return syntax; return syntax;
} }

View File

@@ -14,22 +14,25 @@ import exopandora.worldhandler.builder.component.impl.ComponentSummon;
import exopandora.worldhandler.builder.component.impl.ComponentTag; import exopandora.worldhandler.builder.component.impl.ComponentTag;
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes; import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes.Applyable; import exopandora.worldhandler.builder.impl.abstr.EnumAttributes.Applyable;
import exopandora.worldhandler.builder.types.Coordinate; import exopandora.worldhandler.builder.types.Coordinate.CoordinateType;
import exopandora.worldhandler.builder.types.CoordinateDouble;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import exopandora.worldhandler.format.text.ColoredString; import exopandora.worldhandler.format.text.ColoredString;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString; import net.minecraft.nbt.NBTTagString;
import net.minecraft.potion.Potion; import net.minecraft.potion.Potion;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side; import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderSummon extends CommandBuilderNBT public class BuilderSummon extends CommandBuilderNBT
{ {
private final ComponentAttributeMob attribute; private final ComponentAttributeMob attribute;
@@ -51,45 +54,14 @@ public class BuilderSummon extends CommandBuilderNBT
this.handItems = this.registerNBTComponent(new ComponentTag<NBTTagList>("HandItems", this::itemListSerializer)); this.handItems = this.registerNBTComponent(new ComponentTag<NBTTagList>("HandItems", this::itemListSerializer));
this.summon = this.registerNBTComponent(new ComponentSummon(), "summon"); this.summon = this.registerNBTComponent(new ComponentSummon(), "summon");
this.potion = this.registerNBTComponent(new ComponentPotionMob()); this.potion = this.registerNBTComponent(new ComponentPotionMob());
} this.setX(new CoordinateDouble(0.0, CoordinateType.LOCAL));
this.setY(new CoordinateDouble(0.0, CoordinateType.LOCAL));
public BuilderSummon(int direction) this.setZ(new CoordinateDouble(2.0, CoordinateType.LOCAL));
{
this();
this.setDirection(direction);
}
public void setDirection(int direction)
{
if(direction == 0)
{
this.setX(new Coordinate(0, true));
this.setY(new Coordinate(0, true));
this.setZ(new Coordinate(2, true));
}
else if(direction == 1)
{
this.setX(new Coordinate(-2, true));
this.setY(new Coordinate(0, true));
this.setZ(new Coordinate(0, true));
}
else if(direction == 2)
{
this.setX(new Coordinate(0, true));
this.setY(new Coordinate(0, true));
this.setZ(new Coordinate(-2, true));
}
else if(direction == 3)
{
this.setX(new Coordinate(2, true));
this.setY(new Coordinate(0, true));
this.setZ(new Coordinate(0, true));
}
} }
public void setEntity(String entityName) public void setEntity(String entityName)
{ {
ResourceLocation location = this.summon.resolve(entityName); ResourceLocation location = ComponentSummon.resolve(entityName);
this.summon.setName(entityName); this.summon.setName(entityName);
this.summon.setEntity(location); this.summon.setEntity(location);
@@ -102,34 +74,34 @@ public class BuilderSummon extends CommandBuilderNBT
return this.getNodeAsResourceLocation(0); return this.getNodeAsResourceLocation(0);
} }
public void setX(Coordinate x) public void setX(CoordinateDouble x)
{ {
this.setNode(1, x); this.setNode(1, x);
} }
public Coordinate getX() public CoordinateDouble getX()
{ {
return this.getNodeAsCoordinate(1); return this.getNodeAsCoordinateDouble(1);
} }
public void setY(Coordinate y) public void setY(CoordinateDouble y)
{ {
this.setNode(2, y); this.setNode(2, y);
} }
public Coordinate getY() public CoordinateDouble getY()
{ {
return this.getNodeAsCoordinate(2); return this.getNodeAsCoordinateDouble(2);
} }
public void setZ(Coordinate z) public void setZ(CoordinateDouble z)
{ {
this.setNode(3, z); this.setNode(3, z);
} }
public Coordinate getZ() public CoordinateDouble getZ()
{ {
return this.getNodeAsCoordinate(3); return this.getNodeAsCoordinateDouble(3);
} }
public void setAttribute(EnumAttributes attribute, double ammount) public void setAttribute(EnumAttributes attribute, double ammount)
@@ -175,7 +147,7 @@ public class BuilderSummon extends CommandBuilderNBT
public void setPassenger(String entityName) public void setPassenger(String entityName)
{ {
this.setPassenger(this.summon.resolve(entityName)); this.setPassenger(ComponentSummon.resolve(entityName));
} }
public void setPassenger(ResourceLocation entityName) public void setPassenger(ResourceLocation entityName)
@@ -186,7 +158,7 @@ public class BuilderSummon extends CommandBuilderNBT
passenger.setString("id", entityName.toString()); passenger.setString("id", entityName.toString());
NBTTagList list = new NBTTagList(); NBTTagList list = new NBTTagList();
list.appendTag(passenger); list.add(passenger);
this.passengers.setValue(list); this.passengers.setValue(list);
} }
@@ -201,9 +173,9 @@ public class BuilderSummon extends CommandBuilderNBT
{ {
NBTTagList list = this.passengers.getValue(); NBTTagList list = this.passengers.getValue();
if(list != null && !list.hasNoTags()) if(list != null && !list.isEmpty())
{ {
return new ResourceLocation(list.getCompoundTagAt(0).getString("id")); return new ResourceLocation(list.getCompound(0).getString("id"));
} }
return null; return null;
@@ -232,8 +204,8 @@ public class BuilderSummon extends CommandBuilderNBT
{ {
NBTTagCompound compound = new NBTTagCompound(); NBTTagCompound compound = new NBTTagCompound();
compound.setString("id", item.toString()); compound.setString("id", item.toString());
compound.setInteger("Count", 1); compound.setInt("Count", 1);
list.appendTag(compound); list.add(compound);
} }
this.armorItems.setValue(list); this.armorItems.setValue(list);
@@ -281,8 +253,8 @@ public class BuilderSummon extends CommandBuilderNBT
{ {
NBTTagCompound compound = new NBTTagCompound(); NBTTagCompound compound = new NBTTagCompound();
compound.setString("id", item.toString()); compound.setString("id", item.toString());
compound.setInteger("Count", 1); compound.setInt("Count", 1);
list.appendTag(compound); list.add(compound);
} }
this.handItems.setValue(list); this.handItems.setValue(list);
@@ -300,62 +272,62 @@ public class BuilderSummon extends CommandBuilderNBT
public void setAmplifier(Potion potion, byte amplifier) public void setAmplifier(Potion potion, byte amplifier)
{ {
this.potion.get(potion).setAmplifier(amplifier); this.potion.setAmplifier(potion, amplifier);
} }
public void setSeconds(Potion potion, int seconds) public void setSeconds(Potion potion, int seconds)
{ {
this.potion.get(potion).setSeconds(seconds); this.potion.setSeconds(potion, seconds);
} }
public void setMinutes(Potion potion, int minutes) public void setMinutes(Potion potion, int minutes)
{ {
this.potion.get(potion).setMinutes(minutes); this.potion.setMinutes(potion, minutes);
} }
public void setHours(Potion potion, int hours) public void setHours(Potion potion, int hours)
{ {
this.potion.get(potion).setHours(hours); this.potion.setHours(potion, hours);
} }
public void setShowParticles(Potion potion, boolean showParticles) public void setShowParticles(Potion potion, boolean showParticles)
{ {
this.potion.get(potion).setShowParticles(showParticles); this.potion.setShowParticles(potion, showParticles);
} }
public void setAmbient(Potion potion, boolean ambient) public void setAmbient(Potion potion, boolean ambient)
{ {
this.potion.get(potion).setAmbient(ambient); this.potion.setAmbient(potion, ambient);
} }
public byte getAmplifier(Potion potion) public byte getAmplifier(Potion potion)
{ {
return this.potion.get(potion).getAmplifier(); return this.potion.getAmplifier(potion);
} }
public int getSeconds(Potion potion) public int getSeconds(Potion potion)
{ {
return this.potion.get(potion).getSeconds(); return this.potion.getSeconds(potion);
} }
public int getMinutes(Potion potion) public int getMinutes(Potion potion)
{ {
return this.potion.get(potion).getMinutes(); return this.potion.getMinutes(potion);
} }
public int getHours(Potion potion) public int getHours(Potion potion)
{ {
return this.potion.get(potion).getHours(); return this.potion.getHours(potion);
} }
public boolean getShowParticles(Potion potion) public boolean getShowParticles(Potion potion)
{ {
return this.potion.get(potion).getShowParticles(); return this.potion.getShowParticles(potion);
} }
public boolean getAmbient(Potion potion) public boolean getAmbient(Potion potion)
{ {
return this.potion.get(potion).getAmbient(); return this.potion.getAmbient(potion);
} }
public Set<Potion> getPotions() public Set<Potion> getPotions()
@@ -363,11 +335,11 @@ public class BuilderSummon extends CommandBuilderNBT
return this.potion.getPotions(); return this.potion.getPotions();
} }
private NBTBase itemListSerializer(NBTTagList list) private INBTBase itemListSerializer(NBTTagList list)
{ {
for(int x = 0; x < list.tagCount(); x++) for(int x = 0; x < list.size(); x++)
{ {
if(!list.getCompoundTagAt(x).getString("id").equals(Blocks.AIR.getRegistryName().toString())) if(!list.getCompound(x).getString("id").equals(Blocks.AIR.getRegistryName().toString()))
{ {
return list; return list;
} }
@@ -376,11 +348,11 @@ public class BuilderSummon extends CommandBuilderNBT
return null; return null;
} }
private NBTBase colorStringSerializer(ColoredString string) private INBTBase colorStringSerializer(ColoredString string)
{ {
if(string.getText() != null && !string.getText().isEmpty()) if(string.getText() != null && !string.getText().isEmpty())
{ {
return new NBTTagString(string.toString()); return new NBTTagString(ITextComponent.Serializer.toJson(new TextComponentString(string.toString())));
} }
return null; return null;
@@ -404,9 +376,9 @@ public class BuilderSummon extends CommandBuilderNBT
Syntax syntax = new Syntax(); Syntax syntax = new Syntax();
syntax.addRequired("entity_name", Type.RESOURCE_LOCATION); syntax.addRequired("entity_name", Type.RESOURCE_LOCATION);
syntax.addOptional("x", Type.COORDINATE); syntax.addOptional("x", Type.COORDINATE_DOUBLE);
syntax.addOptional("y", Type.COORDINATE); syntax.addOptional("y", Type.COORDINATE_DOUBLE);
syntax.addOptional("z", Type.COORDINATE); syntax.addOptional("z", Type.COORDINATE_DOUBLE);
syntax.addOptional("nbt", Type.NBT); syntax.addOptional("nbt", Type.NBT);
return syntax; return syntax;

View File

@@ -0,0 +1,88 @@
package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class BuilderTag extends CommandBuilder
{
public BuilderTag()
{
}
public BuilderTag(String player, EnumMode mode, String name)
{
this.setPlayer(player);
this.setMode(mode);
this.setName(name);
}
public void setPlayer(String player)
{
this.setNode(0, player);
}
public String getPlayer()
{
return this.getNodeAsString(0);
}
public void setMode(EnumMode mode)
{
if(mode != null)
{
this.setNode(1, mode.toString());
}
}
public void setName(String name)
{
this.setNode(2, name);
}
public String getName()
{
return this.getNodeAsString(2);
}
@Override
public String getCommandName()
{
return "tag";
}
@Override
public Syntax getSyntax()
{
Syntax syntax = new Syntax();
syntax.addRequired("player", Type.STRING);
syntax.addRequired("add|list|remove", Type.STRING);
syntax.addRequired("name", Type.STRING);
return syntax;
}
public BuilderTag getBuilderForMode(EnumMode mode)
{
return new BuilderTag(this.getPlayer(), mode, this.getName());
}
@OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
ADD,
LIST,
REMOVE;
@Override
public String toString()
{
return this.name().toLowerCase();
}
}
}

View File

@@ -2,25 +2,16 @@ package exopandora.worldhandler.builder.impl;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.impl.abstr.BuilderScoreboard; import exopandora.worldhandler.builder.types.GreedyString;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderScoreboardTeams extends BuilderScoreboard public class BuilderTeams extends CommandBuilder
{ {
public BuilderScoreboardTeams()
{
this.init();
}
private void init()
{
this.setNode(0, "teams");
}
public void setTeam(String name) public void setTeam(String name)
{ {
String mode = this.getMode(); String mode = this.getMode();
@@ -30,22 +21,22 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{ {
if(mode.equals("add")) if(mode.equals("add"))
{ {
this.setNode(3, name); this.setNode(2, new GreedyString(name));
} }
} }
this.setNode(2, team); this.setNode(1, team);
} }
public String getMode() public String getMode()
{ {
return this.getNodeAsString(1); return this.getNodeAsString(0);
} }
@Nullable @Nullable
public String getTeam() public String getTeam()
{ {
return this.getNodeAsString(2); return this.getNodeAsString(1);
} }
public void setMode(String mode) public void setMode(String mode)
@@ -53,10 +44,10 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
String team = this.getTeam(); String team = this.getTeam();
String player = this.getPlayer(); String player = this.getPlayer();
if(mode.equals("add") || mode.equals("remove|empty") || mode.equals("join|leave") || mode.equals("option")) if(mode.equals("add") || mode.equals("remove|empty") || mode.equals("join|leave") || mode.equals("modify"))
{ {
this.updateSyntax(this.getSyntax(mode)); this.updateSyntax(this.getSyntax(mode));
this.setNode(1, mode); this.setNode(0, mode);
if(team != null) if(team != null)
{ {
@@ -67,8 +58,6 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{ {
this.setPlayer(player); this.setPlayer(player);
} }
this.init();
} }
} }
@@ -80,7 +69,7 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{ {
if(mode.equals("join|leave")) if(mode.equals("join|leave"))
{ {
this.setNode(3, player); this.setNode(2, player);
} }
} }
} }
@@ -94,7 +83,7 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{ {
if(mode.equals("join|leave")) if(mode.equals("join|leave"))
{ {
return this.getNodeAsString(3); return this.getNodeAsString(2);
} }
} }
@@ -103,19 +92,19 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
public void setRule(String rule) public void setRule(String rule)
{ {
if(this.getMode() == null || !this.getMode().equals("option")) if(this.getMode() == null || !this.getMode().equals("modify"))
{ {
this.setMode("option"); this.setMode("modify");
} }
this.setNode(3, rule); this.setNode(2, rule);
} }
public String getRule() public String getRule()
{ {
if(this.getMode() == null || this.getMode().equals("option")) if(this.getMode() == null || this.getMode().equals("modify"))
{ {
return this.getNodeAsString(3); return this.getNodeAsString(2);
} }
return null; return null;
@@ -123,19 +112,19 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
public void setValue(String value) public void setValue(String value)
{ {
if(this.getMode() == null || !this.getMode().equals("option")) if(this.getMode() == null || !this.getMode().equals("modify"))
{ {
this.setMode("option"); this.setMode("modify");
} }
this.setNode(4, value); this.setNode(3, value);
} }
public String getValue() public String getValue()
{ {
if(this.getMode() == null || this.getMode().equals("option")) if(this.getMode() == null || this.getMode().equals("modify"))
{ {
return this.getNodeAsString(4); return this.getNodeAsString(3);
} }
return null; return null;
@@ -148,10 +137,9 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{ {
Syntax syntax = new Syntax(); Syntax syntax = new Syntax();
syntax.addRequired("teams", Type.STRING);
syntax.addRequired("add", Type.STRING); syntax.addRequired("add", Type.STRING);
syntax.addRequired("name", Type.STRING); syntax.addRequired("name", Type.STRING);
syntax.addOptional("display_name...", Type.STRING); syntax.addOptional("display_name...", Type.GREEDY_STRING);
return syntax; return syntax;
} }
@@ -159,7 +147,6 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{ {
Syntax syntax = new Syntax(); Syntax syntax = new Syntax();
syntax.addRequired("teams", Type.STRING);
syntax.addRequired("remove|empty", Type.STRING, "remove|empty"); syntax.addRequired("remove|empty", Type.STRING, "remove|empty");
syntax.addRequired("name", Type.STRING); syntax.addRequired("name", Type.STRING);
@@ -169,19 +156,17 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{ {
Syntax syntax = new Syntax(); Syntax syntax = new Syntax();
syntax.addRequired("teams", Type.STRING);
syntax.addRequired("join|leave", Type.STRING, "join|leave"); syntax.addRequired("join|leave", Type.STRING, "join|leave");
syntax.addRequired("name", Type.STRING); syntax.addRequired("name", Type.STRING);
syntax.addOptional("player", Type.STRING); syntax.addOptional("player", Type.STRING);
return syntax; return syntax;
} }
else if(mode.equals("option")) else if(mode.equals("modify"))
{ {
Syntax syntax = new Syntax(); Syntax syntax = new Syntax();
syntax.addRequired("teams", Type.STRING); syntax.addRequired("modify", Type.STRING);
syntax.addRequired("option", Type.STRING);
syntax.addRequired("team", Type.STRING); syntax.addRequired("team", Type.STRING);
syntax.addRequired("friendlyfire|color|seeFriendlyInvisibles|nametagVisibility|deathMessageVisibility|collisionRule", Type.STRING); syntax.addRequired("friendlyfire|color|seeFriendlyInvisibles|nametagVisibility|deathMessageVisibility|collisionRule", Type.STRING);
syntax.addRequired("value", Type.STRING); syntax.addRequired("value", Type.STRING);
@@ -192,28 +177,28 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
return null; return null;
} }
public BuilderScoreboardTeams getBuilderForMode(EnumMode mode) public BuilderTeams getBuilderForMode(EnumMode mode)
{ {
BuilderScoreboardTeams builder = new BuilderScoreboardTeams(); BuilderTeams builder = new BuilderTeams();
switch(mode) switch(mode)
{ {
case JOIN: case JOIN:
case LEAVE: case LEAVE:
builder.setNode(1, mode.toString()); builder.setNode(0, mode.toString());
builder.setTeam(this.getTeam()); builder.setTeam(this.getTeam());
builder.setPlayer(this.getPlayer()); builder.setPlayer(this.getPlayer());
break; break;
case REMOVE: case REMOVE:
case EMPTY: case EMPTY:
builder.setNode(1, mode.toString()); builder.setNode(0, mode.toString());
builder.setTeam(this.getTeam()); builder.setTeam(this.getTeam());
break; break;
case ADD: case ADD:
builder.setMode(mode.toString()); builder.setMode(mode.toString());
builder.setTeam(this.getTeam()); builder.setTeam(this.getTeam());
break; break;
case OPTION: case MODIFY:
builder.setMode(mode.toString()); builder.setMode(mode.toString());
builder.setTeam(this.getTeam()); builder.setTeam(this.getTeam());
builder.setRule(this.getRule()); builder.setRule(this.getRule());
@@ -231,14 +216,19 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{ {
Syntax syntax = new Syntax(); Syntax syntax = new Syntax();
syntax.addRequired("teams", Type.STRING); syntax.addRequired("list|add|remove|empty|join|leave|modify", Type.STRING);
syntax.addRequired("list|add|remove|empty|join|leave|option", Type.STRING);
syntax.addOptional("...", Type.STRING); syntax.addOptional("...", Type.STRING);
return syntax; return syntax;
} }
@SideOnly(Side.CLIENT) @Override
public String getCommandName()
{
return "team";
}
@OnlyIn(Dist.CLIENT)
public static enum EnumMode public static enum EnumMode
{ {
JOIN, JOIN,
@@ -246,7 +236,7 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
REMOVE, REMOVE,
EMPTY, EMPTY,
ADD, ADD,
OPTION; MODIFY;
@Override @Override
public String toString() public String toString()

View File

@@ -3,9 +3,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder; import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class BuilderTime extends CommandBuilder public class BuilderTime extends CommandBuilder
{ {
public BuilderTime() public BuilderTime()
@@ -51,7 +52,7 @@ public class BuilderTime extends CommandBuilder
return syntax; return syntax;
} }
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public static enum EnumMode public static enum EnumMode
{ {
ADD, ADD,

View File

@@ -0,0 +1,93 @@
package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type;
import exopandora.worldhandler.helper.EnumHelper;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class BuilderTrigger extends CommandBuilder
{
public BuilderTrigger()
{
this.setValue(0);
}
public BuilderTrigger(String objective, EnumMode mode, int value)
{
this.setObjective(objective);
this.setMode(mode);
this.setValue(value);
}
public void setObjective(String name)
{
this.setNode(0, name != null ? name.replaceAll(" ", "_") : null);
}
public String getObjective()
{
return this.getNodeAsString(0);
}
public void setMode(EnumMode mode)
{
if(mode != null)
{
this.setNode(1, mode.toString());
}
}
public EnumMode getMode()
{
return EnumHelper.valueOf(this.getNodeAsString(1), EnumMode.class);
}
public void setValue(int value)
{
this.setNode(2, value);
}
public int getValue()
{
return this.getNodeAsInt(2);
}
@Override
public String getCommandName()
{
return "trigger";
}
@Override
public Syntax getSyntax()
{
Syntax syntax = new Syntax();
syntax.addRequired("objective", Type.STRING);
syntax.addRequired("add|set", Type.STRING);
syntax.addRequired("value", Type.INT);
return syntax;
}
public BuilderTrigger getBuilderForMode(EnumMode mode)
{
return new BuilderTrigger(this.getObjective(), mode, this.getValue());
}
@OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
ADD,
SET;
@Override
public String toString()
{
return this.name().toLowerCase();
}
}
}

View File

@@ -3,10 +3,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder; import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderWH extends CommandBuilder public class BuilderWH extends CommandBuilder
{ {
@Override @Override

View File

@@ -3,9 +3,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder; import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class BuilderWeather extends CommandBuilder public class BuilderWeather extends CommandBuilder
{ {
public BuilderWeather() public BuilderWeather()
@@ -51,7 +52,7 @@ public class BuilderWeather extends CommandBuilder
return syntax; return syntax;
} }
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public static enum EnumWeather public static enum EnumWeather
{ {
CLEAR, CLEAR,

View File

@@ -5,10 +5,10 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.builder.CommandBuilder; import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderWhitelist extends CommandBuilder public class BuilderWhitelist extends CommandBuilder
{ {
public BuilderWhitelist() public BuilderWhitelist()
@@ -76,7 +76,7 @@ public class BuilderWhitelist extends CommandBuilder
return syntax; return syntax;
} }
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public static enum EnumMode public static enum EnumMode
{ {
ADD, ADD,

View File

@@ -3,10 +3,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder; import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax; import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type; import exopandora.worldhandler.builder.types.Type;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class BuilderWorldHandler extends CommandBuilder public class BuilderWorldHandler extends CommandBuilder
{ {
@Override @Override

View File

@@ -1,11 +1,21 @@
package exopandora.worldhandler.builder.impl.abstr; package exopandora.worldhandler.builder.impl.abstr;
import exopandora.worldhandler.builder.CommandBuilderNBT; import exopandora.worldhandler.builder.CommandBuilderNBT;
import exopandora.worldhandler.builder.types.Coordinate; import exopandora.worldhandler.builder.types.CoordinateInt;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public abstract class BuilderBlockPos extends CommandBuilderNBT public abstract class BuilderBlockPos extends CommandBuilderNBT
{ {
private final int offset;
public BuilderBlockPos(int offset)
{
this.offset = offset;
}
public void setPosition(BlockPos pos) public void setPosition(BlockPos pos)
{ {
this.setX(pos.getX()); this.setX(pos.getX());
@@ -13,64 +23,64 @@ public abstract class BuilderBlockPos extends CommandBuilderNBT
this.setZ(pos.getZ()); this.setZ(pos.getZ());
} }
public void setX(float x) public void setX(int x)
{ {
this.setX(new Coordinate(x)); this.setX(new CoordinateInt(x));
} }
public void setY(float y) public void setY(int y)
{ {
this.setY(new Coordinate(y)); this.setY(new CoordinateInt(y));
} }
public void setZ(float z) public void setZ(int z)
{ {
this.setZ(new Coordinate(z)); this.setZ(new CoordinateInt(z));
} }
public void setX(Coordinate x) public void setX(CoordinateInt x)
{ {
this.setNode(0, x); this.setNode(this.offset, x);
} }
public void setY(Coordinate y) public void setY(CoordinateInt y)
{ {
this.setNode(1, y); this.setNode(this.offset + 1, y);
} }
public void setZ(Coordinate z) public void setZ(CoordinateInt z)
{ {
this.setNode(2, z); this.setNode(this.offset + 2, z);
} }
public Coordinate getXCoordiante() public CoordinateInt getXCoordinate()
{ {
return this.getNodeAsCoordinate(0); return this.getNodeAsCoordinateInt(this.offset);
} }
public Coordinate getYCoordiante() public CoordinateInt getYCoordinate()
{ {
return this.getNodeAsCoordinate(1); return this.getNodeAsCoordinateInt(this.offset + 1);
} }
public Coordinate getZCoordiante() public CoordinateInt getZCoordinate()
{ {
return this.getNodeAsCoordinate(2); return this.getNodeAsCoordinateInt(this.offset + 2);
} }
public double getX() public int getX()
{ {
return this.getXCoordiante().getValue(); return this.getXCoordinate().getValue();
} }
public double getY() public int getY()
{ {
return this.getYCoordiante().getValue(); return this.getYCoordinate().getValue();
} }
public double getZ() public int getZ()
{ {
return this.getZCoordiante().getValue(); return this.getZCoordinate().getValue();
} }
public BlockPos getBlockPos() public BlockPos getBlockPos()

View File

@@ -1,13 +1,13 @@
package exopandora.worldhandler.builder.impl.abstr; package exopandora.worldhandler.builder.impl.abstr;
import exopandora.worldhandler.builder.CommandBuilder; import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.types.Coordinate; import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.helper.BlockHelper; import exopandora.worldhandler.helper.BlockHelper;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public abstract class BuilderDoubleBlockPos extends CommandBuilder public abstract class BuilderDoubleBlockPos extends CommandBuilder
{ {
public BuilderDoubleBlockPos() public BuilderDoubleBlockPos()
@@ -23,52 +23,49 @@ public abstract class BuilderDoubleBlockPos extends CommandBuilder
this.setZ1(pos.getZ()); this.setZ1(pos.getZ());
} }
public void setX1(float x) public void setX1(int x)
{ {
this.setX1(new Coordinate(x)); this.setX1(new CoordinateInt(x));
} }
public void setY1(float y) public void setY1(int y)
{ {
this.setY1(new Coordinate(y)); this.setY1(new CoordinateInt(y));
} }
public void setZ1(float z) public void setZ1(int z)
{ {
this.setZ1(new Coordinate(z)); this.setZ1(new CoordinateInt(z));
} }
public void setX1(Coordinate x) public void setX1(CoordinateInt x)
{ {
this.setNode(0, x); this.setNode(0, x);
BlockHelper.setPos1(BlockHelper.setX(BlockHelper.getPos1(), x.getValue()));
} }
public void setY1(Coordinate y) public void setY1(CoordinateInt y)
{ {
this.setNode(1, y); this.setNode(1, y);
BlockHelper.setPos1(BlockHelper.setY(BlockHelper.getPos1(), y.getValue()));
} }
public void setZ1(Coordinate z) public void setZ1(CoordinateInt z)
{ {
this.setNode(2, z); this.setNode(2, z);
BlockHelper.setPos1(BlockHelper.setZ(BlockHelper.getPos1(), z.getValue()));
} }
public Coordinate getX1Coordiante() public CoordinateInt getX1Coordiante()
{ {
return this.getNodeAsCoordinate(0); return this.getNodeAsCoordinateInt(0);
} }
public Coordinate getY1Coordiante() public CoordinateInt getY1Coordiante()
{ {
return this.getNodeAsCoordinate(1); return this.getNodeAsCoordinateInt(1);
} }
public Coordinate getZ1Coordiante() public CoordinateInt getZ1Coordiante()
{ {
return this.getNodeAsCoordinate(2); return this.getNodeAsCoordinateInt(2);
} }
public double getX1() public double getX1()
@@ -98,52 +95,49 @@ public abstract class BuilderDoubleBlockPos extends CommandBuilder
this.setZ2(pos.getZ()); this.setZ2(pos.getZ());
} }
public void setX2(float x) public void setX2(int x)
{ {
this.setX2(new Coordinate(x)); this.setX2(new CoordinateInt(x));
} }
public void setY2(float y) public void setY2(int y)
{ {
this.setY2(new Coordinate(y)); this.setY2(new CoordinateInt(y));
} }
public void setZ2(float z) public void setZ2(int z)
{ {
this.setZ2(new Coordinate(z)); this.setZ2(new CoordinateInt(z));
} }
public void setX2(Coordinate x) public void setX2(CoordinateInt x)
{ {
this.setNode(3, x); this.setNode(3, x);
BlockHelper.setPos2(BlockHelper.setX(BlockHelper.getPos2(), x.getValue()));
} }
public void setY2(Coordinate y) public void setY2(CoordinateInt y)
{ {
this.setNode(4, y); this.setNode(4, y);
BlockHelper.setPos2(BlockHelper.setY(BlockHelper.getPos2(), y.getValue()));
} }
public void setZ2(Coordinate z) public void setZ2(CoordinateInt z)
{ {
this.setNode(5, z); this.setNode(5, z);
BlockHelper.setPos2(BlockHelper.setZ(BlockHelper.getPos2(), z.getValue()));
} }
public Coordinate getX2Coordiante() public CoordinateInt getX2Coordiante()
{ {
return this.getNodeAsCoordinate(3); return this.getNodeAsCoordinateInt(3);
} }
public Coordinate getY2Coordiante() public CoordinateInt getY2Coordiante()
{ {
return this.getNodeAsCoordinate(4); return this.getNodeAsCoordinateInt(4);
} }
public Coordinate getZ2Coordiante() public CoordinateInt getZ2Coordiante()
{ {
return this.getNodeAsCoordinate(5); return this.getNodeAsCoordinateInt(5);
} }
public double getX2() public double getX2()
@@ -165,12 +159,4 @@ public abstract class BuilderDoubleBlockPos extends CommandBuilder
{ {
return new BlockPos(this.getX2(), this.getY2(), this.getZ2()); return new BlockPos(this.getX2(), this.getY2(), this.getZ2());
} }
public <T extends BuilderDoubleBlockPos> T addPositionObservers()
{
BlockHelper.addPos1Observer(this::setPosition1);
BlockHelper.addPos2Observer(this::setPosition2);
return (T) this;
}
} }

View File

@@ -1,10 +1,10 @@
package exopandora.worldhandler.builder.impl.abstr; package exopandora.worldhandler.builder.impl.abstr;
import exopandora.worldhandler.builder.CommandBuilder; import exopandora.worldhandler.builder.CommandBuilder;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public abstract class BuilderScoreboard extends CommandBuilder public abstract class BuilderScoreboard extends CommandBuilder
{ {
@Override @Override

View File

@@ -6,10 +6,10 @@ import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public enum EnumAttributes public enum EnumAttributes
{ {
MAX_HEALTH("generic.maxHealth", EnumOperation.ADDITIVE, Applyable.BOTH), MAX_HEALTH("generic.maxHealth", EnumOperation.ADDITIVE, Applyable.BOTH),
@@ -27,8 +27,9 @@ public enum EnumAttributes
private String attribute; private String attribute;
private EnumOperation operation; private EnumOperation operation;
private Applyable applyable; private Applyable applyable;
public enum Applyable @OnlyIn(Dist.CLIENT)
public static enum Applyable
{ {
BOTH, BOTH,
PLAYER, PLAYER,
@@ -72,7 +73,8 @@ public enum EnumAttributes
return this.operation.getOperation().apply(value); return this.operation.getOperation().apply(value);
} }
public enum EnumOperation @OnlyIn(Dist.CLIENT)
public static enum EnumOperation
{ {
ADDITIVE(value -> value, "(+)"), ADDITIVE(value -> value, "(+)"),
PERCENTAGE(value -> value / 100, "%"); PERCENTAGE(value -> value / 100, "%");

View File

@@ -0,0 +1,133 @@
package exopandora.worldhandler.builder.types;
import javax.annotation.Nullable;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.block.state.IBlockState;
import net.minecraft.command.arguments.BlockStateParser;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.state.IProperty;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistries;
@OnlyIn(Dist.CLIENT)
public class BlockResourceLocation extends ItemResourceLocation
{
private IBlockState state;
public BlockResourceLocation()
{
this(null);
}
public BlockResourceLocation(ResourceLocation resource)
{
this(resource, null, null);
}
public BlockResourceLocation(ResourceLocation resource, IBlockState state, NBTTagCompound nbt)
{
super(resource, nbt);
this.state = this.findState(state, resource);
}
private IBlockState findState(IBlockState state, ResourceLocation resource)
{
boolean matchOld = this.state != null && this.state.getBlock().getRegistryName().equals(resource);
boolean matchNew = state != null && state.getBlock().getRegistryName().equals(resource);
if(matchNew)
{
return state;
}
if(matchOld)
{
return this.state;
}
if(resource != null && ForgeRegistries.BLOCKS.containsKey(resource))
{
return ForgeRegistries.BLOCKS.getValue(resource).getDefaultState();
}
return null;
}
@Override
public void setResourceLocation(ResourceLocation resource)
{
super.setResourceLocation(resource);
this.state = this.findState(null, resource);
}
public IBlockState getState()
{
return this.state;
}
public <T extends Comparable<T>> void withState(IProperty<T> property, T value)
{
if(this.state != null && this.state.has(property))
{
this.state = this.state.with(property, value);
}
}
@Nullable
public static BlockResourceLocation valueOf(String input)
{
if(input != null)
{
BlockStateParser parser = new BlockStateParser(new StringReader(input), false);
try
{
parser.parse(true);
}
catch(CommandSyntaxException e)
{
return null;
}
IBlockState state = parser.getState();
if(state != null)
{
return new BlockResourceLocation(state.getBlock().getRegistryName(), state, parser.getNbt());
}
}
return null;
}
@Override
public BlockResourceLocation get()
{
return (BlockResourceLocation) super.get();
}
@Override
public String toString()
{
if(this.resource != null && this.state != null)
{
StringBuilder builder = new StringBuilder(this.state.toString());
String block = this.state.getBlock().toString();
builder.replace(0, block.length(), this.resource.toString());
if(this.nbt != null)
{
builder.append(this.nbt.toString());
}
return builder.toString();
}
return null;
}
}

View File

@@ -1,63 +1,104 @@
package exopandora.worldhandler.builder.types; package exopandora.worldhandler.builder.types;
import net.minecraftforge.fml.relauncher.Side; import java.util.function.Function;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) import javax.annotation.Nullable;
public class Coordinate
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public abstract class Coordinate<T extends Number> implements ICoordinate<T>
{ {
private double value; protected T value;
private boolean relative; protected CoordinateType type;
public Coordinate() public Coordinate(T value)
{ {
this(0, true); this(value, CoordinateType.ABSOLUTE);
} }
public Coordinate(double value) public Coordinate(T value, CoordinateType type)
{ {
this(value, false);
}
public Coordinate(double value, boolean relative)
{
this.relative = relative;
this.value = value; this.value = value;
this.type = type;
} }
public void setValue(double value) public void setValue(T value)
{ {
this.value = value; this.value = value;
} }
public double getValue() public T getValue()
{ {
return this.value; return this.value;
} }
public void setRelative(boolean relative) public void setType(CoordinateType type)
{ {
this.relative = relative; this.type = type;
} }
public boolean isRelative() public CoordinateType getType()
{ {
return this.relative; return this.type;
}
public static Coordinate valueOf(String value)
{
if(value.startsWith("~"))
{
return new Coordinate(Double.parseDouble(value.substring(1)), true);
}
return new Coordinate(Double.parseDouble(value), false);
} }
@Override @Override
public String toString() public String toString()
{ {
return String.valueOf(this.relative ? (this.value != 0 ? "~" + this.value : "~") : this.value); return this.type.format(this.value, this.zero());
}
@Nullable
public static <S extends Number, U extends Coordinate<S>> U parse(U coordiante, String input, Function<String, S> parser)
{
for(CoordinateType type : CoordinateType.values())
{
if(!type.prefix.isEmpty() && input.startsWith(type.prefix))
{
String numbers = input.substring(type.prefix.length());
coordiante.setType(type);
coordiante.setValue(numbers.isEmpty() ? coordiante.zero() : parser.apply(numbers));
return coordiante;
}
}
coordiante.setType(CoordinateType.ABSOLUTE);
coordiante.setValue(parser.apply(input));
return coordiante;
}
@OnlyIn(Dist.CLIENT)
public static enum CoordinateType
{
ABSOLUTE(""),
GLOBAL("~"),
LOCAL("^");
private final String prefix;
private CoordinateType(String prefix)
{
this.prefix = prefix;
}
public <T extends Number> String format(T value, T zero)
{
if(value == null || value.equals(zero))
{
if(this.prefix.isEmpty())
{
return zero.toString();
}
return this.prefix;
}
return this.prefix + value;
}
} }
} }

View File

@@ -0,0 +1,39 @@
package exopandora.worldhandler.builder.types;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class CoordinateDouble extends Coordinate<Double>
{
public CoordinateDouble()
{
super(0.0);
}
public CoordinateDouble(Double value)
{
super(value);
}
public CoordinateDouble(CoordinateType type)
{
super(0.0, type);
}
public CoordinateDouble(Double value, CoordinateType type)
{
super(value, type);
}
public static CoordinateDouble valueOf(String value)
{
return Coordinate.parse(new CoordinateDouble(), value, Double::parseDouble);
}
@Override
public Double zero()
{
return 0.0;
}
}

View File

@@ -0,0 +1,39 @@
package exopandora.worldhandler.builder.types;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class CoordinateInt extends Coordinate<Integer>
{
public CoordinateInt()
{
super(0);
}
public CoordinateInt(Integer value)
{
super(value);
}
public CoordinateInt(CoordinateType type)
{
super(0, type);
}
public CoordinateInt(Integer value, CoordinateType type)
{
super(value, type);
}
public static CoordinateInt valueOf(String value)
{
return Coordinate.parse(new CoordinateInt(), value, Integer::parseInt);
}
@Override
public Integer zero()
{
return 0;
}
}

View File

@@ -0,0 +1,54 @@
package exopandora.worldhandler.builder.types;
import javax.annotation.Nullable;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class GreedyString
{
private String string;
public GreedyString(String string)
{
this.string = string;
}
public String getString()
{
return this.string;
}
public void setString(String string)
{
this.string = string;
}
public boolean isEmpty()
{
if(this.string == null)
{
return true;
}
return this.string.isEmpty();
}
@Nullable
public static GreedyString valueOf(String string)
{
if(string != null && string.matches("\"(.*)\""))
{
return new GreedyString(string.substring(1, string.length() - 1));
}
return null;
}
@Override
public String toString()
{
return "\"" + this.string + "\"";
}
}

View File

@@ -0,0 +1,10 @@
package exopandora.worldhandler.builder.types;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public interface ICoordinate<T extends Number>
{
T zero();
}

View File

@@ -0,0 +1,104 @@
package exopandora.worldhandler.builder.types;
import javax.annotation.Nullable;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.nbt.JsonToNBT;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class ItemResourceLocation
{
protected ResourceLocation resource;
protected NBTTagCompound nbt;
public ItemResourceLocation()
{
this(null, null);
}
public ItemResourceLocation(ResourceLocation resource)
{
this(resource, null);
}
public ItemResourceLocation(ResourceLocation resource, NBTTagCompound nbt)
{
this.resource = resource;
this.nbt = nbt;
}
public ResourceLocation getResourceLocation()
{
return this.resource;
}
public void setResourceLocation(ResourceLocation resource)
{
this.resource = resource;
}
public NBTTagCompound getNBT()
{
return this.nbt;
}
public void setNBT(NBTTagCompound nbt)
{
this.nbt = nbt;
}
public ItemResourceLocation get()
{
if(this.resource != null)
{
return this;
}
return null;
}
@Nullable
public static ItemResourceLocation valueOf(String input)
{
int start = input.indexOf("{");
ResourceLocation resource = new ResourceLocation(input.substring(0, start));
NBTTagCompound nbt = null;
if(start > 0)
{
try
{
nbt = JsonToNBT.getTagFromJson(input.substring(start, input.lastIndexOf("}") + 1));
}
catch(CommandSyntaxException e)
{
return null;
}
}
return new ItemResourceLocation(resource, nbt);
}
@Override
public String toString()
{
if(this.resource != null)
{
StringBuilder builder = new StringBuilder(this.resource.toString());
if(this.nbt != null)
{
builder.append(this.nbt.toString());
}
return builder.toString();
}
return null;
}
}

View File

@@ -1,52 +0,0 @@
package exopandora.worldhandler.builder.types;
import javax.annotation.Nullable;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class Level
{
private int level;
public Level()
{
this(0);
}
public Level(int level)
{
this.level = level;
}
public int getLevel()
{
return this.level;
}
public void setLevel(int level)
{
this.level = level;
}
@Nullable
public static Level valueOf(String value)
{
if(value != null)
{
if(value.matches("[-]?[0-9]+[Ll]?"))
{
return new Level(Integer.valueOf(value.replaceAll("[lL]$", "")));
}
}
return null;
}
@Override
public String toString()
{
return this.level + "L";
}
}

View File

@@ -7,10 +7,10 @@ import java.util.stream.Collectors;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class TargetSelector public class TargetSelector
{ {
private final Map<String, Object> values = new HashMap<String, Object>(); private final Map<String, Object> values = new HashMap<String, Object>();
@@ -20,8 +20,9 @@ public class TargetSelector
{ {
this.values.put(id.toLowerCase(), value); this.values.put(id.toLowerCase(), value);
} }
@Nullable @Nullable
@SuppressWarnings("unchecked")
public <T> T get(String id) public <T> T get(String id)
{ {
return (T) this.values.get(id); return (T) this.values.get(id);

View File

@@ -4,14 +4,15 @@ import java.util.function.Function;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.nbt.JsonToNBT; import net.minecraft.nbt.JsonToNBT;
import net.minecraft.nbt.NBTException;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public enum Type public enum Type
{ {
SHORT(Short::valueOf), SHORT(Short::valueOf),
@@ -22,11 +23,14 @@ public enum Type
LONG(Long::valueOf), LONG(Long::valueOf),
BOOLEAN(Boolean::valueOf), BOOLEAN(Boolean::valueOf),
STRING(String::valueOf), STRING(String::valueOf),
GREEDY_STRING(GreedyString::valueOf),
RESOURCE_LOCATION(Type::parseResourceLocation), RESOURCE_LOCATION(Type::parseResourceLocation),
ITEM_RESOURCE_LOCATION(ItemResourceLocation::valueOf),
BLOCK_RESOURCE_LOCATION(BlockResourceLocation::valueOf),
NBT(Type::parseNBTTagCompound), NBT(Type::parseNBTTagCompound),
COORDINATE(Coordinate::valueOf), COORDINATE_INT(CoordinateInt::valueOf),
TARGET_SELECTOR(TargetSelector::valueOf), COORDINATE_DOUBLE(CoordinateDouble::valueOf),
LEVEL(Level::valueOf); TARGET_SELECTOR(TargetSelector::valueOf);
private final Function<String, Object> parser; private final Function<String, Object> parser;
@@ -36,6 +40,7 @@ public enum Type
} }
@Nullable @Nullable
@SuppressWarnings("unchecked")
public <T> T parse(String object) public <T> T parse(String object)
{ {
return (T) this.parser.apply(object); return (T) this.parser.apply(object);
@@ -56,7 +61,7 @@ public enum Type
{ {
return JsonToNBT.getTagFromJson(value); return JsonToNBT.getTagFromJson(value);
} }
catch(NBTException nbtexception) catch(CommandSyntaxException e)
{ {
return null; return null;
} }

View File

@@ -1,231 +1,89 @@
package exopandora.worldhandler.command; package exopandora.worldhandler.command;
import java.util.Arrays; import com.mojang.brigadier.CommandDispatcher;
import java.util.Collections; import com.mojang.brigadier.arguments.StringArgumentType;
import java.util.List; import com.mojang.brigadier.exceptions.CommandSyntaxException;
import java.util.stream.Collectors;
import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.builder.impl.BuilderClone; import exopandora.worldhandler.builder.impl.BuilderClone;
import exopandora.worldhandler.builder.impl.BuilderClone.EnumMask; import exopandora.worldhandler.builder.impl.BuilderClone.EnumMask;
import exopandora.worldhandler.builder.impl.BuilderFill; import exopandora.worldhandler.builder.impl.BuilderFill;
import exopandora.worldhandler.builder.impl.BuilderWH;
import exopandora.worldhandler.helper.BlockHelper; import exopandora.worldhandler.helper.BlockHelper;
import exopandora.worldhandler.helper.EnumHelper; import exopandora.worldhandler.helper.CommandHelper;
import exopandora.worldhandler.helper.ResourceHelper; import net.minecraft.command.CommandSource;
import net.minecraft.block.Block; import net.minecraft.command.Commands;
import net.minecraft.client.Minecraft; import net.minecraft.command.arguments.BlockStateArgument;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.NumberInvalidException;
import net.minecraft.command.WrongUsageException;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString; import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) public class CommandWH
public class CommandWH extends CommandBase
{ {
@Override public static void register(CommandDispatcher<CommandSource> dispatcher)
public String getName()
{ {
return "wh"; dispatcher.register(Commands.literal("wh")
.then(Commands.literal("pos1")
.executes(context -> pos1(context.getSource())))
.then(Commands.literal("pos2")
.executes(context -> pos2(context.getSource())))
.then(Commands.literal("fill")
.then(Commands.argument("block", BlockStateArgument.blockState())
.executes(context -> fill(context.getSource(), StringArgumentType.getString(context, "block")))))
.then(Commands.literal("replace")
.then(Commands.argument("block", BlockStateArgument.blockState())
.then(Commands.argument("replace", BlockStateArgument.blockState())
.executes(context -> replace(context.getSource(), StringArgumentType.getString(context, "block"), StringArgumentType.getString(context, "replace"))))))
.then(Commands.literal("clone")
.then(Commands.literal("replace")
.executes(context -> clone(context.getSource(), EnumMask.REPLACE)))
.then(Commands.literal("masked")
.executes(context -> clone(context.getSource(), EnumMask.MASKED)))
.then(Commands.literal("filtered")
.executes(context -> clone(context.getSource(), EnumMask.FILTERED)))));
} }
@Override private static int pos1(CommandSource source) throws CommandSyntaxException
public int getRequiredPermissionLevel()
{ {
return 0; BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
BlockPos pos = BlockHelper.getPos1();
ResourceLocation block = ForgeRegistries.BLOCKS.getKey(BlockHelper.getBlock(pos));
CommandHelper.sendFeedback(source, "Set first position to " + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + " (" + block + ")");
return 1;
} }
@Override private static int pos2(CommandSource source) throws CommandSyntaxException
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{ {
if(args.length > 0) BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
{ BlockPos pos = BlockHelper.getPos2();
if(args[0].equals("pos1")) ResourceLocation block = ForgeRegistries.BLOCKS.getKey(BlockHelper.getBlock(pos));
{ CommandHelper.sendFeedback(source, "Set second position to " + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + " (" + block + ")");
BlockHelper.setPos1(BlockHelper.getFocusedBlockPos()); return 1;
sender.sendMessage(new TextComponentString("Set first position to " + BlockHelper.getPos1().getX() + ", " + BlockHelper.getPos1().getY() + ", " + BlockHelper.getPos1().getZ() + " (" + Block.REGISTRY.getNameForObject(BlockHelper.getFocusedBlock()) + ")"));
}
else if(args[0].equals("pos2"))
{
BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
sender.sendMessage(new TextComponentString("Set second position to " + BlockHelper.getPos2().getX() + ", " + BlockHelper.getPos2().getY() + ", " + BlockHelper.getPos2().getZ() + " (" + Block.REGISTRY.getNameForObject(BlockHelper.getFocusedBlock()) + ")"));
}
else if(args[0].equals("fill"))
{
final String usage = "/wh fill <block> [meta]";
if(args.length > 1)
{
ResourceLocation id = new ResourceLocation(args[1]);
int meta = 0;
if(args.length > 2)
{
try
{
meta = Integer.parseInt(args[2]);
}
catch(Exception e)
{
throw new WrongUsageException(usage);
}
}
if(!ResourceHelper.isRegisteredBlock(id.toString()))
{
throw new NumberInvalidException(usage);
}
BuilderFill builder = new BuilderFill();
builder.setBlock1(id);
builder.setMeta1(meta);
WorldHandler.sendCommand(builder);
}
else
{
throw new WrongUsageException(usage);
}
}
else if(args[0].equals("replace"))
{
final String usage = "/wh replace <block1> <meta1> <block2> [meta2]";
if(args.length > 1)
{
ResourceLocation id1 = new ResourceLocation(args[1]);
if(args.length > 2)
{
ResourceLocation id2 = new ResourceLocation(args[3]);
int meta1 = 0;
int meta2 = 0;
try
{
meta1 = Integer.parseInt(args[2]);
}
catch(Exception e)
{
throw new WrongUsageException(usage);
}
if(args.length > 4)
{
try
{
meta2 = Integer.parseInt(args[4]);
}
catch(Exception e)
{
throw new WrongUsageException(usage);
}
}
if(!ResourceHelper.isRegisteredBlock(id1.toString()) || !ResourceHelper.isRegisteredBlock(id2.toString()))
{
throw new WrongUsageException(usage);
}
BuilderFill builder = new BuilderFill();
builder.setPosition1(BlockHelper.getPos1());
builder.setPosition2(BlockHelper.getPos2());
builder.setBlock1(id1);
builder.setMeta1(meta1);
builder.setBlock2(id2);
builder.setMeta2(meta2);
Minecraft.getMinecraft().player.sendChatMessage(builder.getBuilderForReplace().toActualCommand());
}
else
{
throw new WrongUsageException(usage);
}
}
else
{
throw new WrongUsageException(usage);
}
}
else if(args[0].equals("clone"))
{
final String usage = "/wh clone [" + String.join("|", Arrays.stream(EnumMask.MASKED.values()).map(EnumMask::toString).collect(Collectors.toList())) + "]";
EnumMask mask = EnumMask.MASKED;
if(args.length > 1)
{
mask = EnumHelper.valueOf(EnumMask.class, args[1]);
}
if(mask == null)
{
throw new WrongUsageException(usage);
}
BuilderClone builder = new BuilderClone();
builder.setPosition1(BlockHelper.getPos1());
builder.setPosition2(BlockHelper.getPos2());
builder.setMask(mask);
Minecraft.getMinecraft().player.sendChatMessage(builder.toActualCommand());
}
else
{
throw new WrongUsageException(new BuilderWH().toCommand());
}
}
else
{
throw new WrongUsageException(new BuilderWH().toCommand());
}
}
@Override
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos)
{
if(args.length == 1)
{
return this.getListOfStringsMatchingLastWord(args, new String[]{"pos1", "pos2", "fill", "replace", "clone"});
}
else if(args.length == 2)
{
if(args[0].equals("fill") || args[0].equals("replace"))
{
return this.getListOfStringsMatchingLastWord(args, Block.REGISTRY.getKeys());
}
else if(args[0].equals("clone"))
{
return this.getListOfStringsMatchingLastWord(args, new String[]{"replace", "masked", "filtered"});
}
}
else if(args.length == 3)
{
if(args[0].equals("fill") || args[0].equals("replace"))
{
return this.getListOfStringsMatchingLastWord(args, new String[] {"0"});
}
}
else if(args.length == 4)
{
if(args[0].equals("replace"))
{
return this.getListOfStringsMatchingLastWord(args, Block.REGISTRY.getKeys());
}
}
return Collections.<String>emptyList();
} }
@Override private static int fill(CommandSource source, String block)
public String getUsage(ICommandSender sender)
{ {
return new BuilderWH().toCommand(); BuilderFill builder = new BuilderFill();
builder.setBlock1(block);
CommandHelper.sendCommand(builder);
return 1;
} }
}
private static int replace(CommandSource source, String block, String replace)
{
BuilderFill builder = new BuilderFill();
builder.setPosition1(BlockHelper.getPos1());
builder.setPosition2(BlockHelper.getPos2());
builder.setBlock1(block);
builder.setBlock2(replace);
CommandHelper.sendCommand(builder);
return 1;
}
private static int clone(CommandSource source, EnumMask mask)
{
BuilderClone builder = new BuilderClone();
builder.setPosition1(BlockHelper.getPos1());
builder.setPosition2(BlockHelper.getPos2());
builder.setMask(mask);
return 1;
}
}

View File

@@ -1,100 +1,51 @@
package exopandora.worldhandler.command; package exopandora.worldhandler.command;
import java.util.Collections; import org.apache.maven.artifact.versioning.ComparableVersion;
import java.util.List;
import com.mojang.realmsclient.gui.ChatFormatting; import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import exopandora.worldhandler.Main; import exopandora.worldhandler.Main;
import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.helper.ActionHelper;
import exopandora.worldhandler.builder.impl.BuilderWorldHandler; import exopandora.worldhandler.helper.CommandHelper;
import exopandora.worldhandler.event.EventListener;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandBase; import net.minecraft.command.CommandSource;
import net.minecraft.command.CommandException; import net.minecraft.command.Commands;
import net.minecraft.command.ICommandSender; import net.minecraftforge.fml.ModList;
import net.minecraft.command.WrongUsageException; import net.minecraftforge.fml.VersionChecker;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.common.ForgeVersion;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.versioning.ComparableVersion;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) public class CommandWorldHandler
public class CommandWorldHandler extends CommandBase
{ {
@Override public static void register(CommandDispatcher<CommandSource> dispatcher)
public String getName()
{ {
return "worldhandler"; dispatcher.register(Commands.literal("worldhandler")
.then(Commands.literal("help")
.executes(context -> help(context.getSource())))
.then(Commands.literal("display")
.executes(context -> display()))
.then(Commands.literal("version")
.executes(context -> version(context.getSource()))));
} }
@Override private static int help(CommandSource source) throws CommandSyntaxException
public int getRequiredPermissionLevel()
{ {
return 0; CommandHelper.sendFeedback(source, "/worldhandler help");
CommandHelper.sendFeedback(source, "/worldhandler display");
CommandHelper.sendFeedback(source, "/worldhandler version");
return 1;
} }
@Override private static int display() throws CommandSyntaxException
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{ {
if(args.length > 0) Minecraft.getInstance().addScheduledTask(ActionHelper::displayGui);
{ return 1;
if(args[0].equalsIgnoreCase("help"))
{
this.printHelp(sender);
}
else if(args[0].equalsIgnoreCase("display"))
{
Minecraft.getMinecraft().addScheduledTask(EventListener::displayGui);
}
else if(args[0].equalsIgnoreCase("version"))
{
sender.sendMessage(new TextComponentString("Installed: $mcversion-$version"));
ComparableVersion target = ForgeVersion.getResult(Loader.instance().getIndexedModList().get(Main.MODID)).target;
sender.sendMessage(new TextComponentString("Latest: $mcversion-" + (target != null ? target : "$version")));
}
else
{
throw new WrongUsageException(this.getUsage(sender));
}
}
else if(args.length == 0)
{
this.printHelp(sender);
}
else
{
throw new WrongUsageException(this.getUsage(sender));
}
} }
private void printHelp(ICommandSender player) private static int version(CommandSource source) throws CommandSyntaxException
{ {
player.sendMessage(new TextComponentString(ChatFormatting.DARK_GREEN + "--- Showing help page 1 of 1 (/worldhandler help) ---")); CommandHelper.sendFeedback(source, "Installed: $mcversion-$version");
player.sendMessage(new TextComponentString("/worldhandler help")); ComparableVersion target = VersionChecker.getResult(ModList.get().getModContainerById(Main.MODID).get().getModInfo()).target;
player.sendMessage(new TextComponentString("/worldhandler display")); CommandHelper.sendFeedback(source, "Latest: " + Main.MC_VERSION + "-" + (target != null ? target : Main.MOD_VERSION));
player.sendMessage(new TextComponentString("/worldhandler version")); return 1;
player.sendMessage(new TextComponentString(ChatFormatting.GREEN + "Tip: Press '" + WorldHandler.KEY_WORLD_HANDLER.getDisplayName() + "' to open the World Handler"));
} }
}
@Override
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos)
{
if(args.length == 1)
{
return this.getListOfStringsMatchingLastWord(args, new String[]{"help", "display", "version"});
}
return Collections.<String>emptyList();
}
@Override
public String getUsage(ICommandSender sender)
{
return new BuilderWorldHandler().toCommand();
}
}

View File

@@ -1,45 +0,0 @@
package exopandora.worldhandler.command;
import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandHandler;
import net.minecraft.command.ICommand;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class FakeCommandHandler extends CommandHandler
{
@Override
protected MinecraftServer getServer()
{
return null;
}
private void fakeCommand(ICommand command, ClientChatEvent event)
{
Minecraft.getMinecraft().ingameGUI.getChatGUI().addToSentMessages(event.getMessage());
this.tryExecute(Minecraft.getMinecraft().player, dropFirstString(event.getMessage().split(" ")), command, event.getMessage());
if(event != null && event.isCancelable())
{
event.setCanceled(true);
}
}
private static String[] dropFirstString(String[] input)
{
String[] string = new String[input.length - 1];
System.arraycopy(input, 1, string, 0, input.length - 1);
return string;
}
public void tryCommand(ICommand command, ClientChatEvent event)
{
if(event.getMessage().equals("/" + command.getName()) || event.getMessage().startsWith("/" + command.getName() + " "))
{
this.fakeCommand(command, event);
}
}
}

View File

@@ -0,0 +1,124 @@
package exopandora.worldhandler.config;
import java.util.List;
import org.apache.commons.lang3.tuple.Pair;
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
import exopandora.worldhandler.util.UtilKeyBinding;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.config.ModConfig.Type;
public class Config
{
public static final ForgeConfigSpec CLIENT_SPEC;
public static final ClientConfig CLIENT;
private static ModConfig MOD_CONFIG;
private static CommentedFileConfig CONFIG_DATA;
static
{
Pair<ClientConfig, ForgeConfigSpec> pair = new ForgeConfigSpec.Builder().configure(ClientConfig::new);
CLIENT_SPEC = pair.getRight();
CLIENT = pair.getLeft();
}
@OnlyIn(Dist.CLIENT)
public static class ClientConfig
{
private final ConfigCategorySettings settings;
private final ConfigCategoryButcher butcher;
private final ConfigCategorySkin skin;
private final ConfigCategorySliders sliders;
public ClientConfig(ForgeConfigSpec.Builder builder)
{
this.settings = new ConfigCategorySettings(builder);
this.butcher = new ConfigCategoryButcher(builder);
this.skin = new ConfigCategorySkin(builder);
this.sliders = new ConfigCategorySliders(builder);
}
public void read()
{
this.getSettings().read();
this.getButcher().read();
this.getSkin().read();
this.getSliders().read();
}
public ConfigCategorySettings getSettings()
{
return this.settings;
}
public ConfigCategoryButcher getButcher()
{
return this.butcher;
}
public ConfigCategorySkin getSkin()
{
return this.skin;
}
public ConfigCategorySliders getSliders()
{
return this.sliders;
}
}
public static ConfigCategorySettings getSettings()
{
return Config.CLIENT.getSettings();
}
public static ConfigCategoryButcher getButcher()
{
return Config.CLIENT.getButcher();
}
public static ConfigCategorySkin getSkin()
{
return Config.CLIENT.getSkin();
}
public static ConfigCategorySliders getSliders()
{
return Config.CLIENT.getSliders();
}
protected static <T> void set(ForgeConfigSpec.ConfigValue<T> configValue, T value)
{
if(configValue != null && value != null && (!value.equals(configValue.get()) || configValue.get() instanceof List<?>))
{
Config.CONFIG_DATA.set(configValue.getPath(), value);
}
}
public static void configLoad(ModConfig.Loading event)
{
if(event.getConfig().getType().equals(Type.CLIENT))
{
Config.MOD_CONFIG = event.getConfig();
Config.CONFIG_DATA = (CommentedFileConfig) Config.MOD_CONFIG.getConfigData();
Config.CLIENT.read();
}
}
public static void configReload(ModConfig.ConfigReloading event)
{
if(event.getConfig().getType().equals(Type.CLIENT) && Config.CONFIG_DATA != null)
{
Config.CONFIG_DATA.load();
Config.CLIENT.read();
UtilKeyBinding.updatePosKeys();
}
}
}

View File

@@ -1,45 +0,0 @@
package exopandora.worldhandler.config;
import java.util.HashMap;
import java.util.Map;
import exopandora.worldhandler.helper.EntityHelper;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.EntityList;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ConfigButcher
{
private static Map<String, Boolean> ENTITIES = new HashMap<String, Boolean>();
public static final String CATEGORY = "butcher";
public static void load(Configuration config)
{
for(ResourceLocation location : EntityList.ENTITY_EGGS.keySet())
{
String entity = EntityHelper.getEntityName(location);
String translationKey = "entity." + entity + ".name";
String translation = I18n.format(translationKey);
if(!translation.equals(translationKey))
{
ENTITIES.put(entity, config.getBoolean(entity, CATEGORY, false, I18n.format("gui.worldhandler.config.comment.butcher", translation), translationKey));
}
}
if(config.hasChanged())
{
config.save();
}
}
public static Map<String, Boolean> getEntitiyMap()
{
return ENTITIES;
}
}

View File

@@ -0,0 +1,93 @@
package exopandora.worldhandler.config;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
import net.minecraftforge.registries.ForgeRegistries;
@OnlyIn(Dist.CLIENT)
public class ConfigCategoryButcher
{
private final List<String> entities = new ArrayList<String>();
private final ConfigValue<List<? extends String>> valueEntities;
public ConfigCategoryButcher(ForgeConfigSpec.Builder builder)
{
builder.push("butcher");
this.valueEntities = builder.defineList("entities", Collections.<String>emptyList(), this::isValid);
builder.pop();
}
public void read()
{
this.entities.clear();
this.entities.addAll(this.valueEntities.get());
}
private void write()
{
Config.set(this.valueEntities, this.entities);
}
public List<ResourceLocation> getEntities()
{
List<ResourceLocation> list = new ArrayList<ResourceLocation>();
for(String entity : this.entities)
{
ResourceLocation resource = ResourceLocation.makeResourceLocation(entity);
if(resource != null)
{
list.add(resource);
}
}
return list;
}
public boolean containsEntity(ResourceLocation entity)
{
return this.entities.contains(entity.toString());
}
public void addEntity(ResourceLocation entity)
{
if(this.isValid(entity))
{
this.entities.add(entity.toString());
this.write();
}
}
public boolean removeEntity(ResourceLocation entity)
{
boolean removed = this.entities.remove(entity.toString());
if(removed)
{
this.write();
}
return removed;
}
private boolean isValid(Object string)
{
if(string != null)
{
return ForgeRegistries.ENTITIES.containsKey(ResourceLocation.makeResourceLocation(string.toString()));
}
return false;
}
}

View File

@@ -0,0 +1,320 @@
package exopandora.worldhandler.config;
import java.util.Arrays;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
import net.minecraftforge.common.ForgeConfigSpec.IntValue;
@OnlyIn(Dist.CLIENT)
public class ConfigCategorySettings
{
private boolean commandSyntax;
private boolean shortcuts;
private boolean shortcutKeys;
private boolean tooltips;
private boolean watch;
private boolean smoothWatch;
private boolean pause;
private boolean customTimes;
private boolean permissionQuery;
private boolean highlightBlocks;
private int dawn;
private int noon;
private int sunset;
private int midnight;
private String blockPlacingMode;
private final BooleanValue valueCommandSyntax;
private final BooleanValue valueShortcuts;
private final BooleanValue valueShortcutKeys;
private final BooleanValue valueTooltips;
private final BooleanValue valueWatch;
private final BooleanValue valueSmoothWatch;
private final BooleanValue valuePause;
private final BooleanValue valueCustomTimes;
private final BooleanValue valuePermissionQuery;
private final BooleanValue valueHighlightBlocks;
private final IntValue valueDawn;
private final IntValue valueNoon;
private final IntValue valueSunset;
private final IntValue valueMidnight;
private final ConfigValue<String> valueBlockPlacingMode;
public ConfigCategorySettings(ForgeConfigSpec.Builder builder)
{
builder.push("settings");
this.valueCommandSyntax = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.command_syntax"))
.translation("gui.worldhandler.config.key.settings.command_syntax")
.define("command_syntax", false);
this.valueShortcuts = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.shortcuts"))
.translation("gui.worldhandler.config.key.settings.shortcuts")
.define("shortcuts", false);
this.valueShortcutKeys = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.key_shortcuts"))
.translation("gui.worldhandler.config.key.settings.key_shortcuts")
.define("key_shortcuts", false);
this.valueTooltips = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.tooltips"))
.translation("gui.worldhandler.config.key.settings.tooltips")
.define("tooltips", true);
this.valueWatch = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.watch"))
.translation("gui.worldhandler.config.key.settings.watch")
.define("watch", true);
this.valueSmoothWatch = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.smooth_watch"))
.translation("gui.worldhandler.config.key.settings.smooth_watch")
.define("smooth_watch", true);
this.valuePause = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.pause_game"))
.translation("gui.worldhandler.config.key.settings.pause_game")
.define("pause_game", false);
this.valueCustomTimes = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.custom_times"))
.translation("gui.worldhandler.config.key.settings.custom_times")
.define("custom_times", false);
this.valuePermissionQuery = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.permission_query"))
.translation("gui.worldhandler.config.key.settings.permission_query")
.define("permission_query", true);
this.valueHighlightBlocks = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.highlight_blocks"))
.translation("gui.worldhandler.config.key.settings.highlight_blocks")
.define("highlight_blocks", true);
this.valueDawn = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.custom_time_dawn"))
.translation("gui.worldhandler.config.key.settings.custom_time_dawn")
.defineInRange("custom_time_dawn", 1000, 0, 24000);
this.valueNoon = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.custom_time_noon"))
.translation("gui.worldhandler.config.key.settings.custom_time_noon")
.defineInRange("custom_time_noon", 6000, 0, 24000);
this.valueSunset = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.custom_time_sunset"))
.translation("gui.worldhandler.config.key.settings.custom_time_sunset")
.defineInRange("custom_time_sunset", 12500, 0, 24000);
this.valueMidnight = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.custom_time_midnight"))
.translation("gui.worldhandler.config.key.settings.custom_time_midnight")
.defineInRange("custom_time_midnight", 18000, 0, 24000);
this.valueBlockPlacingMode = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.block_placing_mode"))
.translation("gui.worldhandler.config.key.settings.block_placing_mode")
.defineInList("block_placing_mode", "keep", Arrays.asList("keep", "replace", "destroy"));
builder.pop();
}
public void read()
{
this.commandSyntax = this.valueCommandSyntax.get();
this.shortcuts = this.valueShortcuts.get();
this.shortcutKeys = this.valueShortcutKeys.get();
this.tooltips = this.valueTooltips.get();
this.watch = this.valueWatch.get();
this.smoothWatch = this.valueSmoothWatch.get();
this.pause = this.valuePause.get();
this.customTimes = this.valueCustomTimes.get();
this.permissionQuery = this.valuePermissionQuery.get();
this.highlightBlocks = this.valueHighlightBlocks.get();
this.dawn = this.valueDawn.get();
this.noon = this.valueNoon.get();
this.sunset = this.valueSunset.get();
this.midnight = this.valueMidnight.get();
this.blockPlacingMode = this.valueBlockPlacingMode.get();
}
private void write()
{
Config.set(this.valueCommandSyntax, this.commandSyntax);
Config.set(this.valueShortcuts, this.shortcuts);
Config.set(this.valueShortcutKeys, this.shortcutKeys);
Config.set(this.valueTooltips, this.tooltips);
Config.set(this.valueWatch, this.watch);
Config.set(this.valueSmoothWatch, this.smoothWatch);
Config.set(this.valuePause, this.pause);
Config.set(this.valueCustomTimes, this.customTimes);
Config.set(this.valuePermissionQuery, this.permissionQuery);
Config.set(this.valueHighlightBlocks, this.highlightBlocks);
Config.set(this.valueDawn, this.dawn);
Config.set(this.valueNoon, this.noon);
Config.set(this.valueSunset, this.sunset);
Config.set(this.valueMidnight, this.midnight);
Config.set(this.valueBlockPlacingMode, this.blockPlacingMode);
}
public boolean commandSyntax()
{
return this.commandSyntax;
}
public void setCommandSyntax(boolean enabled)
{
this.commandSyntax = enabled;
this.write();
}
public boolean shortcuts()
{
return this.shortcuts;
}
public void setShortcuts(boolean enabled)
{
this.shortcuts = enabled;
this.write();
}
public boolean shortcutKeys()
{
return this.shortcutKeys;
}
public void setShortcutKeys(boolean enabled)
{
this.shortcutKeys = enabled;
this.write();
}
public boolean tooltips()
{
return this.tooltips;
}
public void setTooltips(boolean enabled)
{
this.tooltips = enabled;
this.write();
}
public boolean watch()
{
return this.watch;
}
public void setWatch(boolean enabled)
{
this.watch = enabled;
this.write();
}
public boolean smoothWatch()
{
return this.smoothWatch;
}
public void setSmoothWatch(boolean enabled)
{
this.smoothWatch = enabled;
this.write();
}
public boolean pause()
{
return this.pause;
}
public void setPause(boolean enabled)
{
this.pause = enabled;
this.write();
}
public boolean customTimes()
{
return this.customTimes;
}
public void setCustomTimes(boolean enabled)
{
this.customTimes = enabled;
this.write();
}
public boolean permissionQuery()
{
return this.permissionQuery;
}
public void setPermissionQuery(boolean enabled)
{
this.permissionQuery = enabled;
this.write();
}
public boolean highlightBlocks()
{
return this.highlightBlocks;
}
public void setHighlightBlocks(boolean enabled)
{
this.highlightBlocks = enabled;
this.write();
}
public int getDawn()
{
return this.dawn;
}
public void setDawn(int ticks)
{
this.dawn = ticks;
this.write();
}
public int getNoon()
{
return this.noon;
}
public void setNoon(int ticks)
{
this.noon = ticks;
this.write();
}
public int getSunset()
{
return this.sunset;
}
public void setSunset(int ticks)
{
this.sunset = ticks;
this.write();
}
public int getMidnight()
{
return this.midnight;
}
public void setMidnight(int ticks)
{
this.midnight = ticks;
this.write();
}
public String getBlockPlacingMode()
{
return this.blockPlacingMode;
}
public void setBlockPlacingMode(String mode)
{
this.blockPlacingMode = mode;
this.write();
}
}

View File

@@ -0,0 +1,343 @@
package exopandora.worldhandler.config;
import java.util.Arrays;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
import net.minecraftforge.common.ForgeConfigSpec.IntValue;
@OnlyIn(Dist.CLIENT)
public class ConfigCategorySkin
{
private int iconSize;
private int labelColor;
private int headlineColor;
private int backgroundRed;
private int backgroundGreen;
private int backgroundBlue;
private int backgroundAlpha;
private int buttonRed;
private int buttonGreen;
private int buttonBlue;
private int buttonAlpha;
private String type;
private boolean sharpEdges;
private boolean drawBackground;
private final ConfigValue<Integer> valueIconSize;
private final IntValue valueLabelColor;
private final IntValue valueHeadlineColor;
private final IntValue valueBackgroundRed;
private final IntValue valueBackgroundGreen;
private final IntValue valueBackgroundBlue;
private final IntValue valueBackgroundAlpha;
private final IntValue valueButtonRed;
private final IntValue valueButtonGreen;
private final IntValue valueButtonBlue;
private final IntValue valueButtonAlpha;
private final ConfigValue<String> valueType;
private final BooleanValue valueSharpEdges;
private final BooleanValue valueDrawBackground;
public ConfigCategorySkin(ForgeConfigSpec.Builder builder)
{
builder.push("skin");
this.valueIconSize = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.icon_size"))
.translation("gui.worldhandler.config.key.skin.icon_size")
.defineInList("icon_size", 16, Arrays.asList(16, 32, 64));
this.valueLabelColor = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.label_color"))
.translation("gui.worldhandler.config.key.skin.label_color")
.defineInRange("label_color", 0x1F1F1F, 0x80000000, 0x7FFFFFFF);
this.valueHeadlineColor = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.headline_color"))
.translation("gui.worldhandler.config.key.skin.headline_color")
.defineInRange("headline_color", 0x4F4F4F, 0x80000000, 0x7FFFFFFF);
this.valueBackgroundRed = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.background_red"))
.translation("gui.worldhandler.config.key.skin.background_red")
.defineInRange("background_red", 255, 0, 255);
this.valueBackgroundGreen = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.background_green"))
.translation("gui.worldhandler.config.key.skin.background_green")
.defineInRange("background_green", 255, 0, 255);
this.valueBackgroundBlue = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.background_blue"))
.translation("gui.worldhandler.config.key.skin.background_blue")
.defineInRange("background_blue", 255, 0, 255);
this.valueBackgroundAlpha = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.background_alpha"))
.translation("gui.worldhandler.config.key.skin.background_alpha")
.defineInRange("background_alpha", 255, 0, 255);
this.valueButtonRed = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.button_red"))
.translation("gui.worldhandler.config.key.skin.button_red")
.defineInRange("button_red", 255, 0, 255);
this.valueButtonGreen = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.button_green"))
.translation("gui.worldhandler.config.key.skin.button_green")
.defineInRange("button_green", 255, 0, 255);
this.valueButtonBlue = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.button_blue"))
.translation("gui.worldhandler.config.key.skin.button_blue")
.defineInRange("button_blue", 255, 0, 255);
this.valueButtonAlpha = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.button_alpha"))
.translation("gui.worldhandler.config.key.skin.button_alpha")
.defineInRange("button_alpha", 255, 0, 255);
this.valueType = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.textures"))
.translation("gui.worldhandler.config.key.skin.textures")
.defineInList("textures", "resourcepack", Arrays.asList("resourcepack", "vanilla"));
this.valueSharpEdges = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.sharp_tab_edges"))
.translation("gui.worldhandler.config.key.settings.sharp_tab_edges")
.define("sharp_tab_edges", false);
this.valueDrawBackground = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.draw_background"))
.translation("gui.worldhandler.config.key.settings.draw_background")
.define("draw_background", true);
builder.pop();
}
public void read()
{
this.iconSize = this.valueIconSize.get();
this.labelColor = this.valueLabelColor.get();
this.headlineColor = this.valueHeadlineColor.get();
this.backgroundRed = this.valueBackgroundRed.get();
this.backgroundGreen = this.valueBackgroundGreen.get();
this.backgroundBlue = this.valueBackgroundBlue.get();
this.backgroundAlpha = this.valueBackgroundAlpha.get();
this.buttonRed = this.valueButtonRed.get();
this.buttonGreen = this.valueButtonGreen.get();
this.buttonBlue = this.valueButtonBlue.get();
this.buttonAlpha = this.valueButtonAlpha.get();
this.type = this.valueType.get();
this.sharpEdges = this.valueSharpEdges.get();
this.drawBackground = this.valueDrawBackground.get();
}
private void write()
{
Config.set(this.valueIconSize, this.iconSize);
Config.set(this.valueLabelColor, this.labelColor);
Config.set(this.valueHeadlineColor, this.headlineColor);
Config.set(this.valueBackgroundRed, this.backgroundRed);
Config.set(this.valueBackgroundGreen, this.backgroundGreen);
Config.set(this.valueBackgroundBlue, this.backgroundBlue);
Config.set(this.valueBackgroundAlpha, this.backgroundAlpha);
Config.set(this.valueButtonRed, this.buttonRed);
Config.set(this.valueButtonGreen, this.buttonGreen);
Config.set(this.valueButtonBlue, this.buttonBlue);
Config.set(this.valueButtonAlpha, this.buttonAlpha);
Config.set(this.valueType, this.type);
Config.set(this.valueSharpEdges, this.sharpEdges);
Config.set(this.valueDrawBackground, this.drawBackground);
}
public int getIconSize()
{
return this.iconSize;
}
public void setIconSize(int size)
{
this.iconSize = size;
this.write();
}
public int getLabelColor()
{
return this.labelColor;
}
public void setLabelColor(int color)
{
this.labelColor = color;
this.write();
}
public int getHeadlineColor()
{
return this.headlineColor;
}
public void setHeadlineColor(int color)
{
this.headlineColor = color;
this.write();
}
private int getBackgroundRed()
{
return this.backgroundRed;
}
public float getBackgroundRedF()
{
return this.getBackgroundRed() / 255F;
}
public void setBackgroundRed(int red)
{
this.backgroundRed = red;
this.write();
}
private int getBackgroundGreen()
{
return this.backgroundGreen;
}
public float getBackgroundGreenF()
{
return this.getBackgroundGreen() / 255F;
}
public void setBackgroundGreen(int green)
{
this.backgroundGreen = green;
this.write();
}
private int getBackgroundBlue()
{
return this.backgroundBlue;
}
public float getBackgroundBlueF()
{
return this.getBackgroundBlue() / 255F;
}
public void setBackgroundBlue(int blue)
{
this.backgroundBlue = blue;
this.write();
}
private int getButtonRed()
{
return this.buttonRed;
}
public float getButtonRedF()
{
return this.getButtonRed() / 255F;
}
public void setButtonRed(int red)
{
this.backgroundRed = red;
this.write();
}
private int getButtonGreen()
{
return this.buttonGreen;
}
public float getButtonGreenF()
{
return this.getButtonGreen() / 255F;
}
public void setButtonGreen(int green)
{
this.buttonGreen = green;
this.write();
}
private int getButtonBlue()
{
return this.buttonBlue;
}
public float getButtonBlueF()
{
return this.getButtonBlue() / 255F;
}
public void setButtonBlue(int blue)
{
this.buttonBlue = blue;
this.write();
}
public String getTextureType()
{
return this.type;
}
public void setTextureType(String type)
{
this.type = type;
this.write();
}
public boolean sharpEdges()
{
return this.sharpEdges;
}
public void setSharpEdges(boolean enabled)
{
this.sharpEdges = enabled;
this.write();
}
public boolean drawBackground()
{
return this.drawBackground;
}
public void setDrawBackground(boolean enabled)
{
this.drawBackground = enabled;
this.write();
}
private int getBackgroundAlpha()
{
return this.backgroundAlpha;
}
public float getBackgroundAlphaF()
{
return this.getBackgroundAlpha() / 255F;
}
public void setBackgroundAlpha(int alpha)
{
this.backgroundAlpha = alpha;
this.write();
}
private int getButtonAlpha()
{
return this.buttonAlpha;
}
public float getButtonAlphaF()
{
return this.getButtonAlpha() / 255F;
}
public void setButtonAlpha(int alpha)
{
this.buttonAlpha = alpha;
this.write();
}
}

View File

@@ -0,0 +1,203 @@
package exopandora.worldhandler.config;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.ForgeConfigSpec.DoubleValue;
@OnlyIn(Dist.CLIENT)
public class ConfigCategorySliders
{
private double maxPotionAmplifier;
private double maxItemEnchantment;
private double maxItemAttributes;
private double maxSummonPotionAmplifier;
private double maxSummonPotionMinutes;
private double maxSummonAttributes;
private double maxExperience;
private double maxPlayerPoints;
private double maxTriggerValue;
private final DoubleValue valueMaxPotionAmplifier;
private final DoubleValue valueMaxItemEnchantment;
private final DoubleValue valueMaxItemAttributes;
private final DoubleValue valueMaxSummonPotionAmplifier;
private final DoubleValue valueMaxSummonPotionMinutes;
private final DoubleValue valueMaxSummonAttributes;
private final DoubleValue valueMaxExperience;
private final DoubleValue valueMaxPlayerPoints;
private final DoubleValue valueMaxTriggerValue;
public ConfigCategorySliders(ForgeConfigSpec.Builder builder)
{
builder.push("sliders");
this.valueMaxPotionAmplifier = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_potion_amplifier"))
.translation("gui.worldhandler.config.key.sliders.max_potion_amplifier")
.defineInRange("max_potion_amplifier", 100D, 0D, Byte.MAX_VALUE);
this.valueMaxItemEnchantment = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_item_enchantment"))
.translation("gui.worldhandler.config.key.sliders.max_item_enchantment")
.defineInRange("max_item_enchantment", 100D, 0D, Integer.MAX_VALUE);
this.valueMaxItemAttributes = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_item_attributes"))
.translation("gui.worldhandler.config.key.sliders.max_item_attributes")
.defineInRange("max_item_attributes", 100D, 0D, Double.MAX_VALUE);
this.valueMaxSummonPotionAmplifier = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_summon_potion_amplifier"))
.translation("gui.worldhandler.config.key.sliders.max_summon_potion_amplifier")
.defineInRange("max_summon_potion_amplifier", 100D, 0D, Byte.MAX_VALUE);
this.valueMaxSummonPotionMinutes = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_summon_potion_minutes"))
.translation("gui.worldhandler.config.key.sliders.max_summon_potion_minutes")
.defineInRange("max_summon_potion_minutes", 100D, 0D, 16000);
this.valueMaxSummonAttributes = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_summon_attributes"))
.translation("gui.worldhandler.config.key.sliders.max_summon_attributes")
.defineInRange("max_summon_attributes", 100D, 0D, Double.MAX_VALUE);
this.valueMaxExperience = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_experience"))
.translation("gui.worldhandler.config.key.sliders.max_experience")
.defineInRange("max_experience", 100D, 0D, 100000D);
this.valueMaxPlayerPoints = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_player_points"))
.translation("gui.worldhandler.config.key.sliders.max_player_points")
.defineInRange("max_player_points", 100D, 0D, 100000D);
this.valueMaxTriggerValue = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_trigger_value"))
.translation("gui.worldhandler.config.key.sliders.max_trigger_value")
.defineInRange("max_trigger_value", 100D, 0D, 100000D);
builder.pop();
}
public void read()
{
this.maxPotionAmplifier = this.valueMaxPotionAmplifier.get();
this.maxItemEnchantment = this.valueMaxItemEnchantment.get();
this.maxItemAttributes = this.valueMaxItemAttributes.get();
this.maxSummonPotionAmplifier = this.valueMaxSummonPotionAmplifier.get();
this.maxSummonPotionMinutes = this.valueMaxSummonPotionMinutes.get();
this.maxSummonAttributes = this.valueMaxSummonAttributes.get();
this.maxExperience = this.valueMaxExperience.get();
this.maxPlayerPoints = this.valueMaxPlayerPoints.get();
this.maxTriggerValue = this.valueMaxTriggerValue.get();
}
private void write()
{
Config.set(this.valueMaxPotionAmplifier, this.maxPotionAmplifier);
Config.set(this.valueMaxItemEnchantment, this.maxItemEnchantment);
Config.set(this.valueMaxItemAttributes, this.maxItemAttributes);
Config.set(this.valueMaxSummonPotionAmplifier, this.maxSummonPotionAmplifier);
Config.set(this.valueMaxSummonPotionMinutes, this.maxSummonPotionMinutes);
Config.set(this.valueMaxSummonAttributes, this.maxSummonAttributes);
Config.set(this.valueMaxExperience, this.maxExperience);
Config.set(this.valueMaxPlayerPoints, this.maxPlayerPoints);
Config.set(this.valueMaxTriggerValue, this.maxTriggerValue);
}
public double getMaxPotionAmplifier()
{
return this.maxPotionAmplifier;
}
public void setMaxPotionAmplifier(double max)
{
this.maxPotionAmplifier = max;
this.write();
}
public double getMaxItemEnchantment()
{
return this.maxItemEnchantment;
}
public void setMaxItemEnchantment(double max)
{
this.maxItemEnchantment = max;
this.write();
}
public double getMaxItemAttributes()
{
return this.maxItemAttributes;
}
public void setMaxItemAttributes(double max)
{
this.maxItemAttributes = max;
this.write();
}
public double getMaxSummonPotionAmplifier()
{
return this.maxSummonPotionAmplifier;
}
public void setMaxSummonPotionAmplifier(double max)
{
this.maxSummonPotionAmplifier = max;
this.write();
}
public double getMaxSummonPotionMinutes()
{
return this.maxSummonPotionMinutes;
}
public void setMaxSummonPotionMinutes(double max)
{
this.maxSummonPotionMinutes = max;
this.write();
}
public double getMaxSummonAttributes()
{
return this.maxSummonAttributes;
}
public void setMaxSummonAttributes(double max)
{
this.maxSummonAttributes = max;
this.write();
}
public double getMaxExperience()
{
return this.maxExperience;
}
public void setMaxExperience(double max)
{
this.maxExperience = max;
this.write();
}
public double getMaxPlayerPoints()
{
return this.maxPlayerPoints;
}
public void setMaxPlayerPoints(double max)
{
this.maxPlayerPoints = max;
this.write();
}
public double getMaxTriggerValue()
{
return this.maxTriggerValue;
}
public void setMaxTriggerValue(double max)
{
this.maxTriggerValue = max;
this.write();
}
}

View File

@@ -1,136 +0,0 @@
package exopandora.worldhandler.config;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ConfigSettings
{
private static boolean BIOME_INDICATOR;
private static boolean COMMAND_SYNTAX;
private static boolean SHORTCUTS;
private static boolean SHORTCUT_KEYS;
private static boolean TOOLTIPS;
private static boolean WATCH;
private static boolean SMOOTH_WATCH;
private static boolean PAUSE;
private static boolean CUSTOM_TIMES;
private static boolean PERMISSION_QUERY;
private static boolean HIGHLIGHT_BLOCKS;
private static int DAWN;
private static int NOON;
private static int SUNSET;
private static int MIDNIGHT;
private static String BLOCK_PLACING_MODE;
public static final String CATEGORY = "settings";
public static void load(Configuration config)
{
BIOME_INDICATOR = config.getBoolean("biome_indicator", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.biome_indicator"), "gui.worldhandler.config.key.settings.biome_indicator");
COMMAND_SYNTAX = config.getBoolean("command_syntax", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.command_syntax"), "gui.worldhandler.config.key.settings.command_syntax");
SHORTCUTS = config.getBoolean("shortcuts", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.shortcuts"), "gui.worldhandler.config.key.settings.shortcuts");
SHORTCUT_KEYS = config.getBoolean("key_shortcuts", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.key_shortcuts"), "gui.worldhandler.config.key.settings.key_shortcuts");
TOOLTIPS = config.getBoolean("tooltips", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.settings.tooltips"), "gui.worldhandler.config.key.settings.tooltips");
WATCH = config.getBoolean("watch", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.settings.watch"), "gui.worldhandler.config.key.settings.watch");
SMOOTH_WATCH = config.getBoolean("smooth_watch", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.settings.smooth_watch"), "gui.worldhandler.config.key.settings.smooth_watch");
PAUSE = config.getBoolean("pause_game", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.pause_game"), "gui.worldhandler.config.key.settings.pause_game");
CUSTOM_TIMES = config.getBoolean("custom_times", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.custom_times"), "gui.worldhandler.config.key.settings.custom_times");
PERMISSION_QUERY = config.getBoolean("permission_query", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.settings.permission_query"), "gui.worldhandler.config.key.settings.permission_query");
HIGHLIGHT_BLOCKS = config.getBoolean("highlight_blocks", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.settings.highlight_blocks"), "gui.worldhandler.config.key.settings.highlight_blocks");
DAWN = config.getInt("custom_time_dawn", CATEGORY, 1000, 0, 24000, I18n.format("gui.worldhandler.config.comment.settings.custom_time_dawn"), "gui.worldhandler.config.key.settings.custom_time_dawn");
NOON = config.getInt("custom_time_noon", CATEGORY, 6000, 0, 24000, I18n.format("gui.worldhandler.config.comment.settings.custom_time_noon"), "gui.worldhandler.config.key.settings.custom_time_noon");
SUNSET = config.getInt("custom_time_sunset", CATEGORY, 12500, 0, 24000, I18n.format("gui.worldhandler.config.comment.settings.custom_time_sunset"), "gui.worldhandler.config.key.settings.custom_time_sunset");
MIDNIGHT = config.getInt("custom_time_midnight", CATEGORY, 18000, 0, 24000, I18n.format("gui.worldhandler.config.comment.settings.custom_time_midnight"), "gui.worldhandler.config.key.settings.custom_time_midnight");
BLOCK_PLACING_MODE = config.getString("block_placing_mode", CATEGORY, "keep", I18n.format("gui.worldhandler.config.comment.settings.block_placing_mode"), new String[]{"keep", "replace", "destroy"}, "gui.worldhandler.config.key.settings.block_placing_mode");
if(config.hasChanged())
{
config.save();
}
}
public static boolean isBiomeIndicatorEnabled()
{
return BIOME_INDICATOR;
}
public static boolean isCommandSyntaxEnabled()
{
return COMMAND_SYNTAX;
}
public static boolean areShortcutsEnabled()
{
return SHORTCUTS;
}
public static boolean arePosShortcutsEnabled()
{
return SHORTCUT_KEYS;
}
public static boolean areTooltipsEnabled()
{
return TOOLTIPS;
}
public static boolean isWatchEnabled()
{
return WATCH;
}
public static boolean isSmoothWatchEnabled()
{
return SMOOTH_WATCH;
}
public static boolean isPauseEnabled()
{
return PAUSE;
}
public static boolean isCustomTimeEnabled()
{
return CUSTOM_TIMES;
}
public static boolean isPermissionQueryEnabled()
{
return PERMISSION_QUERY;
}
public static boolean isHighlightBlocksEnabled()
{
return HIGHLIGHT_BLOCKS;
}
public static int getDawn()
{
return DAWN;
}
public static int getNoon()
{
return NOON;
}
public static int getSunset()
{
return SUNSET;
}
public static int getMidnight()
{
return MIDNIGHT;
}
public static String getMode()
{
return BLOCK_PLACING_MODE;
}
}

View File

@@ -1,127 +0,0 @@
package exopandora.worldhandler.config;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ConfigSkin
{
private static int ICON_SIZE;
private static int LABEL_COLOR;
private static int HEADLINE_COLOR;
private static int BACKGROUND_RED;
private static int BACKGROUND_GREEN;
private static int BACKGROUND_BLUE;
private static int BACKGROUND_ALPHA;
private static int BUTTON_RED;
private static int BUTTON_GREEN;
private static int BUTTON_BLUE;
private static int BUTTON_ALPHA;
private static String TYPE;
private static boolean SHARP_EDGES;
private static boolean DRAW_BACKGROUND;
public static final String CATEGORY = "skin";
public static void load(Configuration config)
{
ICON_SIZE = Integer.valueOf(config.getString("icon_size", CATEGORY, "16", I18n.format("gui.worldhandler.config.comment.skin.icons"), new String[]{"16", "32", "64"}, "gui.worldhandler.config.key.skin.icons"));
LABEL_COLOR = config.getInt("label_color", CATEGORY, 0x1F1F1F, 0x80000000, 0x7FFFFFFF, I18n.format("gui.worldhandler.config.comment.skin.label_color"), "gui.worldhandler.config.key.skin.label_color");
HEADLINE_COLOR = config.getInt("headline_color", CATEGORY, 0x4F4F4F, 0x80000000, 0x7FFFFFFF, I18n.format("gui.worldhandler.config.comment.skin.headline_color"), "gui.worldhandler.config.key.skin.headline_color");
BACKGROUND_RED = config.getInt("background_red", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.background_red"), "gui.worldhandler.config.key.skin.background_red");
BACKGROUND_GREEN = config.getInt("background_green", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.background_green"), "gui.worldhandler.config.key.skin.background_green");
BACKGROUND_BLUE = config.getInt("background_blue", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.background_blue"), "gui.worldhandler.config.key.skin.background_blue");
BACKGROUND_ALPHA = config.getInt("background_alpha", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.background_alpha"), "gui.worldhandler.config.key.skin.background_alpha");
BUTTON_RED = config.getInt("button_red", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.button_red"), "gui.worldhandler.config.key.skin.button_red");
BUTTON_GREEN = config.getInt("button_green", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.button_green"), "gui.worldhandler.config.key.skin.button_green");
BUTTON_BLUE = config.getInt("button_blue", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.button_blue"), "gui.worldhandler.config.key.skin.button_blue");
BUTTON_ALPHA = config.getInt("button_alpha", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.button_alpha"), "gui.worldhandler.config.key.skin.button_alpha");
TYPE = config.getString("textures", CATEGORY, "resourcepack", I18n.format("gui.worldhandler.config.comment.skin.textures"), new String[]{"resourcepack", "vanilla"}, "gui.worldhandler.config.key.skin.textures");
SHARP_EDGES = config.getBoolean("sharp_tab_edges", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.skin.sharp_tab_edges"), "gui.worldhandler.config.key.skin.sharp_tab_edges");
DRAW_BACKGROUND = config.getBoolean("draw_background", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.skin.draw_background"), "gui.worldhandler.config.key.skin.draw_background");
if(config.hasChanged())
{
config.save();
}
}
public static int getIconSize()
{
return ICON_SIZE;
}
public static int getLabelColor()
{
return LABEL_COLOR;
}
public static int getHeadlineColor()
{
return HEADLINE_COLOR;
}
public static int getBackgroundRed()
{
return BACKGROUND_RED;
}
public static int getBackgroundGreen()
{
return BACKGROUND_GREEN;
}
public static int getBackgroundBlue()
{
return BACKGROUND_BLUE;
}
public static int getButtonRed()
{
return BUTTON_RED;
}
public static int getButtonGreen()
{
return BUTTON_GREEN;
}
public static int getButtonBlue()
{
return BUTTON_BLUE;
}
public static String getTextureType()
{
return TYPE;
}
public static boolean areSharpEdgesEnabled()
{
return SHARP_EDGES;
}
public static boolean isBackgroundDrawingEnabled()
{
return DRAW_BACKGROUND;
}
public static int getBackgroundAlpha()
{
return BACKGROUND_ALPHA;
}
public static int getButtonAlpha()
{
return BUTTON_ALPHA;
}
}

View File

@@ -1,84 +0,0 @@
package exopandora.worldhandler.config;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ConfigSliders
{
private static double MAX_POTION_AMPLIFIER;
private static double MAX_ITEM_ENCHANTENT;
private static double MAX_ITEM_ATTRIBUTES;
private static double MAX_SUMMON_POTION_AMPLIFIER;
private static double MAX_SUMMON_POTION_MINUTES;
private static double MAX_SUMMON_ATTRIBUTES;
private static double MAX_EXPERIENCE;
private static double MAX_PLAYER_POINTS;
public static final String CATEGORY = "sliders";
public static void load(Configuration config)
{
MAX_POTION_AMPLIFIER = config.get(CATEGORY, "max_potion_amplifier", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_potion_amplifier"), 0D, Byte.MAX_VALUE).setLanguageKey("gui.worldhandler.config.key.sliders.max_potion_amplifier").getDouble();
MAX_ITEM_ENCHANTENT = config.get(CATEGORY, "max_item_enchantment", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_item_enchantment"), 0D, Integer.MAX_VALUE).setLanguageKey("gui.worldhandler.config.key.sliders.max_item_enchantment").getDouble();
MAX_ITEM_ATTRIBUTES = config.get(CATEGORY, "max_item_attributes", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_item_attributes"), 0D, Double.MAX_VALUE).setLanguageKey("gui.worldhandler.config.key.sliders.max_item_attributes").getDouble();
MAX_SUMMON_POTION_AMPLIFIER = config.get(CATEGORY, "max_summon_potion_amplifier", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_summon_potion_amplifier"), 0D, Byte.MAX_VALUE).setLanguageKey("gui.worldhandler.config.key.sliders.max_summon_potion_amplifier").getDouble();
MAX_SUMMON_POTION_MINUTES = config.get(CATEGORY, "max_summon_potion_minutes", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_summon_potion_minutes"), 0D, 16000).setLanguageKey("gui.worldhandler.config.key.sliders.max_summon_potion_minutes").getDouble();
MAX_SUMMON_ATTRIBUTES = config.get(CATEGORY, "max_summon_attributes", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_summon_attributes"), 0D, Double.MAX_VALUE).setLanguageKey("gui.worldhandler.config.key.sliders.max_summon_attributes").getDouble();
MAX_EXPERIENCE = config.get(CATEGORY, "max_experience", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_experience"), 0D, 100000D).setLanguageKey("gui.worldhandler.config.key.sliders.max_experience").getDouble();
MAX_PLAYER_POINTS = config.get(CATEGORY, "max_player_points", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_player_points"), 0D, 100000D).setLanguageKey("gui.worldhandler.config.key.sliders.max_player_points").getDouble();
if(config.hasChanged())
{
config.save();
}
}
public static double getMaxPotionAmplifier()
{
return MAX_POTION_AMPLIFIER;
}
public static double getMaxItemEnchantment()
{
return MAX_ITEM_ENCHANTENT;
}
public static double getMaxItemAttributes()
{
return MAX_ITEM_ATTRIBUTES;
}
public static double getMaxSummonPotionAmplifier()
{
return MAX_SUMMON_POTION_AMPLIFIER;
}
public static double getMaxSummonPotionMinutes()
{
return MAX_SUMMON_POTION_MINUTES;
}
public static double getMaxSummonAttributes()
{
return MAX_SUMMON_ATTRIBUTES;
}
public static double getMaxExperience()
{
return MAX_EXPERIENCE;
}
public static double getMaxPlayerPoints()
{
return MAX_PLAYER_POINTS;
}
}

View File

@@ -0,0 +1,121 @@
package exopandora.worldhandler.event;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.ParseResults;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import exopandora.worldhandler.config.Config;
import exopandora.worldhandler.helper.BlockHelper;
import exopandora.worldhandler.helper.CommandHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.command.CommandSource;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
@OnlyIn(Dist.CLIENT)
public class ClientEventHandler
{
public static void renderWorldLastEvent(RenderWorldLastEvent event)
{
if(Config.getSettings().highlightBlocks() && Minecraft.getInstance().world != null)
{
GlStateManager.pushMatrix();
GlStateManager.disableAlphaTest();
GlStateManager.enableBlend();
GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.lineWidth(2.0F);
GlStateManager.disableTexture2D();
GlStateManager.depthMask(false);
final double constant = 0.0020000000949949026D;
EntityPlayer player = Minecraft.getInstance().player;
double playerX = player.lastTickPosX + (player.posX - player.lastTickPosX) * Minecraft.getInstance().getRenderPartialTicks();
double playerY = player.lastTickPosY + (player.posY - player.lastTickPosY) * Minecraft.getInstance().getRenderPartialTicks();
double playerZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * Minecraft.getInstance().getRenderPartialTicks();
double minX = Math.min(BlockHelper.getPos1().getX(), BlockHelper.getPos2().getX()) - constant - playerX;
double minY = Math.min(BlockHelper.getPos1().getY(), BlockHelper.getPos2().getY()) - constant - playerY;
double minZ = Math.min(BlockHelper.getPos1().getZ(), BlockHelper.getPos2().getZ()) - constant - playerZ;
double maxX = Math.max(BlockHelper.getPos1().getX(), BlockHelper.getPos2().getX()) + constant - playerX + 1;
double maxY = Math.max(BlockHelper.getPos1().getY(), BlockHelper.getPos2().getY()) + constant - playerY + 1;
double maxZ = Math.max(BlockHelper.getPos1().getZ(), BlockHelper.getPos2().getZ()) + constant - playerZ + 1;
Tessellator tesselator = Tessellator.getInstance();
BufferBuilder buffer = tesselator.getBuffer();
final int alpha = 255;
final int color1 = 223;
final int color2 = 127;
GlStateManager.lineWidth(2.0F);
buffer.begin(3, DefaultVertexFormats.POSITION_COLOR);
buffer.pos(minX, minY, minZ).color((float) color1, (float) color1, (float) color1, 0.0F).endVertex();
buffer.pos(minX, minY, minZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(maxX, minY, minZ).color(color1, color2, color2, alpha).endVertex();
buffer.pos(maxX, minY, maxZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(minX, minY, maxZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(minX, minY, minZ).color(color2, color2, color1, alpha).endVertex();
buffer.pos(minX, maxY, minZ).color(color2, color1, color2, alpha).endVertex();
buffer.pos(maxX, maxY, minZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(maxX, maxY, maxZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(minX, maxY, maxZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(minX, maxY, minZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(minX, maxY, maxZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(minX, minY, maxZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(maxX, minY, maxZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(maxX, maxY, maxZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(maxX, maxY, minZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(maxX, minY, minZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(maxX, minY, minZ).color((float) color1, (float) color1, (float) color1, 0.0F).endVertex();
tesselator.draw();
GlStateManager.lineWidth(1.0F);
GlStateManager.depthMask(true);
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
GlStateManager.enableAlphaTest();
GlStateManager.popMatrix();
}
}
public static void clientChatEvent(ClientChatEvent event)
{
if(!Minecraft.getInstance().isSingleplayer())
{
CommandDispatcher<CommandSource> dispatcher = new CommandDispatcher<CommandSource>();
CommandHelper.registerCommands(dispatcher);
StringReader command = new StringReader(event.getMessage());
command.skip();
ParseResults<CommandSource> result = dispatcher.parse(command, Minecraft.getInstance().player.getCommandSource());
if(result.getContext().getCommand() != null)
{
try
{
dispatcher.execute(result);
}
catch(CommandSyntaxException e)
{
e.printStackTrace();
}
if(event.isCancelable())
{
event.setCanceled(true);
}
}
}
}
}

View File

@@ -1,172 +0,0 @@
package exopandora.worldhandler.event;
import com.mojang.realmsclient.gui.ChatFormatting;
import exopandora.worldhandler.Main;
import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.command.FakeCommandHandler;
import exopandora.worldhandler.config.ConfigSettings;
import exopandora.worldhandler.gui.container.impl.GuiWorldHandlerContainer;
import exopandora.worldhandler.gui.content.Contents;
import exopandora.worldhandler.helper.BlockHelper;
import exopandora.worldhandler.hud.BiomeIndicator;
import exopandora.worldhandler.util.UtilPlayer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.util.text.ChatType;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class EventListener
{
private final FakeCommandHandler commandHandler = new FakeCommandHandler();
private final BiomeIndicator biomeIndicator = new BiomeIndicator();
@SubscribeEvent
public void renderWorldLastEvent(RenderWorldLastEvent event)
{
if(ConfigSettings.isHighlightBlocksEnabled() && Minecraft.getMinecraft().world != null)
{
GlStateManager.pushMatrix();
GlStateManager.disableAlpha();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.glLineWidth(2.0F);
GlStateManager.disableTexture2D();
GlStateManager.depthMask(false);
final double constant = 0.0020000000949949026D;
EntityPlayer player = Minecraft.getMinecraft().player;
double playerX = player.lastTickPosX + (player.posX - player.lastTickPosX) * Minecraft.getMinecraft().getRenderPartialTicks();
double playerY = player.lastTickPosY + (player.posY - player.lastTickPosY) * Minecraft.getMinecraft().getRenderPartialTicks();
double playerZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * Minecraft.getMinecraft().getRenderPartialTicks();
double minX = Math.min(BlockHelper.getPos1().getX(), BlockHelper.getPos2().getX()) - constant - playerX;
double minY = Math.min(BlockHelper.getPos1().getY(), BlockHelper.getPos2().getY()) - constant - playerY;
double minZ = Math.min(BlockHelper.getPos1().getZ(), BlockHelper.getPos2().getZ()) - constant - playerZ;
double maxX = Math.max(BlockHelper.getPos1().getX(), BlockHelper.getPos2().getX()) + constant - playerX + 1;
double maxY = Math.max(BlockHelper.getPos1().getY(), BlockHelper.getPos2().getY()) + constant - playerY + 1;
double maxZ = Math.max(BlockHelper.getPos1().getZ(), BlockHelper.getPos2().getZ()) + constant - playerZ + 1;
final float opacity = 0.2F;
for(int x = 1; x < maxX - minX; x++)
{
RenderGlobal.drawBoundingBox(minX, minY, minZ, minX + x + 2 * constant, maxY, maxZ, 0.0F, 0.0F, 0.0F, opacity);
}
for(int y = 1; y < maxY - minY; y++)
{
RenderGlobal.drawBoundingBox(minX, minY, minZ, maxX, minY + y + 2 * constant, maxZ, 0.0F, 0.0F, 0.0F, opacity);
}
for(int z = 1; z < maxZ - minZ; z++)
{
RenderGlobal.drawBoundingBox(minX, minY, minZ, maxX, maxY, minZ + z + 2 * constant, 0.0F, 0.0F, 0.0F, opacity);
}
RenderGlobal.renderFilledBox(minX, minY, minZ, maxX, maxY, maxZ, 0.0F, 0.0F, 0.0F, opacity / 2);
RenderGlobal.renderFilledBox(maxX, maxY, maxZ, minX, minY, minZ, 0.0F, 0.0F, 0.0F, opacity / 2);
GlStateManager.depthMask(true);
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
GlStateManager.enableAlpha();
GlStateManager.popMatrix();
}
}
@SubscribeEvent
public void clientTickEvent(ClientTickEvent event)
{
if(Minecraft.getMinecraft().inGameHasFocus && event.phase.equals(Phase.START))
{
if(ConfigSettings.isBiomeIndicatorEnabled())
{
this.biomeIndicator.tick();
}
}
}
@SubscribeEvent
public void keyInputEvent(KeyInputEvent event)
{
if(WorldHandler.KEY_WORLD_HANDLER.isPressed())
{
displayGui();
}
else if(WorldHandler.KEY_WORLD_HANDLER_POS1.isPressed() && ConfigSettings.arePosShortcutsEnabled())
{
BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
}
else if(WorldHandler.KEY_WORLD_HANDLER_POS2.isPressed() && ConfigSettings.arePosShortcutsEnabled())
{
BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
}
}
@SubscribeEvent
public void onConfigChanged(OnConfigChangedEvent event)
{
if(event.getModID().equals(Main.MODID))
{
WorldHandler.updateConfig();
}
}
@SubscribeEvent
public void clientChatEvent(ClientChatEvent event)
{
if(!Minecraft.getMinecraft().isSingleplayer())
{
this.commandHandler.tryCommand(WorldHandler.COMMAND_WORLD_HANDLER, event);
this.commandHandler.tryCommand(WorldHandler.COMMAND_WH, event);
}
}
public static void displayGui()
{
if(!UtilPlayer.canIssueCommand() && ConfigSettings.isPermissionQueryEnabled())
{
Minecraft.getMinecraft().ingameGUI.addChatMessage(ChatType.GAME_INFO, new TextComponentString(ChatFormatting.RED + I18n.format("worldhandler.permission.refused")));
Minecraft.getMinecraft().ingameGUI.addChatMessage(ChatType.GAME_INFO, new TextComponentString(ChatFormatting.RED + I18n.format("worldhandler.permission.refused.change", I18n.format("gui.worldhandler.config.key.settings.permission_query"))));
}
else
{
try
{
if(BlockHelper.isFocusedBlockEqualTo(Blocks.STANDING_SIGN) || BlockHelper.isFocusedBlockEqualTo(Blocks.WALL_SIGN))
{
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.SIGN_EDITOR));
}
else if(BlockHelper.isFocusedBlockEqualTo(Blocks.NOTEBLOCK))
{
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.NOTE_EDITOR));
}
else
{
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.MAIN));
}
}
catch(Exception e)
{
WorldHandler.throwError(e);
}
}
}
}

View File

@@ -0,0 +1,34 @@
package exopandora.worldhandler.event;
import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.config.Config;
import exopandora.worldhandler.helper.ActionHelper;
import exopandora.worldhandler.helper.BlockHelper;
import net.minecraft.client.Minecraft;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
@OnlyIn(Dist.CLIENT)
public class KeyHandler
{
//TODO FORGE switch to KeyInputEvent
public static void keyInputEvent(ClientTickEvent event)
{
if(Minecraft.getInstance().isGameFocused())
{
if(WorldHandler.KEY_WORLD_HANDLER.isPressed())
{
ActionHelper.displayGui();
}
else if(WorldHandler.KEY_WORLD_HANDLER_POS1.isPressed() && Config.getSettings().shortcutKeys())
{
BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
}
else if(WorldHandler.KEY_WORLD_HANDLER_POS2.isPressed() && Config.getSettings().shortcutKeys())
{
BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
}
}
}
}

View File

@@ -2,11 +2,14 @@ package exopandora.worldhandler.format;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
/**
* XXX To be replaced with TextFormatting
*/
@Deprecated @Deprecated
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public enum EnumColor public enum EnumColor
{ {
DEFAULT("reset", "r"), DEFAULT("reset", "r"),
@@ -30,7 +33,7 @@ public enum EnumColor
OBFUSCATED("obfuscated", "k"), OBFUSCATED("obfuscated", "k"),
BOLD("bold", "l"), BOLD("bold", "l"),
STRIKETHROUGH("strikethrough", "m"), STRIKETHROUGH("strikethrough", "m"),
UNDERLINED("underlined", "n"), UNDERLINE("underline", "n"),
ITALIC("italic", "o"); ITALIC("italic", "o");
private String format; private String format;

View File

@@ -2,10 +2,10 @@ package exopandora.worldhandler.format;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class TextFormatting public class TextFormatting
{ {
public static String shortenString(String str, int maxWidth, FontRenderer fontRenderer) public static String shortenString(String str, int maxWidth, FontRenderer fontRenderer)
@@ -88,7 +88,7 @@ public class TextFormatting
return minute; return minute;
} }
public static String getWorldTime(long tick) public static String formatWorldTime(long tick)
{ {
int hour = TextFormatting.getHour(tick); int hour = TextFormatting.getHour(tick);
int minute = TextFormatting.getMinute(tick); int minute = TextFormatting.getMinute(tick);

View File

@@ -3,10 +3,14 @@ package exopandora.worldhandler.format.text;
import com.mojang.realmsclient.gui.ChatFormatting; import com.mojang.realmsclient.gui.ChatFormatting;
import exopandora.worldhandler.format.EnumColor; import exopandora.worldhandler.format.EnumColor;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) /**
* XXX To be replaced with ITextComponent
*/
@Deprecated
@OnlyIn(Dist.CLIENT)
public class ColoredString extends FormattedString public class ColoredString extends FormattedString
{ {
private EnumColor color = EnumColor.DEFAULT; private EnumColor color = EnumColor.DEFAULT;
@@ -92,16 +96,6 @@ public class ColoredString extends FormattedString
return result; return result;
} }
public String getTextFieldString()
{
if(this.text != null)
{
return this.getFormattedString(super.getPreformattedString(this.text));
}
return null;
}
@Override @Override
public String toString() public String toString()
{ {
@@ -124,4 +118,9 @@ public class ColoredString extends FormattedString
return null; return null;
} }
public String textFormatter(String string, Integer integer)
{
return this.getFormattedString(string);
}
} }

View File

@@ -1,9 +1,9 @@
package exopandora.worldhandler.format.text; package exopandora.worldhandler.format.text;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public abstract class FormattedString public abstract class FormattedString
{ {
protected String text; protected String text;

View File

@@ -1,9 +1,9 @@
package exopandora.worldhandler.format.text; package exopandora.worldhandler.format.text;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class JsonClickEvent public class JsonClickEvent
{ {
private String action; private String action;

View File

@@ -1,9 +1,9 @@
package exopandora.worldhandler.format.text; package exopandora.worldhandler.format.text;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class JsonSignLine extends FormattedString public class JsonSignLine extends FormattedString
{ {
private String color; private String color;

View File

@@ -9,10 +9,10 @@ import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer; import com.google.gson.JsonSerializer;
import exopandora.worldhandler.format.EnumColor; import exopandora.worldhandler.format.EnumColor;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class JsonSignLineSerializer implements JsonSerializer<JsonSignLine> public class JsonSignLineSerializer implements JsonSerializer<JsonSignLine>
{ {
@Override @Override

View File

@@ -3,10 +3,10 @@ package exopandora.worldhandler.format.text;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) @OnlyIn(Dist.CLIENT)
public class SignText public class SignText
{ {
private static final Gson GSON = new GsonBuilder().registerTypeAdapter(JsonSignLine.class, new JsonSignLineSerializer()).create(); private static final Gson GSON = new GsonBuilder().registerTypeAdapter(JsonSignLine.class, new JsonSignLineSerializer()).create();

View File

@@ -1,9 +1,13 @@
package exopandora.worldhandler.gui.button; package exopandora.worldhandler.gui.button;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT) /**
* XXX To be replaced by a proper registry object
*/
@Deprecated
@OnlyIn(Dist.CLIENT)
public enum EnumIcon public enum EnumIcon
{ {
WEATHER_SUN(0, 0), WEATHER_SUN(0, 0),

Some files were not shown because too many files have changed in this diff Show More