Update mod for Forge 1.16.5-36.1.0

This commit is contained in:
Stephen Seo 2021-05-21 14:44:31 +09:00
parent 3e6d184971
commit 7f3dfb42e6
28 changed files with 581 additions and 584 deletions

View file

@ -1,11 +1,11 @@
buildscript { buildscript {
repositories { repositories {
maven { url = "http://files.minecraftforge.net/maven" } maven { url = "https://files.minecraftforge.net/maven" }
jcenter() jcenter()
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true
classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4'
} }
} }
@ -14,11 +14,12 @@ apply plugin: 'eclipse'
//apply plugin: 'maven-publish' //apply plugin: 'maven-publish'
apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'com.github.johnrengelman.shadow'
version = "1.16" version = "1.17"
group = "com.burnedkirby.TurnBasedMinecraft" group = "com.burnedkirby.TurnBasedMinecraft"
archivesBaseName = "TurnBasedMinecraft" archivesBaseName = "TurnBasedMinecraft"
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. java.toolchain.languageVersion = JavaLanguageVersion.of(8)
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
minecraft { minecraft {
// The mappings can be changed at any time, and must be in the following format. // The mappings can be changed at any time, and must be in the following format.
@ -26,7 +27,7 @@ minecraft {
// stable_# Stables are built at the discretion of the MCP team. // stable_# Stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work. // Use non-default mappings at your own risk. they may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace. // Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'snapshot', version: '20200514-1.16' mappings channel: 'official', version: '1.16.5'
// 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('src/main/resources/META-INF/accesstransformer.cfg') // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
@ -38,7 +39,7 @@ minecraft {
workingDirectory project.file('run') workingDirectory project.file('run')
// Recommended logging data for a userdev environment // Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' property 'forge.logging.markers', 'REGISTRIES'
// Recommended logging level for the console // Recommended logging level for the console
property 'forge.logging.console.level', 'debug' property 'forge.logging.console.level', 'debug'
@ -54,7 +55,7 @@ minecraft {
workingDirectory project.file('run') workingDirectory project.file('run')
// Recommended logging data for a userdev environment // Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' property 'forge.logging.markers', 'REGISTRIES'
// Recommended logging level for the console // Recommended logging level for the console
property 'forge.logging.console.level', 'debug' property 'forge.logging.console.level', 'debug'
@ -70,12 +71,12 @@ minecraft {
workingDirectory project.file('run') workingDirectory project.file('run')
// Recommended logging data for a userdev environment // Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' property 'forge.logging.markers', 'REGISTRIES'
// Recommended logging level for the console // Recommended logging level for the console
property 'forge.logging.console.level', 'debug' property 'forge.logging.console.level', 'debug'
args '--mod', 'TurnBasedMinecraftMod', '--all', '--output', file('src/generated/resources/') args '--mod', 'TurnBasedMinecraftMod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources')
mods { mods {
TurnBasedMinecraftMod { TurnBasedMinecraftMod {
@ -86,11 +87,14 @@ minecraft {
} }
} }
// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }
dependencies { dependencies {
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied. // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it. // The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft 'net.minecraftforge:forge:1.16.3-34.1.0' minecraft 'net.minecraftforge:forge:1.16.5-36.1.0'
// You may put jars on which you depend on in ./libs or you may define them like so.. // You may put jars on which you depend on in ./libs or you may define them like so..
// compile "some.group:artifact:version:classifier" // compile "some.group:artifact:version:classifier"

Binary file not shown.

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

53
gradlew vendored
View file

@ -1,5 +1,21 @@
#!/usr/bin/env sh #!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
############################################################################## ##############################################################################
## ##
## Gradle start up script for UN*X ## Gradle start up script for UN*X
@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"` 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. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS="" DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD="maximum"
@ -66,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@ -109,10 +126,11 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi fi
# For Cygwin, switch paths to Windows format before running java # For Cygwin or MSYS, switch paths to Windows format before running java
if $cygwin ; then if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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"` 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
@ -138,19 +156,19 @@ if $cygwin ; then
else else
eval `echo args$i`="\"$arg\"" eval `echo args$i`="\"$arg\""
fi fi
i=$((i+1)) i=`expr $i + 1`
done done
case $i in case $i in
(0) set -- ;; 0) set -- ;;
(1) set -- "$args0" ;; 1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;; 2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;; 3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;; 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac esac
fi fi
@ -159,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " " echo " "
} }
APP_ARGS=$(save "$@") APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules # 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" 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" "$@" exec "$JAVACMD" "$@"

43
gradlew.bat vendored
View file

@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off @if "%DEBUG%" == "" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. @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 DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe @rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init if "%ERRORLEVEL%" == "0" goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -35,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=% set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init if exist "%JAVA_EXE%" goto execute
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@ -45,28 +64,14 @@ echo location of your Java installation.
goto fail goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute :execute
@rem Setup the command line @rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell

View file

@ -126,26 +126,21 @@ public class BattleGui extends Screen {
} }
stateChanged = false; stateChanged = false;
// field_230705_e_ is probably a list of buttons buttons.clear();
field_230705_e_.clear(); children.clear();
// field_230710_m_ is probably a list of gui elements
field_230710_m_.clear();
switch (state) { switch (state) {
case MAIN_MENU: case MAIN_MENU:
info = "What will you do?"; info = "What will you do?";
// func_230480_a_ is probably addButton addButton(new Button(width * 3 / 7 - 25, 40, 50, 20, new StringTextComponent("Attack"), (button) -> {
// field_230708_k_ is probably width
// field_230709_l_ is probably height
func_230480_a_(new Button(field_230708_k_ * 3 / 7 - 25, 40, 50, 20, new StringTextComponent("Attack"), (button) -> {
buttonActionEvent(button, ButtonAction.ATTACK); buttonActionEvent(button, ButtonAction.ATTACK);
})); }));
func_230480_a_(new Button(field_230708_k_ * 4 / 7 - 25, 40, 50, 20, new StringTextComponent("Defend"), (button) -> { addButton(new Button(width * 4 / 7 - 25, 40, 50, 20, new StringTextComponent("Defend"), (button) -> {
buttonActionEvent(button, ButtonAction.DEFEND); buttonActionEvent(button, ButtonAction.DEFEND);
})); }));
func_230480_a_(new Button(field_230708_k_ * 3 / 7 - 25, 60, 50, 20, new StringTextComponent("Item"), (button) -> { addButton(new Button(width * 3 / 7 - 25, 60, 50, 20, new StringTextComponent("Item"), (button) -> {
buttonActionEvent(button, ButtonAction.ITEM); buttonActionEvent(button, ButtonAction.ITEM);
})); }));
func_230480_a_(new Button(field_230708_k_ * 4 / 7 - 25, 60, 50, 20, new StringTextComponent("Flee"), (button) -> { addButton(new Button(width * 4 / 7 - 25, 60, 50, 20, new StringTextComponent("Flee"), (button) -> {
buttonActionEvent(button, ButtonAction.FLEE); buttonActionEvent(button, ButtonAction.FLEE);
})); }));
break; break;
@ -156,11 +151,11 @@ public class BattleGui extends Screen {
for (Map.Entry<Integer, Combatant> e : TurnBasedMinecraftMod.proxy.getLocalBattle() for (Map.Entry<Integer, Combatant> e : TurnBasedMinecraftMod.proxy.getLocalBattle()
.getSideAEntrySet()) { .getSideAEntrySet()) {
if (e.getValue().entity != null) { if (e.getValue().entity != null) {
func_230480_a_(new EntitySelectionButton(field_230708_k_ / 4 - 60, y, 120, 20, e.getValue().entity.getName().getString(), e.getKey(), true, (button) -> { addButton(new EntitySelectionButton(width / 4 - 60, y, 120, 20, e.getValue().entity.getName().getString(), e.getKey(), true, (button) -> {
buttonActionEvent(button, ButtonAction.ATTACK_TARGET); buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
})); }));
} else { } else {
func_230480_a_(new EntitySelectionButton(field_230708_k_ / 4 - 60, y, 120, 20, "Unknown", e.getKey(), true, (button) -> { addButton(new EntitySelectionButton(width / 4 - 60, y, 120, 20, "Unknown", e.getKey(), true, (button) -> {
buttonActionEvent(button, ButtonAction.ATTACK_TARGET); buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
})); }));
} }
@ -174,11 +169,11 @@ public class BattleGui extends Screen {
for (Map.Entry<Integer, Combatant> e : TurnBasedMinecraftMod.proxy.getLocalBattle() for (Map.Entry<Integer, Combatant> e : TurnBasedMinecraftMod.proxy.getLocalBattle()
.getSideBEntrySet()) { .getSideBEntrySet()) {
if (e.getValue().entity != null) { if (e.getValue().entity != null) {
func_230480_a_(new EntitySelectionButton(field_230708_k_ * 3 / 4 - 60, y, 120, 20, e.getValue().entity.getName().getString(), e.getKey(), false, (button) -> { addButton(new EntitySelectionButton(width * 3 / 4 - 60, y, 120, 20, e.getValue().entity.getName().getString(), e.getKey(), false, (button) -> {
buttonActionEvent(button, ButtonAction.ATTACK_TARGET); buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
})); }));
} else { } else {
func_230480_a_(new EntitySelectionButton(field_230708_k_ * 3 / 4 - 60, y, 120, 20, "Unknown", e.getKey(), false, (button) -> { addButton(new EntitySelectionButton(width * 3 / 4 - 60, y, 120, 20, "Unknown", e.getKey(), false, (button) -> {
buttonActionEvent(button, ButtonAction.ATTACK_TARGET); buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
})); }));
} }
@ -187,19 +182,19 @@ public class BattleGui extends Screen {
} catch (ConcurrentModificationException e) { } catch (ConcurrentModificationException e) {
// ignored // ignored
} }
func_230480_a_(new Button(field_230708_k_ / 2 - 30, field_230709_l_ - 120, 60, 20, new StringTextComponent("Cancel"), (button) -> { addButton(new Button(width / 2 - 30, height - 120, 60, 20, new StringTextComponent("Cancel"), (button) -> {
buttonActionEvent(button, ButtonAction.CANCEL); buttonActionEvent(button, ButtonAction.CANCEL);
})); }));
break; break;
case ITEM_ACTION: case ITEM_ACTION:
info = "What will you do with an item?"; info = "What will you do with an item?";
func_230480_a_(new Button(field_230708_k_ * 1 / 4 - 40, field_230709_l_ - 120, 80, 20, new StringTextComponent("Switch Held"), (button) -> { addButton(new Button(width * 1 / 4 - 40, height - 120, 80, 20, new StringTextComponent("Switch Held"), (button) -> {
buttonActionEvent(button, ButtonAction.SWITCH_HELD_ITEM); buttonActionEvent(button, ButtonAction.SWITCH_HELD_ITEM);
})); }));
func_230480_a_(new Button(field_230708_k_ * 2 / 4 - 40, field_230709_l_ - 120, 80, 20, new StringTextComponent("Use"), (button) -> { addButton(new Button(width * 2 / 4 - 40, height - 120, 80, 20, new StringTextComponent("Use"), (button) -> {
buttonActionEvent(button, ButtonAction.DECIDE_USE_ITEM); buttonActionEvent(button, ButtonAction.DECIDE_USE_ITEM);
})); }));
func_230480_a_(new Button(field_230708_k_ * 3 / 4 - 40, field_230709_l_ - 120, 80, 20, new StringTextComponent("Cancel"), (button) -> { addButton(new Button(width * 3 / 4 - 40, height - 120, 80, 20, new StringTextComponent("Cancel"), (button) -> {
buttonActionEvent(button, ButtonAction.CANCEL); buttonActionEvent(button, ButtonAction.CANCEL);
})); }));
break; break;
@ -209,22 +204,22 @@ public class BattleGui extends Screen {
case SWITCH_ITEM: case SWITCH_ITEM:
info = "To which item will you switch to?"; info = "To which item will you switch to?";
for (int i = 0; i < 9; ++i) { for (int i = 0; i < 9; ++i) {
func_230480_a_(new ItemSelectionButton(field_230708_k_ / 2 - 88 + i * 20, field_230709_l_ - 19, 16, 16, "", i, (button) -> { addButton(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, "", i, (button) -> {
buttonActionEvent(button, ButtonAction.DO_ITEM_SWITCH); buttonActionEvent(button, ButtonAction.DO_ITEM_SWITCH);
})); }));
} }
func_230480_a_(new Button(field_230708_k_ / 2 - 40, field_230709_l_ - 120, 80, 20, new StringTextComponent("Cancel"), (button) -> { addButton(new Button(width / 2 - 40, height - 120, 80, 20, new StringTextComponent("Cancel"), (button) -> {
buttonActionEvent(button, ButtonAction.CANCEL); buttonActionEvent(button, ButtonAction.CANCEL);
})); }));
break; break;
case USE_ITEM: case USE_ITEM:
info = "Which item will you use?"; info = "Which item will you use?";
for (int i = 0; i < 9; ++i) { for (int i = 0; i < 9; ++i) {
func_230480_a_(new ItemSelectionButton(field_230708_k_ / 2 - 88 + i * 20, field_230709_l_ - 19, 16, 16, "", i, (button) -> { addButton(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, "", i, (button) -> {
buttonActionEvent(button, ButtonAction.DO_USE_ITEM); buttonActionEvent(button, ButtonAction.DO_USE_ITEM);
})); }));
} }
func_230480_a_(new Button(field_230708_k_ / 2 - 40, field_230709_l_ - 120, 80, 20, new StringTextComponent("Cancel"), (button) -> { addButton(new Button(width / 2 - 40, height - 120, 80, 20, new StringTextComponent("Cancel"), (button) -> {
buttonActionEvent(button, ButtonAction.CANCEL); buttonActionEvent(button, ButtonAction.CANCEL);
})); }));
break; break;
@ -232,10 +227,10 @@ public class BattleGui extends Screen {
} }
@Override @Override
public void func_230430_a_(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
if (TurnBasedMinecraftMod.proxy.getLocalBattle() == null) { if (TurnBasedMinecraftMod.proxy.getLocalBattle() == null) {
// drawHoveringText("Waiting...", field_230708_k_ / 2 - 50, field_230709_l_ / 2); // drawHoveringText("Waiting...", width / 2 - 50, height / 2);
drawString(matrixStack, "Waiting...", field_230708_k_ / 2 - 50, field_230709_l_ / 2, 0xFFFFFFFF); drawString(matrixStack, "Waiting...", width / 2 - 50, height / 2, 0xFFFFFFFF);
return; return;
} }
if (TurnBasedMinecraftMod.proxy.getLocalBattle().getState() == Battle.State.DECISION if (TurnBasedMinecraftMod.proxy.getLocalBattle().getState() == Battle.State.DECISION
@ -251,7 +246,7 @@ public class BattleGui extends Screen {
updateState(); updateState();
super.func_230430_a_(matrixStack, mouseX, mouseY, partialTicks); super.render(matrixStack, mouseX, mouseY, partialTicks);
String timeRemainingString = "Time remaining: "; String timeRemainingString = "Time remaining: ";
int timeRemainingInt = timeRemaining.get(); int timeRemainingInt = timeRemaining.get();
@ -263,13 +258,12 @@ public class BattleGui extends Screen {
timeRemainingString += "\u00A7c"; timeRemainingString += "\u00A7c";
} }
timeRemainingString += Integer.toString(timeRemainingInt); timeRemainingString += Integer.toString(timeRemainingInt);
int stringWidth = field_230712_o_.getStringWidth(timeRemainingString); int stringWidth = font.width(timeRemainingString);
// func_238467_a_ is probably fill fill(matrixStack, width / 2 - stringWidth / 2, 5, width / 2 + stringWidth / 2, 15, 0x70000000);
func_238467_a_(matrixStack, field_230708_k_ / 2 - stringWidth / 2, 5, field_230708_k_ / 2 + stringWidth / 2, 15, 0x70000000); drawString(matrixStack, timeRemainingString, width / 2 - stringWidth / 2, 5, 0xFFFFFFFF);
drawString(matrixStack, timeRemainingString, field_230708_k_ / 2 - stringWidth / 2, 5, 0xFFFFFFFF); stringWidth = font.width(info);
stringWidth = field_230712_o_.getStringWidth(info); fill(matrixStack, width / 2 - stringWidth / 2, 20, width / 2 + stringWidth / 2, 30, 0x70000000);
func_238467_a_(matrixStack, field_230708_k_ / 2 - stringWidth / 2, 20, field_230708_k_ / 2 + stringWidth / 2, 30, 0x70000000); drawString(matrixStack, info, width / 2 - stringWidth / 2, 20, 0xFFFFFFFF);
drawString(matrixStack, info, field_230708_k_ / 2 - stringWidth / 2, 20, 0xFFFFFFFF);
} }
protected void buttonActionEvent(Button button, ButtonAction action) { protected void buttonActionEvent(Button button, ButtonAction action) {
@ -315,7 +309,7 @@ public class BattleGui extends Screen {
.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), .sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(),
Battle.Decision.SWITCH_ITEM, ((ItemSelectionButton) button).getID())); Battle.Decision.SWITCH_ITEM, ((ItemSelectionButton) button).getID()));
if (((ItemSelectionButton) button).getID() >= 0 && ((ItemSelectionButton) button).getID() < 9) { if (((ItemSelectionButton) button).getID() >= 0 && ((ItemSelectionButton) button).getID() < 9) {
Minecraft.getInstance().player.inventory.currentItem = ((ItemSelectionButton) button).getID(); Minecraft.getInstance().player.inventory.selected = ((ItemSelectionButton) button).getID();
} }
setState(MenuState.WAITING); setState(MenuState.WAITING);
} else { } else {
@ -335,21 +329,23 @@ public class BattleGui extends Screen {
} }
} }
// @Override
// protected void init() {
// }
// func_231177_au__ is probably isPauseScreen
@Override @Override
public boolean func_231177_au__() { public boolean isPauseScreen() {
return false; return false;
} }
// func_231046_a_ is probably keyPressed
@Override @Override
public boolean func_231046_a_(int a, int b, int c) { public boolean keyPressed(int a, int b, int c) {
if (getMinecraft().player.isCreative()) { if (getMinecraft().player.isCreative()) {
return super.func_231046_a_(a, b, c); return super.keyPressed(a, b, c);
}
return false; // TODO verify return value
}
@Override
public boolean keyReleased(int a, int b, int c) {
if (getMinecraft().player.isCreative()) {
return super.keyReleased(a, b, c);
} }
return false; // TODO verify return value return false; // TODO verify return value
} }
@ -359,6 +355,6 @@ public class BattleGui extends Screen {
} }
private void drawString(MatrixStack matrixStack, String string, int x, int y, int color) { private void drawString(MatrixStack matrixStack, String string, int x, int y, int color) {
field_230712_o_.func_238405_a_(matrixStack, string, x, y, color); font.draw(matrixStack, string, x, y, color);
} }
} }

View file

@ -180,7 +180,7 @@ public class BattleMusic
if(initialized && next != null) if(initialized && next != null)
{ {
logger.debug("play called with file " + next.getName() + " and vol " + volume); logger.debug("play called with file " + next.getName() + " and vol " + volume);
Minecraft.getInstance().getSoundHandler().pause(); Minecraft.getInstance().getSoundManager().pause();
String suffix = next.getName().substring(next.getName().length() - 3).toLowerCase(); String suffix = next.getName().substring(next.getName().length() - 3).toLowerCase();
if(suffix.equals("mid") && sequencer != null) if(suffix.equals("mid") && sequencer != null)
{ {
@ -325,7 +325,7 @@ public class BattleMusic
} }
if(resumeMCSounds) if(resumeMCSounds)
{ {
Minecraft.getInstance().getSoundHandler().resume(); Minecraft.getInstance().getSoundManager().resume();
} }
isPlaying = false; isPlaying = false;
} }

View file

@ -49,10 +49,10 @@ public class ClientProxy extends CommonProxy
@Override @Override
public void setBattleGuiAsGui() public void setBattleGuiAsGui()
{ {
if(Minecraft.getInstance().currentScreen != battleGui) if(Minecraft.getInstance().screen != battleGui)
{ {
battleGui.turnEnd(); battleGui.turnEnd();
Minecraft.getInstance().displayGuiScreen(battleGui); Minecraft.getInstance().setScreen(battleGui);
} }
} }
@ -78,7 +78,7 @@ public class ClientProxy extends CommonProxy
public void battleEnded() public void battleEnded()
{ {
localBattle = null; localBattle = null;
Minecraft.getInstance().displayGuiScreen(null); Minecraft.getInstance().setScreen(null);
stopMusic(true); stopMusic(true);
battleMusicCount = 0; battleMusicCount = 0;
sillyMusicCount = 0; sillyMusicCount = 0;
@ -93,15 +93,15 @@ public class ClientProxy extends CommonProxy
@Override @Override
public void playBattleMusic() public void playBattleMusic()
{ {
GameSettings gs = Minecraft.getInstance().gameSettings; GameSettings gs = Minecraft.getInstance().options;
battleMusic.playBattle(gs.getSoundLevel(SoundCategory.MUSIC) * gs.getSoundLevel(SoundCategory.MASTER)); battleMusic.playBattle(gs.getSoundSourceVolume(SoundCategory.MUSIC) * gs.getSoundSourceVolume(SoundCategory.MASTER));
} }
@Override @Override
public void playSillyMusic() public void playSillyMusic()
{ {
GameSettings gs = Minecraft.getInstance().gameSettings; GameSettings gs = Minecraft.getInstance().options;
battleMusic.playSilly(gs.getSoundLevel(SoundCategory.MUSIC) * gs.getSoundLevel(SoundCategory.MASTER)); battleMusic.playSilly(gs.getSoundSourceVolume(SoundCategory.MUSIC) * gs.getSoundSourceVolume(SoundCategory.MASTER));
} }
@Override @Override
@ -163,10 +163,10 @@ public class ClientProxy extends CommonProxy
StringTextComponent prefix = new StringTextComponent("TBM: "); StringTextComponent prefix = new StringTextComponent("TBM: ");
// func_240718_a_ is set color // func_240718_a_ is set color
// func_240713_a_ is set bold // func_240713_a_ is set bold
prefix.func_230530_a_(prefix.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240713_a_(true)); prefix.withStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
StringTextComponent text = new StringTextComponent(message); StringTextComponent text = new StringTextComponent(message);
prefix.getSiblings().add(text); prefix.getSiblings().add(text);
text.func_230530_a_(text.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF)).func_240713_a_(false)); text.withStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
// UUID is required by sendMessage, but appears to be unused, so just give dummy UUID // UUID is required by sendMessage, but appears to be unused, so just give dummy UUID
Minecraft.getInstance().player.sendMessage(prefix, UUID.randomUUID()); Minecraft.getInstance().player.sendMessage(prefix, UUID.randomUUID());
} }
@ -235,11 +235,11 @@ public class ClientProxy extends CommonProxy
@Override @Override
public void createLocalBattle(int id) public void createLocalBattle(int id)
{ {
localBattle = new Battle(null, id, null, null, false, Minecraft.getInstance().world.func_234923_W_()); localBattle = new Battle(null, id, null, null, false, Minecraft.getInstance().level.dimension());
} }
@Override @Override
public Entity getEntity(int id, RegistryKey<World> dim) { public Entity getEntity(int id, RegistryKey<World> dim) {
return Minecraft.getInstance().world.getEntityByID(id); return Minecraft.getInstance().level.getEntity(id);
} }
} }

View file

@ -26,9 +26,9 @@ public class EntitySelectionButton extends Button {
} }
@Override @Override
public void func_230430_a_(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { public void renderButton(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
super.func_230430_a_(matrixStack, mouseX, mouseY, partialTicks); super.renderButton(matrixStack, mouseX, mouseY, partialTicks);
Entity e = Minecraft.getInstance().world.getEntityByID(entityID); Entity e = Minecraft.getInstance().level.getEntity(entityID);
if (e != null && e instanceof LivingEntity && ((LivingEntity) e).isAlive()) { if (e != null && e instanceof LivingEntity && ((LivingEntity) e).isAlive()) {
int health = (int) (((LivingEntity) e).getHealth() + 0.5f); int health = (int) (((LivingEntity) e).getHealth() + 0.5f);
int xpos = getX(); int xpos = getX();
@ -78,22 +78,10 @@ public class EntitySelectionButton extends Button {
} }
private int getX() { private int getX() {
return field_230690_l_; return x;
} }
private int getY() { private int getY() {
return field_230691_m_; return y;
}
private int getWidth() {
return field_230688_j_;
}
private int getHeight() {
return field_230689_k_;
}
private void fill(MatrixStack matrixStack, int x, int y, int width, int height, int color) {
func_238467_a_(matrixStack, x, y, width, height, color);
} }
} }

View file

@ -17,9 +17,8 @@ public class ItemSelectionButton extends Button {
} }
@Override @Override
public void func_230430_a_(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { public void renderButton(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
// field_230694_p_ is probably isVisible if (visible) {
if (field_230694_p_) {
boolean hovered = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + getWidth() && mouseY < getY() + getHeight(); boolean hovered = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + getWidth() && mouseY < getY() + getHeight();
if (hovered) { if (hovered) {
fill(matrixStack, getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x80FFFFFF); fill(matrixStack, getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x80FFFFFF);
@ -30,23 +29,10 @@ public class ItemSelectionButton extends Button {
} }
private int getX() { private int getX() {
return field_230690_l_; return x;
} }
private int getY() { private int getY() {
return field_230691_m_; return y;
}
private int getWidth() {
return field_230688_j_;
}
private int getHeight() {
return field_230689_k_;
}
private void fill(MatrixStack matrixStack, int x, int y, int width, int height, int color) {
func_238467_a_(matrixStack, x, y, width, height, color);
} }
} }

View file

@ -17,11 +17,11 @@ public class AttackEventHandler
{ {
private boolean isAttackerValid(LivingAttackEvent event) private boolean isAttackerValid(LivingAttackEvent event)
{ {
if(event.getSource().getTrueSource() == null) if(event.getSource().getEntity() == null)
{ {
return false; return false;
} }
else if(event.getSource().getTrueSource().equals(TurnBasedMinecraftMod.proxy.getAttackingEntity())) else if(event.getSource().getEntity().equals(TurnBasedMinecraftMod.proxy.getAttackingEntity()))
{ {
return true; return true;
} }
@ -38,7 +38,7 @@ public class AttackEventHandler
{ {
iter.remove(); iter.remove();
} }
else if(event.getSource().getTrueSource().equals(attacker.entity) && event.getSource().isProjectile()) else if(event.getSource().getEntity().equals(attacker.entity) && event.getSource().isProjectile())
{ {
iter.remove(); iter.remove();
if(!isValid) if(!isValid)
@ -46,7 +46,7 @@ public class AttackEventHandler
Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(attacker.battleID); Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(attacker.battleID);
if(b != null) if(b != null)
{ {
b.sendMessageToAllPlayers(PacketBattleMessage.MessageType.ARROW_HIT, attacker.entity.getEntityId(), event.getEntity().getEntityId(), 0); b.sendMessageToAllPlayers(PacketBattleMessage.MessageType.ARROW_HIT, attacker.entity.getId(), event.getEntity().getId(), 0);
} }
isValid = true; isValid = true;
} }
@ -60,7 +60,7 @@ public class AttackEventHandler
@SubscribeEvent @SubscribeEvent
public void entityAttacked(LivingAttackEvent event) public void entityAttacked(LivingAttackEvent event)
{ {
if(event.getEntity().world.isRemote) if(event.getEntity().level.isClientSide)
{ {
return; return;
} }
@ -69,9 +69,9 @@ public class AttackEventHandler
BattleManager battleManager = proxy.getBattleManager(); BattleManager battleManager = proxy.getBattleManager();
// handle edit entity, pick entity via attack // handle edit entity, pick entity via attack
{ {
if(event.getSource().getTrueSource() != null && event.getEntity() != null) if(event.getSource().getEntity() != null && event.getEntity() != null)
{ {
final EditingInfo editingInfo = proxy.getEditingInfo(event.getSource().getTrueSource().getEntityId()); final EditingInfo editingInfo = proxy.getEditingInfo(event.getSource().getEntity().getId());
if(editingInfo != null && editingInfo.isPendingEntitySelection) if(editingInfo != null && editingInfo.isPendingEntitySelection)
{ {
editingInfo.isPendingEntitySelection = false; editingInfo.isPendingEntitySelection = false;
@ -84,13 +84,13 @@ public class AttackEventHandler
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity)editingInfo.editor), new PacketGeneralMessage("Cannot edit custom name from entity without custom name")); TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity)editingInfo.editor), new PacketGeneralMessage("Cannot edit custom name from entity without custom name"));
return; return;
} }
editingInfo.entityInfo = config.getCustomEntityInfo(event.getEntity().getCustomName().getUnformattedComponentText()); editingInfo.entityInfo = config.getCustomEntityInfo(event.getEntity().getCustomName().getString());
if(editingInfo.entityInfo == null) if(editingInfo.entityInfo == null)
{ {
editingInfo.entityInfo = new EntityInfo(); editingInfo.entityInfo = new EntityInfo();
editingInfo.entityInfo.customName = event.getEntity().getCustomName().getString(); editingInfo.entityInfo.customName = event.getEntity().getCustomName().getString();
} }
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity)editingInfo.editor), new PacketGeneralMessage("Editing custom name \"" + event.getEntity().getCustomName().getUnformattedComponentText() + "\"")); TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity)editingInfo.editor), new PacketGeneralMessage("Editing custom name \"" + event.getEntity().getCustomName().getString() + "\""));
TurnBasedMinecraftMod.logger.info("Begin editing custom \"" + event.getEntity().getCustomName().getString() + "\""); TurnBasedMinecraftMod.logger.info("Begin editing custom \"" + event.getEntity().getCustomName().getString() + "\"");
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity)editingInfo.editor), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo)); TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity)editingInfo.editor), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} }
@ -114,9 +114,9 @@ public class AttackEventHandler
} }
} }
} }
if(event.getEntity() != null && event.getSource().getTrueSource() != null && (battleManager.isRecentlyLeftBattle(event.getEntity().getEntityId()) || battleManager.isRecentlyLeftBattle(event.getSource().getTrueSource().getEntityId()))) if(event.getEntity() != null && event.getSource().getEntity() != null && (battleManager.isRecentlyLeftBattle(event.getEntity().getId()) || battleManager.isRecentlyLeftBattle(event.getSource().getEntity().getId())))
{ {
if(event.getSource().getTrueSource().getEntity() instanceof CreeperEntity && TurnBasedMinecraftMod.proxy.getConfig().getCreeperAlwaysAllowDamage()) { if(event.getSource().getEntity().getEntity() instanceof CreeperEntity && TurnBasedMinecraftMod.proxy.getConfig().getCreeperAlwaysAllowDamage()) {
event.setCanceled(false); event.setCanceled(false);
} else { } else {
// TurnBasedMinecraftMod.logger.debug("Canceled attack"); // TurnBasedMinecraftMod.logger.debug("Canceled attack");
@ -126,11 +126,11 @@ public class AttackEventHandler
} }
else if(!isAttackerValid(event) else if(!isAttackerValid(event)
&& event.getEntity() != null && event.getEntity() != null
&& event.getSource().getTrueSource() != null && event.getSource().getEntity() != null
&& event.getEntity() != event.getSource().getTrueSource() && event.getEntity() != event.getSource().getEntity()
&& !config.getBattleIgnoringPlayers().contains(event.getSource().getTrueSource().getEntityId()) && !config.getBattleIgnoringPlayers().contains(event.getSource().getEntity().getId())
&& !config.getBattleIgnoringPlayers().contains(event.getEntity().getEntityId()) && !config.getBattleIgnoringPlayers().contains(event.getEntity().getId())
&& event.getEntity().getEntityWorld().func_234923_W_().equals(event.getSource().getTrueSource().getEntityWorld().func_234923_W_()) && event.getEntity().level.dimension().equals(event.getSource().getEntity().level.dimension())
&& battleManager.checkAttack(event)) && battleManager.checkAttack(event))
{ {
// TurnBasedMinecraftMod.logger.debug("Canceled LivingAttackEvent between " + TurnBasedMinecraftMod.proxy.getAttackingEntity() + " and " + event.getEntity()); // TurnBasedMinecraftMod.logger.debug("Canceled LivingAttackEvent between " + TurnBasedMinecraftMod.proxy.getAttackingEntity() + " and " + event.getEntity());
@ -150,19 +150,19 @@ public class AttackEventHandler
{ {
Config config = TurnBasedMinecraftMod.proxy.getConfig(); Config config = TurnBasedMinecraftMod.proxy.getConfig();
BattleManager battleManager = TurnBasedMinecraftMod.proxy.getBattleManager(); BattleManager battleManager = TurnBasedMinecraftMod.proxy.getBattleManager();
if(event.getEntity().world.isRemote if(event.getEntity().level.isClientSide
|| config.isOldBattleBehaviorEnabled() || config.isOldBattleBehaviorEnabled()
|| (event.getEntity() != null && battleManager.isRecentlyLeftBattle(event.getEntity().getEntityId())) || (event.getEntity() != null && battleManager.isRecentlyLeftBattle(event.getEntity().getId()))
|| (event.getTarget() != null && battleManager.isRecentlyLeftBattle(event.getTarget().getEntityId())) || (event.getTarget() != null && battleManager.isRecentlyLeftBattle(event.getTarget().getId()))
|| (event.getEntity() != null && event.getTarget() != null && Utility.distanceBetweenEntities(event.getEntity(), event.getTarget()) > (double)config.getAggroStartBattleDistance())) || (event.getEntity() != null && event.getTarget() != null && Utility.distanceBetweenEntities(event.getEntity(), event.getTarget()) > (double)config.getAggroStartBattleDistance()))
{ {
return; return;
} }
else if(event.getEntity() != null else if(event.getEntity() != null
&& event.getTarget() != null && event.getTarget() != null
&& !config.getBattleIgnoringPlayers().contains(event.getEntity().getEntityId()) && !config.getBattleIgnoringPlayers().contains(event.getEntity().getId())
&& !config.getBattleIgnoringPlayers().contains(event.getTarget().getEntityId()) && !config.getBattleIgnoringPlayers().contains(event.getTarget().getId())
&& event.getEntity().getEntityWorld().func_234923_W_().equals(event.getTarget().getEntityWorld().func_234923_W_())) && event.getEntity().level.dimension().equals(event.getTarget().level.dimension()))
{ {
TurnBasedMinecraftMod.proxy.getBattleManager().checkTargeted(event); TurnBasedMinecraftMod.proxy.getBattleManager().checkTargeted(event);
} }

View file

@ -138,7 +138,7 @@ public class Battle
{ {
EntityInfo entityInfo; EntityInfo entityInfo;
try { try {
entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getCustomEntityInfoReference(e.getCustomName().getUnformattedComponentText()); entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getCustomEntityInfoReference(e.getCustomName().getString());
} catch(NullPointerException exception) { } catch(NullPointerException exception) {
entityInfo = null; entityInfo = null;
} }
@ -154,19 +154,19 @@ public class Battle
Combatant newCombatant = new Combatant(e, entityInfo); Combatant newCombatant = new Combatant(e, entityInfo);
newCombatant.isSideA = true; newCombatant.isSideA = true;
newCombatant.battleID = getId(); newCombatant.battleID = getId();
this.sideA.put(e.getEntityId(), newCombatant); this.sideA.put(e.getId(), newCombatant);
if(e instanceof PlayerEntity) if(e instanceof PlayerEntity)
{ {
newCombatant.recalcSpeedOnCompare = true; newCombatant.recalcSpeedOnCompare = true;
playerCount.incrementAndGet(); playerCount.incrementAndGet();
players.put(e.getEntityId(), newCombatant); players.put(e.getId(), newCombatant);
} }
if(TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled()) if(TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled())
{ {
newCombatant.x = e.getPosX(); newCombatant.x = e.getX();
newCombatant.z = e.getPosZ(); newCombatant.z = e.getZ();
newCombatant.yaw = e.rotationYaw; newCombatant.yaw = e.xRot;
newCombatant.pitch = e.rotationPitch; newCombatant.pitch = e.yRot;
} }
} }
} }
@ -176,7 +176,7 @@ public class Battle
{ {
EntityInfo entityInfo; EntityInfo entityInfo;
try { try {
entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getCustomEntityInfoReference(e.getCustomName().getUnformattedComponentText()); entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getCustomEntityInfoReference(e.getCustomName().getString());
} catch(NullPointerException exception) { } catch(NullPointerException exception) {
entityInfo = null; entityInfo = null;
} }
@ -192,19 +192,19 @@ public class Battle
Combatant newCombatant = new Combatant(e, entityInfo); Combatant newCombatant = new Combatant(e, entityInfo);
newCombatant.isSideA = false; newCombatant.isSideA = false;
newCombatant.battleID = getId(); newCombatant.battleID = getId();
this.sideB.put(e.getEntityId(), newCombatant); this.sideB.put(e.getId(), newCombatant);
if(e instanceof PlayerEntity) if(e instanceof PlayerEntity)
{ {
newCombatant.recalcSpeedOnCompare = true; newCombatant.recalcSpeedOnCompare = true;
playerCount.incrementAndGet(); playerCount.incrementAndGet();
players.put(e.getEntityId(), newCombatant); players.put(e.getId(), newCombatant);
} }
if(TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled()) if(TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled())
{ {
newCombatant.x = e.getPosX(); newCombatant.x = e.getX();
newCombatant.z = e.getPosZ(); newCombatant.z = e.getZ();
newCombatant.yaw = e.rotationYaw; newCombatant.yaw = e.xRot;
newCombatant.pitch = e.rotationPitch; newCombatant.pitch = e.yRot;
} }
} }
} }
@ -215,30 +215,30 @@ public class Battle
{ {
if(c.entityInfo != null) if(c.entityInfo != null)
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getEntityId(), 0, id, c.entityInfo.category); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getId(), 0, id, c.entityInfo.category);
} }
else if(c.entity instanceof PlayerEntity) else if(c.entity instanceof PlayerEntity)
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getEntityId(), 0, id, "player"); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getId(), 0, id, "player");
} }
else else
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getEntityId(), 0, id); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getId(), 0, id);
} }
} }
for(Combatant c : this.sideB.values()) for(Combatant c : this.sideB.values())
{ {
if(c.entityInfo != null) if(c.entityInfo != null)
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getEntityId(), 0, id, c.entityInfo.category); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getId(), 0, id, c.entityInfo.category);
} }
else if(c.entity instanceof PlayerEntity) else if(c.entity instanceof PlayerEntity)
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getEntityId(), 0, id, "player"); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getId(), 0, id, "player");
} }
else else
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getEntityId(), 0, id); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getId(), 0, id);
} }
} }
} }
@ -276,14 +276,14 @@ public class Battle
{ {
for(Combatant c : sideAEntryQueue) for(Combatant c : sideAEntryQueue)
{ {
if(c.entity.getEntityId() == entityID) if(c.entity.getId() == entityID)
{ {
return true; return true;
} }
} }
for(Combatant c : sideBEntryQueue) for(Combatant c : sideBEntryQueue)
{ {
if(c.entity.getEntityId() == entityID) if(c.entity.getId() == entityID)
{ {
return true; return true;
} }
@ -295,7 +295,7 @@ public class Battle
{ {
for(Combatant c : sideAEntryQueue) for(Combatant c : sideAEntryQueue)
{ {
if(c.entity.getEntityId() == entityID) if(c.entity.getId() == entityID)
{ {
return true; return true;
} }
@ -307,7 +307,7 @@ public class Battle
{ {
EntityInfo entityInfo; EntityInfo entityInfo;
try { try {
entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getCustomEntityInfoReference(e.getCustomName().getUnformattedComponentText()); entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getCustomEntityInfoReference(e.getCustomName().getString());
} catch(NullPointerException exception) { } catch(NullPointerException exception) {
entityInfo = null; entityInfo = null;
} }
@ -329,13 +329,13 @@ public class Battle
} }
else else
{ {
sideA.put(e.getEntityId(), newCombatant); sideA.put(e.getId(), newCombatant);
} }
if(e instanceof PlayerEntity) if(e instanceof PlayerEntity)
{ {
newCombatant.recalcSpeedOnCompare = true; newCombatant.recalcSpeedOnCompare = true;
playerCount.incrementAndGet(); playerCount.incrementAndGet();
players.put(e.getEntityId(), newCombatant); players.put(e.getId(), newCombatant);
if(state == State.DECISION) if(state == State.DECISION)
{ {
undecidedCount.incrementAndGet(); undecidedCount.incrementAndGet();
@ -343,24 +343,24 @@ public class Battle
} }
if(TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled()) if(TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled())
{ {
newCombatant.x = e.getPosX(); newCombatant.x = e.getX();
newCombatant.z = e.getPosZ(); newCombatant.z = e.getZ();
newCombatant.yaw = e.rotationYaw; newCombatant.yaw = e.xRot;
newCombatant.pitch = e.rotationPitch; newCombatant.pitch = e.yRot;
} }
if(isServer) if(isServer)
{ {
if(newCombatant.entityInfo != null) if(newCombatant.entityInfo != null)
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getEntityId(), 0, id, newCombatant.entityInfo.category); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getId(), 0, id, newCombatant.entityInfo.category);
} }
else if(newCombatant.entity instanceof PlayerEntity) else if(newCombatant.entity instanceof PlayerEntity)
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getEntityId(), 0, id, "player"); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getId(), 0, id, "player");
} }
else else
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getEntityId(), 0, id); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getId(), 0, id);
} }
} }
notifyPlayersBattleInfo(); notifyPlayersBattleInfo();
@ -370,7 +370,7 @@ public class Battle
{ {
EntityInfo entityInfo; EntityInfo entityInfo;
try { try {
entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getCustomEntityInfoReference(e.getCustomName().getUnformattedComponentText()); entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getCustomEntityInfoReference(e.getCustomName().getString());
} catch(NullPointerException exception) { } catch(NullPointerException exception) {
entityInfo = null; entityInfo = null;
} }
@ -392,13 +392,13 @@ public class Battle
} }
else else
{ {
sideB.put(e.getEntityId(), newCombatant); sideB.put(e.getId(), newCombatant);
} }
if(e instanceof PlayerEntity) if(e instanceof PlayerEntity)
{ {
newCombatant.recalcSpeedOnCompare = true; newCombatant.recalcSpeedOnCompare = true;
playerCount.incrementAndGet(); playerCount.incrementAndGet();
players.put(e.getEntityId(), newCombatant); players.put(e.getId(), newCombatant);
if(state == State.DECISION) if(state == State.DECISION)
{ {
undecidedCount.incrementAndGet(); undecidedCount.incrementAndGet();
@ -406,24 +406,24 @@ public class Battle
} }
if(TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled()) if(TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled())
{ {
newCombatant.x = e.getPosX(); newCombatant.x = e.getX();
newCombatant.z = e.getPosZ(); newCombatant.z = e.getZ();
newCombatant.yaw = e.rotationYaw; newCombatant.yaw = e.xRot;
newCombatant.pitch = e.rotationPitch; newCombatant.pitch = e.yRot;
} }
if(isServer) if(isServer)
{ {
if(newCombatant.entityInfo != null) if(newCombatant.entityInfo != null)
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getEntityId(), 0, id, newCombatant.entityInfo.category); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getId(), 0, id, newCombatant.entityInfo.category);
} }
else if(newCombatant.entity instanceof PlayerEntity) else if(newCombatant.entity instanceof PlayerEntity)
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getEntityId(), 0, id, "player"); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getId(), 0, id, "player");
} }
else else
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getEntityId(), 0, id); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getId(), 0, id);
} }
} }
notifyPlayersBattleInfo(); notifyPlayersBattleInfo();
@ -465,7 +465,7 @@ public class Battle
Collection<Integer> sideAIDs = new ArrayList<Integer>(sideA.size()); Collection<Integer> sideAIDs = new ArrayList<Integer>(sideA.size());
for(Combatant combatant : sideA.values()) for(Combatant combatant : sideA.values())
{ {
sideAIDs.add(combatant.entity.getEntityId()); sideAIDs.add(combatant.entity.getId());
} }
return sideAIDs; return sideAIDs;
} }
@ -475,7 +475,7 @@ public class Battle
Collection<Integer> sideBIDs = new ArrayList<Integer>(sideB.size()); Collection<Integer> sideBIDs = new ArrayList<Integer>(sideB.size());
for(Combatant combatant : sideB.values()) for(Combatant combatant : sideB.values())
{ {
sideBIDs.add(combatant.entity.getEntityId()); sideBIDs.add(combatant.entity.getId());
} }
return sideBIDs; return sideBIDs;
} }
@ -594,7 +594,7 @@ public class Battle
{ {
category = "player"; category = "player";
} }
sendMessageToAllPlayers(PacketBattleMessage.MessageType.DIED, entry.getValue().entity.getEntityId(), 0, 0, category); sendMessageToAllPlayers(PacketBattleMessage.MessageType.DIED, entry.getValue().entity.getId(), 0, 0, category);
} }
} }
for(Iterator<Map.Entry<Integer, Combatant>> iter = sideB.entrySet().iterator(); iter.hasNext();) for(Iterator<Map.Entry<Integer, Combatant>> iter = sideB.entrySet().iterator(); iter.hasNext();)
@ -615,7 +615,7 @@ public class Battle
{ {
category = "player"; category = "player";
} }
sendMessageToAllPlayers(PacketBattleMessage.MessageType.DIED, entry.getValue().entity.getEntityId(), 0, 0, category); sendMessageToAllPlayers(PacketBattleMessage.MessageType.DIED, entry.getValue().entity.getId(), 0, 0, category);
} }
} }
if(players.isEmpty() || sideA.isEmpty() || sideB.isEmpty()) if(players.isEmpty() || sideA.isEmpty() || sideB.isEmpty())
@ -641,7 +641,7 @@ public class Battle
Map.Entry<Integer, Combatant> entry = iter.next(); Map.Entry<Integer, Combatant> entry = iter.next();
if(entry.getValue().entity != null && ((PlayerEntity)entry.getValue().entity).isCreative()) if(entry.getValue().entity != null && ((PlayerEntity)entry.getValue().entity).isCreative())
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.BECAME_CREATIVE, entry.getValue().entity.getEntityId(), 0, 0); sendMessageToAllPlayers(PacketBattleMessage.MessageType.BECAME_CREATIVE, entry.getValue().entity.getId(), 0, 0);
iter.remove(); iter.remove();
sideA.remove(entry.getKey()); sideA.remove(entry.getKey());
sideB.remove(entry.getKey()); sideB.remove(entry.getKey());
@ -677,19 +677,23 @@ public class Battle
{ {
for(Combatant c : sideA.values()) for(Combatant c : sideA.values())
{ {
c.entity.setPositionAndRotation(c.x, c.entity.getPosY(), c.z, c.yaw, c.pitch); c.entity.setPos(c.x, c.entity.getY(), c.z);
c.entity.setYBodyRot(c.yaw);
c.entity.setYHeadRot(c.pitch);
} }
for(Combatant c : sideB.values()) for(Combatant c : sideB.values())
{ {
c.entity.setPositionAndRotation(c.x, c.entity.getPosY(), c.z, c.yaw, c.pitch); c.entity.setPos(c.x, c.entity.getY(), c.z);
c.entity.setYBodyRot(c.yaw);
c.entity.setYHeadRot(c.pitch);
} }
} }
private void removeCombatant(Combatant c) private void removeCombatant(Combatant c)
{ {
sideA.remove(c.entity.getEntityId()); sideA.remove(c.entity.getId());
sideB.remove(c.entity.getEntityId()); sideB.remove(c.entity.getId());
if(players.remove(c.entity.getEntityId()) != null) if(players.remove(c.entity.getId()) != null)
{ {
playerCount.decrementAndGet(); playerCount.decrementAndGet();
} }
@ -713,14 +717,14 @@ public class Battle
} }
for(Iterator<Combatant> iter = sideAEntryQueue.iterator(); iter.hasNext();) { for(Iterator<Combatant> iter = sideAEntryQueue.iterator(); iter.hasNext();) {
Combatant c = iter.next(); Combatant c = iter.next();
if(c.entity.getEntityId() == e.id) { if(c.entity.getId() == e.id) {
iter.remove(); iter.remove();
break; break;
} }
} }
for(Iterator<Combatant> iter = sideBEntryQueue.iterator(); iter.hasNext();) { for(Iterator<Combatant> iter = sideBEntryQueue.iterator(); iter.hasNext();) {
Combatant c = iter.next(); Combatant c = iter.next();
if(c.entity.getEntityId() == e.id) { if(c.entity.getId() == e.id) {
iter.remove(); iter.remove();
break; break;
} }
@ -805,12 +809,12 @@ public class Battle
boolean combatantsChanged = false; boolean combatantsChanged = false;
for(Combatant c = sideAEntryQueue.poll(); c != null; c = sideAEntryQueue.poll()) for(Combatant c = sideAEntryQueue.poll(); c != null; c = sideAEntryQueue.poll())
{ {
sideA.put(c.entity.getEntityId(), c); sideA.put(c.entity.getId(), c);
combatantsChanged = true; combatantsChanged = true;
} }
for(Combatant c = sideBEntryQueue.poll(); c != null; c = sideBEntryQueue.poll()) for(Combatant c = sideBEntryQueue.poll(); c != null; c = sideBEntryQueue.poll())
{ {
sideB.put(c.entity.getEntityId(), c); sideB.put(c.entity.getId(), c);
combatantsChanged = true; combatantsChanged = true;
} }
if(TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled()) if(TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled())
@ -914,7 +918,7 @@ public class Battle
continue; continue;
} }
debugLog = next.entity.getDisplayName().getUnformattedComponentText(); debugLog = next.entity.getDisplayName().getString();
next.remainingDefenses = 0; next.remainingDefenses = 0;
@ -925,7 +929,7 @@ public class Battle
{ {
case UNDECIDED: case UNDECIDED:
debugLog += " undecided"; debugLog += " undecided";
sendMessageToAllPlayers(PacketBattleMessage.MessageType.DID_NOTHING, next.entity.getEntityId(), 0, 0); sendMessageToAllPlayers(PacketBattleMessage.MessageType.DID_NOTHING, next.entity.getId(), 0, 0);
break; break;
case ATTACK: case ATTACK:
debugLog += " attack"; debugLog += " attack";
@ -942,7 +946,7 @@ public class Battle
{ {
continue; continue;
} }
ItemStack heldItemStack = ((PlayerEntity)next.entity).getHeldItemMainhand(); ItemStack heldItemStack = ((PlayerEntity)next.entity).getMainHandItem();
if(heldItemStack.getItem() instanceof BowItem) if(heldItemStack.getItem() instanceof BowItem)
{ {
debugLog += " with bow"; debugLog += " with bow";
@ -950,8 +954,8 @@ public class Battle
{ {
final Entity nextEntity = next.entity; final Entity nextEntity = next.entity;
final Entity targetEntity = target.entity; final Entity targetEntity = target.entity;
final float yawDirection = Utility.yawDirection(next.entity.getPosX(), next.entity.getPosZ(), target.entity.getPosX(), target.entity.getPosZ()); final float yawDirection = Utility.yawDirection(next.entity.getX(), next.entity.getZ(), target.entity.getX(), target.entity.getZ());
final float pitchDirection = Utility.pitchDirection(next.entity.getPosX(), next.entity.getPosY(), next.entity.getPosZ(), target.entity.getPosX(), target.entity.getPosY(), target.entity.getPosZ()); final float pitchDirection = Utility.pitchDirection(next.entity.getX(), next.entity.getY(), next.entity.getZ(), target.entity.getX(), target.entity.getY(), target.entity.getZ());
final int randomTimeLeft = random.nextInt(heldItemStack.getItem().getUseDuration(heldItemStack) / 3); final int randomTimeLeft = random.nextInt(heldItemStack.getItem().getUseDuration(heldItemStack) / 3);
if(TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled()) if(TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled())
{ {
@ -959,15 +963,15 @@ public class Battle
next.pitch = pitchDirection; next.pitch = pitchDirection;
} }
// have player look at attack target // have player look at attack target
((ServerPlayerEntity)nextEntity).connection.setPlayerLocation(nextEntity.getPosX(), nextEntity.getPosY(), nextEntity.getPosZ(), yawDirection, pitchDirection); ((ServerPlayerEntity)nextEntity).connection.teleport(nextEntity.getX(), nextEntity.getY(), nextEntity.getZ(), yawDirection, pitchDirection);
BowItem itemBow = (BowItem)heldItemStack.getItem(); BowItem itemBow = (BowItem)heldItemStack.getItem();
TurnBasedMinecraftMod.proxy.getAttackerViaBowSet().add(new AttackerViaBow(nextEntity, getId())); TurnBasedMinecraftMod.proxy.getAttackerViaBowSet().add(new AttackerViaBow(nextEntity, getId()));
itemBow.onPlayerStoppedUsing(((PlayerEntity)nextEntity).getHeldItemMainhand(), nextEntity.getEntityWorld(), (LivingEntity) nextEntity, randomTimeLeft); itemBow.releaseUsing(((PlayerEntity)nextEntity).getMainHandItem(), nextEntity.level, (LivingEntity) nextEntity, randomTimeLeft);
sendMessageToAllPlayers(PacketBattleMessage.MessageType.FIRED_ARROW, nextEntity.getEntityId(), targetEntity.getEntityId(), 0); sendMessageToAllPlayers(PacketBattleMessage.MessageType.FIRED_ARROW, nextEntity.getId(), targetEntity.getId(), 0);
} }
else else
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.BOW_NO_AMMO, next.entity.getEntityId(), 0, 0); sendMessageToAllPlayers(PacketBattleMessage.MessageType.BOW_NO_AMMO, next.entity.getId(), 0, 0);
} }
continue; continue;
} }
@ -994,8 +998,8 @@ public class Battle
final Entity nextEntity = next.entity; final Entity nextEntity = next.entity;
final Entity targetEntity = target.entity; final Entity targetEntity = target.entity;
final EntityInfo targetEntityInfo = target.entityInfo; final EntityInfo targetEntityInfo = target.entityInfo;
final float yawDirection = Utility.yawDirection(next.entity.getPosX(), next.entity.getPosZ(), target.entity.getPosX(), target.entity.getPosZ()); final float yawDirection = Utility.yawDirection(next.entity.getX(), next.entity.getZ(), target.entity.getX(), target.entity.getZ());
final float pitchDirection = Utility.pitchDirection(next.entity.getPosX(), next.entity.getPosY(), next.entity.getPosZ(), target.entity.getPosX(), target.entity.getPosY(), target.entity.getPosZ()); final float pitchDirection = Utility.pitchDirection(next.entity.getX(), next.entity.getY(), next.entity.getZ(), target.entity.getX(), target.entity.getY(), target.entity.getZ());
final boolean defenseDamageTriggered; final boolean defenseDamageTriggered;
if(!(targetEntity instanceof PlayerEntity) && targetEntityInfo.defenseDamage > 0 && targetEntityInfo.defenseDamageProbability > 0) if(!(targetEntity instanceof PlayerEntity) && targetEntityInfo.defenseDamage > 0 && targetEntityInfo.defenseDamageProbability > 0)
{ {
@ -1018,20 +1022,20 @@ public class Battle
next.pitch = pitchDirection; next.pitch = pitchDirection;
} }
// have player look at attack target // have player look at attack target
((ServerPlayerEntity)nextEntity).connection.setPlayerLocation(nextEntity.getPosX(), nextEntity.getPosY(), nextEntity.getPosZ(), yawDirection, pitchDirection); ((ServerPlayerEntity)nextEntity).connection.teleport(nextEntity.getX(), nextEntity.getY(), nextEntity.getZ(), yawDirection, pitchDirection);
TurnBasedMinecraftMod.proxy.setAttackingEntity(nextEntity); TurnBasedMinecraftMod.proxy.setAttackingEntity(nextEntity);
TurnBasedMinecraftMod.proxy.setAttackingDamage(0); TurnBasedMinecraftMod.proxy.setAttackingDamage(0);
((PlayerEntity)nextEntity).attackTargetEntityWithCurrentItem(targetEntity); ((PlayerEntity)nextEntity).attack(targetEntity);
TurnBasedMinecraftMod.proxy.setAttackingEntity(null); TurnBasedMinecraftMod.proxy.setAttackingEntity(null);
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ATTACK, nextEntity.getEntityId(), targetEntity.getEntityId(), TurnBasedMinecraftMod.proxy.getAttackingDamage()); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ATTACK, nextEntity.getId(), targetEntity.getId(), TurnBasedMinecraftMod.proxy.getAttackingDamage());
if(defenseDamageTriggered) if(defenseDamageTriggered)
{ {
// defense damage // defense damage
DamageSource defenseDamageSource = DamageSource.causeMobDamage((LivingEntity) targetEntity); DamageSource defenseDamageSource = DamageSource.mobAttack((LivingEntity) targetEntity);
TurnBasedMinecraftMod.proxy.setAttackingEntity(targetEntity); TurnBasedMinecraftMod.proxy.setAttackingEntity(targetEntity);
nextEntity.attackEntityFrom(defenseDamageSource, targetEntityInfo.defenseDamage); nextEntity.hurt(defenseDamageSource, targetEntityInfo.defenseDamage);
TurnBasedMinecraftMod.proxy.setAttackingEntity(null); TurnBasedMinecraftMod.proxy.setAttackingEntity(null);
sendMessageToAllPlayers(PacketBattleMessage.MessageType.DEFENSE_DAMAGE, targetEntity.getEntityId(), nextEntity.getEntityId(), targetEntityInfo.defenseDamage); sendMessageToAllPlayers(PacketBattleMessage.MessageType.DEFENSE_DAMAGE, targetEntity.getId(), nextEntity.getId(), targetEntityInfo.defenseDamage);
} }
} }
else else
@ -1039,24 +1043,24 @@ public class Battle
debugLog += " hit blocked"; debugLog += " hit blocked";
// blocked // blocked
--target.remainingDefenses; --target.remainingDefenses;
sendMessageToAllPlayers(PacketBattleMessage.MessageType.DEFEND, target.entity.getEntityId(), next.entity.getEntityId(), 0); sendMessageToAllPlayers(PacketBattleMessage.MessageType.DEFEND, target.entity.getId(), next.entity.getId(), 0);
} }
} }
else else
{ {
debugLog += " hit missed"; debugLog += " hit missed";
// miss // miss
sendMessageToAllPlayers(PacketBattleMessage.MessageType.MISS, next.entity.getEntityId(), target.entity.getEntityId(), 0); sendMessageToAllPlayers(PacketBattleMessage.MessageType.MISS, next.entity.getId(), target.entity.getId(), 0);
} }
} }
else else
{ {
debugLog += " as mob"; debugLog += " as mob";
LivingEntity attackTarget = ((MobEntity)next.entity).getAttackTarget(); LivingEntity attackTarget = ((MobEntity)next.entity).getTarget();
if(attackTarget != null && hasCombatant(attackTarget.getEntityId())) if(attackTarget != null && hasCombatant(attackTarget.getId()))
{ {
debugLog += " to targeted"; debugLog += " to targeted";
target = getCombatantByID(attackTarget.getEntityId()); target = getCombatantByID(attackTarget.getId());
} }
else else
{ {
@ -1114,7 +1118,7 @@ public class Battle
if(target.remainingDefenses <= 0) if(target.remainingDefenses <= 0)
{ {
debugLog += " hit success"; debugLog += " hit success";
DamageSource damageSource = DamageSource.causeMobDamage((LivingEntity)next.entity); DamageSource damageSource = DamageSource.mobAttack((LivingEntity)next.entity);
int damageAmount = next.entityInfo.attackPower; int damageAmount = next.entityInfo.attackPower;
if(next.entityInfo.attackVariance > 0) if(next.entityInfo.attackVariance > 0)
{ {
@ -1166,23 +1170,23 @@ public class Battle
} }
TurnBasedMinecraftMod.proxy.setAttackingEntity(nextEntity); TurnBasedMinecraftMod.proxy.setAttackingEntity(nextEntity);
targetEntity.attackEntityFrom(damageSource, finalDamageAmount); targetEntity.hurt(damageSource, finalDamageAmount);
TurnBasedMinecraftMod.proxy.setAttackingEntity(null); TurnBasedMinecraftMod.proxy.setAttackingEntity(null);
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ATTACK, nextEntity.getEntityId(), targetEntity.getEntityId(), finalDamageAmount); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ATTACK, nextEntity.getId(), targetEntity.getId(), finalDamageAmount);
if(defenseDamageTriggered) if(defenseDamageTriggered)
{ {
// defense damage // defense damage
DamageSource defenseDamageSource = DamageSource.causeMobDamage((LivingEntity)targetEntity); DamageSource defenseDamageSource = DamageSource.mobAttack((LivingEntity)targetEntity);
TurnBasedMinecraftMod.proxy.setAttackingEntity(targetEntity); TurnBasedMinecraftMod.proxy.setAttackingEntity(targetEntity);
nextEntity.attackEntityFrom(defenseDamageSource, targetEntityInfo.defenseDamage); nextEntity.hurt(defenseDamageSource, targetEntityInfo.defenseDamage);
TurnBasedMinecraftMod.proxy.setAttackingEntity(null); TurnBasedMinecraftMod.proxy.setAttackingEntity(null);
sendMessageToAllPlayers(PacketBattleMessage.MessageType.DEFENSE_DAMAGE, targetEntity.getEntityId(), nextEntity.getEntityId(), targetEntityInfo.defenseDamage); sendMessageToAllPlayers(PacketBattleMessage.MessageType.DEFENSE_DAMAGE, targetEntity.getId(), nextEntity.getId(), targetEntityInfo.defenseDamage);
} }
// attack effect // attack effect
if(attackEffectTriggered) if(attackEffectTriggered)
{ {
nextEntityInfo.attackEffect.applyEffectToEntity((LivingEntity)targetEntity); nextEntityInfo.attackEffect.applyEffectToEntity((LivingEntity)targetEntity);
sendMessageToAllPlayers(PacketBattleMessage.MessageType.WAS_AFFECTED, nextEntity.getEntityId(), targetEntity.getEntityId(), 0, nextEntityInfo.attackEffect.getAffectedString()); sendMessageToAllPlayers(PacketBattleMessage.MessageType.WAS_AFFECTED, nextEntity.getId(), targetEntity.getId(), 0, nextEntityInfo.attackEffect.getAffectedString());
} }
} }
else else
@ -1190,21 +1194,21 @@ public class Battle
debugLog += " hit blocked"; debugLog += " hit blocked";
// blocked // blocked
--target.remainingDefenses; --target.remainingDefenses;
sendMessageToAllPlayers(PacketBattleMessage.MessageType.DEFEND, target.entity.getEntityId(), next.entity.getEntityId(), 0); sendMessageToAllPlayers(PacketBattleMessage.MessageType.DEFEND, target.entity.getId(), next.entity.getId(), 0);
} }
} }
else else
{ {
debugLog += " hit missed"; debugLog += " hit missed";
// miss // miss
sendMessageToAllPlayers(PacketBattleMessage.MessageType.MISS, next.entity.getEntityId(), target.entity.getEntityId(), 0); sendMessageToAllPlayers(PacketBattleMessage.MessageType.MISS, next.entity.getId(), target.entity.getId(), 0);
} }
} }
break; break;
case DEFEND: case DEFEND:
debugLog += " defend"; debugLog += " defend";
next.remainingDefenses = TurnBasedMinecraftMod.proxy.getConfig().getDefenseDuration(); next.remainingDefenses = TurnBasedMinecraftMod.proxy.getConfig().getDefenseDuration();
sendMessageToAllPlayers(PacketBattleMessage.MessageType.DEFENDING, next.entity.getEntityId(), 0, 0); sendMessageToAllPlayers(PacketBattleMessage.MessageType.DEFENDING, next.entity.getId(), 0, 0);
break; break;
case FLEE: case FLEE:
debugLog += " flee"; debugLog += " flee";
@ -1286,14 +1290,14 @@ public class Battle
{ {
fleeingCategory = "player"; fleeingCategory = "player";
} }
sendMessageToAllPlayers(PacketBattleMessage.MessageType.FLEE, next.entity.getEntityId(), 0, 1, fleeingCategory); sendMessageToAllPlayers(PacketBattleMessage.MessageType.FLEE, next.entity.getId(), 0, 1, fleeingCategory);
removeCombatant(next); removeCombatant(next);
} }
else else
{ {
debugLog += " fail"; debugLog += " fail";
// flee fail // flee fail
sendMessageToAllPlayers(PacketBattleMessage.MessageType.FLEE, next.entity.getEntityId(), 0, 0); sendMessageToAllPlayers(PacketBattleMessage.MessageType.FLEE, next.entity.getId(), 0, 0);
} }
break; break;
case USE_ITEM: case USE_ITEM:
@ -1301,66 +1305,66 @@ public class Battle
if(next.itemToUse < 0 || next.itemToUse > 8) if(next.itemToUse < 0 || next.itemToUse > 8)
{ {
debugLog += " invalid"; debugLog += " invalid";
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getEntityId(), 0, PacketBattleMessage.UsedItemAction.USED_INVALID.getValue()); sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_INVALID.getValue());
break; break;
} }
ItemStack targetItemStack = ((PlayerEntity)next.entity).inventory.getStackInSlot(next.itemToUse); ItemStack targetItemStack = ((PlayerEntity)next.entity).inventory.getItem(next.itemToUse);
Item targetItem = targetItemStack.getItem(); Item targetItem = targetItemStack.getItem();
if(targetItem == null) if(targetItem == null)
{ {
debugLog += " null"; debugLog += " null";
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getEntityId(), 0, PacketBattleMessage.UsedItemAction.USED_NOTHING.getValue()); sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_NOTHING.getValue());
break; break;
} }
if(targetItem.getGroup() == ItemGroup.FOOD) if(targetItem.getItemCategory() == ItemGroup.TAB_FOOD)
{ {
debugLog += " food"; debugLog += " food";
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getEntityId(), 0, PacketBattleMessage.UsedItemAction.USED_FOOD.getValue(), targetItemStack.getDisplayName().getString()); sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_FOOD.getValue(), targetItemStack.getDisplayName().getString());
final Entity nextEntity = next.entity; final Entity nextEntity = next.entity;
final int nextItemToUse = next.itemToUse; final int nextItemToUse = next.itemToUse;
((PlayerEntity)nextEntity).inventory.setInventorySlotContents(nextItemToUse, targetItem.onItemUseFinish(targetItemStack, nextEntity.world, (LivingEntity)nextEntity)); ((PlayerEntity)nextEntity).inventory.setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level, (LivingEntity)nextEntity));
} }
else if(targetItem instanceof PotionItem) else if(targetItem instanceof PotionItem)
{ {
debugLog += " potion"; debugLog += " potion";
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getEntityId(), 0, PacketBattleMessage.UsedItemAction.USED_POTION.getValue(), targetItemStack.getDisplayName().getString()); sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_POTION.getValue(), targetItemStack.getDisplayName().getString());
final Entity nextEntity = next.entity; final Entity nextEntity = next.entity;
final int nextItemToUse = next.itemToUse; final int nextItemToUse = next.itemToUse;
((PlayerEntity)nextEntity).inventory.setInventorySlotContents(nextItemToUse, targetItem.onItemUseFinish(targetItemStack, nextEntity.world, (LivingEntity)nextEntity)); ((PlayerEntity)nextEntity).inventory.setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level, (LivingEntity)nextEntity));
} }
else else
{ {
debugLog += " non-consumable"; debugLog += " non-consumable";
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getEntityId(), 0, PacketBattleMessage.UsedItemAction.USED_INVALID.getValue(), targetItemStack.getDisplayName().getString()); sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_INVALID.getValue(), targetItemStack.getDisplayName().getString());
} }
break; break;
case SWITCH_ITEM: { case SWITCH_ITEM: {
debugLog += " switch item"; debugLog += " switch item";
if (next.itemToUse < 0 || next.itemToUse > 8) { if (next.itemToUse < 0 || next.itemToUse > 8) {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.SWITCHED_ITEM, next.entity.getEntityId(), 0, 0); sendMessageToAllPlayers(PacketBattleMessage.MessageType.SWITCHED_ITEM, next.entity.getId(), 0, 0);
break; break;
} }
final Entity nextEntity = next.entity; final Entity nextEntity = next.entity;
final int nextItemToUse = next.itemToUse; final int nextItemToUse = next.itemToUse;
((PlayerEntity) nextEntity).inventory.currentItem = nextItemToUse; ((PlayerEntity) nextEntity).inventory.selected = nextItemToUse;
sendMessageToAllPlayers(PacketBattleMessage.MessageType.SWITCHED_ITEM, next.entity.getEntityId(), 0, 1); sendMessageToAllPlayers(PacketBattleMessage.MessageType.SWITCHED_ITEM, next.entity.getId(), 0, 1);
} }
break; break;
case CREEPER_WAIT: case CREEPER_WAIT:
debugLog += " creeper wait"; debugLog += " creeper wait";
if(next.creeperTurns < TurnBasedMinecraftMod.proxy.getConfig().getCreeperExplodeTurn()) { if(next.creeperTurns < TurnBasedMinecraftMod.proxy.getConfig().getCreeperExplodeTurn()) {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.CREEPER_WAIT, next.entity.getEntityId(), 0, 0); sendMessageToAllPlayers(PacketBattleMessage.MessageType.CREEPER_WAIT, next.entity.getId(), 0, 0);
} else { } else {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.CREEPER_WAIT_FINAL, next.entity.getEntityId(), 0, 0); sendMessageToAllPlayers(PacketBattleMessage.MessageType.CREEPER_WAIT_FINAL, next.entity.getId(), 0, 0);
} }
break; break;
case CREEPER_EXPLODE: { case CREEPER_EXPLODE: {
debugLog += " creeper explode"; debugLog += " creeper explode";
sendMessageToAllPlayers(PacketBattleMessage.MessageType.CREEPER_EXPLODE, next.entity.getEntityId(), 0, 0); sendMessageToAllPlayers(PacketBattleMessage.MessageType.CREEPER_EXPLODE, next.entity.getId(), 0, 0);
final Entity nextEntity = next.entity; final Entity nextEntity = next.entity;
final EntityInfo nextEntityInfo = next.entityInfo; final EntityInfo nextEntityInfo = next.entityInfo;
for (Combatant c : sideA.values()) { for (Combatant c : sideA.values()) {
if (c.entity.getEntityId() != next.entity.getEntityId()) { if (c.entity.getId() != next.entity.getId()) {
int hitChance = next.entityInfo.attackProbability; int hitChance = next.entityInfo.attackProbability;
if (c.entity instanceof PlayerEntity) { if (c.entity instanceof PlayerEntity) {
hitChance = hitChance * (100 - TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion()) / 100; hitChance = hitChance * (100 - TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion()) / 100;
@ -1393,18 +1397,18 @@ public class Battle
} }
TurnBasedMinecraftMod.proxy.setAttackingEntity(nextEntity); TurnBasedMinecraftMod.proxy.setAttackingEntity(nextEntity);
targetEntity.attackEntityFrom(DamageSource.causeMobDamage((LivingEntity) nextEntity), finalDamageAmount); targetEntity.hurt(DamageSource.mobAttack((LivingEntity) nextEntity), finalDamageAmount);
TurnBasedMinecraftMod.proxy.setAttackingEntity(null); TurnBasedMinecraftMod.proxy.setAttackingEntity(null);
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ATTACK, nextEntity.getEntityId(), targetEntity.getEntityId(), finalDamageAmount); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ATTACK, nextEntity.getId(), targetEntity.getId(), finalDamageAmount);
if(attackEffectTriggered) { if(attackEffectTriggered) {
nextEntityInfo.attackEffect.applyEffectToEntity((LivingEntity)targetEntity); nextEntityInfo.attackEffect.applyEffectToEntity((LivingEntity)targetEntity);
sendMessageToAllPlayers(PacketBattleMessage.MessageType.WAS_AFFECTED, nextEntity.getEntityId(), targetEntity.getEntityId(), 0, nextEntityInfo.attackEffect.getAffectedString()); sendMessageToAllPlayers(PacketBattleMessage.MessageType.WAS_AFFECTED, nextEntity.getId(), targetEntity.getId(), 0, nextEntityInfo.attackEffect.getAffectedString());
} }
} }
} }
} }
for(Combatant c : sideB.values()) { for(Combatant c : sideB.values()) {
if (c.entity.getEntityId() != next.entity.getEntityId()) { if (c.entity.getId() != next.entity.getId()) {
int hitChance = next.entityInfo.attackProbability; int hitChance = next.entityInfo.attackProbability;
if (c.entity instanceof PlayerEntity) { if (c.entity instanceof PlayerEntity) {
hitChance = hitChance * (100 - TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion()) / 100; hitChance = hitChance * (100 - TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion()) / 100;
@ -1437,17 +1441,17 @@ public class Battle
} }
TurnBasedMinecraftMod.proxy.setAttackingEntity(nextEntity); TurnBasedMinecraftMod.proxy.setAttackingEntity(nextEntity);
targetEntity.attackEntityFrom(DamageSource.causeMobDamage((LivingEntity) nextEntity), finalDamageAmount); targetEntity.hurt(DamageSource.mobAttack((LivingEntity) nextEntity), finalDamageAmount);
TurnBasedMinecraftMod.proxy.setAttackingEntity(null); TurnBasedMinecraftMod.proxy.setAttackingEntity(null);
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ATTACK, nextEntity.getEntityId(), targetEntity.getEntityId(), finalDamageAmount); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ATTACK, nextEntity.getId(), targetEntity.getId(), finalDamageAmount);
if(attackEffectTriggered) { if(attackEffectTriggered) {
nextEntityInfo.attackEffect.applyEffectToEntity((LivingEntity)targetEntity); nextEntityInfo.attackEffect.applyEffectToEntity((LivingEntity)targetEntity);
sendMessageToAllPlayers(PacketBattleMessage.MessageType.WAS_AFFECTED, nextEntity.getEntityId(), targetEntity.getEntityId(), 0, nextEntityInfo.attackEffect.getAffectedString()); sendMessageToAllPlayers(PacketBattleMessage.MessageType.WAS_AFFECTED, nextEntity.getId(), targetEntity.getId(), 0, nextEntityInfo.attackEffect.getAffectedString());
} }
} }
} }
} }
((CreeperEntity)nextEntity).setCreeperState(1000000); ((CreeperEntity)nextEntity).setSwellDir(1000000);
} }
break; break;
} }
@ -1494,18 +1498,18 @@ public class Battle
for(Combatant c : sideA.values()) { for(Combatant c : sideA.values()) {
if(c.entity instanceof CreeperEntity) { if(c.entity instanceof CreeperEntity) {
if(c.creeperTurns <= TurnBasedMinecraftMod.proxy.getConfig().getCreeperExplodeTurn()) { if(c.creeperTurns <= TurnBasedMinecraftMod.proxy.getConfig().getCreeperExplodeTurn()) {
((CreeperEntity)c.entity).setCreeperState(-10); ((CreeperEntity)c.entity).setSwellDir(-10);
} else { } else {
((CreeperEntity)c.entity).setCreeperState(1000000); ((CreeperEntity)c.entity).setSwellDir(1000000);
} }
} }
} }
for(Combatant c : sideB.values()) { for(Combatant c : sideB.values()) {
if(c.entity instanceof CreeperEntity) { if(c.entity instanceof CreeperEntity) {
if(c.creeperTurns <= TurnBasedMinecraftMod.proxy.getConfig().getCreeperExplodeTurn()) { if(c.creeperTurns <= TurnBasedMinecraftMod.proxy.getConfig().getCreeperExplodeTurn()) {
((CreeperEntity)c.entity).setCreeperState(-10); ((CreeperEntity)c.entity).setSwellDir(-10);
} else { } else {
((CreeperEntity) c.entity).setCreeperState(1000000); ((CreeperEntity) c.entity).setSwellDir(1000000);
} }
} }
} }

View file

@ -55,19 +55,19 @@ public class BattleManager
String receiverCustomName; String receiverCustomName;
try { try {
receiverCustomName = event.getEntity().getCustomName().getUnformattedComponentText(); receiverCustomName = event.getEntity().getCustomName().getString();
} catch (NullPointerException e) { } catch (NullPointerException e) {
receiverCustomName = null; receiverCustomName = null;
} }
String attackerClassName; String attackerClassName;
try { try {
attackerClassName = event.getSource().getTrueSource().getClass().getName(); attackerClassName = event.getSource().getEntity().getClass().getName();
} catch (NullPointerException e) { } catch (NullPointerException e) {
attackerClassName = null; attackerClassName = null;
} }
String attackerCustomName; String attackerCustomName;
try { try {
attackerCustomName = event.getSource().getTrueSource().getCustomName().getUnformattedComponentText(); attackerCustomName = event.getSource().getEntity().getCustomName().getString();
} catch (NullPointerException e) { } catch (NullPointerException e) {
attackerCustomName = null; attackerCustomName = null;
} }
@ -75,7 +75,7 @@ public class BattleManager
// verify that both entities are EntityPlayer and not in creative or has a corresponding EntityInfo // verify that both entities are EntityPlayer and not in creative or has a corresponding EntityInfo
if(!((event.getEntity() instanceof PlayerEntity && !((PlayerEntity)event.getEntity()).isCreative()) if(!((event.getEntity() instanceof PlayerEntity && !((PlayerEntity)event.getEntity()).isCreative())
|| (config.getEntityInfoReference(receiverClassName) != null || config.getCustomEntityInfoReference(receiverCustomName) != null)) || (config.getEntityInfoReference(receiverClassName) != null || config.getCustomEntityInfoReference(receiverCustomName) != null))
|| !((event.getSource().getTrueSource() instanceof PlayerEntity && !((PlayerEntity)event.getSource().getTrueSource()).isCreative()) || !((event.getSource().getEntity() instanceof PlayerEntity && !((PlayerEntity)event.getSource().getEntity()).isCreative())
|| (config.getEntityInfoReference(attackerClassName) != null || config.getCustomEntityInfoReference(attackerCustomName) != null))) || (config.getEntityInfoReference(attackerClassName) != null || config.getCustomEntityInfoReference(attackerCustomName) != null)))
{ {
// logger.debug("BattleManager: Failed first check, attacker is \"" + attackerClassName + "\", defender is \"" + receiverClassName + "\""); // logger.debug("BattleManager: Failed first check, attacker is \"" + attackerClassName + "\", defender is \"" + receiverClassName + "\"");
@ -92,8 +92,8 @@ public class BattleManager
if(entityInfo != null && (config.isIgnoreBattleType(entityInfo.category) || entityInfo.ignoreBattle)) if(entityInfo != null && (config.isIgnoreBattleType(entityInfo.category) || entityInfo.ignoreBattle))
{ {
// attacked entity ignores battle // attacked entity ignores battle
Battle battle = battleMap.get(entityToBattleMap.get(new EntityIDDimPair(event.getSource().getTrueSource()))); Battle battle = battleMap.get(entityToBattleMap.get(new EntityIDDimPair(event.getSource().getEntity())));
if(battle != null && battle.hasCombatant(event.getSource().getTrueSource().getEntityId())) { if(battle != null && battle.hasCombatant(event.getSource().getEntity().getId())) {
logger.debug("Attack Canceled: attacked ignores battle but attacker in battle"); logger.debug("Attack Canceled: attacked ignores battle but attacker in battle");
return true; return true;
} else { } else {
@ -105,14 +105,14 @@ public class BattleManager
entityInfo = config.getCustomEntityInfoReference(attackerCustomName); entityInfo = config.getCustomEntityInfoReference(attackerCustomName);
if(entityInfo == null) if(entityInfo == null)
{ {
entityInfo = config.getMatchingEntityInfo(event.getSource().getTrueSource()); entityInfo = config.getMatchingEntityInfo(event.getSource().getEntity());
} }
if(entityInfo != null && (config.isIgnoreBattleType(entityInfo.category) || entityInfo.ignoreBattle)) if(entityInfo != null && (config.isIgnoreBattleType(entityInfo.category) || entityInfo.ignoreBattle))
{ {
// attacker entity ignores battle // attacker entity ignores battle
Battle battle = battleMap.get(entityToBattleMap.get(new EntityIDDimPair(event.getEntity()))); Battle battle = battleMap.get(entityToBattleMap.get(new EntityIDDimPair(event.getEntity())));
if(battle != null && battle.hasCombatant(event.getEntity().getEntityId())) { if(battle != null && battle.hasCombatant(event.getEntity().getId())) {
logger.debug("Attack Canceled: attacker ignores battle but attacked in battle"); logger.debug("Attack Canceled: attacker ignores battle but attacked in battle");
return true; return true;
} else { } else {
@ -122,12 +122,12 @@ public class BattleManager
} }
// check if one is in battle // check if one is in battle
Battle attackerBattle = battleMap.get(entityToBattleMap.get(new EntityIDDimPair(event.getSource().getTrueSource()))); Battle attackerBattle = battleMap.get(entityToBattleMap.get(new EntityIDDimPair(event.getSource().getEntity())));
if(attackerBattle != null && !attackerBattle.hasCombatant(event.getSource().getTrueSource().getEntityId())) { if(attackerBattle != null && !attackerBattle.hasCombatant(event.getSource().getEntity().getId())) {
attackerBattle = null; attackerBattle = null;
} }
Battle defenderBattle = battleMap.get(entityToBattleMap.get(new EntityIDDimPair(event.getEntity()))); Battle defenderBattle = battleMap.get(entityToBattleMap.get(new EntityIDDimPair(event.getEntity())));
if(defenderBattle != null && !defenderBattle.hasCombatant(event.getEntity().getEntityId())) { if(defenderBattle != null && !defenderBattle.hasCombatant(event.getEntity().getId())) {
defenderBattle = null; defenderBattle = null;
} }
@ -136,14 +136,14 @@ public class BattleManager
return true; return true;
} else if(attackerBattle == null && defenderBattle == null) { } else if(attackerBattle == null && defenderBattle == null) {
// neither entity is in battle // neither entity is in battle
if(event.getEntity() instanceof PlayerEntity || event.getSource().getTrueSource() instanceof PlayerEntity) if(event.getEntity() instanceof PlayerEntity || event.getSource().getEntity() instanceof PlayerEntity)
{ {
// at least one of the entities is a player, create Battle // at least one of the entities is a player, create Battle
Collection<Entity> sideA = new ArrayList<Entity>(1); Collection<Entity> sideA = new ArrayList<Entity>(1);
Collection<Entity> sideB = new ArrayList<Entity>(1); Collection<Entity> sideB = new ArrayList<Entity>(1);
sideA.add(event.getEntity()); sideA.add(event.getEntity());
sideB.add(event.getSource().getTrueSource()); sideB.add(event.getSource().getEntity());
createBattle(sideA, sideB, event.getEntity().getEntityWorld().func_234923_W_()); createBattle(sideA, sideB, event.getEntity().level.dimension());
logger.debug("Attack Not Canceled: new battle created"); logger.debug("Attack Not Canceled: new battle created");
} }
else else
@ -157,7 +157,7 @@ public class BattleManager
if (attackerBattle.getSize() >= config.getMaxInBattle()) { if (attackerBattle.getSize() >= config.getMaxInBattle()) {
// battle limit reached, cannot add to battle // battle limit reached, cannot add to battle
return true; return true;
} else if (attackerBattle.hasCombatantInSideA(event.getSource().getTrueSource().getEntityId())) { } else if (attackerBattle.hasCombatantInSideA(event.getSource().getEntity().getId())) {
attackerBattle.addCombatantToSideB(event.getEntity()); attackerBattle.addCombatantToSideB(event.getEntity());
} else { } else {
attackerBattle.addCombatantToSideA(event.getEntity()); attackerBattle.addCombatantToSideA(event.getEntity());
@ -167,12 +167,12 @@ public class BattleManager
if (defenderBattle.getSize() >= config.getMaxInBattle()) { if (defenderBattle.getSize() >= config.getMaxInBattle()) {
// battle limit reached, cannot add to battle // battle limit reached, cannot add to battle
return true; return true;
} else if (defenderBattle.hasCombatantInSideA(event.getEntity().getEntityId())) { } else if (defenderBattle.hasCombatantInSideA(event.getEntity().getId())) {
defenderBattle.addCombatantToSideB(event.getSource().getTrueSource()); defenderBattle.addCombatantToSideB(event.getSource().getEntity());
} else { } else {
defenderBattle.addCombatantToSideA(event.getSource().getTrueSource()); defenderBattle.addCombatantToSideA(event.getSource().getEntity());
} }
entityToBattleMap.put(new EntityIDDimPair(event.getSource().getTrueSource()), defenderBattle.getId()); entityToBattleMap.put(new EntityIDDimPair(event.getSource().getEntity()), defenderBattle.getId());
} }
} }
@ -184,13 +184,13 @@ public class BattleManager
{ {
String targetedCustomName; String targetedCustomName;
try { try {
targetedCustomName = event.getTarget().getCustomName().getUnformattedComponentText(); targetedCustomName = event.getTarget().getCustomName().getString();
} catch (NullPointerException e) { } catch (NullPointerException e) {
targetedCustomName = null; targetedCustomName = null;
} }
String attackerCustomName; String attackerCustomName;
try { try {
attackerCustomName = event.getEntity().getCustomName().getUnformattedComponentText(); attackerCustomName = event.getEntity().getCustomName().getString();
} catch (NullPointerException e) { } catch (NullPointerException e) {
attackerCustomName = null; attackerCustomName = null;
} }
@ -227,11 +227,11 @@ public class BattleManager
// check if one is in battle // check if one is in battle
Battle attackerBattle = battleMap.get(entityToBattleMap.get(new EntityIDDimPair(event.getEntity()))); Battle attackerBattle = battleMap.get(entityToBattleMap.get(new EntityIDDimPair(event.getEntity())));
if(attackerBattle != null && !attackerBattle.hasCombatant(event.getEntity().getEntityId())) { if(attackerBattle != null && !attackerBattle.hasCombatant(event.getEntity().getId())) {
attackerBattle = null; attackerBattle = null;
} }
Battle defenderBattle = battleMap.get(entityToBattleMap.get(new EntityIDDimPair(event.getTarget()))); Battle defenderBattle = battleMap.get(entityToBattleMap.get(new EntityIDDimPair(event.getTarget())));
if(defenderBattle != null && !defenderBattle.hasCombatant(event.getTarget().getEntityId())) { if(defenderBattle != null && !defenderBattle.hasCombatant(event.getTarget().getId())) {
defenderBattle = null; defenderBattle = null;
} }
@ -246,7 +246,7 @@ public class BattleManager
Collection<Entity> sideB = new ArrayList<Entity>(1); Collection<Entity> sideB = new ArrayList<Entity>(1);
sideA.add(event.getEntity()); sideA.add(event.getEntity());
sideB.add(event.getTarget()); sideB.add(event.getTarget());
createBattle(sideA, sideB, event.getEntity().getEntityWorld().func_234923_W_()); createBattle(sideA, sideB, event.getEntity().level.dimension());
logger.debug("neither in battle, at least one is player, creating new battle"); logger.debug("neither in battle, at least one is player, creating new battle");
} }
} else { } else {
@ -255,7 +255,7 @@ public class BattleManager
if (attackerBattle.getSize() >= TurnBasedMinecraftMod.proxy.getConfig().getMaxInBattle()) { if (attackerBattle.getSize() >= TurnBasedMinecraftMod.proxy.getConfig().getMaxInBattle()) {
// battle max reached, cannot add to battle // battle max reached, cannot add to battle
return; return;
} else if (attackerBattle.hasCombatantInSideA(event.getEntity().getEntityId())) { } else if (attackerBattle.hasCombatantInSideA(event.getEntity().getId())) {
attackerBattle.addCombatantToSideB(event.getTarget()); attackerBattle.addCombatantToSideB(event.getTarget());
} else { } else {
attackerBattle.addCombatantToSideA(event.getTarget()); attackerBattle.addCombatantToSideA(event.getTarget());
@ -265,7 +265,7 @@ public class BattleManager
if (defenderBattle.getSize() >= TurnBasedMinecraftMod.proxy.getConfig().getMaxInBattle()) { if (defenderBattle.getSize() >= TurnBasedMinecraftMod.proxy.getConfig().getMaxInBattle()) {
// battle max reached, cannot add to battle // battle max reached, cannot add to battle
return; return;
} else if (defenderBattle.hasCombatantInSideA(event.getTarget().getEntityId())) { } else if (defenderBattle.hasCombatantInSideA(event.getTarget().getId())) {
defenderBattle.addCombatantToSideB(event.getEntity()); defenderBattle.addCombatantToSideB(event.getEntity());
} else { } else {
defenderBattle.addCombatantToSideA(event.getEntity()); defenderBattle.addCombatantToSideA(event.getEntity());
@ -314,7 +314,7 @@ public class BattleManager
if(c.entity instanceof ServerPlayerEntity) { if(c.entity instanceof ServerPlayerEntity) {
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(()->(ServerPlayerEntity) c.entity), new PacketGeneralMessage("You just left battle! " + config.getLeaveBattleCooldownSeconds() + " seconds until you can attack/be-attacked again!")); TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(()->(ServerPlayerEntity) c.entity), new PacketGeneralMessage("You just left battle! " + config.getLeaveBattleCooldownSeconds() + " seconds until you can attack/be-attacked again!"));
} }
recentlyLeftBattle.put(c.entity.getEntityId(), c); recentlyLeftBattle.put(c.entity.getId(), c);
entityToBattleMap.remove(new EntityIDDimPair(c.entity)); entityToBattleMap.remove(new EntityIDDimPair(c.entity));
} }
@ -325,7 +325,7 @@ public class BattleManager
{ {
Map.Entry<Integer, Combatant> entry = iter.next(); Map.Entry<Integer, Combatant> entry = iter.next();
if(entry.getValue().entity instanceof CreeperEntity && TurnBasedMinecraftMod.proxy.getConfig().getCreeperStopExplodeOnLeaveBattle()) { if(entry.getValue().entity instanceof CreeperEntity && TurnBasedMinecraftMod.proxy.getConfig().getCreeperStopExplodeOnLeaveBattle()) {
((CreeperEntity)entry.getValue().entity).setCreeperState(-10); ((CreeperEntity)entry.getValue().entity).setSwellDir(-10);
} }
if(current - entry.getValue().time > TurnBasedMinecraftMod.proxy.getConfig().getLeaveBattleCooldownNanos()) if(current - entry.getValue().time > TurnBasedMinecraftMod.proxy.getConfig().getLeaveBattleCooldownNanos())
{ {

View file

@ -58,13 +58,13 @@ public class Combatant
LivingEntity c0Entity = (LivingEntity)c0.entity; LivingEntity c0Entity = (LivingEntity)c0.entity;
boolean isHaste = false; boolean isHaste = false;
boolean isSlow = false; boolean isSlow = false;
for(EffectInstance e : c0Entity.getActivePotionEffects()) for(EffectInstance e : c0Entity.getActiveEffects())
{ {
if(e.getEffectName().equals(Effects.HASTE.getName()) || e.getEffectName().equals(Effects.SPEED.getName())) if(e.getEffect().equals(Effects.MOVEMENT_SPEED) || e.getEffect().equals(Effects.DIG_SPEED))
{ {
isHaste = true; isHaste = true;
} }
else if(e.getEffectName().equals(Effects.SLOWNESS.getName())) else if(e.getEffect().equals(Effects.MOVEMENT_SLOWDOWN) || e.getEffect().equals(Effects.DIG_SLOWDOWN))
{ {
isSlow = true; isSlow = true;
} }
@ -92,13 +92,13 @@ public class Combatant
LivingEntity c1Entity = (LivingEntity)c1.entity; LivingEntity c1Entity = (LivingEntity)c1.entity;
boolean isHaste = false; boolean isHaste = false;
boolean isSlow = false; boolean isSlow = false;
for(EffectInstance e : c1Entity.getActivePotionEffects()) for(EffectInstance e : c1Entity.getActiveEffects())
{ {
if(e.getEffectName().equals(Effects.HASTE.getName())) if(e.getEffect().equals(Effects.MOVEMENT_SPEED))
{ {
isHaste = true; isHaste = true;
} }
else if(e.getEffectName().equals(Effects.SLOWNESS.getName())) else if(e.getEffect().equals(Effects.MOVEMENT_SLOWDOWN))
{ {
isSlow = true; isSlow = true;
} }

View file

@ -154,7 +154,7 @@ public class CommonProxy
protected final EditingInfo setEditingPlayer(PlayerEntity player) protected final EditingInfo setEditingPlayer(PlayerEntity player)
{ {
return editingPlayers.put(player.getEntityId(), new EditingInfo(player)); return editingPlayers.put(player.getId(), new EditingInfo(player));
} }
protected final EditingInfo removeEditingInfo(int id) protected final EditingInfo removeEditingInfo(int id)
@ -163,6 +163,6 @@ public class CommonProxy
} }
public Entity getEntity(int id, RegistryKey<World> dim) { public Entity getEntity(int id, RegistryKey<World> dim) {
return ServerLifecycleHooks.getCurrentServer().getWorld(dim).getEntityByID(id); return ServerLifecycleHooks.getCurrentServer().getLevel(dim).getEntity(id);
} }
} }

View file

@ -9,7 +9,7 @@ import net.minecraftforge.fml.network.PacketDistributor;
public class DimensionChangedHandler { public class DimensionChangedHandler {
@SubscribeEvent @SubscribeEvent
public void dimensionChanged(EntityTravelToDimensionEvent event) { public void dimensionChanged(EntityTravelToDimensionEvent event) {
if(event.getEntity().world.isRemote) { if(event.getEntity().level.isClientSide) {
return; return;
} }
if(TurnBasedMinecraftMod.proxy.getBattleManager().forceLeaveBattle(new EntityIDDimPair(event.getEntity())) if(TurnBasedMinecraftMod.proxy.getBattleManager().forceLeaveBattle(new EntityIDDimPair(event.getEntity()))

View file

@ -11,7 +11,8 @@ public class EntityIDDimPair {
EntityIDDimPair() { EntityIDDimPair() {
id = 0; id = 0;
dim = Minecraft.getInstance().world.func_234923_W_(); // dim = Minecraft.getInstance().world.dimension();
dim = null;
} }
EntityIDDimPair(int id, RegistryKey<World> dim) { EntityIDDimPair(int id, RegistryKey<World> dim) {
@ -20,8 +21,8 @@ public class EntityIDDimPair {
} }
EntityIDDimPair(Entity entity) { EntityIDDimPair(Entity entity) {
id = entity.getEntityId(); id = entity.getId();
dim = entity.getEntityWorld().func_234923_W_(); dim = entity.level.dimension();
} }
public Entity getEntity() { public Entity getEntity() {

View file

@ -202,23 +202,23 @@ public class EntityInfo
public EffectInstance getPotionEffect(int duration, int amplifier) { public EffectInstance getPotionEffect(int duration, int amplifier) {
switch(this) { switch(this) {
case SPEED: case SPEED:
return new EffectInstance(Effects.SPEED, duration, amplifier); return new EffectInstance(Effects.MOVEMENT_SPEED, duration, amplifier);
case SLOW: case SLOW:
return new EffectInstance(Effects.SLOWNESS, duration, amplifier); return new EffectInstance(Effects.MOVEMENT_SLOWDOWN, duration, amplifier);
case HASTE: case HASTE:
return new EffectInstance(Effects.HASTE, duration, amplifier); return new EffectInstance(Effects.DIG_SPEED, duration, amplifier);
case MINING_FATIGUE: case MINING_FATIGUE:
return new EffectInstance(Effects.MINING_FATIGUE, duration, amplifier); return new EffectInstance(Effects.DIG_SLOWDOWN, duration, amplifier);
case STRENGTH: case STRENGTH:
return new EffectInstance(Effects.STRENGTH, duration, amplifier); return new EffectInstance(Effects.DAMAGE_BOOST, duration, amplifier);
case JUMP_BOOST: case JUMP_BOOST:
return new EffectInstance(Effects.JUMP_BOOST, duration, amplifier); return new EffectInstance(Effects.JUMP, duration, amplifier);
case NAUSEA: case NAUSEA:
return new EffectInstance(Effects.NAUSEA, duration, amplifier); return new EffectInstance(Effects.CONFUSION, duration, amplifier);
case REGENERATION: case REGENERATION:
return new EffectInstance(Effects.REGENERATION, duration, amplifier); return new EffectInstance(Effects.REGENERATION, duration, amplifier);
case RESISTANCE: case RESISTANCE:
return new EffectInstance(Effects.RESISTANCE, duration, amplifier); return new EffectInstance(Effects.DAMAGE_RESISTANCE, duration, amplifier);
case FIRE_RESISTANCE: case FIRE_RESISTANCE:
return new EffectInstance(Effects.FIRE_RESISTANCE, duration, amplifier); return new EffectInstance(Effects.FIRE_RESISTANCE, duration, amplifier);
case WATER_BREATHING: case WATER_BREATHING:
@ -276,12 +276,12 @@ public class EntityInfo
{ {
if(this == FIRE) if(this == FIRE)
{ {
entity.setFire(duration / 20); entity.setSecondsOnFire(duration / 20);
return; return;
} }
else if(this != UNKNOWN) else if(this != UNKNOWN)
{ {
entity.addPotionEffect(getPotionEffect(duration, amplifier)); entity.addEffect(getPotionEffect(duration, amplifier));
} }
} }

View file

@ -9,13 +9,13 @@ public class PlayerJoinEventHandler
@SubscribeEvent @SubscribeEvent
public void entityJoinHandler(EntityJoinWorldEvent event) public void entityJoinHandler(EntityJoinWorldEvent event)
{ {
if(event.getWorld().isRemote) if(event.getWorld().isClientSide)
{ {
return; return;
} }
if(event.getEntity() instanceof PlayerEntity && TurnBasedMinecraftMod.proxy.getConfig().getBattleDisabledForAll()) if(event.getEntity() instanceof PlayerEntity && TurnBasedMinecraftMod.proxy.getConfig().getBattleDisabledForAll())
{ {
TurnBasedMinecraftMod.proxy.getConfig().addBattleIgnoringPlayer(event.getEntity().getEntityId()); TurnBasedMinecraftMod.proxy.getConfig().addBattleIgnoringPlayer(event.getEntity().getId());
} }
} }
} }

View file

@ -35,7 +35,7 @@ public class TurnBasedMinecraftMod
{ {
public static final String MODID = "com_burnedkirby_turnbasedminecraft"; public static final String MODID = "com_burnedkirby_turnbasedminecraft";
public static final String NAME = "Turn Based Minecraft Mod"; public static final String NAME = "Turn Based Minecraft Mod";
public static final String VERSION = "1.16"; public static final String VERSION = "1.17";
public static final String CONFIG_FILENAME = "TBM_Config.toml"; public static final String CONFIG_FILENAME = "TBM_Config.toml";
public static final String DEFAULT_CONFIG_FILENAME = "TBM_Config_DEFAULT.toml"; public static final String DEFAULT_CONFIG_FILENAME = "TBM_Config_DEFAULT.toml";
public static final String CONFIG_DIRECTORY = "config/TurnBasedMinecraft/"; public static final String CONFIG_DIRECTORY = "config/TurnBasedMinecraft/";
@ -76,7 +76,7 @@ public class TurnBasedMinecraftMod
private void firstInit(final FMLCommonSetupEvent event) private void firstInit(final FMLCommonSetupEvent event)
{ {
proxy = DistExecutor.safeRunForDist(()->()->new ClientProxy(), ()->()->new CommonProxy()); proxy = DistExecutor.safeRunForDist(()-> ClientProxy::new, ()-> CommonProxy::new);
proxy.setLogger(logger); proxy.setLogger(logger);
proxy.initialize(); proxy.initialize();
@ -150,43 +150,43 @@ public class TurnBasedMinecraftMod
// register commands // register commands
// tbm-disable // tbm-disable
event.getServer().getCommandManager().getDispatcher().register( event.getServer().getCommands().getDispatcher().register(
Commands.literal("tbm-disable") Commands.literal("tbm-disable")
.requires(c -> { .requires(c -> {
return !proxy.getConfig().getIfOnlyOPsCanDisableTurnBasedForSelf() || c.hasPermissionLevel(2); return !proxy.getConfig().getIfOnlyOPsCanDisableTurnBasedForSelf() || c.hasPermission(2);
}) })
.executes( c -> { .executes( c -> {
proxy.getConfig().addBattleIgnoringPlayer(c.getSource().asPlayer().getEntityId()); proxy.getConfig().addBattleIgnoringPlayer(c.getSource().getPlayerOrException().getId());
c.getSource().sendFeedback(new StringTextComponent("Disabled turn-based-combat for current player"), true); c.getSource().sendSuccess(new StringTextComponent("Disabled turn-based-combat for current player"), true);
return 1; return 1;
})); }));
// tbm-disable-all // tbm-disable-all
event.getServer().getCommandManager().getDispatcher().register( event.getServer().getCommands().getDispatcher().register(
Commands.literal("tbm-disable-all") Commands.literal("tbm-disable-all")
.requires(c -> { .requires(c -> {
return c.hasPermissionLevel(2); return c.hasPermission(2);
}) })
.executes(c -> { .executes(c -> {
proxy.getConfig().setBattleDisabledForAll(true); proxy.getConfig().setBattleDisabledForAll(true);
for(ServerPlayerEntity player : c.getSource().getServer().getPlayerList().getPlayers()) { for(ServerPlayerEntity player : c.getSource().getServer().getPlayerList().getPlayers()) {
proxy.getConfig().addBattleIgnoringPlayer(player.getEntityId()); proxy.getConfig().addBattleIgnoringPlayer(player.getId());
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP disabled turn-based-combat for everyone")); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP disabled turn-based-combat for everyone"));
} }
return 1; return 1;
})); }));
// tbm-enable // tbm-enable
event.getServer().getCommandManager().getDispatcher().register( event.getServer().getCommands().getDispatcher().register(
Commands.literal("tbm-enable") Commands.literal("tbm-enable")
.requires(c -> !proxy.getConfig().getIfOnlyOPsCanDisableTurnBasedForSelf() || c.hasPermissionLevel(2)) .requires(c -> !proxy.getConfig().getIfOnlyOPsCanDisableTurnBasedForSelf() || c.hasPermission(2))
.executes(c -> { .executes(c -> {
proxy.getConfig().removeBattleIgnoringPlayer(c.getSource().asPlayer().getEntityId()); proxy.getConfig().removeBattleIgnoringPlayer(c.getSource().getPlayerOrException().getId());
c.getSource().sendFeedback(new StringTextComponent("Enabled turn-based-combat for current player"), true); c.getSource().sendSuccess(new StringTextComponent("Enabled turn-based-combat for current player"), true);
return 1; return 1;
})); }));
// tbm-enable-all // tbm-enable-all
event.getServer().getCommandManager().getDispatcher().register( event.getServer().getCommands().getDispatcher().register(
Commands.literal("tbm-enable-all") Commands.literal("tbm-enable-all")
.requires(c -> c.hasPermissionLevel(2)) .requires(c -> c.hasPermission(2))
.executes(c -> { .executes(c -> {
proxy.getConfig().setBattleDisabledForAll(false); proxy.getConfig().setBattleDisabledForAll(false);
proxy.getConfig().clearBattleIgnoringPlayers(); proxy.getConfig().clearBattleIgnoringPlayers();
@ -196,36 +196,36 @@ public class TurnBasedMinecraftMod
return 1; return 1;
})); }));
// tbm-set-enable // tbm-set-enable
event.getServer().getCommandManager().getDispatcher().register( event.getServer().getCommands().getDispatcher().register(
Commands.literal("tbm-set-enable") Commands.literal("tbm-set-enable")
.requires(c -> c.hasPermissionLevel(2)) .requires(c -> c.hasPermission(2))
.then(Commands.argument("targets", EntityArgument.players()).executes(c -> { .then(Commands.argument("targets", EntityArgument.players()).executes(c -> {
for(ServerPlayerEntity player : EntityArgument.getPlayers(c, "targets")) { for(ServerPlayerEntity player : EntityArgument.getPlayers(c, "targets")) {
proxy.getConfig().addBattleIgnoringPlayer(player.getEntityId()); proxy.getConfig().addBattleIgnoringPlayer(player.getId());
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP enabled turn-based-combat for you")); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP enabled turn-based-combat for you"));
c.getSource().sendFeedback(new StringTextComponent("Enabled turn-based-combat for " + player.getDisplayName().getUnformattedComponentText()), true); c.getSource().sendSuccess(new StringTextComponent("Enabled turn-based-combat for " + player.getDisplayName().getString()), true);
} }
return 1; return 1;
}))); })));
// tbm-set-disable // tbm-set-disable
event.getServer().getCommandManager().getDispatcher().register( event.getServer().getCommands().getDispatcher().register(
Commands.literal("tbm-set-disable") Commands.literal("tbm-set-disable")
.requires(c -> c.hasPermissionLevel(2)) .requires(c -> c.hasPermission(2))
.then(Commands.argument("targets", EntityArgument.players()).executes(c -> { .then(Commands.argument("targets", EntityArgument.players()).executes(c -> {
for(ServerPlayerEntity player : EntityArgument.getPlayers(c, "targets")) { for(ServerPlayerEntity player : EntityArgument.getPlayers(c, "targets")) {
proxy.getConfig().removeBattleIgnoringPlayer(player.getEntityId()); proxy.getConfig().removeBattleIgnoringPlayer(player.getId());
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP disabled turn-based-combat for you")); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP disabled turn-based-combat for you"));
c.getSource().sendFeedback(new StringTextComponent("Disabled turn-based-combat for " + player.getDisplayName().getUnformattedComponentText()), true); c.getSource().sendSuccess(new StringTextComponent("Disabled turn-based-combat for " + player.getDisplayName().getString()), true);
} }
return 1; return 1;
}))); })));
// tbm-edit // tbm-edit
event.getServer().getCommandManager().getDispatcher().register( event.getServer().getCommands().getDispatcher().register(
Commands.literal("tbm-edit") Commands.literal("tbm-edit")
.requires(c -> c.hasPermissionLevel(2)) .requires(c -> c.hasPermission(2))
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if(editingInfo != null) { } else if(editingInfo != null) {
@ -233,20 +233,20 @@ public class TurnBasedMinecraftMod
} else { } else {
proxy.setEditingPlayer(player); proxy.setEditingPlayer(player);
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
logger.info("Begin editing TBM Entity for player \"" + player.getDisplayName().getUnformattedComponentText() + "\" (\"" + c.getSource().getName() + "\")"); logger.info("Begin editing TBM Entity for player \"" + player.getDisplayName().getString() + "\" (\"" + c.getSource().getDisplayName() + "\")");
} }
return 1; return 1;
}) })
.then(Commands.literal("finish") .then(Commands.literal("finish")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
if(!proxy.getConfig().editEntityEntry(editingInfo.entityInfo)) { if(!proxy.getConfig().editEntityEntry(editingInfo.entityInfo)) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("An error occurred while attempting to save an entry to the config")); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("An error occurred while attempting to save an entry to the config"));
proxy.removeEditingInfo(player.getEntityId()); proxy.removeEditingInfo(player.getId());
} else { } else {
proxy.removeEditingInfo(player.getEntityId()); proxy.removeEditingInfo(player.getId());
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("Entity info saved in config and loaded.")); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("Entity info saved in config and loaded."));
} }
} else if(editingInfo != null) { } else if(editingInfo != null) {
@ -259,18 +259,18 @@ public class TurnBasedMinecraftMod
})) }))
.then(Commands.literal("cancel") .then(Commands.literal("cancel")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null) { if(editingInfo != null) {
proxy.removeEditingInfo(player.getEntityId()); proxy.removeEditingInfo(player.getId());
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("Cancelled editing entry.")); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("Cancelled editing entry."));
} }
return 1; return 1;
})) }))
.then(Commands.literal("custom") .then(Commands.literal("custom")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
Message exceptionMessage = new LiteralMessage("Invalid action for tbm-edit"); Message exceptionMessage = new LiteralMessage("Invalid action for tbm-edit");
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage); throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
@ -278,16 +278,16 @@ public class TurnBasedMinecraftMod
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
proxy.setEditingPlayer(player); proxy.setEditingPlayer(player);
proxy.getEditingInfo(player.getEntityId()).isEditingCustomName = true; proxy.getEditingInfo(player.getId()).isEditingCustomName = true;
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
logger.info("Begin editing custom TBM Entity for player \"" + player.getDisplayName().getUnformattedComponentText() + "\" (\"" + c.getSource().getName() + "\")"); logger.info("Begin editing custom TBM Entity for player \"" + player.getDisplayName().getString() + "\" (\"" + c.getSource().getDisplayName() + "\")");
} }
return 1; return 1;
})) }))
.then(Commands.literal("edit") .then(Commands.literal("edit")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if(editingInfo != null){ } else if(editingInfo != null){
@ -300,8 +300,8 @@ public class TurnBasedMinecraftMod
}) })
.then(Commands.literal("ignoreBattle") .then(Commands.literal("ignoreBattle")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_IGNORE_BATTLE)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_IGNORE_BATTLE));
} else if(editingInfo != null) { } else if(editingInfo != null) {
@ -314,8 +314,8 @@ public class TurnBasedMinecraftMod
}) })
.then(Commands.argument("ignoreBattle", BoolArgumentType.bool()) .then(Commands.argument("ignoreBattle", BoolArgumentType.bool())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
boolean ignoreBattle = BoolArgumentType.getBool(c, "ignoreBattle"); boolean ignoreBattle = BoolArgumentType.getBool(c, "ignoreBattle");
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
editingInfo.entityInfo.ignoreBattle = ignoreBattle; editingInfo.entityInfo.ignoreBattle = ignoreBattle;
@ -331,8 +331,8 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("attackPower") .then(Commands.literal("attackPower")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_POWER)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_POWER));
} else if(editingInfo != null) { } else if(editingInfo != null) {
@ -345,8 +345,8 @@ public class TurnBasedMinecraftMod
}) })
.then(Commands.argument("attackPower", IntegerArgumentType.integer()) .then(Commands.argument("attackPower", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int attackPower = IntegerArgumentType.getInteger(c, "attackPower"); int attackPower = IntegerArgumentType.getInteger(c, "attackPower");
if(attackPower < 0) { if(attackPower < 0) {
attackPower = 0; attackPower = 0;
@ -365,8 +365,8 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("attackProbability") .then(Commands.literal("attackProbability")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_PROBABILITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_PROBABILITY));
} else if(editingInfo != null) { } else if(editingInfo != null) {
@ -379,8 +379,8 @@ public class TurnBasedMinecraftMod
}) })
.then(Commands.argument("attackProbability", IntegerArgumentType.integer()) .then(Commands.argument("attackProbability", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int attackProbability = IntegerArgumentType.getInteger(c, "attackProbability"); int attackProbability = IntegerArgumentType.getInteger(c, "attackProbability");
if(attackProbability < 0) { if(attackProbability < 0) {
attackProbability = 0; attackProbability = 0;
@ -401,8 +401,8 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("attackVariance") .then(Commands.literal("attackVariance")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_VARIANCE)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_VARIANCE));
} else if(editingInfo != null) { } else if(editingInfo != null) {
@ -415,8 +415,8 @@ public class TurnBasedMinecraftMod
}) })
.then(Commands.argument("attackVariance", IntegerArgumentType.integer()) .then(Commands.argument("attackVariance", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int attackVariance = IntegerArgumentType.getInteger(c, "attackVariance"); int attackVariance = IntegerArgumentType.getInteger(c, "attackVariance");
if(attackVariance < 0) { if(attackVariance < 0) {
attackVariance = 0; attackVariance = 0;
@ -435,8 +435,8 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("attackEffect") .then(Commands.literal("attackEffect")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT));
} else if(editingInfo != null) { } else if(editingInfo != null) {
@ -449,8 +449,8 @@ public class TurnBasedMinecraftMod
}) })
.then(Commands.argument("attackEffect", StringArgumentType.word()) .then(Commands.argument("attackEffect", StringArgumentType.word())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
EntityInfo.Effect effect = EntityInfo.Effect.fromString(StringArgumentType.getString(c, "attackEffect")); EntityInfo.Effect effect = EntityInfo.Effect.fromString(StringArgumentType.getString(c, "attackEffect"));
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
editingInfo.entityInfo.attackEffect = effect; editingInfo.entityInfo.attackEffect = effect;
@ -466,8 +466,8 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("attackEffectProbability") .then(Commands.literal("attackEffectProbability")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT_PROBABILITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT_PROBABILITY));
} else if(editingInfo != null) { } else if(editingInfo != null) {
@ -480,8 +480,8 @@ public class TurnBasedMinecraftMod
}) })
.then(Commands.argument("attackEffectProbability", IntegerArgumentType.integer()) .then(Commands.argument("attackEffectProbability", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int attackEffectProbability = IntegerArgumentType.getInteger(c, "attackEffectProbability"); int attackEffectProbability = IntegerArgumentType.getInteger(c, "attackEffectProbability");
if(attackEffectProbability < 0) { if(attackEffectProbability < 0) {
attackEffectProbability = 0; attackEffectProbability = 0;
@ -502,8 +502,8 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("defenseDamage") .then(Commands.literal("defenseDamage")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE));
} else if(editingInfo != null) { } else if(editingInfo != null) {
@ -516,8 +516,8 @@ public class TurnBasedMinecraftMod
}) })
.then(Commands.argument("defenseDamage", IntegerArgumentType.integer()) .then(Commands.argument("defenseDamage", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int defenseDamage = IntegerArgumentType.getInteger(c, "defenseDamage"); int defenseDamage = IntegerArgumentType.getInteger(c, "defenseDamage");
if(defenseDamage < 0) { if(defenseDamage < 0) {
defenseDamage = 0; defenseDamage = 0;
@ -536,8 +536,8 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("defenseDamageProbability") .then(Commands.literal("defenseDamageProbability")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE_PROBABILITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE_PROBABILITY));
} else if(editingInfo != null) { } else if(editingInfo != null) {
@ -550,8 +550,8 @@ public class TurnBasedMinecraftMod
}) })
.then(Commands.argument("defenseDamageProbability", IntegerArgumentType.integer()) .then(Commands.argument("defenseDamageProbability", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int defenseDamageProbability = IntegerArgumentType.getInteger(c, "defenseDamageProbability"); int defenseDamageProbability = IntegerArgumentType.getInteger(c, "defenseDamageProbability");
if(defenseDamageProbability < 0) { if(defenseDamageProbability < 0) {
defenseDamageProbability = 0; defenseDamageProbability = 0;
@ -572,8 +572,8 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("evasion") .then(Commands.literal("evasion")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_EVASION)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_EVASION));
} else if(editingInfo != null) { } else if(editingInfo != null) {
@ -586,8 +586,8 @@ public class TurnBasedMinecraftMod
}) })
.then(Commands.argument("evasion", IntegerArgumentType.integer()) .then(Commands.argument("evasion", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int evasion = IntegerArgumentType.getInteger(c, "evasion"); int evasion = IntegerArgumentType.getInteger(c, "evasion");
if(evasion < 0) { if(evasion < 0) {
evasion = 0; evasion = 0;
@ -608,8 +608,8 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("speed") .then(Commands.literal("speed")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SPEED)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SPEED));
} else if(editingInfo != null) { } else if(editingInfo != null) {
@ -622,8 +622,8 @@ public class TurnBasedMinecraftMod
}) })
.then(Commands.argument("speed", IntegerArgumentType.integer()) .then(Commands.argument("speed", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int speed = IntegerArgumentType.getInteger(c, "speed"); int speed = IntegerArgumentType.getInteger(c, "speed");
if(speed < 0) { if(speed < 0) {
speed = 0; speed = 0;
@ -642,8 +642,8 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("category") .then(Commands.literal("category")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_CATEGORY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_CATEGORY));
} else if(editingInfo != null) { } else if(editingInfo != null) {
@ -656,8 +656,8 @@ public class TurnBasedMinecraftMod
}) })
.then(Commands.argument("category", StringArgumentType.word()) .then(Commands.argument("category", StringArgumentType.word())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
String category = StringArgumentType.getString(c, "category"); String category = StringArgumentType.getString(c, "category");
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
editingInfo.entityInfo.category = category; editingInfo.entityInfo.category = category;
@ -673,8 +673,8 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("decisionAttack") .then(Commands.literal("decisionAttack")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_ATTACK)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_ATTACK));
} else if(editingInfo != null) { } else if(editingInfo != null) {
@ -687,8 +687,8 @@ public class TurnBasedMinecraftMod
}) })
.then(Commands.argument("decisionAttack", IntegerArgumentType.integer()) .then(Commands.argument("decisionAttack", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int decisionAttack = IntegerArgumentType.getInteger(c, "decisionAttack"); int decisionAttack = IntegerArgumentType.getInteger(c, "decisionAttack");
if(decisionAttack < 0) { if(decisionAttack < 0) {
decisionAttack = 0; decisionAttack = 0;
@ -709,8 +709,8 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("decisionDefend") .then(Commands.literal("decisionDefend")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_DEFEND)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_DEFEND));
} else if(editingInfo != null) { } else if(editingInfo != null) {
@ -723,8 +723,8 @@ public class TurnBasedMinecraftMod
}) })
.then(Commands.argument("decisionDefend", IntegerArgumentType.integer()) .then(Commands.argument("decisionDefend", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int decisionDefend = IntegerArgumentType.getInteger(c, "decisionDefend"); int decisionDefend = IntegerArgumentType.getInteger(c, "decisionDefend");
if(decisionDefend < 0) { if(decisionDefend < 0) {
decisionDefend = 0; decisionDefend = 0;
@ -745,8 +745,8 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("decisionFlee") .then(Commands.literal("decisionFlee")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_FLEE)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_FLEE));
} else if(editingInfo != null) { } else if(editingInfo != null) {
@ -759,8 +759,8 @@ public class TurnBasedMinecraftMod
}) })
.then(Commands.argument("decisionFlee", IntegerArgumentType.integer()) .then(Commands.argument("decisionFlee", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer(); ServerPlayerEntity player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int decisionFlee = IntegerArgumentType.getInteger(c, "decisionFlee"); int decisionFlee = IntegerArgumentType.getInteger(c, "decisionFlee");
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
editingInfo.entityInfo.decisionFlee = decisionFlee; editingInfo.entityInfo.decisionFlee = decisionFlee;

View file

@ -39,9 +39,9 @@ public class Utility
public static boolean doesPlayerHaveArrows(PlayerEntity player) public static boolean doesPlayerHaveArrows(PlayerEntity player)
{ {
for(int i = 0; i < player.inventory.getSizeInventory(); ++i) for(int i = 0; i < player.inventory.getContainerSize(); ++i)
{ {
if(player.inventory.getStackInSlot(i).getItem() instanceof ArrowItem) if(player.inventory.getItem(i).getItem() instanceof ArrowItem)
{ {
return true; return true;
} }
@ -51,15 +51,15 @@ public class Utility
public static double distanceBetweenEntities(Entity a, Entity b) public static double distanceBetweenEntities(Entity a, Entity b)
{ {
return Math.sqrt(Math.pow(a.getPosX() - b.getPosX(), 2.0) + Math.pow(a.getPosY()- b.getPosY(), 2.0) + Math.pow(a.getPosZ()- b.getPosZ(), 2.0)); return Math.sqrt(Math.pow(a.getX() - b.getX(), 2.0) + Math.pow(a.getY()- b.getY(), 2.0) + Math.pow(a.getZ()- b.getZ(), 2.0));
} }
public static String serializeDimension(RegistryKey<World> dimObject) { public static String serializeDimension(RegistryKey<World> dimObject) {
return dimObject.func_240901_a_().toString(); return dimObject.getRegistryName().toString();
} }
public static RegistryKey<World> deserializeDimension(String dimString) { public static RegistryKey<World> deserializeDimension(String dimString) {
ResourceLocation dimRes = new ResourceLocation(dimString); ResourceLocation dimRes = new ResourceLocation(dimString);
return RegistryKey.func_240903_a_(Registry.field_239699_ae_, dimRes); return RegistryKey.create(Registry.DIMENSION_REGISTRY, dimRes);
} }
} }

View file

@ -42,7 +42,7 @@ public class PacketBattleDecision
if(b != null) if(b != null)
{ {
ServerPlayerEntity player = ctx.get().getSender(); ServerPlayerEntity player = ctx.get().getSender();
b.setDecision(player.getEntityId(), pkt.decision, pkt.targetIDOrItemID); b.setDecision(player.getId(), pkt.decision, pkt.targetIDOrItemID);
} }
}); });
ctx.get().setPacketHandled(true); ctx.get().setPacketHandled(true);

View file

@ -68,7 +68,7 @@ public class PacketBattleInfo
TurnBasedMinecraftMod.proxy.getLocalBattle().clearCombatants(); TurnBasedMinecraftMod.proxy.getLocalBattle().clearCombatants();
for(Integer id : pkt.sideA) for(Integer id : pkt.sideA)
{ {
Entity e = Minecraft.getInstance().world.getEntityByID(id); Entity e = Minecraft.getInstance().level.getEntity(id);
if(e != null) if(e != null)
{ {
TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideA(e); TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideA(e);
@ -76,7 +76,7 @@ public class PacketBattleInfo
} }
for(Integer id : pkt.sideB) for(Integer id : pkt.sideB)
{ {
Entity e = Minecraft.getInstance().world.getEntityByID(id); Entity e = Minecraft.getInstance().level.getEntity(id);
if(e != null) if(e != null)
{ {
TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideB(e); TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideB(e);

View file

@ -136,9 +136,9 @@ public class PacketBattleMessage
buf.writeInt(pkt.messageType.getValue()); buf.writeInt(pkt.messageType.getValue());
buf.writeInt(pkt.entityIDFrom); buf.writeInt(pkt.entityIDFrom);
buf.writeInt(pkt.entityIDTo); buf.writeInt(pkt.entityIDTo);
buf.writeString(Utility.serializeDimension(pkt.dimension)); buf.writeUtf(Utility.serializeDimension(pkt.dimension));
buf.writeInt(pkt.amount); buf.writeInt(pkt.amount);
buf.writeString(pkt.custom); buf.writeUtf(pkt.custom);
} }
public static PacketBattleMessage decode(PacketBuffer buf) { public static PacketBattleMessage decode(PacketBuffer buf) {
@ -147,9 +147,9 @@ public class PacketBattleMessage
buf.readInt()), buf.readInt()),
buf.readInt(), buf.readInt(),
buf.readInt(), buf.readInt(),
Utility.deserializeDimension(buf.readString()), Utility.deserializeDimension(buf.readUtf()),
buf.readInt(), buf.readInt(),
buf.readString()); buf.readUtf());
} }
public static class Handler { public static class Handler {
@ -301,27 +301,27 @@ public class PacketBattleMessage
break; break;
case CREEPER_WAIT: { case CREEPER_WAIT: {
StringTextComponent prefix = new StringTextComponent("TBM: "); StringTextComponent prefix = new StringTextComponent("TBM: ");
prefix.func_230530_a_(prefix.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240713_a_(true)); prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
StringTextComponent message = new StringTextComponent(from + " is charging up!"); StringTextComponent message = new StringTextComponent(from + " is charging up!");
message.func_230530_a_(message.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00))); message.setStyle(message.getStyle().withColor(Color.fromRgb(0xFFFFFF00)));
prefix.getSiblings().add(message); prefix.getSiblings().add(message);
TurnBasedMinecraftMod.proxy.displayTextComponent(prefix); TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
} }
break; break;
case CREEPER_WAIT_FINAL: { case CREEPER_WAIT_FINAL: {
StringTextComponent prefix = new StringTextComponent("TBM: "); StringTextComponent prefix = new StringTextComponent("TBM: ");
prefix.func_230530_a_(prefix.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240713_a_(true)); prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
StringTextComponent message = new StringTextComponent(from + " is about to explode!"); StringTextComponent message = new StringTextComponent(from + " is about to explode!");
message.func_230530_a_(message.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFF5050))); message.setStyle(message.getStyle().withColor(Color.fromRgb(0xFFFF5050)));
prefix.getSiblings().add(message); prefix.getSiblings().add(message);
TurnBasedMinecraftMod.proxy.displayTextComponent(prefix); TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
} }
break; break;
case CREEPER_EXPLODE: { case CREEPER_EXPLODE: {
StringTextComponent prefix = new StringTextComponent("TBM: "); StringTextComponent prefix = new StringTextComponent("TBM: ");
prefix.func_230530_a_(prefix.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240713_a_(true)); prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
StringTextComponent message = new StringTextComponent(from + " exploded!"); StringTextComponent message = new StringTextComponent(from + " exploded!");
message.func_230530_a_(message.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFF0000))); message.setStyle(message.getStyle().withColor(Color.fromRgb(0xFFFF0000)));
prefix.getSiblings().add(message); prefix.getSiblings().add(message);
TurnBasedMinecraftMod.proxy.displayTextComponent(prefix); TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
} }

View file

@ -85,48 +85,48 @@ public class PacketEditingMessage
public static void encode(PacketEditingMessage pkt, PacketBuffer buf) { public static void encode(PacketEditingMessage pkt, PacketBuffer buf) {
buf.writeInt(pkt.type.getValue()); buf.writeInt(pkt.type.getValue());
if(pkt.entityInfo.classType != null) { if(pkt.entityInfo.classType != null) {
buf.writeString(pkt.entityInfo.classType.getName()); buf.writeUtf(pkt.entityInfo.classType.getName());
} else { } else {
buf.writeString("unknown"); buf.writeUtf("unknown");
} }
buf.writeBoolean(pkt.entityInfo.ignoreBattle); buf.writeBoolean(pkt.entityInfo.ignoreBattle);
buf.writeInt(pkt.entityInfo.attackPower); buf.writeInt(pkt.entityInfo.attackPower);
buf.writeInt(pkt.entityInfo.attackProbability); buf.writeInt(pkt.entityInfo.attackProbability);
buf.writeInt(pkt.entityInfo.attackVariance); buf.writeInt(pkt.entityInfo.attackVariance);
buf.writeString(pkt.entityInfo.attackEffect.toString()); buf.writeUtf(pkt.entityInfo.attackEffect.toString());
buf.writeInt(pkt.entityInfo.attackEffectProbability); buf.writeInt(pkt.entityInfo.attackEffectProbability);
buf.writeInt(pkt.entityInfo.defenseDamage); buf.writeInt(pkt.entityInfo.defenseDamage);
buf.writeInt(pkt.entityInfo.defenseDamageProbability); buf.writeInt(pkt.entityInfo.defenseDamageProbability);
buf.writeInt(pkt.entityInfo.evasion); buf.writeInt(pkt.entityInfo.evasion);
buf.writeInt(pkt.entityInfo.speed); buf.writeInt(pkt.entityInfo.speed);
buf.writeString(pkt.entityInfo.category); buf.writeUtf(pkt.entityInfo.category);
buf.writeInt(pkt.entityInfo.decisionAttack); buf.writeInt(pkt.entityInfo.decisionAttack);
buf.writeInt(pkt.entityInfo.decisionDefend); buf.writeInt(pkt.entityInfo.decisionDefend);
buf.writeInt(pkt.entityInfo.decisionFlee); buf.writeInt(pkt.entityInfo.decisionFlee);
buf.writeString(pkt.entityInfo.customName); buf.writeUtf(pkt.entityInfo.customName);
} }
public static PacketEditingMessage decode(PacketBuffer buf) { public static PacketEditingMessage decode(PacketBuffer buf) {
Type type = Type.valueOf(buf.readInt()); Type type = Type.valueOf(buf.readInt());
EntityInfo einfo = new EntityInfo(); EntityInfo einfo = new EntityInfo();
try { try {
einfo.classType = einfo.getClass().getClassLoader().loadClass(buf.readString()); einfo.classType = einfo.getClass().getClassLoader().loadClass(buf.readUtf());
} catch (ClassNotFoundException e) { /* ignored */ } } catch (ClassNotFoundException e) { /* ignored */ }
einfo.ignoreBattle = buf.readBoolean(); einfo.ignoreBattle = buf.readBoolean();
einfo.attackPower = buf.readInt(); einfo.attackPower = buf.readInt();
einfo.attackProbability = buf.readInt(); einfo.attackProbability = buf.readInt();
einfo.attackVariance = buf.readInt(); einfo.attackVariance = buf.readInt();
einfo.attackEffect = EntityInfo.Effect.fromString(buf.readString()); einfo.attackEffect = EntityInfo.Effect.fromString(buf.readUtf());
einfo.attackEffectProbability = buf.readInt(); einfo.attackEffectProbability = buf.readInt();
einfo.defenseDamage = buf.readInt(); einfo.defenseDamage = buf.readInt();
einfo.defenseDamageProbability = buf.readInt(); einfo.defenseDamageProbability = buf.readInt();
einfo.evasion = buf.readInt(); einfo.evasion = buf.readInt();
einfo.speed = buf.readInt(); einfo.speed = buf.readInt();
einfo.category = buf.readString(); einfo.category = buf.readUtf();
einfo.decisionAttack = buf.readInt(); einfo.decisionAttack = buf.readInt();
einfo.decisionDefend = buf.readInt(); einfo.decisionDefend = buf.readInt();
einfo.decisionFlee = buf.readInt(); einfo.decisionFlee = buf.readInt();
einfo.customName = buf.readString(); einfo.customName = buf.readUtf();
return new PacketEditingMessage(type, einfo); return new PacketEditingMessage(type, einfo);
} }
@ -138,12 +138,12 @@ public class PacketEditingMessage
case ATTACK_ENTITY: case ATTACK_ENTITY:
{ {
StringTextComponent prefix = new StringTextComponent("TBM: "); StringTextComponent prefix = new StringTextComponent("TBM: ");
prefix.func_230530_a_(prefix.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240713_a_(true)); prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
StringTextComponent text = new StringTextComponent("Attack the entity you want to edit for TurnBasedMinecraftMod. "); StringTextComponent text = new StringTextComponent("Attack the entity you want to edit for TurnBasedMinecraftMod. ");
text.func_230530_a_(text.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF)).func_240713_a_(false)); text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
StringTextComponent cancel = new StringTextComponent("Cancel"); StringTextComponent cancel = new StringTextComponent("Cancel");
cancel.func_230530_a_(cancel.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFF0000)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit cancel"))); cancel.setStyle(cancel.getStyle().withColor(Color.fromRgb(0xFFFF0000)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit cancel")));
text.getSiblings().add(cancel); text.getSiblings().add(cancel);
prefix.getSiblings().add(text); prefix.getSiblings().add(text);
@ -153,130 +153,130 @@ public class PacketEditingMessage
case PICK_EDIT: case PICK_EDIT:
{ {
StringTextComponent prefix = new StringTextComponent("TBM: "); StringTextComponent prefix = new StringTextComponent("TBM: ");
prefix.func_230530_a_(prefix.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240713_a_(true)); prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
StringTextComponent text = new StringTextComponent("Edit what value? "); StringTextComponent text = new StringTextComponent("Edit what value? ");
text.func_230530_a_(text.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF)).func_240713_a_(false)); text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
StringTextComponent option = new StringTextComponent("IgB"); StringTextComponent option = new StringTextComponent("IgB");
// HoverEvent.Action.field_230550_a_ is probably SHOW_TEXT // HoverEvent.Action.SHOW_TEXT is probably SHOW_TEXT
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle")) option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle"))
.func_240716_a_(new HoverEvent(HoverEvent.Action.field_230550_a_, new StringTextComponent("IgnoreBattle")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("IgnoreBattle"))));
StringTextComponent value = new StringTextComponent("(" + pkt.entityInfo.ignoreBattle + ") "); StringTextComponent value = new StringTextComponent("(" + pkt.entityInfo.ignoreBattle + ") ");
value.func_230530_a_(value.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
option = new StringTextComponent("AP"); option = new StringTextComponent("AP");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackPower")) option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackPower"))
.func_240716_a_(new HoverEvent(HoverEvent.Action.field_230550_a_, new StringTextComponent("AttackPower")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("AttackPower"))));
value = new StringTextComponent("(" + pkt.entityInfo.attackPower + ") "); value = new StringTextComponent("(" + pkt.entityInfo.attackPower + ") ");
value.func_230530_a_(value.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
option = new StringTextComponent("APr"); option = new StringTextComponent("APr");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackProbability")) option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackProbability"))
.func_240716_a_(new HoverEvent(HoverEvent.Action.field_230550_a_, new StringTextComponent("AttackProbability")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("AttackProbability"))));
value = new StringTextComponent("(" + pkt.entityInfo.attackProbability + "%) "); value = new StringTextComponent("(" + pkt.entityInfo.attackProbability + "%) ");
value.func_230530_a_(value.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
option = new StringTextComponent("AV"); option = new StringTextComponent("AV");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackVariance")) option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackVariance"))
.func_240716_a_(new HoverEvent(HoverEvent.Action.field_230550_a_, new StringTextComponent("AttackVariance")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("AttackVariance"))));
value = new StringTextComponent("(" + pkt.entityInfo.attackVariance + ") "); value = new StringTextComponent("(" + pkt.entityInfo.attackVariance + ") ");
value.func_230530_a_(value.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
option = new StringTextComponent("AE"); option = new StringTextComponent("AE");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffect")) option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffect"))
.func_240716_a_(new HoverEvent(HoverEvent.Action.field_230550_a_, new StringTextComponent("AttackEffect")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("AttackEffect"))));
value = new StringTextComponent("(" + pkt.entityInfo.attackEffect.toString() + ") "); value = new StringTextComponent("(" + pkt.entityInfo.attackEffect.toString() + ") ");
value.func_230530_a_(value.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
option = new StringTextComponent("AEPr"); option = new StringTextComponent("AEPr");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffectProbability")) option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffectProbability"))
.func_240716_a_(new HoverEvent(HoverEvent.Action.field_230550_a_, new StringTextComponent("AttackEffectProbability")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("AttackEffectProbability"))));
value = new StringTextComponent("(" + pkt.entityInfo.attackEffectProbability + "%) "); value = new StringTextComponent("(" + pkt.entityInfo.attackEffectProbability + "%) ");
value.func_230530_a_(value.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
option = new StringTextComponent("DD"); option = new StringTextComponent("DD");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamage")) option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamage"))
.func_240716_a_(new HoverEvent(HoverEvent.Action.field_230550_a_, new StringTextComponent("DefenseDamage")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("DefenseDamage"))));
value = new StringTextComponent("(" + pkt.entityInfo.defenseDamage + ") "); value = new StringTextComponent("(" + pkt.entityInfo.defenseDamage + ") ");
value.func_230530_a_(value.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
option = new StringTextComponent("DDPr"); option = new StringTextComponent("DDPr");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamageProbability")) option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamageProbability"))
.func_240716_a_(new HoverEvent(HoverEvent.Action.field_230550_a_, new StringTextComponent("DefenseDamageProbability")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("DefenseDamageProbability"))));
value = new StringTextComponent("(" + pkt.entityInfo.defenseDamageProbability + "%) "); value = new StringTextComponent("(" + pkt.entityInfo.defenseDamageProbability + "%) ");
value.func_230530_a_(value.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
option = new StringTextComponent("E"); option = new StringTextComponent("E");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit evasion")) option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit evasion"))
.func_240716_a_(new HoverEvent(HoverEvent.Action.field_230550_a_, new StringTextComponent("Evasion")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("Evasion"))));
value = new StringTextComponent("(" + pkt.entityInfo.evasion + "%) "); value = new StringTextComponent("(" + pkt.entityInfo.evasion + "%) ");
value.func_230530_a_(value.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
option = new StringTextComponent("S"); option = new StringTextComponent("S");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit speed")) option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit speed"))
.func_240716_a_(new HoverEvent(HoverEvent.Action.field_230550_a_, new StringTextComponent("Speed")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("Speed"))));
value = new StringTextComponent("(" + pkt.entityInfo.speed + ") "); value = new StringTextComponent("(" + pkt.entityInfo.speed + ") ");
value.func_230530_a_(value.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
option = new StringTextComponent("C"); option = new StringTextComponent("C");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category")) option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category"))
.func_240716_a_(new HoverEvent(HoverEvent.Action.field_230550_a_, new StringTextComponent("Category")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("Category"))));
value = new StringTextComponent("(" + pkt.entityInfo.category + ") "); value = new StringTextComponent("(" + pkt.entityInfo.category + ") ");
value.func_230530_a_(value.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
option = new StringTextComponent("DecA"); option = new StringTextComponent("DecA");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionAttack")) option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionAttack"))
.func_240716_a_(new HoverEvent(HoverEvent.Action.field_230550_a_, new StringTextComponent("DecisionAttack")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("DecisionAttack"))));
value = new StringTextComponent("(" + pkt.entityInfo.decisionAttack + "%) "); value = new StringTextComponent("(" + pkt.entityInfo.decisionAttack + "%) ");
value.func_230530_a_(value.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
option = new StringTextComponent("DecD"); option = new StringTextComponent("DecD");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionDefend")) option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionDefend"))
.func_240716_a_(new HoverEvent(HoverEvent.Action.field_230550_a_, new StringTextComponent("DecisionDefend")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("DecisionDefend"))));
value = new StringTextComponent("(" + pkt.entityInfo.decisionDefend + "%) "); value = new StringTextComponent("(" + pkt.entityInfo.decisionDefend + "%) ");
value.func_230530_a_(value.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
option = new StringTextComponent("DecF"); option = new StringTextComponent("DecF");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionFlee")) option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionFlee"))
.func_240716_a_(new HoverEvent(HoverEvent.Action.field_230550_a_, new StringTextComponent("DecisionFlee")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("DecisionFlee"))));
value = new StringTextComponent("(" + pkt.entityInfo.decisionFlee + "%) "); value = new StringTextComponent("(" + pkt.entityInfo.decisionFlee + "%) ");
value.func_230530_a_(value.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
option = new StringTextComponent("Finished Editing"); option = new StringTextComponent("Finished Editing");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit finish"))); option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit finish")));
text.getSiblings().add(option); text.getSiblings().add(option);
text.getSiblings().add(new StringTextComponent(" ")); text.getSiblings().add(new StringTextComponent(" "));
option = new StringTextComponent("Cancel"); option = new StringTextComponent("Cancel");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFF0000)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit cancel"))); option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFF0000)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit cancel")));
text.getSiblings().add(option); text.getSiblings().add(option);
prefix.getSiblings().add(text); prefix.getSiblings().add(text);
@ -286,18 +286,18 @@ public class PacketEditingMessage
case EDIT_IGNORE_BATTLE: case EDIT_IGNORE_BATTLE:
{ {
StringTextComponent prefix = new StringTextComponent("TBM: "); StringTextComponent prefix = new StringTextComponent("TBM: ");
prefix.func_230530_a_(prefix.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240713_a_(true)); prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
StringTextComponent text = new StringTextComponent("ignoreBattle: "); StringTextComponent text = new StringTextComponent("ignoreBattle: ");
text.func_230530_a_(text.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF)).func_240713_a_(false)); text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
StringTextComponent option = new StringTextComponent("true"); StringTextComponent option = new StringTextComponent("true");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle true"))); option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle true")));
text.getSiblings().add(option); text.getSiblings().add(option);
text.getSiblings().add(new StringTextComponent(" ")); text.getSiblings().add(new StringTextComponent(" "));
option = new StringTextComponent("false"); option = new StringTextComponent("false");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFF0000)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle false"))); option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFF0000)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle false")));
text.getSiblings().add(option); text.getSiblings().add(option);
prefix.getSiblings().add(text); prefix.getSiblings().add(text);
@ -307,14 +307,14 @@ public class PacketEditingMessage
case EDIT_ATTACK_POWER: case EDIT_ATTACK_POWER:
{ {
StringTextComponent prefix = new StringTextComponent("TBM: "); StringTextComponent prefix = new StringTextComponent("TBM: ");
prefix.func_230530_a_(prefix.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240713_a_(true)); prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
StringTextComponent text = new StringTextComponent("attackPower: "); StringTextComponent text = new StringTextComponent("attackPower: ");
text.func_230530_a_(text.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF)).func_240713_a_(false)); text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
for(int i = 0; i <= 15; ++i) for(int i = 0; i <= 15; ++i)
{ {
StringTextComponent option = new StringTextComponent(Integer.toString(i)); StringTextComponent option = new StringTextComponent(Integer.toString(i));
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackPower " + Integer.toString(i)))); option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackPower " + Integer.toString(i))));
text.getSiblings().add(option); text.getSiblings().add(option);
if(i < 15) if(i < 15)
{ {
@ -331,14 +331,14 @@ public class PacketEditingMessage
case EDIT_ATTACK_PROBABILITY: case EDIT_ATTACK_PROBABILITY:
{ {
StringTextComponent prefix = new StringTextComponent("TBM: "); StringTextComponent prefix = new StringTextComponent("TBM: ");
prefix.func_230530_a_(prefix.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240713_a_(true)); prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
StringTextComponent text = new StringTextComponent("attackProbability: "); StringTextComponent text = new StringTextComponent("attackProbability: ");
text.func_230530_a_(text.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF)).func_240713_a_(false)); text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
for(int i = 10; i <= 100; i += 10) for(int i = 10; i <= 100; i += 10)
{ {
StringTextComponent option = new StringTextComponent(Integer.toString(i) + "%"); StringTextComponent option = new StringTextComponent(Integer.toString(i) + "%");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackProbability " + Integer.toString(i)))); option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackProbability " + Integer.toString(i))));
text.getSiblings().add(option); text.getSiblings().add(option);
if(i < 100) if(i < 100)
{ {
@ -355,14 +355,14 @@ public class PacketEditingMessage
case EDIT_ATTACK_VARIANCE: case EDIT_ATTACK_VARIANCE:
{ {
StringTextComponent prefix = new StringTextComponent("TBM: "); StringTextComponent prefix = new StringTextComponent("TBM: ");
prefix.func_230530_a_(prefix.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240713_a_(true)); prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
StringTextComponent text = new StringTextComponent("attackVariance: "); StringTextComponent text = new StringTextComponent("attackVariance: ");
text.func_230530_a_(text.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF)).func_240713_a_(false)); text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
for(int i = 0; i <= 10; ++i) for(int i = 0; i <= 10; ++i)
{ {
StringTextComponent option = new StringTextComponent(Integer.toString(i)); StringTextComponent option = new StringTextComponent(Integer.toString(i));
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackVariance " + Integer.toString(i)))); option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackVariance " + Integer.toString(i))));
text.getSiblings().add(option); text.getSiblings().add(option);
if(i < 10) if(i < 10)
{ {
@ -379,14 +379,14 @@ public class PacketEditingMessage
case EDIT_ATTACK_EFFECT: case EDIT_ATTACK_EFFECT:
{ {
StringTextComponent prefix = new StringTextComponent("TBM: "); StringTextComponent prefix = new StringTextComponent("TBM: ");
prefix.func_230530_a_(prefix.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240713_a_(true)); prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
StringTextComponent text = new StringTextComponent("attackEffect: "); StringTextComponent text = new StringTextComponent("attackEffect: ");
text.func_230530_a_(text.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF)).func_240713_a_(false)); text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
for(EntityInfo.Effect e : EntityInfo.Effect.values()) for(EntityInfo.Effect e : EntityInfo.Effect.values())
{ {
StringTextComponent option = new StringTextComponent(e.toString()); StringTextComponent option = new StringTextComponent(e.toString());
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffect " + e.toString()))); option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffect " + e.toString())));
text.getSiblings().add(option); text.getSiblings().add(option);
if(e != EntityInfo.Effect.UNKNOWN) if(e != EntityInfo.Effect.UNKNOWN)
{ {
@ -402,14 +402,14 @@ public class PacketEditingMessage
case EDIT_ATTACK_EFFECT_PROBABILITY: case EDIT_ATTACK_EFFECT_PROBABILITY:
{ {
StringTextComponent prefix = new StringTextComponent("TBM: "); StringTextComponent prefix = new StringTextComponent("TBM: ");
prefix.func_230530_a_(prefix.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240713_a_(true)); prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
StringTextComponent text = new StringTextComponent("attackEffectProbability: "); StringTextComponent text = new StringTextComponent("attackEffectProbability: ");
text.func_230530_a_(text.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF)).func_240713_a_(false)); text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
for(int i = 0; i <= 100; i += 10) for(int i = 0; i <= 100; i += 10)
{ {
StringTextComponent option = new StringTextComponent(Integer.toString(i) + "%"); StringTextComponent option = new StringTextComponent(Integer.toString(i) + "%");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffectProbability " + Integer.toString(i)))); option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffectProbability " + Integer.toString(i))));
text.getSiblings().add(option); text.getSiblings().add(option);
if(i < 100) if(i < 100)
{ {
@ -426,14 +426,14 @@ public class PacketEditingMessage
case EDIT_DEFENSE_DAMAGE: case EDIT_DEFENSE_DAMAGE:
{ {
StringTextComponent prefix = new StringTextComponent("TBM: "); StringTextComponent prefix = new StringTextComponent("TBM: ");
prefix.func_230530_a_(prefix.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240713_a_(true)); prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
StringTextComponent text = new StringTextComponent("defenseDamage: "); StringTextComponent text = new StringTextComponent("defenseDamage: ");
text.func_230530_a_(text.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF)).func_240713_a_(false)); text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
for(int i = 0; i <= 15; ++i) for(int i = 0; i <= 15; ++i)
{ {
StringTextComponent option = new StringTextComponent(Integer.toString(i)); StringTextComponent option = new StringTextComponent(Integer.toString(i));
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamage " + Integer.toString(i)))); option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamage " + Integer.toString(i))));
text.getSiblings().add(option); text.getSiblings().add(option);
if(i < 15) if(i < 15)
{ {
@ -450,14 +450,14 @@ public class PacketEditingMessage
case EDIT_DEFENSE_DAMAGE_PROBABILITY: case EDIT_DEFENSE_DAMAGE_PROBABILITY:
{ {
StringTextComponent prefix = new StringTextComponent("TBM: "); StringTextComponent prefix = new StringTextComponent("TBM: ");
prefix.func_230530_a_(prefix.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240713_a_(true)); prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
StringTextComponent text = new StringTextComponent("defenseDamageProbability: "); StringTextComponent text = new StringTextComponent("defenseDamageProbability: ");
text.func_230530_a_(text.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF)).func_240713_a_(false)); text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
for(int i = 0; i <= 100; i += 10) for(int i = 0; i <= 100; i += 10)
{ {
StringTextComponent option = new StringTextComponent(Integer.toString(i) + "%"); StringTextComponent option = new StringTextComponent(Integer.toString(i) + "%");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamageProbability " + Integer.toString(i)))); option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamageProbability " + Integer.toString(i))));
text.getSiblings().add(option); text.getSiblings().add(option);
if(i < 100) if(i < 100)
{ {
@ -474,14 +474,14 @@ public class PacketEditingMessage
case EDIT_EVASION: case EDIT_EVASION:
{ {
StringTextComponent prefix = new StringTextComponent("TBM: "); StringTextComponent prefix = new StringTextComponent("TBM: ");
prefix.func_230530_a_(prefix.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240713_a_(true)); prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
StringTextComponent text = new StringTextComponent("evasion: "); StringTextComponent text = new StringTextComponent("evasion: ");
text.func_230530_a_(text.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF)).func_240713_a_(false)); text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
for(int i = 0; i <= 100; i += 10) for(int i = 0; i <= 100; i += 10)
{ {
StringTextComponent option = new StringTextComponent(Integer.toString(i) + "%"); StringTextComponent option = new StringTextComponent(Integer.toString(i) + "%");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit evasion " + Integer.toString(i)))); option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit evasion " + Integer.toString(i))));
text.getSiblings().add(option); text.getSiblings().add(option);
if(i < 100) if(i < 100)
{ {
@ -498,14 +498,14 @@ public class PacketEditingMessage
case EDIT_SPEED: case EDIT_SPEED:
{ {
StringTextComponent prefix = new StringTextComponent("TBM: "); StringTextComponent prefix = new StringTextComponent("TBM: ");
prefix.func_230530_a_(prefix.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240713_a_(true)); prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
StringTextComponent text = new StringTextComponent("speed: "); StringTextComponent text = new StringTextComponent("speed: ");
text.func_230530_a_(text.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF)).func_240713_a_(false)); text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
for(int i = 0; i <= 100; i += 10) for(int i = 0; i <= 100; i += 10)
{ {
StringTextComponent option = new StringTextComponent(Integer.toString(i)); StringTextComponent option = new StringTextComponent(Integer.toString(i));
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit speed " + Integer.toString(i)))); option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit speed " + Integer.toString(i))));
text.getSiblings().add(option); text.getSiblings().add(option);
if(i < 100) if(i < 100)
{ {
@ -522,18 +522,18 @@ public class PacketEditingMessage
case EDIT_CATEGORY: case EDIT_CATEGORY:
{ {
StringTextComponent prefix = new StringTextComponent("TBM: "); StringTextComponent prefix = new StringTextComponent("TBM: ");
prefix.func_230530_a_(prefix.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240713_a_(true)); prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
StringTextComponent text = new StringTextComponent("category: "); StringTextComponent text = new StringTextComponent("category: ");
text.func_230530_a_(text.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF)).func_240713_a_(false)); text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
StringTextComponent option = new StringTextComponent("monster"); StringTextComponent option = new StringTextComponent("monster");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category monster"))); option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category monster")));
if(TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("monster")) if(TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("monster"))
{ {
StringTextComponent optionInfo = new StringTextComponent("(battle-"); StringTextComponent optionInfo = new StringTextComponent("(battle-");
optionInfo.func_230530_a_(optionInfo.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); optionInfo.setStyle(optionInfo.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
StringTextComponent optionInfoBool = new StringTextComponent("disabled"); StringTextComponent optionInfoBool = new StringTextComponent("disabled");
optionInfoBool.func_230530_a_(optionInfoBool.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFF0000))); optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(Color.fromRgb(0xFFFF0000)));
optionInfo.getSiblings().add(optionInfoBool); optionInfo.getSiblings().add(optionInfoBool);
optionInfo.getSiblings().add(new StringTextComponent(")")); optionInfo.getSiblings().add(new StringTextComponent(")"));
option.getSiblings().add(optionInfo); option.getSiblings().add(optionInfo);
@ -541,9 +541,9 @@ public class PacketEditingMessage
else else
{ {
StringTextComponent optionInfo = new StringTextComponent("(battle-"); StringTextComponent optionInfo = new StringTextComponent("(battle-");
optionInfo.func_230530_a_(optionInfo.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); optionInfo.setStyle(optionInfo.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
StringTextComponent optionInfoBool = new StringTextComponent("enabled"); StringTextComponent optionInfoBool = new StringTextComponent("enabled");
optionInfoBool.func_230530_a_(optionInfoBool.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00))); optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(Color.fromRgb(0xFF00FF00)));
optionInfo.getSiblings().add(optionInfoBool); optionInfo.getSiblings().add(optionInfoBool);
optionInfo.getSiblings().add(new StringTextComponent(")")); optionInfo.getSiblings().add(new StringTextComponent(")"));
option.getSiblings().add(optionInfo); option.getSiblings().add(optionInfo);
@ -552,13 +552,13 @@ public class PacketEditingMessage
text.getSiblings().add(new StringTextComponent(", ")); text.getSiblings().add(new StringTextComponent(", "));
option = new StringTextComponent("animal"); option = new StringTextComponent("animal");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category animal"))); option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category animal")));
if(TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("animal")) if(TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("animal"))
{ {
StringTextComponent optionInfo = new StringTextComponent("(battle-"); StringTextComponent optionInfo = new StringTextComponent("(battle-");
optionInfo.func_230530_a_(optionInfo.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); optionInfo.setStyle(optionInfo.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
StringTextComponent optionInfoBool = new StringTextComponent("disabled"); StringTextComponent optionInfoBool = new StringTextComponent("disabled");
optionInfoBool.func_230530_a_(optionInfoBool.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFF0000))); optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(Color.fromRgb(0xFFFF0000)));
optionInfo.getSiblings().add(optionInfoBool); optionInfo.getSiblings().add(optionInfoBool);
optionInfo.getSiblings().add(new StringTextComponent(")")); optionInfo.getSiblings().add(new StringTextComponent(")"));
option.getSiblings().add(optionInfo); option.getSiblings().add(optionInfo);
@ -566,9 +566,9 @@ public class PacketEditingMessage
else else
{ {
StringTextComponent optionInfo = new StringTextComponent("(battle-"); StringTextComponent optionInfo = new StringTextComponent("(battle-");
optionInfo.func_230530_a_(optionInfo.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); optionInfo.setStyle(optionInfo.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
StringTextComponent optionInfoBool = new StringTextComponent("enabled"); StringTextComponent optionInfoBool = new StringTextComponent("enabled");
optionInfoBool.func_230530_a_(optionInfoBool.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00))); optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(Color.fromRgb(0xFF00FF00)));
optionInfo.getSiblings().add(optionInfoBool); optionInfo.getSiblings().add(optionInfoBool);
optionInfo.getSiblings().add(new StringTextComponent(")")); optionInfo.getSiblings().add(new StringTextComponent(")"));
option.getSiblings().add(optionInfo); option.getSiblings().add(optionInfo);
@ -577,13 +577,13 @@ public class PacketEditingMessage
text.getSiblings().add(new StringTextComponent(", ")); text.getSiblings().add(new StringTextComponent(", "));
option = new StringTextComponent("passive"); option = new StringTextComponent("passive");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category passive"))); option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category passive")));
if(TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("passive")) if(TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("passive"))
{ {
StringTextComponent optionInfo = new StringTextComponent("(battle-"); StringTextComponent optionInfo = new StringTextComponent("(battle-");
optionInfo.func_230530_a_(optionInfo.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); optionInfo.setStyle(optionInfo.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
StringTextComponent optionInfoBool = new StringTextComponent("disabled"); StringTextComponent optionInfoBool = new StringTextComponent("disabled");
optionInfoBool.func_230530_a_(optionInfoBool.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFF0000))); optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(Color.fromRgb(0xFFFF0000)));
optionInfo.getSiblings().add(optionInfoBool); optionInfo.getSiblings().add(optionInfoBool);
optionInfo.getSiblings().add(new StringTextComponent(")")); optionInfo.getSiblings().add(new StringTextComponent(")"));
option.getSiblings().add(optionInfo); option.getSiblings().add(optionInfo);
@ -591,9 +591,9 @@ public class PacketEditingMessage
else else
{ {
StringTextComponent optionInfo = new StringTextComponent("(battle-"); StringTextComponent optionInfo = new StringTextComponent("(battle-");
optionInfo.func_230530_a_(optionInfo.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); optionInfo.setStyle(optionInfo.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
StringTextComponent optionInfoBool = new StringTextComponent("enabled"); StringTextComponent optionInfoBool = new StringTextComponent("enabled");
optionInfoBool.func_230530_a_(optionInfoBool.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00))); optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(Color.fromRgb(0xFF00FF00)));
optionInfo.getSiblings().add(optionInfoBool); optionInfo.getSiblings().add(optionInfoBool);
optionInfo.getSiblings().add(new StringTextComponent(")")); optionInfo.getSiblings().add(new StringTextComponent(")"));
option.getSiblings().add(optionInfo); option.getSiblings().add(optionInfo);
@ -602,13 +602,13 @@ public class PacketEditingMessage
text.getSiblings().add(new StringTextComponent(", ")); text.getSiblings().add(new StringTextComponent(", "));
option = new StringTextComponent("boss"); option = new StringTextComponent("boss");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category boss"))); option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category boss")));
if(TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("boss")) if(TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("boss"))
{ {
StringTextComponent optionInfo = new StringTextComponent("(battle-"); StringTextComponent optionInfo = new StringTextComponent("(battle-");
optionInfo.func_230530_a_(optionInfo.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); optionInfo.setStyle(optionInfo.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
StringTextComponent optionInfoBool = new StringTextComponent("disabled"); StringTextComponent optionInfoBool = new StringTextComponent("disabled");
optionInfoBool.func_230530_a_(optionInfoBool.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFF0000))); optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(Color.fromRgb(0xFFFF0000)));
optionInfo.getSiblings().add(optionInfoBool); optionInfo.getSiblings().add(optionInfoBool);
optionInfo.getSiblings().add(new StringTextComponent(")")); optionInfo.getSiblings().add(new StringTextComponent(")"));
option.getSiblings().add(optionInfo); option.getSiblings().add(optionInfo);
@ -616,9 +616,9 @@ public class PacketEditingMessage
else else
{ {
StringTextComponent optionInfo = new StringTextComponent("(battle-"); StringTextComponent optionInfo = new StringTextComponent("(battle-");
optionInfo.func_230530_a_(optionInfo.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); optionInfo.setStyle(optionInfo.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
StringTextComponent optionInfoBool = new StringTextComponent("enabled"); StringTextComponent optionInfoBool = new StringTextComponent("enabled");
optionInfoBool.func_230530_a_(optionInfoBool.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00))); optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(Color.fromRgb(0xFF00FF00)));
optionInfo.getSiblings().add(optionInfoBool); optionInfo.getSiblings().add(optionInfoBool);
optionInfo.getSiblings().add(new StringTextComponent(")")); optionInfo.getSiblings().add(new StringTextComponent(")"));
option.getSiblings().add(optionInfo); option.getSiblings().add(optionInfo);
@ -627,13 +627,13 @@ public class PacketEditingMessage
text.getSiblings().add(new StringTextComponent(", ")); text.getSiblings().add(new StringTextComponent(", "));
option = new StringTextComponent("player"); option = new StringTextComponent("player");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category player"))); option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category player")));
if(TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("player")) if(TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("player"))
{ {
StringTextComponent optionInfo = new StringTextComponent("(battle-"); StringTextComponent optionInfo = new StringTextComponent("(battle-");
optionInfo.func_230530_a_(optionInfo.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); optionInfo.setStyle(optionInfo.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
StringTextComponent optionInfoBool = new StringTextComponent("disabled"); StringTextComponent optionInfoBool = new StringTextComponent("disabled");
optionInfoBool.func_230530_a_(optionInfoBool.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFF0000))); optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(Color.fromRgb(0xFFFF0000)));
optionInfo.getSiblings().add(optionInfoBool); optionInfo.getSiblings().add(optionInfoBool);
optionInfo.getSiblings().add(new StringTextComponent(")")); optionInfo.getSiblings().add(new StringTextComponent(")"));
option.getSiblings().add(optionInfo); option.getSiblings().add(optionInfo);
@ -641,9 +641,9 @@ public class PacketEditingMessage
else else
{ {
StringTextComponent optionInfo = new StringTextComponent("(battle-"); StringTextComponent optionInfo = new StringTextComponent("(battle-");
optionInfo.func_230530_a_(optionInfo.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF))); optionInfo.setStyle(optionInfo.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
StringTextComponent optionInfoBool = new StringTextComponent("enabled"); StringTextComponent optionInfoBool = new StringTextComponent("enabled");
optionInfoBool.func_230530_a_(optionInfoBool.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00))); optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(Color.fromRgb(0xFF00FF00)));
optionInfo.getSiblings().add(optionInfoBool); optionInfo.getSiblings().add(optionInfoBool);
optionInfo.getSiblings().add(new StringTextComponent(")")); optionInfo.getSiblings().add(new StringTextComponent(")"));
option.getSiblings().add(optionInfo); option.getSiblings().add(optionInfo);
@ -659,14 +659,14 @@ public class PacketEditingMessage
case EDIT_DECISION_ATTACK: case EDIT_DECISION_ATTACK:
{ {
StringTextComponent prefix = new StringTextComponent("TBM: "); StringTextComponent prefix = new StringTextComponent("TBM: ");
prefix.func_230530_a_(prefix.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240713_a_(true)); prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
StringTextComponent text = new StringTextComponent("decisionAttack: "); StringTextComponent text = new StringTextComponent("decisionAttack: ");
text.func_230530_a_(text.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF)).func_240713_a_(false)); text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
for(int i = 0; i <= 100; i += 10) for(int i = 0; i <= 100; i += 10)
{ {
StringTextComponent option = new StringTextComponent(Integer.toString(i) + "%"); StringTextComponent option = new StringTextComponent(Integer.toString(i) + "%");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionAttack " + Integer.toString(i)))); option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionAttack " + Integer.toString(i))));
text.getSiblings().add(option); text.getSiblings().add(option);
if(i < 100) if(i < 100)
{ {
@ -681,14 +681,14 @@ public class PacketEditingMessage
case EDIT_DECISION_DEFEND: case EDIT_DECISION_DEFEND:
{ {
StringTextComponent prefix = new StringTextComponent("TBM: "); StringTextComponent prefix = new StringTextComponent("TBM: ");
prefix.func_230530_a_(prefix.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240713_a_(true)); prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
StringTextComponent text = new StringTextComponent("decisionDefend: "); StringTextComponent text = new StringTextComponent("decisionDefend: ");
text.func_230530_a_(text.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF)).func_240713_a_(false)); text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
for(int i = 0; i <= 100; i += 10) for(int i = 0; i <= 100; i += 10)
{ {
StringTextComponent option = new StringTextComponent(Integer.toString(i) + "%"); StringTextComponent option = new StringTextComponent(Integer.toString(i) + "%");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionDefend " + Integer.toString(i)))); option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionDefend " + Integer.toString(i))));
text.getSiblings().add(option); text.getSiblings().add(option);
if(i < 100) if(i < 100)
{ {
@ -703,14 +703,14 @@ public class PacketEditingMessage
case EDIT_DECISION_FLEE: case EDIT_DECISION_FLEE:
{ {
StringTextComponent prefix = new StringTextComponent("TBM: "); StringTextComponent prefix = new StringTextComponent("TBM: ");
prefix.func_230530_a_(prefix.getStyle().func_240718_a_(Color.func_240743_a_(0xFF00FF00)).func_240713_a_(true)); prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
StringTextComponent text = new StringTextComponent("decisionFlee: "); StringTextComponent text = new StringTextComponent("decisionFlee: ");
text.func_230530_a_(text.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFFFF)).func_240713_a_(false)); text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
for(int i = 0; i <= 100; i += 10) for(int i = 0; i <= 100; i += 10)
{ {
StringTextComponent option = new StringTextComponent(Integer.toString(i) + "%"); StringTextComponent option = new StringTextComponent(Integer.toString(i) + "%");
option.func_230530_a_(option.getStyle().func_240718_a_(Color.func_240743_a_(0xFFFFFF00)).func_240715_a_(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionFlee " + Integer.toString(i)))); option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionFlee " + Integer.toString(i))));
text.getSiblings().add(option); text.getSiblings().add(option);
if(i < 100) if(i < 100)
{ {

View file

@ -22,11 +22,11 @@ public class PacketGeneralMessage
} }
public static void encode(PacketGeneralMessage pkt, PacketBuffer buf) { public static void encode(PacketGeneralMessage pkt, PacketBuffer buf) {
buf.writeString(pkt.message); buf.writeUtf(pkt.message);
} }
public static PacketGeneralMessage decode(PacketBuffer buf) { public static PacketGeneralMessage decode(PacketBuffer buf) {
return new PacketGeneralMessage(buf.readString()); return new PacketGeneralMessage(buf.readUtf());
} }
public static class Handler { public static class Handler {

View file

@ -15,7 +15,7 @@ license="MIT"
# The modid of the mod # The modid of the mod
modId="com_burnedkirby_turnbasedminecraft" #mandatory modId="com_burnedkirby_turnbasedminecraft" #mandatory
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
version="1.16" #mandatory version="1.17" #mandatory
# A display name for the mod # A display name for the mod
displayName="TurnBasedMinecraftMod" #mandatory displayName="TurnBasedMinecraftMod" #mandatory
# A URL to query for updates for this mod. See the JSON update specification <here> # A URL to query for updates for this mod. See the JSON update specification <here>
@ -39,7 +39,7 @@ Implements turn-based-battle in Minecraft.
# Does this dependency have to exist - if not, ordering below must be specified # Does this dependency have to exist - if not, ordering below must be specified
mandatory=true #mandatory mandatory=true #mandatory
# The version range of the dependency # The version range of the dependency
versionRange="[34,)" #mandatory versionRange="[36,)" #mandatory
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
ordering="NONE" ordering="NONE"
# Side this dependency is applied on - BOTH, CLIENT or SERVER # Side this dependency is applied on - BOTH, CLIENT or SERVER
@ -48,6 +48,6 @@ Implements turn-based-battle in Minecraft.
[[dependencies.com_burnedkirby_turnbasedminecraft]] [[dependencies.com_burnedkirby_turnbasedminecraft]]
modId="minecraft" modId="minecraft"
mandatory=true mandatory=true
versionRange="[1.16.3,)" versionRange="[1.16.5,1.17)"
ordering="NONE" ordering="NONE"
side="BOTH" side="BOTH"

View file

@ -3,7 +3,7 @@
"modid": "com_burnedkirby_turnbasedminecraft", "modid": "com_burnedkirby_turnbasedminecraft",
"name": "Turn Based Minecraft", "name": "Turn Based Minecraft",
"description": "Changes battles to be turn-based.", "description": "Changes battles to be turn-based.",
"version": "1.16", "version": "1.17",
"mcversion": "1.16.3", "mcversion": "1.16.3",
"url": "", "url": "",
"updateUrl": "", "updateUrl": "",