]> git.seodisparate.com - TurnBasedMinecraftMod/commitdiff
Update for forge-1.18.2-40.1.0 (mod ver 1.18.0) 1.18.0
authorStephen Seo <seo.disparate@gmail.com>
Tue, 17 May 2022 05:47:42 +0000 (14:47 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Tue, 17 May 2022 07:10:18 +0000 (16:10 +0900)
34 files changed:
Changelog.md
README.md
build.gradle
gradle.properties [new file with mode: 0644]
gradle/wrapper/gradle-wrapper.jar
gradle/wrapper/gradle-wrapper.properties
gradlew
src/main/java/com/burnedkirby/TurnBasedMinecraft/client/BattleGui.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/client/BattleMusic.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ClientProxy.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/client/EntitySelectionButton.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ItemSelectionButton.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/AttackEventHandler.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/AttackerViaBow.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Battle.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/BattleManager.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Combatant.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/CommonProxy.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/DimensionChangedHandler.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/EditingInfo.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/EntityIDDimPair.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/EntityInfo.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/PlayerJoinEventHandler.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Utility.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattleDecision.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattleInfo.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattleMessage.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattleRequestInfo.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketEditingMessage.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketGeneralMessage.java
src/main/resources/META-INF/mods.toml
src/main/resources/assets/com_burnedkirby_turnbasedminecraft/TBM_Config.toml
src/main/resources/mcmod.info

index 5b1b23de5a86aa2cd189f31980491cb568d801fb..e4bdf2ef9c000072f792333097a6490e61c7e91a 100644 (file)
@@ -1,5 +1,10 @@
 # Upcoming changes
 
+# Version 1.18.0
+
+Mod now works with Forge-1.18.2-40.1.0 .  
+Note that the mod's version is confusingly similar (1.18.0).
+
 # Version 1.17.2
 
 (try to) Fix potential freeze bug when an entity leaves battle.
index 0e12c4f1af40166279f6ceedd0af4bce15418b1c..1b9881130f2edb4781f5557113e4fa956cfa1c3a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -57,7 +57,7 @@ configured for them.)
 # Building
 
 Simply invoke `./gradlew build` in the mod directory and after some time the
-finished jar will be saved at "build/reobfShadowJar/output.jar"
+finished jar will be saved at "build/libs/TurnBasedMinecraft-1.18.0.jar"
 
 # Other notes
 
index 9f1ee806faf37ed8b4a35f82d5c2c12f4f9f10f9..7f14b10719033c2d9c2a54e9fe33ddcc958274c6 100644 (file)
-buildscript {\r
-    repositories {\r
-        maven { url = "https://files.minecraftforge.net/maven" }\r
-        jcenter()\r
-        mavenCentral()\r
-    }\r
-    dependencies {\r
-        classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true\r
-        classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4'\r
-    }\r
-}\r
-apply plugin: 'net.minecraftforge.gradle'\r
-apply plugin: 'eclipse'\r
-//apply plugin: 'maven-publish'\r
-apply plugin: 'com.github.johnrengelman.shadow'\r
-\r
-version = "1.17.2"\r
-group = "com.burnedkirby.TurnBasedMinecraft"\r
-archivesBaseName = "TurnBasedMinecraft"\r
-\r
-java.toolchain.languageVersion = JavaLanguageVersion.of(8)\r
-println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))\r
-\r
-minecraft {\r
-    // The mappings can be changed at any time, and must be in the following format.\r
-    // snapshot_YYYYMMDD   Snapshot are built nightly.\r
-    // stable_#            Stables are built at the discretion of the MCP team.\r
-    // Use non-default mappings at your own risk. they may not always work.\r
-    // Simply re-run your setup task after changing the mappings to update your workspace.\r
-    mappings channel: 'official', version: '1.16.5'\r
-    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.\r
-\r
-    // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')\r
-\r
-    // Default run configurations.\r
-    // These can be tweaked, removed, or duplicated as needed.\r
-    runs {\r
-        client {\r
-            workingDirectory project.file('run')\r
-\r
-            // Recommended logging data for a userdev environment\r
-            property 'forge.logging.markers', 'REGISTRIES'\r
-\r
-            // Recommended logging level for the console\r
-            property 'forge.logging.console.level', 'debug'\r
-\r
-            mods {\r
-                TurnBasedMinecraftMod {\r
-                    source sourceSets.main\r
-                }\r
-            }\r
-        }\r
-\r
-        server {\r
-            workingDirectory project.file('run')\r
-\r
-            // Recommended logging data for a userdev environment\r
-            property 'forge.logging.markers', 'REGISTRIES'\r
-\r
-            // Recommended logging level for the console\r
-            property 'forge.logging.console.level', 'debug'\r
-\r
-            mods {\r
-                TurnBasedMinecraftMod {\r
-                    source sourceSets.main\r
-                }\r
-            }\r
-        }\r
-\r
-        data {\r
-            workingDirectory project.file('run')\r
-\r
-            // Recommended logging data for a userdev environment\r
-            property 'forge.logging.markers', 'REGISTRIES'\r
-\r
-            // Recommended logging level for the console\r
-            property 'forge.logging.console.level', 'debug'\r
-\r
-            args '--mod', 'TurnBasedMinecraftMod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources')\r
-\r
-            mods {\r
-                TurnBasedMinecraftMod {\r
-                    source sourceSets.main\r
-                }\r
-            }\r
-        }\r
-    }\r
-}\r
-\r
-// Include resources generated by data generators.\r
-sourceSets.main.resources { srcDir 'src/generated/resources' }\r
-\r
-dependencies {\r
-    // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed\r
-    // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.\r
-    // The userdev artifact is a special name and will get all sorts of transformations applied to it.\r
-    minecraft 'net.minecraftforge:forge:1.16.5-36.1.0'\r
-\r
-    // You may put jars on which you depend on in ./libs or you may define them like so..\r
-    // compile "some.group:artifact:version:classifier"\r
-    // compile "some.group:artifact:version"\r
-\r
-    // Real examples\r
-    // compile 'com.mod-buildcraft:buildcraft:6.0.8:dev'  // adds buildcraft to the dev env\r
-    // compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env\r
-\r
-    // The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.\r
-    // provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'\r
-\r
-    // These dependencies get remapped to your current MCP mappings\r
-    // deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'\r
-\r
-    // For more info...\r
-    // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html\r
-    // http://www.gradle.org/docs/current/userguide/dependency_management.html\r
-\r
-    compile files('libs/javamp3-1.0.3.jar')\r
-\r
-    shadow files('libs/javamp3-1.0.3.jar')\r
-}\r
-\r
-shadowJar {\r
-    project.configurations.shadow.setTransitive(true);\r
-    configurations = [project.configurations.shadow]\r
-    relocate 'fr.delthas', 'com.burnedkirby.tbm_repack.fr.delthas'\r
-    classifier '' // replace the default jar\r
-}\r
-\r
-reobf {\r
-    shadowJar {} // reobfuscate the shadowed jar\r
-}\r
-\r
-// Example for how to get properties into the manifest for reading by the runtime..\r
-jar {\r
-    manifest {\r
-        attributes([\r
-            "Specification-Title": "TurnBasedMinecraftMod",\r
-            "Specification-Vendor": "TurnBasedMinecraftMod_BK",\r
-            "Specification-Version": "1", // We are version 1 of ourselves\r
-            "Implementation-Title": project.name,\r
-            "Implementation-Version": "${version}",\r
-            "Implementation-Vendor" :"TurnBasedMinecraftMod_BK",\r
-            "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),\r
-//            "ContainedDeps": "javamp3-1.0.3.jar"\r
-        ])\r
-    }\r
-}\r
-\r
-// Example configuration to allow publishing using the maven-publish task\r
-// we define a custom artifact that is sourced from the reobfJar output task\r
-// and then declare that to be published\r
-// Note you'll need to add a repository here\r
-//def reobfFile = file("$buildDir/reobfJar/output.jar")\r
-//def reobfArtifact = artifacts.add('default', reobfFile) {\r
-//    type 'jar'\r
-//    builtBy 'reobfJar'\r
-//}\r
-//publishing {\r
-//    publications {\r
-//        mavenJava(MavenPublication) {\r
-//            artifact reobfArtifact\r
-//        }\r
-//    }\r
-//    repositories {\r
-//        maven {\r
-//            url "file:///${project.projectDir}/mcmodsrepo"\r
-//        }\r
-//    }\r
-//}\r
+buildscript {
+    repositories {
+        maven { url = "https://maven.minecraftforge.net" }
+        jcenter()
+        mavenCentral()
+        gradlePluginPortal()
+    }
+    dependencies {
+        classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
+        classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.2'
+    }
+}
+apply plugin: 'net.minecraftforge.gradle'
+//apply plugin: 'eclipse'
+//apply plugin: 'maven-publish'
+
+version = "1.18.0"
+group = "com.burnedkirby.TurnBasedMinecraft"
+archivesBaseName = "TurnBasedMinecraft"
+
+java.toolchain.languageVersion = JavaLanguageVersion.of(17)
+println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
+
+minecraft {
+    // The mappings can be changed at any time, and must be in the following format.
+    // snapshot_YYYYMMDD   Snapshot are built nightly.
+    // stable_#            Stables are built at the discretion of the MCP team.
+    // Use non-default mappings at your own risk. they may not always work.
+    // Simply re-run your setup task after changing the mappings to update your workspace.
+    mappings channel: 'official', version: '1.18.2'
+    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
+
+    // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
+
+    // Default run configurations.
+    // These can be tweaked, removed, or duplicated as needed.
+    runs {
+        client {
+            workingDirectory project.file('run')
+
+            // Recommended logging data for a userdev environment
+            property 'forge.logging.markers', 'REGISTRIES'
+
+            // Recommended logging level for the console
+            property 'forge.logging.console.level', 'debug'
+
+            // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
+            property 'forge.enabledGameTestNamespaces', 'TurnBasedMinecraftMod'
+
+            mods {
+                TurnBasedMinecraftMod {
+                    source sourceSets.main
+                }
+            }
+        }
+
+        server {
+            workingDirectory project.file('run')
+
+            // Recommended logging data for a userdev environment
+            property 'forge.logging.markers', 'REGISTRIES'
+
+            // Recommended logging level for the console
+            property 'forge.logging.console.level', 'debug'
+
+            // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
+            property 'forge.enabledGameTestNamespaces', 'TurnBasedMinecraftMod'
+
+            mods {
+                TurnBasedMinecraftMod {
+                    source sourceSets.main
+                }
+            }
+        }
+
+        // This run config launches GameTestServer and runs all registered gametests, then exits.
+        // By default, the server will crash when no gametests are provided.
+        // The gametest system is also enabled by default for other run configs under the /test command.
+        gameTestServer {
+            workingDirectory project.file('run')
+
+            // Recommended logging data for a userdev environment
+            // The markers can be added/remove as needed separated by commas.
+            // "SCAN": For mods scan.
+            // "REGISTRIES": For firing of registry events.
+            // "REGISTRYDUMP": For getting the contents of all registries.
+            property 'forge.logging.markers', 'REGISTRIES'
+
+            // Recommended logging level for the console
+            // You can set various levels here.
+            // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
+            property 'forge.logging.console.level', 'debug'
+
+            // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
+            property 'forge.enabledGameTestNamespaces', 'TurnBasedMinecraftMod'
+
+            mods {
+                TurnBasedMinecraftMod {
+                    source sourceSets.main
+                }
+            }
+        }
+
+        data {
+            workingDirectory project.file('run')
+
+            // Recommended logging data for a userdev environment
+            property 'forge.logging.markers', 'REGISTRIES'
+
+            // Recommended logging level for the console
+            property 'forge.logging.console.level', 'debug'
+
+            args '--mod', 'TurnBasedMinecraftMod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources')
+
+            mods {
+                TurnBasedMinecraftMod {
+                    source sourceSets.main
+                }
+            }
+        }
+    }
+}
+
+// Include resources generated by data generators.
+sourceSets.main.resources { srcDir 'src/generated/resources' }
+
+//repositories {
+//    // Put repositories for dependencies here
+//    // ForgeGradle automatically adds the Forge maven and Maven Central for you
+//
+//    // If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
+//    // flatDir {
+//    //     dir 'libs'
+//    // }
+//    mavenCentral()
+//    jcenter()
+//
+//    dependencies {
+//        classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4'
+//    }
+//}
+
+apply plugin: 'com.github.johnrengelman.shadow'
+
+configurations {
+    shade
+    impelmentation.extendsFrom shade
+}
+
+dependencies {
+    // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
+    // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
+    // The userdev artifact is a special name and will get all sorts of transformations applied to it.
+    minecraft 'net.minecraftforge:forge:1.18.2-40.1.0'
+
+    // Real mod deobf dependency examples - these get remapped to your current mappings
+    // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
+    // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
+    // implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency
+
+    // Examples using mod jars from ./libs
+    // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
+
+    // For more info...
+    // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
+    // http://www.gradle.org/docs/current/userguide/dependency_management.html
+    implementation files('libs/javamp3-1.0.3.jar')
+
+    shade files('libs/javamp3-1.0.3.jar')
+}
+
+// Example for how to get properties into the manifest for reading by the runtime..
+jar {
+    archiveClassifier = 'slim'
+    manifest {
+        attributes([
+            "Specification-Title": "TurnBasedMinecraftMod",
+            "Specification-Vendor": "TurnBasedMinecraftMod_BK",
+            "Specification-Version": "1", // We are version 1 of ourselves
+            "Implementation-Title": project.name,
+            "Implementation-Version": "${version}",
+            "Implementation-Vendor" :"TurnBasedMinecraftMod_BK",
+            "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
+//            "ContainedDeps": "javamp3-1.0.3.jar"
+        ])
+    }
+}
+
+shadowJar {
+    archiveClassifier = ''
+    //project.configurations.shadow.setTransitive(true);
+    configurations = [project.configurations.shade]
+    relocate 'fr.delthas', 'com.burnedkirby.tbm_repack.fr.delthas'
+    finalizedBy 'reobfShadowJar'
+}
+
+assemble.dependsOn shadowJar
+
+reobf {
+    shadowJar {} // reobfuscate the shadowed jar
+}
+
+// Example configuration to allow publishing using the maven-publish task
+// we define a custom artifact that is sourced from the reobfJar output task
+// and then declare that to be published
+// Note you'll need to add a repository here
+//def reobfFile = file("$buildDir/reobfJar/output.jar")
+//def reobfArtifact = artifacts.add('default', reobfFile) {
+//    type 'jar'
+//    builtBy 'reobfJar'
+//}
+//publishing {
+//    publications {
+//        mavenJava(MavenPublication) {
+//            artifact reobfArtifact
+//        }
+//    }
+//    repositories {
+//        maven {
+//            url "file:///${project.projectDir}/mcmodsrepo"
+//        }
+//    }
+//}
diff --git a/gradle.properties b/gradle.properties
new file mode 100644 (file)
index 0000000..8fe20ee
--- /dev/null
@@ -0,0 +1 @@
+org.gradle.jvmargs=-Xmx4096m
index e708b1c023ec8b20f512888fe07c5bd3ff77bb8f..7454180f2ae8848c63b8b4dea2cb829da983f2fa 100644 (file)
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
index 28ff446a21577879ae608199a6bbd5f86c8e58ab..41dfb87909a877d96c3af4adccce4c7a301b55a2 100644 (file)
@@ -1,5 +1,5 @@
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index 4f906e0c811fc9e230eb44819f509cd0627f2600..c53aefaa5fc898b78c7265ea99a3bdc09349a7d0 100755 (executable)
--- a/gradlew
+++ b/gradlew
@@ -1,7 +1,7 @@
-#!/usr/bin/env sh
+#!/bin/sh
 
 #
-# Copyright 2015 the original author or authors.
+# Copyright Â© 2015-2021 the original authors.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 #
 
 ##############################################################################
-##
-##  Gradle start up script for UN*X
-##
+#
+#   Gradle start up script for POSIX generated by Gradle.
+#
+#   Important for running:
+#
+#   (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+#       noncompliant, but you have some other compliant shell such as ksh or
+#       bash, then to run this script, type that shell name before the whole
+#       command line, like:
+#
+#           ksh Gradle
+#
+#       Busybox and similar reduced shells will NOT work, because this script
+#       requires all of these POSIX shell features:
+#         * functions;
+#         * expansions Â«$var», Â«${var}», Â«${var:-default}», Â«${var+SET}»,
+#           Â«${var#prefix}», Â«${var%suffix}», and Â«$( cmd )»;
+#         * compound commands having a testable exit status, especially Â«case»;
+#         * various built-in commands including Â«command», Â«set», and Â«ulimit».
+#
+#   Important for patching:
+#
+#   (2) This script targets any POSIX shell, so it avoids extensions provided
+#       by Bash, Ksh, etc; in particular arrays are avoided.
+#
+#       The "traditional" practice of packing multiple parameters into a
+#       space-separated string is a well documented source of bugs and security
+#       problems, so this is (mostly) avoided, by progressively accumulating
+#       options in "$@", and eventually passing that to Java.
+#
+#       Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+#       and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+#       see the in-line comments for details.
+#
+#       There are tweaks for specific operating systems such as AIX, CygWin,
+#       Darwin, MinGW, and NonStop.
+#
+#   (3) This script is generated from the Groovy template
+#       https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+#       within the Gradle project.
+#
+#       You can find Gradle at https://github.com/gradle/gradle/.
+#
 ##############################################################################
 
 # Attempt to set APP_HOME
+
 # Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
-    ls=`ls -ld "$PRG"`
-    link=`expr "$ls" : '.*-> \(.*\)$'`
-    if expr "$link" : '/.*' > /dev/null; then
-        PRG="$link"
-    else
-        PRG=`dirname "$PRG"`"/$link"
-    fi
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+    APP_HOME=${app_path%"${app_path##*/}"}  # leaves a trailing /; empty if no leading path
+    [ -h "$app_path" ]
+do
+    ls=$( ls -ld "$app_path" )
+    link=${ls#*' -> '}
+    case $link in             #(
+      /*)   app_path=$link ;; #(
+      *)    app_path=$APP_HOME$link ;;
+    esac
 done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
+
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
 
 APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
+APP_BASE_NAME=${0##*/}
 
 # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
 DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
 
 # Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
+MAX_FD=maximum
 
 warn () {
     echo "$*"
-}
+} >&2
 
 die () {
     echo
     echo "$*"
     echo
     exit 1
-}
+} >&2
 
 # OS specific support (must be 'true' or 'false').
 cygwin=false
 msys=false
 darwin=false
 nonstop=false
-case "`uname`" in
-  CYGWIN* )
-    cygwin=true
-    ;;
-  Darwin* )
-    darwin=true
-    ;;
-  MINGW* )
-    msys=true
-    ;;
-  NONSTOP* )
-    nonstop=true
-    ;;
+case "$( uname )" in                #(
+  CYGWIN* )         cygwin=true  ;; #(
+  Darwin* )         darwin=true  ;; #(
+  MSYS* | MINGW* )  msys=true    ;; #(
+  NONSTOP* )        nonstop=true ;;
 esac
 
 CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
 if [ -n "$JAVA_HOME" ] ; then
     if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
         # IBM's JDK on AIX uses strange locations for the executables
-        JAVACMD="$JAVA_HOME/jre/sh/java"
+        JAVACMD=$JAVA_HOME/jre/sh/java
     else
-        JAVACMD="$JAVA_HOME/bin/java"
+        JAVACMD=$JAVA_HOME/bin/java
     fi
     if [ ! -x "$JAVACMD" ] ; then
         die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
 location of your Java installation."
     fi
 else
-    JAVACMD="java"
+    JAVACMD=java
     which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
 
 Please set the JAVA_HOME variable in your environment to match the
@@ -106,80 +140,95 @@ location of your Java installation."
 fi
 
 # Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
-    MAX_FD_LIMIT=`ulimit -H -n`
-    if [ $? -eq 0 ] ; then
-        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
-            MAX_FD="$MAX_FD_LIMIT"
-        fi
-        ulimit -n $MAX_FD
-        if [ $? -ne 0 ] ; then
-            warn "Could not set maximum file descriptor limit: $MAX_FD"
-        fi
-    else
-        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
-    fi
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+    case $MAX_FD in #(
+      max*)
+        MAX_FD=$( ulimit -H -n ) ||
+            warn "Could not query maximum file descriptor limit"
+    esac
+    case $MAX_FD in  #(
+      '' | soft) :;; #(
+      *)
+        ulimit -n "$MAX_FD" ||
+            warn "Could not set maximum file descriptor limit to $MAX_FD"
+    esac
 fi
 
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
-    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
+# Collect all arguments for the java command, stacking in reverse order:
+#   * args from the command line
+#   * the main class name
+#   * -classpath
+#   * -D...appname settings
+#   * --module-path (only if needed)
+#   * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
 
 # For Cygwin or MSYS, switch paths to Windows format before running java
-if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
-    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
-    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
-    JAVACMD=`cygpath --unix "$JAVACMD"`
-
-    # We build the pattern for arguments to be converted via cygpath
-    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
-    SEP=""
-    for dir in $ROOTDIRSRAW ; do
-        ROOTDIRS="$ROOTDIRS$SEP$dir"
-        SEP="|"
-    done
-    OURCYGPATTERN="(^($ROOTDIRS))"
-    # Add a user-defined pattern to the cygpath arguments
-    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
-        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
-    fi
+if "$cygwin" || "$msys" ; then
+    APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+    CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+    JAVACMD=$( cygpath --unix "$JAVACMD" )
+
     # Now convert the arguments - kludge to limit ourselves to /bin/sh
-    i=0
-    for arg in "$@" ; do
-        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
-        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
-
-        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
-            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
-        else
-            eval `echo args$i`="\"$arg\""
+    for arg do
+        if
+            case $arg in                                #(
+              -*)   false ;;                            # don't mess with options #(
+              /?*)  t=${arg#/} t=/${t%%/*}              # looks like a POSIX filepath
+                    [ -e "$t" ] ;;                      #(
+              *)    false ;;
+            esac
+        then
+            arg=$( cygpath --path --ignore --mixed "$arg" )
         fi
-        i=`expr $i + 1`
+        # Roll the args list around exactly as many times as the number of
+        # args, so each arg winds up back in the position where it started, but
+        # possibly modified.
+        #
+        # NB: a `for` loop captures its iteration list before it begins, so
+        # changing the positional parameters here affects neither the number of
+        # iterations, nor the values presented in `arg`.
+        shift                   # remove old arg
+        set -- "$@" "$arg"      # push replacement arg
     done
-    case $i in
-        0) set -- ;;
-        1) set -- "$args0" ;;
-        2) set -- "$args0" "$args1" ;;
-        3) set -- "$args0" "$args1" "$args2" ;;
-        4) set -- "$args0" "$args1" "$args2" "$args3" ;;
-        5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
-        6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
-        7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
-        8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
-        9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
-    esac
 fi
 
-# Escape application args
-save () {
-    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
-    echo " "
-}
-APP_ARGS=`save "$@"`
+# Collect all arguments for the java command;
+#   * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
+#     shell script including quotes and variable substitutions, so put them in
+#     double quotes to make sure that they get re-expanded; and
+#   * put everything else in single quotes, so that it's not re-expanded.
+
+set -- \
+        "-Dorg.gradle.appname=$APP_BASE_NAME" \
+        -classpath "$CLASSPATH" \
+        org.gradle.wrapper.GradleWrapperMain \
+        "$@"
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+#   readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+#   set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
 
-# 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 -- $(
+        printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+        xargs -n1 |
+        sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+        tr '\n' ' '
+    )" '"$@"'
 
 exec "$JAVACMD" "$@"
index fa3368306c3f4142da6569bd3de4c9357d88fd4b..22d1c87df44488364cddf6754c91ae64e355cb05 100644 (file)
@@ -1,24 +1,20 @@
 package com.burnedkirby.TurnBasedMinecraft.client;
 
-import java.util.ConcurrentModificationException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-
 import com.burnedkirby.TurnBasedMinecraft.common.Battle;
 import com.burnedkirby.TurnBasedMinecraft.common.Combatant;
 import com.burnedkirby.TurnBasedMinecraft.common.Config;
 import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
 import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleDecision;
-
-import com.mojang.blaze3d.matrix.MatrixStack;
+import com.mojang.blaze3d.vertex.PoseStack;
 import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.gui.widget.button.Button;
-import net.minecraft.client.renderer.IRenderTypeBuffer;
-import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.util.math.vector.Matrix4f;
-import net.minecraft.util.text.StringTextComponent;
+import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.network.chat.TextComponent;
+
+import java.util.ConcurrentModificationException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
 
 public class BattleGui extends Screen {
        private AtomicInteger timeRemaining;
@@ -27,7 +23,6 @@ public class BattleGui extends Screen {
        private MenuState state;
        private boolean stateChanged;
        private String info;
-       private Matrix4f identity;
 
        private enum MenuState {
                MAIN_MENU(0), ATTACK_TARGET(1), ITEM_ACTION(2), WAITING(3), SWITCH_ITEM(4), USE_ITEM(5);
@@ -84,14 +79,12 @@ public class BattleGui extends Screen {
        }
 
        public BattleGui() {
-               super(new StringTextComponent("Battle Gui"));
+               super(new TextComponent("Battle Gui"));
                timeRemaining = new AtomicInteger((int) (Config.BATTLE_DECISION_DURATION_NANO_DEFAULT / 1000000000L));
                lastInstant = System.nanoTime();
                elapsedTime = 0;
                state = MenuState.MAIN_MENU;
                stateChanged = true;
-               identity = new Matrix4f();
-               identity.setIdentity();
        }
 
        private void setState(MenuState state) {
@@ -126,21 +119,20 @@ public class BattleGui extends Screen {
                }
 
                stateChanged = false;
-               buttons.clear();
-               children.clear();
+               clearWidgets();
                switch (state) {
                case MAIN_MENU:
                        info = "What will you do?";
-                       addButton(new Button(width * 3 / 7 - 25, 40, 50, 20, new StringTextComponent("Attack"), (button) -> {
+                       addRenderableWidget(new Button(width * 3 / 7 - 25, 40, 50, 20, new TextComponent("Attack"), (button) -> {
                                buttonActionEvent(button, ButtonAction.ATTACK);
                        }));
-                       addButton(new Button(width * 4 / 7 - 25, 40, 50, 20, new StringTextComponent("Defend"), (button) -> {
+                       addRenderableWidget(new Button(width * 4 / 7 - 25, 40, 50, 20, new TextComponent("Defend"), (button) -> {
                                buttonActionEvent(button, ButtonAction.DEFEND);
                        }));
-                       addButton(new Button(width * 3 / 7 - 25, 60, 50, 20, new StringTextComponent("Item"), (button) -> {
+                       addRenderableWidget(new Button(width * 3 / 7 - 25, 60, 50, 20, new TextComponent("Item"), (button) -> {
                                buttonActionEvent(button, ButtonAction.ITEM);
                        }));
-                       addButton(new Button(width * 4 / 7 - 25, 60, 50, 20, new StringTextComponent("Flee"), (button) -> {
+                       addRenderableWidget(new Button(width * 4 / 7 - 25, 60, 50, 20, new TextComponent("Flee"), (button) -> {
                                buttonActionEvent(button, ButtonAction.FLEE);
                        }));
                        break;
@@ -151,11 +143,11 @@ public class BattleGui extends Screen {
                                for (Map.Entry<Integer, Combatant> e : TurnBasedMinecraftMod.proxy.getLocalBattle()
                                                .getSideAEntrySet()) {
                                        if (e.getValue().entity != null) {
-                                               addButton(new EntitySelectionButton(width / 4 - 60, y, 120, 20, e.getValue().entity.getName().getString(), e.getKey(), true, (button) -> {
+                                               addRenderableWidget(new EntitySelectionButton(width / 4 - 60, y, 120, 20, e.getValue().entity.getName().getString(), e.getKey(), true, (button) -> {
                                                        buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
                                                }));
                                        } else {
-                                               addButton(new EntitySelectionButton(width / 4 - 60, y, 120, 20, "Unknown", e.getKey(), true, (button) -> {
+                                               addRenderableWidget(new EntitySelectionButton(width / 4 - 60, y, 120, 20, "Unknown", e.getKey(), true, (button) -> {
                                                        buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
                                                }));
                                        }
@@ -169,11 +161,11 @@ public class BattleGui extends Screen {
                                for (Map.Entry<Integer, Combatant> e : TurnBasedMinecraftMod.proxy.getLocalBattle()
                                                .getSideBEntrySet()) {
                                        if (e.getValue().entity != null) {
-                                               addButton(new EntitySelectionButton(width * 3 / 4 - 60, y, 120, 20, e.getValue().entity.getName().getString(), e.getKey(), false, (button) -> {
+                                               addRenderableWidget(new EntitySelectionButton(width * 3 / 4 - 60, y, 120, 20, e.getValue().entity.getName().getString(), e.getKey(), false, (button) -> {
                                                        buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
                                                }));
                                        } else {
-                                               addButton(new EntitySelectionButton(width * 3 / 4 - 60, y, 120, 20, "Unknown", e.getKey(), false, (button) -> {
+                                               addRenderableWidget(new EntitySelectionButton(width * 3 / 4 - 60, y, 120, 20, "Unknown", e.getKey(), false, (button) -> {
                                                        buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
                                                }));
                                        }
@@ -182,19 +174,19 @@ public class BattleGui extends Screen {
                        } catch (ConcurrentModificationException e) {
                                // ignored
                        }
-                       addButton(new Button(width / 2 - 30, height - 120, 60, 20, new StringTextComponent("Cancel"), (button) -> {
+                       addRenderableWidget(new Button(width / 2 - 30, height - 120, 60, 20, new TextComponent("Cancel"), (button) -> {
                                buttonActionEvent(button, ButtonAction.CANCEL);
                        }));
                        break;
                case ITEM_ACTION:
                        info = "What will you do with an item?";
-                       addButton(new Button(width * 1 / 4 - 40, height - 120, 80, 20, new StringTextComponent("Switch Held"), (button) -> {
+                       addRenderableWidget(new Button(width * 1 / 4 - 40, height - 120, 80, 20, new TextComponent("Switch Held"), (button) -> {
                                buttonActionEvent(button, ButtonAction.SWITCH_HELD_ITEM);
                        }));
-                       addButton(new Button(width * 2 / 4 - 40, height - 120, 80, 20, new StringTextComponent("Use"), (button) -> {
+                       addRenderableWidget(new Button(width * 2 / 4 - 40, height - 120, 80, 20, new TextComponent("Use"), (button) -> {
                                buttonActionEvent(button, ButtonAction.DECIDE_USE_ITEM);
                        }));
-                       addButton(new Button(width * 3 / 4 - 40, height - 120, 80, 20, new StringTextComponent("Cancel"), (button) -> {
+                       addRenderableWidget(new Button(width * 3 / 4 - 40, height - 120, 80, 20, new TextComponent("Cancel"), (button) -> {
                                buttonActionEvent(button, ButtonAction.CANCEL);
                        }));
                        break;
@@ -204,22 +196,22 @@ public class BattleGui extends Screen {
                case SWITCH_ITEM:
                        info = "To which item will you switch to?";
                        for (int i = 0; i < 9; ++i) {
-                               addButton(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, "", i, (button) -> {
+                               addRenderableWidget(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, "", i, (button) -> {
                                        buttonActionEvent(button, ButtonAction.DO_ITEM_SWITCH);
                                }));
                        }
-                       addButton(new Button(width / 2 - 40, height - 120, 80, 20, new StringTextComponent("Cancel"), (button) -> {
+                       addRenderableWidget(new Button(width / 2 - 40, height - 120, 80, 20, new TextComponent("Cancel"), (button) -> {
                                buttonActionEvent(button, ButtonAction.CANCEL);
                        }));
                        break;
                case USE_ITEM:
                        info = "Which item will you use?";
                        for (int i = 0; i < 9; ++i) {
-                               addButton(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, "", i, (button) -> {
+                               addRenderableWidget(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, "", i, (button) -> {
                                        buttonActionEvent(button, ButtonAction.DO_USE_ITEM);
                                }));
                        }
-                       addButton(new Button(width / 2 - 40, height - 120, 80, 20, new StringTextComponent("Cancel"), (button) -> {
+                       addRenderableWidget(new Button(width / 2 - 40, height - 120, 80, 20, new TextComponent("Cancel"), (button) -> {
                                buttonActionEvent(button, ButtonAction.CANCEL);
                        }));
                        break;
@@ -227,10 +219,10 @@ public class BattleGui extends Screen {
        }
 
        @Override
-       public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
+       public void render(PoseStack poseStack, int mouseX, int mouseY, float partialTicks) {
                if (TurnBasedMinecraftMod.proxy.getLocalBattle() == null) {
                        // drawHoveringText("Waiting...", width / 2 - 50, height / 2);
-                       drawString(matrixStack, "Waiting...", width / 2 - 50, height / 2, 0xFFFFFFFF);
+                       drawString(poseStack, "Waiting...", width / 2 - 50, height / 2, 0xFFFFFFFF);
                        return;
                }
                if (TurnBasedMinecraftMod.proxy.getLocalBattle().getState() == Battle.State.DECISION
@@ -246,7 +238,7 @@ public class BattleGui extends Screen {
 
                updateState();
 
-               super.render(matrixStack, mouseX, mouseY, partialTicks);
+               super.render(poseStack, mouseX, mouseY, partialTicks);
 
                String timeRemainingString = "Time remaining: ";
                int timeRemainingInt = timeRemaining.get();
@@ -259,11 +251,11 @@ public class BattleGui extends Screen {
                }
                timeRemainingString += Integer.toString(timeRemainingInt);
                int stringWidth = font.width(timeRemainingString);
-               fill(matrixStack, width / 2 - stringWidth / 2, 5, width / 2 + stringWidth / 2, 15, 0x70000000);
-               drawString(matrixStack, timeRemainingString, width / 2 - stringWidth / 2, 5, 0xFFFFFFFF);
+               fill(poseStack, width / 2 - stringWidth / 2, 5, width / 2 + stringWidth / 2, 15, 0x70000000);
+               drawString(poseStack, timeRemainingString, width / 2 - stringWidth / 2, 5, 0xFFFFFFFF);
                stringWidth = font.width(info);
-               fill(matrixStack, width / 2 - stringWidth / 2, 20, width / 2 + stringWidth / 2, 30, 0x70000000);
-               drawString(matrixStack, info, width / 2 - stringWidth / 2, 20, 0xFFFFFFFF);
+               fill(poseStack, width / 2 - stringWidth / 2, 20, width / 2 + stringWidth / 2, 30, 0x70000000);
+               drawString(poseStack, info, width / 2 - stringWidth / 2, 20, 0xFFFFFFFF);
        }
 
        protected void buttonActionEvent(Button button, ButtonAction action) {
@@ -309,7 +301,7 @@ public class BattleGui extends Screen {
                                                .sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(),
                                                                Battle.Decision.SWITCH_ITEM, ((ItemSelectionButton) button).getID()));
                                if (((ItemSelectionButton) button).getID() >= 0 && ((ItemSelectionButton) button).getID() < 9) {
-                                       Minecraft.getInstance().player.inventory.selected = ((ItemSelectionButton) button).getID();
+                                       Minecraft.getInstance().player.getInventory().selected = ((ItemSelectionButton) button).getID();
                                }
                                setState(MenuState.WAITING);
                        } else {
@@ -354,7 +346,7 @@ public class BattleGui extends Screen {
                timeRemaining.set(remaining);
        }
 
-       private void drawString(MatrixStack matrixStack, String string, int x, int y, int color) {
-               font.draw(matrixStack, string, x, y, color);
+       private void drawString(PoseStack poseStack, String string, int x, int y, int color) {
+               font.draw(poseStack, string, x, y, color);
        }
 }
index adb37fb7f70fb91d10c5a8d6bdc3f8716d1c12d9..a48ccb592520c96ea23c4c0b2253eaf21f4f37f0 100644 (file)
@@ -1,21 +1,18 @@
 package com.burnedkirby.TurnBasedMinecraft.client;
 
-import java.io.*;
-import java.util.ArrayList;
-import java.util.concurrent.atomic.AtomicBoolean;
+import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
+import fr.delthas.javamp3.Sound;
+import net.minecraft.client.Minecraft;
+import org.apache.logging.log4j.Logger;
 
 import javax.sound.midi.MidiChannel;
 import javax.sound.midi.MidiSystem;
 import javax.sound.midi.MidiUnavailableException;
 import javax.sound.midi.Sequencer;
 import javax.sound.sampled.*;
-
-import fr.delthas.javamp3.Sound;
-import org.apache.logging.log4j.Logger;
-
-import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
-
-import net.minecraft.client.Minecraft;
+import java.io.*;
+import java.util.ArrayList;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 public class BattleMusic
 {
index f11d253a6e8f76daeba3a49f5fbe2d48a1516e7b..a87421da07a6ad5e03a0520b0caf86828d74771d 100644 (file)
@@ -2,18 +2,25 @@ package com.burnedkirby.TurnBasedMinecraft.client;
 
 import com.burnedkirby.TurnBasedMinecraft.common.Battle;
 import com.burnedkirby.TurnBasedMinecraft.common.CommonProxy;
-
-import net.minecraft.client.GameSettings;
+import com.burnedkirby.TurnBasedMinecraft.common.EntityInfo;
+import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
+import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleMessage;
+import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketEditingMessage;
+import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketGeneralMessage;
 import net.minecraft.client.Minecraft;
-import net.minecraft.entity.Entity;
-import net.minecraft.util.RegistryKey;
-import net.minecraft.util.SoundCategory;
-import net.minecraft.util.text.Color;
-import net.minecraft.util.text.ITextComponent;
-import net.minecraft.util.text.StringTextComponent;
-import net.minecraft.world.World;
+import net.minecraft.client.Options;
+import net.minecraft.network.chat.ClickEvent;
+import net.minecraft.network.chat.HoverEvent;
+import net.minecraft.network.chat.TextColor;
+import net.minecraft.network.chat.TextComponent;
+import net.minecraft.resources.ResourceKey;
+import net.minecraft.sounds.SoundSource;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.level.Level;
+import net.minecraftforge.network.NetworkEvent;
 
 import java.util.UUID;
+import java.util.function.Supplier;
 
 public class ClientProxy extends CommonProxy
 {
@@ -93,15 +100,15 @@ public class ClientProxy extends CommonProxy
     @Override
     public void playBattleMusic()
     {
-        GameSettings gs = Minecraft.getInstance().options;
-        battleMusic.playBattle(gs.getSoundSourceVolume(SoundCategory.MUSIC) * gs.getSoundSourceVolume(SoundCategory.MASTER));
+        Options gs = Minecraft.getInstance().options;
+        battleMusic.playBattle(gs.getSoundSourceVolume(SoundSource.MUSIC) * gs.getSoundSourceVolume(SoundSource.MASTER));
     }
 
     @Override
     public void playSillyMusic()
     {
-        GameSettings gs = Minecraft.getInstance().options;
-        battleMusic.playSilly(gs.getSoundSourceVolume(SoundCategory.MUSIC) * gs.getSoundSourceVolume(SoundCategory.MASTER));
+        Options gs = Minecraft.getInstance().options;
+        battleMusic.playSilly(gs.getSoundSourceVolume(SoundSource.MUSIC) * gs.getSoundSourceVolume(SoundSource.MASTER));
     }
 
     @Override
@@ -149,17 +156,17 @@ public class ClientProxy extends CommonProxy
     @Override
     public void displayString(String message)
     {
-        StringTextComponent prefix = new StringTextComponent("TBM: ");
-        prefix.withStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
-        StringTextComponent text = new StringTextComponent(message);
+        TextComponent prefix = new TextComponent("TBM: ");
+        prefix.withStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true));
+        TextComponent text = new TextComponent(message);
         prefix.getSiblings().add(text);
-        text.withStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
+        text.withStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
         // UUID is required by sendMessage, but appears to be unused, so just give dummy UUID
         Minecraft.getInstance().player.sendMessage(prefix, UUID.randomUUID());
     }
 
     @Override
-    public void displayTextComponent(ITextComponent text)
+    public void displayTextComponent(TextComponent text)
     {
         // UUID is required by sendMessage, but appears to be unused, so just give dummy UUID
         Minecraft.getInstance().player.sendMessage(text, UUID.randomUUID());
@@ -231,7 +238,783 @@ public class ClientProxy extends CommonProxy
     }
 
     @Override
-    public Entity getEntity(int id, RegistryKey<World> dim) {
+    public Entity getEntity(int id, ResourceKey<Level> dim) {
         return Minecraft.getInstance().level.getEntity(id);
     }
+
+    @Override
+    public <MSG> void handlePacket(MSG msg, Supplier<NetworkEvent.Context> ctx) {
+        if (msg.getClass() == PacketBattleMessage.class) {
+            PacketBattleMessage pkt = (PacketBattleMessage)msg;
+            Entity fromEntity = getEntity(pkt.getEntityIDFrom(), pkt.getDimension());
+            String from = "Unknown";
+            if(fromEntity != null)
+            {
+                from = fromEntity.getDisplayName().getString();
+            }
+            else if(TurnBasedMinecraftMod.proxy.getLocalBattle() != null)
+            {
+                fromEntity = TurnBasedMinecraftMod.proxy.getLocalBattle().getCombatantEntity(pkt.getEntityIDFrom());
+                if(fromEntity != null)
+                {
+                    from = fromEntity.getDisplayName().getString();
+                }
+            }
+            Entity toEntity = TurnBasedMinecraftMod.proxy.getEntity(pkt.getEntityIDTo(), pkt.getDimension());
+            String to = "Unknown";
+            if(toEntity != null)
+            {
+                to = toEntity.getDisplayName().getString();
+            }
+            else if(TurnBasedMinecraftMod.proxy.getLocalBattle() != null)
+            {
+                toEntity = TurnBasedMinecraftMod.proxy.getLocalBattle().getCombatantEntity(pkt.getEntityIDTo());
+                if(toEntity != null)
+                {
+                    to = toEntity.getDisplayName().getString();
+                }
+            }
+
+            switch(pkt.getMessageType())
+            {
+                case ENTERED:
+                    TurnBasedMinecraftMod.proxy.displayString(from + " entered battle!");
+                    if(TurnBasedMinecraftMod.proxy.getLocalBattle() == null || TurnBasedMinecraftMod.proxy.getLocalBattle().getId() != pkt.getAmount())
+                    {
+                        TurnBasedMinecraftMod.proxy.createLocalBattle(pkt.getAmount());
+                    }
+                    TurnBasedMinecraftMod.proxy.battleStarted();
+                    TurnBasedMinecraftMod.proxy.typeEnteredBattle(pkt.getCustom());
+                    break;
+                case FLEE:
+                    if(pkt.getAmount() != 0)
+                    {
+                        TurnBasedMinecraftMod.proxy.displayString(from + " fled battle!");
+                        TurnBasedMinecraftMod.proxy.typeLeftBattle(pkt.getCustom());
+                    }
+                    else
+                    {
+                        TurnBasedMinecraftMod.proxy.displayString(from + " tried to flee battle but failed!");
+                    }
+                    break;
+                case DIED:
+                    TurnBasedMinecraftMod.proxy.displayString(from + " died in battle!");
+                    TurnBasedMinecraftMod.proxy.typeLeftBattle(pkt.getCustom());
+                    break;
+                case ENDED:
+                    TurnBasedMinecraftMod.proxy.displayString("Battle has ended!");
+                    TurnBasedMinecraftMod.proxy.battleEnded();
+                    break;
+                case ATTACK:
+                    TurnBasedMinecraftMod.proxy.displayString(from + " attacked " + to + " and dealt " + pkt.getAmount() + " damage!");
+                    break;
+                case DEFEND:
+                    TurnBasedMinecraftMod.proxy.displayString(from + " blocked " + to + "'s attack!");
+                    break;
+                case DEFENSE_DAMAGE:
+                    TurnBasedMinecraftMod.proxy.displayString(from + " retaliated from " + to + "'s attack and dealt " + pkt.getAmount() + " damage!");
+                    break;
+                case MISS:
+                    TurnBasedMinecraftMod.proxy.displayString(from + " attacked " + to + " but missed!");
+                    break;
+                case DEFENDING:
+                    TurnBasedMinecraftMod.proxy.displayString(from + " is defending!");
+                    break;
+                case DID_NOTHING:
+                    TurnBasedMinecraftMod.proxy.displayString(from + " did nothing!");
+                    break;
+                case USED_ITEM:
+                    switch(PacketBattleMessage.UsedItemAction.valueOf(pkt.getAmount()))
+                    {
+                        case USED_NOTHING:
+                            TurnBasedMinecraftMod.proxy.displayString(from + " tried to use nothing!");
+                            break;
+                        case USED_INVALID:
+                            if(pkt.getCustom().length() > 0)
+                            {
+                                TurnBasedMinecraftMod.proxy.displayString(from + " tried to consume " + pkt.getCustom() + " and failed!");
+                            }
+                            else
+                            {
+                                TurnBasedMinecraftMod.proxy.displayString(from + " tried to consume an invalid item and failed!");
+                            }
+                            break;
+                        case USED_FOOD:
+                            TurnBasedMinecraftMod.proxy.displayString(from + " ate a " + pkt.getCustom() + "!");
+                            break;
+                        case USED_POTION:
+                            TurnBasedMinecraftMod.proxy.displayString(from + " drank a " + pkt.getCustom() + "!");
+                            break;
+                    }
+                    break;
+                case TURN_BEGIN:
+                    TurnBasedMinecraftMod.proxy.displayString("The turn begins!");
+                    TurnBasedMinecraftMod.proxy.battleGuiTurnBegin();
+                    break;
+                case TURN_END:
+                    if(TurnBasedMinecraftMod.proxy.getLocalBattle() != null)
+                    {
+                        if(pkt.getAmount() == 0)
+                        {
+                            TurnBasedMinecraftMod.proxy.displayString("The turn ended!");
+                        }
+                        else
+                        {
+                            TurnBasedMinecraftMod.proxy.displayString("The turn ended (abnormally due to internal error)!");
+                        }
+                    }
+                    TurnBasedMinecraftMod.proxy.battleGuiTurnEnd();
+                    break;
+                case SWITCHED_ITEM:
+                    if(pkt.getAmount() != 0)
+                    {
+                        TurnBasedMinecraftMod.proxy.displayString(from + " switched to a different item!");
+                    }
+                    else
+                    {
+                        TurnBasedMinecraftMod.proxy.displayString(from + " switched to a different item but failed because it was invalid!");
+                    }
+                    break;
+                case WAS_AFFECTED:
+                    TurnBasedMinecraftMod.proxy.displayString(to + " was " + pkt.getCustom() + " by " + from + "!");
+                    break;
+                case BECAME_CREATIVE:
+                    TurnBasedMinecraftMod.proxy.displayString(from + " entered creative mode and left battle!");
+                    break;
+                case FIRED_ARROW:
+                    TurnBasedMinecraftMod.proxy.displayString(from + " let loose an arrow towards " + to + "!");
+                    break;
+                case ARROW_HIT:
+                    TurnBasedMinecraftMod.proxy.displayString(to + " was hit by " + from + "'s arrow!");
+                    break;
+                case BOW_NO_AMMO:
+                    TurnBasedMinecraftMod.proxy.displayString(from + " tried to use their bow but ran out of ammo!");
+                    break;
+                case CREEPER_WAIT: {
+                    TextComponent prefix = new TextComponent("TBM: ");
+                    prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true));
+                    TextComponent message = new TextComponent(from + " is charging up!");
+                    message.setStyle(message.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)));
+                    prefix.getSiblings().add(message);
+                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
+                }
+                break;
+                case CREEPER_WAIT_FINAL: {
+                    TextComponent prefix = new TextComponent("TBM: ");
+                    prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true));
+                    TextComponent message = new TextComponent(from + " is about to explode!");
+                    message.setStyle(message.getStyle().withColor(TextColor.fromRgb(0xFFFF5050)));
+                    prefix.getSiblings().add(message);
+                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
+                }
+                break;
+                case CREEPER_EXPLODE: {
+                    TextComponent prefix = new TextComponent("TBM: ");
+                    prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true));
+                    TextComponent message = new TextComponent(from + " exploded!");
+                    message.setStyle(message.getStyle().withColor(TextColor.fromRgb(0xFFFF0000)));
+                    prefix.getSiblings().add(message);
+                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
+                }
+                break;
+            }
+        } else if (msg.getClass() == PacketGeneralMessage.class) {
+            PacketGeneralMessage pkt = (PacketGeneralMessage)msg;
+            displayString(pkt.getMessage());
+        } else if (msg.getClass() == PacketEditingMessage.class) {
+            PacketEditingMessage pkt = (PacketEditingMessage)msg;
+            switch(pkt.getType())
+            {
+                case ATTACK_ENTITY:
+                {
+                    TextComponent prefix = new TextComponent("TBM: ");
+                    prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true));
+                    TextComponent text = new TextComponent("Attack the entity you want to edit for TurnBasedMinecraftMod. ");
+                    text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
+
+                    TextComponent cancel = new TextComponent("Cancel");
+                    cancel.setStyle(cancel.getStyle().withColor(TextColor.fromRgb(0xFFFF0000)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit cancel")));
+                    text.getSiblings().add(cancel);
+
+                    prefix.getSiblings().add(text);
+                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
+                    break;
+                }
+                case PICK_EDIT:
+                {
+                    TextComponent prefix = new TextComponent("TBM: ");
+                    prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true));
+                    TextComponent text = new TextComponent("Edit what value? ");
+                    text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
+
+                    TextComponent option = new TextComponent("IgB");
+                    // HoverEvent.Action.SHOW_TEXT is probably SHOW_TEXT
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle"))
+                            .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("IgnoreBattle"))));
+                    TextComponent value = new TextComponent("(" + pkt.getEntityInfo().ignoreBattle + ") ");
+                    value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                    option.getSiblings().add(value);
+                    text.getSiblings().add(option);
+
+                    option = new TextComponent("AP");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackPower"))
+                            .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("AttackPower"))));
+                    value = new TextComponent("(" + pkt.getEntityInfo().attackPower + ") ");
+                    value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                    option.getSiblings().add(value);
+                    text.getSiblings().add(option);
+
+                    option = new TextComponent("APr");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackProbability"))
+                            .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("AttackProbability"))));
+                    value = new TextComponent("(" + pkt.getEntityInfo().attackProbability + "%) ");
+                    value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                    option.getSiblings().add(value);
+                    text.getSiblings().add(option);
+
+                    option = new TextComponent("AV");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackVariance"))
+                            .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("AttackVariance"))));
+                    value = new TextComponent("(" + pkt.getEntityInfo().attackVariance + ") ");
+                    value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                    option.getSiblings().add(value);
+                    text.getSiblings().add(option);
+
+                    option = new TextComponent("AE");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffect"))
+                            .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("AttackEffect"))));
+                    value = new TextComponent("(" + pkt.getEntityInfo().attackEffect.toString() + ") ");
+                    value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                    option.getSiblings().add(value);
+                    text.getSiblings().add(option);
+
+                    option = new TextComponent("AEPr");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffectProbability"))
+                            .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("AttackEffectProbability"))));
+                    value = new TextComponent("(" + pkt.getEntityInfo().attackEffectProbability + "%) ");
+                    value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                    option.getSiblings().add(value);
+                    text.getSiblings().add(option);
+
+                    option = new TextComponent("DD");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamage"))
+                            .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("DefenseDamage"))));
+                    value = new TextComponent("(" + pkt.getEntityInfo().defenseDamage + ") ");
+                    value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                    option.getSiblings().add(value);
+                    text.getSiblings().add(option);
+
+                    option = new TextComponent("DDPr");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamageProbability"))
+                            .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("DefenseDamageProbability"))));
+                    value = new TextComponent("(" + pkt.getEntityInfo().defenseDamageProbability + "%) ");
+                    value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                    option.getSiblings().add(value);
+                    text.getSiblings().add(option);
+
+                    option = new TextComponent("E");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit evasion"))
+                            .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("Evasion"))));
+                    value = new TextComponent("(" + pkt.getEntityInfo().evasion + "%) ");
+                    value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                    option.getSiblings().add(value);
+                    text.getSiblings().add(option);
+
+                    option = new TextComponent("S");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit speed"))
+                            .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("Speed"))));
+                    value = new TextComponent("(" + pkt.getEntityInfo().speed + ") ");
+                    value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                    option.getSiblings().add(value);
+                    text.getSiblings().add(option);
+
+                    option = new TextComponent("C");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category"))
+                            .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("Category"))));
+                    value = new TextComponent("(" + pkt.getEntityInfo().category + ") ");
+                    value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                    option.getSiblings().add(value);
+                    text.getSiblings().add(option);
+
+                    option = new TextComponent("DecA");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionAttack"))
+                            .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("DecisionAttack"))));
+                    value = new TextComponent("(" + pkt.getEntityInfo().decisionAttack + "%) ");
+                    value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                    option.getSiblings().add(value);
+                    text.getSiblings().add(option);
+
+                    option = new TextComponent("DecD");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionDefend"))
+                            .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("DecisionDefend"))));
+                    value = new TextComponent("(" + pkt.getEntityInfo().decisionDefend + "%) ");
+                    value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                    option.getSiblings().add(value);
+                    text.getSiblings().add(option);
+
+                    option = new TextComponent("DecF");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionFlee"))
+                            .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("DecisionFlee"))));
+                    value = new TextComponent("(" + pkt.getEntityInfo().decisionFlee + "%) ");
+                    value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                    option.getSiblings().add(value);
+                    text.getSiblings().add(option);
+
+                    option = new TextComponent("Finished Editing");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit finish")));
+                    text.getSiblings().add(option);
+                    text.getSiblings().add(new TextComponent(" "));
+
+                    option = new TextComponent("Cancel");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFF0000)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit cancel")));
+                    text.getSiblings().add(option);
+
+                    prefix.getSiblings().add(text);
+                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
+                    break;
+                }
+                case EDIT_IGNORE_BATTLE:
+                {
+                    TextComponent prefix = new TextComponent("TBM: ");
+                    prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true));
+                    TextComponent text = new TextComponent("ignoreBattle: ");
+                    text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
+
+                    TextComponent option = new TextComponent("true");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle true")));
+                    text.getSiblings().add(option);
+
+                    text.getSiblings().add(new TextComponent(" "));
+
+                    option = new TextComponent("false");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFF0000)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle false")));
+                    text.getSiblings().add(option);
+
+                    prefix.getSiblings().add(text);
+                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
+                    break;
+                }
+                case EDIT_ATTACK_POWER:
+                {
+                    TextComponent prefix = new TextComponent("TBM: ");
+                    prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true));
+                    TextComponent text = new TextComponent("attackPower: ");
+                    text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
+
+                    for(int i = 0; i <= 15; ++i)
+                    {
+                        TextComponent option = new TextComponent(Integer.toString(i));
+                        option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackPower " + Integer.toString(i))));
+                        text.getSiblings().add(option);
+                        if(i < 15)
+                        {
+                            text.getSiblings().add(new TextComponent(", "));
+                        }
+                    }
+
+                    text.getSiblings().add(new TextComponent(" (or use command \"/tbm-edit edit attackPower <integer>\")"));
+
+                    prefix.getSiblings().add(text);
+                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
+                    break;
+                }
+                case EDIT_ATTACK_PROBABILITY:
+                {
+                    TextComponent prefix = new TextComponent("TBM: ");
+                    prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true));
+                    TextComponent text = new TextComponent("attackProbability: ");
+                    text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
+
+                    for(int i = 10; i <= 100; i += 10)
+                    {
+                        TextComponent option = new TextComponent(Integer.toString(i) + "%");
+                        option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackProbability " + Integer.toString(i))));
+                        text.getSiblings().add(option);
+                        if(i < 100)
+                        {
+                            text.getSiblings().add(new TextComponent(", "));
+                        }
+                    }
+
+                    text.getSiblings().add(new TextComponent(" (or use command \"/tbm-edit edit attackProbability <percentage-integer>\")"));
+
+                    prefix.getSiblings().add(text);
+                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
+                    break;
+                }
+                case EDIT_ATTACK_VARIANCE:
+                {
+                    TextComponent prefix = new TextComponent("TBM: ");
+                    prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true));
+                    TextComponent text = new TextComponent("attackVariance: ");
+                    text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
+
+                    for(int i = 0; i <= 10; ++i)
+                    {
+                        TextComponent option = new TextComponent(Integer.toString(i));
+                        option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackVariance " + Integer.toString(i))));
+                        text.getSiblings().add(option);
+                        if(i < 10)
+                        {
+                            text.getSiblings().add(new TextComponent(", "));
+                        }
+                    }
+
+                    text.getSiblings().add(new TextComponent(" (or use command \"/tbm-edit edit attackVariance <integer>\")"));
+
+                    prefix.getSiblings().add(text);
+                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
+                    break;
+                }
+                case EDIT_ATTACK_EFFECT:
+                {
+                    TextComponent prefix = new TextComponent("TBM: ");
+                    prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true));
+                    TextComponent text = new TextComponent("attackEffect: ");
+                    text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
+
+                    for(EntityInfo.Effect e : EntityInfo.Effect.values())
+                    {
+                        TextComponent option = new TextComponent(e.toString());
+                        option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffect " + e.toString())));
+                        text.getSiblings().add(option);
+                        if(e != EntityInfo.Effect.UNKNOWN)
+                        {
+                            // TODO find a better way to handle printing comma for items before last
+                            text.getSiblings().add(new TextComponent(", "));
+                        }
+                    }
+
+                    prefix.getSiblings().add(text);
+                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
+                    break;
+                }
+                case EDIT_ATTACK_EFFECT_PROBABILITY:
+                {
+                    TextComponent prefix = new TextComponent("TBM: ");
+                    prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true));
+                    TextComponent text = new TextComponent("attackEffectProbability: ");
+                    text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
+
+                    for(int i = 0; i <= 100; i += 10)
+                    {
+                        TextComponent option = new TextComponent(Integer.toString(i) + "%");
+                        option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffectProbability " + Integer.toString(i))));
+                        text.getSiblings().add(option);
+                        if(i < 100)
+                        {
+                            text.getSiblings().add(new TextComponent(", "));
+                        }
+                    }
+
+                    text.getSiblings().add(new TextComponent(" (or use command \"/tbm-edit edit attackEffectProbability <percentage-integer>\")"));
+
+                    prefix.getSiblings().add(text);
+                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
+                    break;
+                }
+                case EDIT_DEFENSE_DAMAGE:
+                {
+                    TextComponent prefix = new TextComponent("TBM: ");
+                    prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true));
+                    TextComponent text = new TextComponent("defenseDamage: ");
+                    text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
+
+                    for(int i = 0; i <= 15; ++i)
+                    {
+                        TextComponent option = new TextComponent(Integer.toString(i));
+                        option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamage " + Integer.toString(i))));
+                        text.getSiblings().add(option);
+                        if(i < 15)
+                        {
+                            text.getSiblings().add(new TextComponent(", "));
+                        }
+                    }
+
+                    text.getSiblings().add(new TextComponent(" (or use command \"/tbm-edit edit defenseDamage <integer>\")"));
+
+                    prefix.getSiblings().add(text);
+                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
+                    break;
+                }
+                case EDIT_DEFENSE_DAMAGE_PROBABILITY:
+                {
+                    TextComponent prefix = new TextComponent("TBM: ");
+                    prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true));
+                    TextComponent text = new TextComponent("defenseDamageProbability: ");
+                    text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
+
+                    for(int i = 0; i <= 100; i += 10)
+                    {
+                        TextComponent option = new TextComponent(Integer.toString(i) + "%");
+                        option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamageProbability " + Integer.toString(i))));
+                        text.getSiblings().add(option);
+                        if(i < 100)
+                        {
+                            text.getSiblings().add(new TextComponent(", "));
+                        }
+                    }
+
+                    text.getSiblings().add(new TextComponent(" (or use command \"/tbm-edit edit defenseDamageProbability <percentage-integer>\")"));
+
+                    prefix.getSiblings().add(text);
+                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
+                    break;
+                }
+                case EDIT_EVASION:
+                {
+                    TextComponent prefix = new TextComponent("TBM: ");
+                    prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true));
+                    TextComponent text = new TextComponent("evasion: ");
+                    text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
+
+                    for(int i = 0; i <= 100; i += 10)
+                    {
+                        TextComponent option = new TextComponent(Integer.toString(i) + "%");
+                        option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit evasion " + Integer.toString(i))));
+                        text.getSiblings().add(option);
+                        if(i < 100)
+                        {
+                            text.getSiblings().add(new TextComponent(", "));
+                        }
+                    }
+
+                    text.getSiblings().add(new TextComponent(" (or use command \"/tbm-edit edit evasion <percentage-integer>\")"));
+
+                    prefix.getSiblings().add(text);
+                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
+                    break;
+                }
+                case EDIT_SPEED:
+                {
+                    TextComponent prefix = new TextComponent("TBM: ");
+                    prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true));
+                    TextComponent text = new TextComponent("speed: ");
+                    text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
+
+                    for(int i = 0; i <= 100; i += 10)
+                    {
+                        TextComponent option = new TextComponent(Integer.toString(i));
+                        option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit speed " + Integer.toString(i))));
+                        text.getSiblings().add(option);
+                        if(i < 100)
+                        {
+                            text.getSiblings().add(new TextComponent(", "));
+                        }
+                    }
+
+                    text.getSiblings().add(new TextComponent(" (or use command \"/tbm-edit edit speed <integer>\")"));
+
+                    prefix.getSiblings().add(text);
+                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
+                    break;
+                }
+                case EDIT_CATEGORY:
+                {
+                    TextComponent prefix = new TextComponent("TBM: ");
+                    prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true));
+                    TextComponent text = new TextComponent("category: ");
+                    text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
+
+                    TextComponent option = new TextComponent("monster");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category monster")));
+                    if(TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("monster"))
+                    {
+                        TextComponent optionInfo = new TextComponent("(battle-");
+                        optionInfo.setStyle(optionInfo.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                        TextComponent optionInfoBool = new TextComponent("disabled");
+                        optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(TextColor.fromRgb(0xFFFF0000)));
+                        optionInfo.getSiblings().add(optionInfoBool);
+                        optionInfo.getSiblings().add(new TextComponent(")"));
+                        option.getSiblings().add(optionInfo);
+                    }
+                    else
+                    {
+                        TextComponent optionInfo = new TextComponent("(battle-");
+                        optionInfo.setStyle(optionInfo.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                        TextComponent optionInfoBool = new TextComponent("enabled");
+                        optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)));
+                        optionInfo.getSiblings().add(optionInfoBool);
+                        optionInfo.getSiblings().add(new TextComponent(")"));
+                        option.getSiblings().add(optionInfo);
+                    }
+                    text.getSiblings().add(option);
+                    text.getSiblings().add(new TextComponent(", "));
+
+                    option = new TextComponent("animal");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category animal")));
+                    if(TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("animal"))
+                    {
+                        TextComponent optionInfo = new TextComponent("(battle-");
+                        optionInfo.setStyle(optionInfo.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                        TextComponent optionInfoBool = new TextComponent("disabled");
+                        optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(TextColor.fromRgb(0xFFFF0000)));
+                        optionInfo.getSiblings().add(optionInfoBool);
+                        optionInfo.getSiblings().add(new TextComponent(")"));
+                        option.getSiblings().add(optionInfo);
+                    }
+                    else
+                    {
+                        TextComponent optionInfo = new TextComponent("(battle-");
+                        optionInfo.setStyle(optionInfo.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                        TextComponent optionInfoBool = new TextComponent("enabled");
+                        optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)));
+                        optionInfo.getSiblings().add(optionInfoBool);
+                        optionInfo.getSiblings().add(new TextComponent(")"));
+                        option.getSiblings().add(optionInfo);
+                    }
+                    text.getSiblings().add(option);
+                    text.getSiblings().add(new TextComponent(", "));
+
+                    option = new TextComponent("passive");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category passive")));
+                    if(TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("passive"))
+                    {
+                        TextComponent optionInfo = new TextComponent("(battle-");
+                        optionInfo.setStyle(optionInfo.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                        TextComponent optionInfoBool = new TextComponent("disabled");
+                        optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(TextColor.fromRgb(0xFFFF0000)));
+                        optionInfo.getSiblings().add(optionInfoBool);
+                        optionInfo.getSiblings().add(new TextComponent(")"));
+                        option.getSiblings().add(optionInfo);
+                    }
+                    else
+                    {
+                        TextComponent optionInfo = new TextComponent("(battle-");
+                        optionInfo.setStyle(optionInfo.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                        TextComponent optionInfoBool = new TextComponent("enabled");
+                        optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)));
+                        optionInfo.getSiblings().add(optionInfoBool);
+                        optionInfo.getSiblings().add(new TextComponent(")"));
+                        option.getSiblings().add(optionInfo);
+                    }
+                    text.getSiblings().add(option);
+                    text.getSiblings().add(new TextComponent(", "));
+
+                    option = new TextComponent("boss");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category boss")));
+                    if(TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("boss"))
+                    {
+                        TextComponent optionInfo = new TextComponent("(battle-");
+                        optionInfo.setStyle(optionInfo.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                        TextComponent optionInfoBool = new TextComponent("disabled");
+                        optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(TextColor.fromRgb(0xFFFF0000)));
+                        optionInfo.getSiblings().add(optionInfoBool);
+                        optionInfo.getSiblings().add(new TextComponent(")"));
+                        option.getSiblings().add(optionInfo);
+                    }
+                    else
+                    {
+                        TextComponent optionInfo = new TextComponent("(battle-");
+                        optionInfo.setStyle(optionInfo.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                        TextComponent optionInfoBool = new TextComponent("enabled");
+                        optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)));
+                        optionInfo.getSiblings().add(optionInfoBool);
+                        optionInfo.getSiblings().add(new TextComponent(")"));
+                        option.getSiblings().add(optionInfo);
+                    }
+                    text.getSiblings().add(option);
+                    text.getSiblings().add(new TextComponent(", "));
+
+                    option = new TextComponent("player");
+                    option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category player")));
+                    if(TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("player"))
+                    {
+                        TextComponent optionInfo = new TextComponent("(battle-");
+                        optionInfo.setStyle(optionInfo.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                        TextComponent optionInfoBool = new TextComponent("disabled");
+                        optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(TextColor.fromRgb(0xFFFF0000)));
+                        optionInfo.getSiblings().add(optionInfoBool);
+                        optionInfo.getSiblings().add(new TextComponent(")"));
+                        option.getSiblings().add(optionInfo);
+                    }
+                    else
+                    {
+                        TextComponent optionInfo = new TextComponent("(battle-");
+                        optionInfo.setStyle(optionInfo.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
+                        TextComponent optionInfoBool = new TextComponent("enabled");
+                        optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)));
+                        optionInfo.getSiblings().add(optionInfoBool);
+                        optionInfo.getSiblings().add(new TextComponent(")"));
+                        option.getSiblings().add(optionInfo);
+                    }
+                    text.getSiblings().add(option);
+
+                    text.getSiblings().add(new TextComponent(" (or use command \"/tbm-edit edit category <string>\")"));
+
+                    prefix.getSiblings().add(text);
+                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
+                    break;
+                }
+                case EDIT_DECISION_ATTACK:
+                {
+                    TextComponent prefix = new TextComponent("TBM: ");
+                    prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true));
+                    TextComponent text = new TextComponent("decisionAttack: ");
+                    text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
+
+                    for(int i = 0; i <= 100; i += 10)
+                    {
+                        TextComponent option = new TextComponent(Integer.toString(i) + "%");
+                        option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionAttack " + Integer.toString(i))));
+                        text.getSiblings().add(option);
+                        if(i < 100)
+                        {
+                            text.getSiblings().add(new TextComponent(", "));
+                        }
+                    }
+
+                    prefix.getSiblings().add(text);
+                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
+                    break;
+                }
+                case EDIT_DECISION_DEFEND:
+                {
+                    TextComponent prefix = new TextComponent("TBM: ");
+                    prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true));
+                    TextComponent text = new TextComponent("decisionDefend: ");
+                    text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
+
+                    for(int i = 0; i <= 100; i += 10)
+                    {
+                        TextComponent option = new TextComponent(Integer.toString(i) + "%");
+                        option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionDefend " + Integer.toString(i))));
+                        text.getSiblings().add(option);
+                        if(i < 100)
+                        {
+                            text.getSiblings().add(new TextComponent(", "));
+                        }
+                    }
+
+                    prefix.getSiblings().add(text);
+                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
+                    break;
+                }
+                case EDIT_DECISION_FLEE:
+                {
+                    TextComponent prefix = new TextComponent("TBM: ");
+                    prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true));
+                    TextComponent text = new TextComponent("decisionFlee: ");
+                    text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
+
+                    for(int i = 0; i <= 100; i += 10)
+                    {
+                        TextComponent option = new TextComponent(Integer.toString(i) + "%");
+                        option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionFlee " + Integer.toString(i))));
+                        text.getSiblings().add(option);
+                        if(i < 100)
+                        {
+                            text.getSiblings().add(new TextComponent(", "));
+                        }
+                    }
+
+                    prefix.getSiblings().add(text);
+                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
+                    break;
+                }
+                default:
+                    break;
+            }
+        }
+    }
 }
index 99a017b0667ba48a2c2ff8d779d057a2b956fdd9..59cd7296446bf65b7402c310d22e49811f4b7546 100644 (file)
@@ -1,18 +1,18 @@
 package com.burnedkirby.TurnBasedMinecraft.client;
 
-import com.mojang.blaze3d.matrix.MatrixStack;
+import com.mojang.blaze3d.vertex.PoseStack;
 import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.widget.button.Button;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.LivingEntity;
-import net.minecraft.util.text.StringTextComponent;
+import net.minecraft.client.gui.components.Button;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.entity.LivingEntity;
+import net.minecraft.network.chat.TextComponent;
 
 public class EntitySelectionButton extends Button {
     private int entityID;
     private boolean isSideA;
 
-    public EntitySelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int entityID, boolean isSideA, Button.IPressable onPress) {
-        super(x, y, widthIn, heightIn, new StringTextComponent(buttonText), onPress);
+    public EntitySelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int entityID, boolean isSideA, Button.OnPress onPress) {
+        super(x, y, widthIn, heightIn, new TextComponent(buttonText), onPress);
         this.entityID = entityID;
         this.isSideA = isSideA;
     }
@@ -26,8 +26,8 @@ public class EntitySelectionButton extends Button {
     }
 
     @Override
-    public void renderButton(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
-        super.renderButton(matrixStack, mouseX, mouseY, partialTicks);
+    public void renderButton(PoseStack poseStack, int mouseX, int mouseY, float partialTicks) {
+        super.renderButton(poseStack, mouseX, mouseY, partialTicks);
         Entity e = Minecraft.getInstance().level.getEntity(entityID);
         if (e != null && e instanceof LivingEntity && ((LivingEntity) e).isAlive()) {
             int health = (int) (((LivingEntity) e).getHealth() + 0.5f);
@@ -41,38 +41,38 @@ public class EntitySelectionButton extends Button {
                 xoffset = -4;
             }
             if (health > 200) {
-                fill(matrixStack, xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
-                fill(matrixStack, xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
-                fill(matrixStack, xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
-                fill(matrixStack, xpos, getY() + getHeight() / 5, xpos + 2, getY() + getHeight() * 2 / 5, 0xFF00FFFF);
-                fill(matrixStack, xpos, getY(), xpos + 2, getY() + getHeight() / 5, 0xFF0000FF);
+                fill(poseStack, xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
+                fill(poseStack, xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
+                fill(poseStack, xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
+                fill(poseStack, xpos, getY() + getHeight() / 5, xpos + 2, getY() + getHeight() * 2 / 5, 0xFF00FFFF);
+                fill(poseStack, xpos, getY(), xpos + 2, getY() + getHeight() / 5, 0xFF0000FF);
                 int healthHeight = ((health - 200) * getHeight() / 100);
-                fill(matrixStack, xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFFFFFF);
+                fill(poseStack, xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFFFFFF);
             } else if (health > 100) {
-                fill(matrixStack, xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
-                fill(matrixStack, xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
-                fill(matrixStack, xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
-                fill(matrixStack, xpos, getY() + getHeight() / 5, xpos + 2, getY() + getHeight() * 2 / 5, 0xFF00FFFF);
+                fill(poseStack, xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
+                fill(poseStack, xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
+                fill(poseStack, xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
+                fill(poseStack, xpos, getY() + getHeight() / 5, xpos + 2, getY() + getHeight() * 2 / 5, 0xFF00FFFF);
                 int healthHeight = ((health - 100) * getHeight() / 100);
-                fill(matrixStack, xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF0000FF);
+                fill(poseStack, xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF0000FF);
             } else if (health > 50) {
-                fill(matrixStack, xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
-                fill(matrixStack, xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
-                fill(matrixStack, xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
+                fill(poseStack, xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
+                fill(poseStack, xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
+                fill(poseStack, xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
                 int healthHeight = ((health - 50) * getHeight() / 50);
-                fill(matrixStack, xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF00FFFF);
+                fill(poseStack, xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF00FFFF);
             } else if (health > 20) {
-                fill(matrixStack, xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
-                fill(matrixStack, xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
+                fill(poseStack, xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
+                fill(poseStack, xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
                 int healthHeight = ((health - 20) * getHeight() / 30);
-                fill(matrixStack, xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF00FF00);
+                fill(poseStack, xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF00FF00);
             } else if (health > 10) {
-                fill(matrixStack, xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
+                fill(poseStack, xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
                 int healthHeight = ((health - 10) * getHeight() / 10);
-                fill(matrixStack, xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFFFF00);
+                fill(poseStack, xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFFFF00);
             } else {
                 int healthHeight = (health * getHeight() / 10);
-                fill(matrixStack, xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFF0000);
+                fill(poseStack, xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFF0000);
             }
         }
     }
index 56f1e2a26387c96683a531216cf293a4137ce874..1e3bd62ca8cc11131f7b9cf27b4d2db2dc05e485 100644 (file)
@@ -1,14 +1,14 @@
 package com.burnedkirby.TurnBasedMinecraft.client;
 
-import com.mojang.blaze3d.matrix.MatrixStack;
-import net.minecraft.client.gui.widget.button.Button;
-import net.minecraft.util.text.StringTextComponent;
+import com.mojang.blaze3d.vertex.PoseStack;
+import net.minecraft.client.gui.components.Button;
+import net.minecraft.network.chat.TextComponent;
 
 public class ItemSelectionButton extends Button {
     private int itemStackID;
 
-    public ItemSelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int itemStackID, Button.IPressable onPress) {
-        super(x, y, widthIn, heightIn, new StringTextComponent(buttonText), onPress);
+    public ItemSelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int itemStackID, Button.OnPress onPress) {
+        super(x, y, widthIn, heightIn, new TextComponent(buttonText), onPress);
         this.itemStackID = itemStackID;
     }
 
@@ -17,13 +17,13 @@ public class ItemSelectionButton extends Button {
     }
 
     @Override
-    public void renderButton(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
+    public void renderButton(PoseStack poseStack, int mouseX, int mouseY, float partialTicks) {
         if (visible) {
             boolean hovered = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + getWidth() && mouseY < getY() + getHeight();
             if (hovered) {
-                fill(matrixStack, getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x80FFFFFF);
+                fill(poseStack, getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x80FFFFFF);
             } else {
-                fill(matrixStack, getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x20707070);
+                fill(poseStack, getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x20707070);
             }
         }
     }
index 79de50b7e95765c4c2ead76cef9feacc858d0bfe..59de6e092a0732842b387fa4117e22dce2218c78 100644 (file)
@@ -6,12 +6,12 @@ import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleMessage;
 
 import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketEditingMessage;
 import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketGeneralMessage;
-import net.minecraft.entity.monster.CreeperEntity;
-import net.minecraft.entity.player.ServerPlayerEntity;
+import net.minecraft.world.entity.monster.Creeper;
+import net.minecraft.server.level.ServerPlayer;
 import net.minecraftforge.event.entity.living.LivingAttackEvent;
 import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
 import net.minecraftforge.eventbus.api.SubscribeEvent;
-import net.minecraftforge.fml.network.PacketDistributor;
+import net.minecraftforge.network.PacketDistributor;
 
 public class AttackEventHandler
 {
@@ -81,7 +81,7 @@ public class AttackEventHandler
                        if(!event.getEntity().hasCustomName())
                         {
                             TurnBasedMinecraftMod.logger.error("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"));
+                            TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)editingInfo.editor), new PacketGeneralMessage("Cannot edit custom name from entity without custom name"));
                             return;
                         }
                         editingInfo.entityInfo = config.getCustomEntityInfo(event.getEntity().getCustomName().getString());
@@ -90,9 +90,9 @@ public class AttackEventHandler
                             editingInfo.entityInfo = new EntityInfo();
                             editingInfo.entityInfo.customName = event.getEntity().getCustomName().getString();
                         }
-                        TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity)editingInfo.editor), new PacketGeneralMessage("Editing custom name \"" + event.getEntity().getCustomName().getString() + "\""));
+                        TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)editingInfo.editor), new PacketGeneralMessage("Editing custom name \"" + 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(() -> (ServerPlayer)editingInfo.editor), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
                     }
                     else
                     {
@@ -106,9 +106,9 @@ public class AttackEventHandler
                         {
                             editingInfo.entityInfo = editingInfo.entityInfo.clone();
                         }
-                        TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity)editingInfo.editor), new PacketGeneralMessage("Editing entity \"" + editingInfo.entityInfo.classType.getName() + "\""));
+                        TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)editingInfo.editor), new PacketGeneralMessage("Editing entity \"" + editingInfo.entityInfo.classType.getName() + "\""));
                         TurnBasedMinecraftMod.logger.info("Begin editing \"" + editingInfo.entityInfo.classType.getName() + "\"");
-                        TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity)editingInfo.editor), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
+                        TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)editingInfo.editor), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
                     }
                     return;
                 }
@@ -116,7 +116,7 @@ public class AttackEventHandler
         }
         if(event.getEntity() != null && event.getSource().getEntity() != null && (battleManager.isRecentlyLeftBattle(event.getEntity().getId()) || battleManager.isRecentlyLeftBattle(event.getSource().getEntity().getId())))
         {
-            if(event.getSource().getEntity().getEntity() instanceof CreeperEntity && TurnBasedMinecraftMod.proxy.getConfig().getCreeperAlwaysAllowDamage()) {
+            if(event.getSource().getEntity() instanceof Creeper && TurnBasedMinecraftMod.proxy.getConfig().getCreeperAlwaysAllowDamage()) {
                 event.setCanceled(false);
             } else {
 //            TurnBasedMinecraftMod.logger.debug("Canceled attack");
index 1b545e29df85669316d92d2ba57fa2c62b0bb675..b7d279f1d32c9c3edb7d4488c506383dc9d4d87b 100644 (file)
@@ -1,6 +1,6 @@
 package com.burnedkirby.TurnBasedMinecraft.common;
 
-import net.minecraft.entity.Entity;
+import net.minecraft.world.entity.Entity;
 
 public class AttackerViaBow
 {
index 1bacc908bf640ca4104bcb14dd19ea0387299158..6caeb69a2e87723ee1c92b6bb9d247f7e88e479d 100644 (file)
@@ -1,23 +1,22 @@
 package com.burnedkirby.TurnBasedMinecraft.common;
 
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicInteger;
-
 import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleInfo;
 import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleMessage;
+import net.minecraft.resources.ResourceKey;
+import net.minecraft.server.level.ServerPlayer;
+import net.minecraft.world.damagesource.DamageSource;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.entity.LivingEntity;
+import net.minecraft.world.entity.Mob;
+import net.minecraft.world.entity.monster.Creeper;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.item.*;
+import net.minecraft.world.level.Level;
+import net.minecraftforge.network.PacketDistributor;
 
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.LivingEntity;
-import net.minecraft.entity.MobEntity;
-import net.minecraft.entity.monster.CreeperEntity;
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.entity.player.ServerPlayerEntity;
-import net.minecraft.item.*;
-import net.minecraft.util.DamageSource;
-import net.minecraft.util.RegistryKey;
-import net.minecraft.world.World;
-import net.minecraftforge.fml.network.PacketDistributor;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
 
 public class Battle
 {
@@ -44,7 +43,7 @@ public class Battle
     
     public String debugLog; // TODO remove after freeze bug has been found
 
-    private RegistryKey<World> dimension;
+    private ResourceKey<Level> dimension;
     
     public enum State
     {
@@ -117,7 +116,7 @@ public class Battle
         }
     }
 
-    public Battle(BattleManager battleManager, int id, Collection<Entity> sideA, Collection<Entity> sideB, boolean isServer, RegistryKey<World> dimension)
+    public Battle(BattleManager battleManager, int id, Collection<Entity> sideA, Collection<Entity> sideB, boolean isServer, ResourceKey<Level> dimension)
     {
         this.battleManager = battleManager;
         this.isServer = isServer;
@@ -147,7 +146,7 @@ public class Battle
                     entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(e);
                 }
 
-                if(entityInfo == null && !(e instanceof PlayerEntity) && TurnBasedMinecraftMod.proxy.isServerRunning())
+                if(entityInfo == null && !(e instanceof Player) && TurnBasedMinecraftMod.proxy.isServerRunning())
                 {
                     continue;
                 }
@@ -155,7 +154,7 @@ public class Battle
                 newCombatant.isSideA = true;
                 newCombatant.battleID = getId();
                 this.sideA.put(e.getId(), newCombatant);
-                if(e instanceof PlayerEntity)
+                if(e instanceof Player)
                 {
                     newCombatant.recalcSpeedOnCompare = true;
                     playerCount.incrementAndGet();
@@ -165,8 +164,8 @@ public class Battle
                 {
                     newCombatant.x = e.getX();
                     newCombatant.z = e.getZ();
-                    newCombatant.yaw = e.xRot;
-                    newCombatant.pitch = e.yRot;
+                    newCombatant.yaw = e.getXRot();
+                    newCombatant.pitch = e.getYRot();
                 }
             }
         }
@@ -185,7 +184,7 @@ public class Battle
                     entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(e);
                 }
 
-                if(entityInfo == null && !(e instanceof PlayerEntity) && TurnBasedMinecraftMod.proxy.isServerRunning())
+                if(entityInfo == null && !(e instanceof Player) && TurnBasedMinecraftMod.proxy.isServerRunning())
                 {
                     continue;
                 }
@@ -193,7 +192,7 @@ public class Battle
                 newCombatant.isSideA = false;
                 newCombatant.battleID = getId();
                 this.sideB.put(e.getId(), newCombatant);
-                if(e instanceof PlayerEntity)
+                if(e instanceof Player)
                 {
                     newCombatant.recalcSpeedOnCompare = true;
                     playerCount.incrementAndGet();
@@ -203,8 +202,8 @@ public class Battle
                 {
                     newCombatant.x = e.getX();
                     newCombatant.z = e.getZ();
-                    newCombatant.yaw = e.xRot;
-                    newCombatant.pitch = e.yRot;
+                    newCombatant.yaw = e.getXRot();
+                    newCombatant.pitch = e.getYRot();
                 }
             }
         }
@@ -217,7 +216,7 @@ public class Battle
                 {
                     sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getId(), 0, id, c.entityInfo.category);
                 }
-                else if(c.entity instanceof PlayerEntity)
+                else if(c.entity instanceof Player)
                 {
                     sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getId(), 0, id, "player");
                 }
@@ -232,7 +231,7 @@ public class Battle
                 {
                     sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getId(), 0, id, c.entityInfo.category);
                 }
-                else if(c.entity instanceof PlayerEntity)
+                else if(c.entity instanceof Player)
                 {
                     sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getId(), 0, id, "player");
                 }
@@ -316,7 +315,7 @@ public class Battle
             entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(e);
         }
 
-        if(entityInfo == null && !(e instanceof PlayerEntity) && TurnBasedMinecraftMod.proxy.isServerRunning())
+        if(entityInfo == null && !(e instanceof Player) && TurnBasedMinecraftMod.proxy.isServerRunning())
         {
             return;
         }
@@ -331,7 +330,7 @@ public class Battle
         {
             sideA.put(e.getId(), newCombatant);
         }
-        if(e instanceof PlayerEntity)
+        if(e instanceof Player)
         {
             newCombatant.recalcSpeedOnCompare = true;
             playerCount.incrementAndGet();
@@ -345,8 +344,8 @@ public class Battle
         {
             newCombatant.x = e.getX();
             newCombatant.z = e.getZ();
-            newCombatant.yaw = e.xRot;
-            newCombatant.pitch = e.yRot;
+            newCombatant.yaw = e.getXRot();
+            newCombatant.pitch = e.getYRot();
         }
         if(isServer)
         {
@@ -354,7 +353,7 @@ public class Battle
             {
                 sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getId(), 0, id, newCombatant.entityInfo.category);
             }
-            else if(newCombatant.entity instanceof PlayerEntity)
+            else if(newCombatant.entity instanceof Player)
             {
                 sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getId(), 0, id, "player");
             }
@@ -379,7 +378,7 @@ public class Battle
             entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(e);
         }
 
-        if(entityInfo == null && !(e instanceof PlayerEntity) && TurnBasedMinecraftMod.proxy.isServerRunning())
+        if(entityInfo == null && !(e instanceof Player) && TurnBasedMinecraftMod.proxy.isServerRunning())
         {
             return;
         }
@@ -394,7 +393,7 @@ public class Battle
         {
             sideB.put(e.getId(), newCombatant);
         }
-        if(e instanceof PlayerEntity)
+        if(e instanceof Player)
         {
             newCombatant.recalcSpeedOnCompare = true;
             playerCount.incrementAndGet();
@@ -408,8 +407,8 @@ public class Battle
         {
             newCombatant.x = e.getX();
             newCombatant.z = e.getZ();
-            newCombatant.yaw = e.xRot;
-            newCombatant.pitch = e.yRot;
+            newCombatant.yaw = e.getXRot();
+            newCombatant.pitch = e.getYRot();
         }
         if(isServer)
         {
@@ -417,7 +416,7 @@ public class Battle
             {
                 sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getId(), 0, id, newCombatant.entityInfo.category);
             }
-            else if(newCombatant.entity instanceof PlayerEntity)
+            else if(newCombatant.entity instanceof Player)
             {
                 sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getId(), 0, id, "player");
             }
@@ -545,7 +544,7 @@ public class Battle
         PacketBattleInfo infoPacket = new PacketBattleInfo(getSideAIDs(), getSideBIDs(), timer);
         for(Combatant p : players.values())
         {
-            TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity)p.entity), infoPacket);
+            TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)p.entity), infoPacket);
         }
     }
     
@@ -565,7 +564,7 @@ public class Battle
         {
             if(p.entity.isAlive())
             {
-                TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) p.entity), packet);
+                TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) p.entity), packet);
             }
         }
     }
@@ -590,7 +589,7 @@ public class Battle
                 {
                     category = entry.getValue().entityInfo.category;
                 }
-                else if(entry.getValue().entity instanceof PlayerEntity)
+                else if(entry.getValue().entity instanceof Player)
                 {
                     category = "player";
                 }
@@ -611,7 +610,7 @@ public class Battle
                 {
                     category = entry.getValue().entityInfo.category;
                 }
-                else if(entry.getValue().entity instanceof PlayerEntity)
+                else if(entry.getValue().entity instanceof Player)
                 {
                     category = "player";
                 }
@@ -639,7 +638,7 @@ public class Battle
         for(Iterator<Map.Entry<Integer, Combatant>> iter = players.entrySet().iterator(); iter.hasNext();)
         {
             Map.Entry<Integer, Combatant> entry = iter.next();
-            if(entry.getValue().entity != null && ((PlayerEntity)entry.getValue().entity).isCreative())
+            if(entry.getValue().entity != null && ((Player)entry.getValue().entity).isCreative())
             {
                 sendMessageToAllPlayers(PacketBattleMessage.MessageType.BECAME_CREATIVE, entry.getValue().entity.getId(), 0, 0);
                 iter.remove();
@@ -702,9 +701,9 @@ public class Battle
     
     private void removeCombatantPostRemove(Combatant c)
     {
-        if(c.entity instanceof PlayerEntity)
+        if(c.entity instanceof Player)
         {
-            TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) c.entity), new PacketBattleMessage(PacketBattleMessage.MessageType.ENDED, 0, 0, dimension, 0));
+            TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) c.entity), new PacketBattleMessage(PacketBattleMessage.MessageType.ENDED, 0, 0, dimension, 0));
         }
         battleManager.addRecentlyLeftBattle(c);
     }
@@ -831,9 +830,9 @@ public class Battle
                 for(Combatant c : sideA.values())
                 {
                     // picking decision for sideA non-players
-                    if(!(c.entity instanceof PlayerEntity) && c.decision == Decision.UNDECIDED && c.entityInfo != null)
+                    if(!(c.entity instanceof Player) && c.decision == Decision.UNDECIDED && c.entityInfo != null)
                     {
-                        if(c.entity instanceof CreeperEntity) {
+                        if(c.entity instanceof Creeper) {
                             if(c.creeperTurns++ < TurnBasedMinecraftMod.proxy.getConfig().getCreeperExplodeTurn()) {
                                 c.decision = Decision.CREEPER_WAIT;
                             } else {
@@ -858,9 +857,9 @@ public class Battle
                 }
                 for(Combatant c : sideB.values())
                 {
-                    if(!(c.entity instanceof PlayerEntity) && c.decision == Decision.UNDECIDED && c.entityInfo != null)
+                    if(!(c.entity instanceof Player) && c.decision == Decision.UNDECIDED && c.entityInfo != null)
                     {
-                        if(c.entity instanceof CreeperEntity) {
+                        if(c.entity instanceof Creeper) {
                             if(c.creeperTurns++ < TurnBasedMinecraftMod.proxy.getConfig().getCreeperExplodeTurn()) {
                                 c.decision = Decision.CREEPER_WAIT;
                             } else {
@@ -934,7 +933,7 @@ public class Battle
                     case ATTACK:
                         debugLog += " attack";
                         Combatant target = null;
-                        if(next.entity instanceof PlayerEntity)
+                        if(next.entity instanceof Player)
                         {
                             debugLog += " as player";
                             target = sideA.get(next.targetEntityID);
@@ -946,11 +945,11 @@ public class Battle
                             {
                                 continue;
                             }
-                            ItemStack heldItemStack = ((PlayerEntity)next.entity).getMainHandItem();
+                            ItemStack heldItemStack = ((Player)next.entity).getMainHandItem();
                             if(heldItemStack.getItem() instanceof BowItem)
                             {
                                 debugLog += " with bow";
-                                if(Utility.doesPlayerHaveArrows((PlayerEntity)next.entity))
+                                if(Utility.doesPlayerHaveArrows((Player)next.entity))
                                 {
                                     final Entity nextEntity = next.entity;
                                     final Entity targetEntity = target.entity;
@@ -963,10 +962,10 @@ public class Battle
                                         next.pitch = pitchDirection;
                                     }
                                     // have player look at attack target
-                                    ((ServerPlayerEntity)nextEntity).connection.teleport(nextEntity.getX(), nextEntity.getY(), nextEntity.getZ(), yawDirection, pitchDirection);
+                                    ((ServerPlayer)nextEntity).connection.teleport(nextEntity.getX(), nextEntity.getY(), nextEntity.getZ(), yawDirection, pitchDirection);
                                     BowItem itemBow = (BowItem)heldItemStack.getItem();
                                     TurnBasedMinecraftMod.proxy.getAttackerViaBowSet().add(new AttackerViaBow(nextEntity, getId()));
-                                    itemBow.releaseUsing(((PlayerEntity)nextEntity).getMainHandItem(), nextEntity.level, (LivingEntity) nextEntity, randomTimeLeft);
+                                    itemBow.releaseUsing(((Player)nextEntity).getMainHandItem(), nextEntity.level, (LivingEntity) nextEntity, randomTimeLeft);
                                     sendMessageToAllPlayers(PacketBattleMessage.MessageType.FIRED_ARROW, nextEntity.getId(), targetEntity.getId(), 0);
                                 }
                                 else
@@ -977,7 +976,7 @@ public class Battle
                             }
                             debugLog += " without bow";
                             int hitChance = TurnBasedMinecraftMod.proxy.getConfig().getPlayerAttackProbability();
-                            if(target.entity instanceof PlayerEntity)
+                            if(target.entity instanceof Player)
                             {
                                 hitChance = hitChance * (100 - TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion()) / 100;
                             }
@@ -1001,7 +1000,7 @@ public class Battle
                                     final float yawDirection = Utility.yawDirection(next.entity.getX(), next.entity.getZ(), target.entity.getX(), target.entity.getZ());
                                     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;
-                                    if(!(targetEntity instanceof PlayerEntity) && targetEntityInfo.defenseDamage > 0 && targetEntityInfo.defenseDamageProbability > 0)
+                                    if(!(targetEntity instanceof Player) && targetEntityInfo.defenseDamage > 0 && targetEntityInfo.defenseDamageProbability > 0)
                                     {
                                         if(random.nextInt(100) < targetEntityInfo.defenseDamageProbability)
                                         {
@@ -1022,10 +1021,10 @@ public class Battle
                                         next.pitch = pitchDirection;
                                     }
                                     // have player look at attack target
-                                    ((ServerPlayerEntity)nextEntity).connection.teleport(nextEntity.getX(), nextEntity.getY(), nextEntity.getZ(), yawDirection, pitchDirection);
+                                    ((ServerPlayer)nextEntity).connection.teleport(nextEntity.getX(), nextEntity.getY(), nextEntity.getZ(), yawDirection, pitchDirection);
                                     TurnBasedMinecraftMod.proxy.setAttackingEntity(nextEntity);
                                     TurnBasedMinecraftMod.proxy.setAttackingDamage(0);
-                                    ((PlayerEntity)nextEntity).attack(targetEntity);
+                                    ((Player)nextEntity).attack(targetEntity);
                                     TurnBasedMinecraftMod.proxy.setAttackingEntity(null);
                                     sendMessageToAllPlayers(PacketBattleMessage.MessageType.ATTACK, nextEntity.getId(), targetEntity.getId(), TurnBasedMinecraftMod.proxy.getAttackingDamage());
                                     if(defenseDamageTriggered)
@@ -1056,7 +1055,7 @@ public class Battle
                         else
                         {
                             debugLog += " as mob";
-                            LivingEntity attackTarget = ((MobEntity)next.entity).getTarget();
+                            LivingEntity attackTarget = ((Mob)next.entity).getTarget();
                             if(attackTarget != null && hasCombatant(attackTarget.getId()))
                             {
                                 debugLog += " to targeted";
@@ -1101,7 +1100,7 @@ public class Battle
                                 continue;
                             }
                             int hitChance = next.entityInfo.attackProbability;
-                            if(target.entity instanceof PlayerEntity)
+                            if(target.entity instanceof Player)
                             {
                                 hitChance = hitChance * (100 - TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion()) / 100;
                             }
@@ -1137,7 +1136,7 @@ public class Battle
                                     final boolean defenseDamageTriggered;
                                     final boolean attackEffectTriggered;
 
-                                    if(!(targetEntity instanceof PlayerEntity) && targetEntityInfo.defenseDamage > 0 && targetEntityInfo.defenseDamageProbability > 0)
+                                    if(!(targetEntity instanceof Player) && targetEntityInfo.defenseDamage > 0 && targetEntityInfo.defenseDamageProbability > 0)
                                     {
                                         if(random.nextInt(100) < targetEntityInfo.defenseDamageProbability)
                                         {
@@ -1217,7 +1216,7 @@ public class Battle
                         {
                             for(Combatant c : sideB.values())
                             {
-                                if(c.entity instanceof PlayerEntity)
+                                if(c.entity instanceof Player)
                                 {
                                     if(TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed() > fastestEnemySpeed)
                                     {
@@ -1237,7 +1236,7 @@ public class Battle
                         {
                             for(Combatant c : sideA.values())
                             {
-                                if(c.entity instanceof PlayerEntity)
+                                if(c.entity instanceof Player)
                                 {
                                     if(TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed() > fastestEnemySpeed)
                                     {
@@ -1254,7 +1253,7 @@ public class Battle
                             }
                         }
                         int fleeProbability = 0;
-                        if(next.entity instanceof PlayerEntity)
+                        if(next.entity instanceof Player)
                         {
                             if(fastestEnemySpeed >= TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed())
                             {
@@ -1286,7 +1285,7 @@ public class Battle
                             {
                                 fleeingCategory = next.entityInfo.category;
                             }
-                            else if(next.entity instanceof PlayerEntity)
+                            else if(next.entity instanceof Player)
                             {
                                 fleeingCategory = "player";
                             }
@@ -1308,43 +1307,33 @@ public class Battle
                             sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_INVALID.getValue());
                             break;
                         }
-                        ItemStack targetItemStack = ((PlayerEntity)next.entity).inventory.getItem(next.itemToUse);
+                        ItemStack targetItemStack = ((Player) next.entity).getInventory().getItem(next.itemToUse);
                         Item targetItem = targetItemStack.getItem();
                         if(targetItem == null)
                         {
                             debugLog += " null";
                             sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_NOTHING.getValue());
                             break;
-                        }
-                        // check if use item is a food
-                        boolean isFood = false;
-                        // first check other mod foods
-                        for(ItemGroup itemGroup : BattleManager.getOtherFoodItemGroups()) {
-                            if(targetItem.getItemCategory() == itemGroup && targetItem.isEdible()) {
-                                isFood = true;
-                                break;
-                            }
-                        }
-                        if(isFood) {
+                        } else if(targetItem.isEdible()) {
                             debugLog += " food";
                             sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_FOOD.getValue(), targetItemStack.getDisplayName().getString());
                             final Entity nextEntity = next.entity;
                             final int nextItemToUse = next.itemToUse;
-                            ((PlayerEntity)nextEntity).inventory.setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level, (LivingEntity)nextEntity));
+                            ((Player) nextEntity).getInventory().setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level, (LivingEntity)nextEntity));
                         } else {
                             // then check vanilla foods
-                            if (targetItem.getItemCategory() == ItemGroup.TAB_FOOD && targetItem.isEdible()) {
+                            if (targetItem.getItemCategory() == CreativeModeTab.TAB_FOOD && targetItem.isEdible()) {
                                 debugLog += " food";
                                 sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_FOOD.getValue(), targetItemStack.getDisplayName().getString());
                                 final Entity nextEntity = next.entity;
                                 final int nextItemToUse = next.itemToUse;
-                                ((PlayerEntity) nextEntity).inventory.setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level, (LivingEntity) nextEntity));
+                                ((Player) nextEntity).getInventory().setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level, (LivingEntity) nextEntity));
                             } else if (targetItem instanceof PotionItem) {
                                 debugLog += " potion";
                                 sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_POTION.getValue(), targetItemStack.getDisplayName().getString());
                                 final Entity nextEntity = next.entity;
                                 final int nextItemToUse = next.itemToUse;
-                                ((PlayerEntity) nextEntity).inventory.setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level, (LivingEntity) nextEntity));
+                                ((Player) nextEntity).getInventory().setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level, (LivingEntity) nextEntity));
                             } else {
                                 debugLog += " non-consumable";
                                 sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_INVALID.getValue(), targetItemStack.getDisplayName().getString());
@@ -1359,7 +1348,7 @@ public class Battle
                         }
                         final Entity nextEntity = next.entity;
                         final int nextItemToUse = next.itemToUse;
-                        ((PlayerEntity) nextEntity).inventory.selected = nextItemToUse;
+                        ((Player) nextEntity).getInventory().selected = nextItemToUse;
                         sendMessageToAllPlayers(PacketBattleMessage.MessageType.SWITCHED_ITEM, next.entity.getId(), 0, 1);
                     }
                         break;
@@ -1379,7 +1368,7 @@ public class Battle
                         for (Combatant c : sideA.values()) {
                             if (c.entity.getId() != next.entity.getId()) {
                                 int hitChance = next.entityInfo.attackProbability;
-                                if (c.entity instanceof PlayerEntity) {
+                                if (c.entity instanceof Player) {
                                     hitChance = hitChance * (100 - TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion()) / 100;
                                 } else {
                                     hitChance = hitChance * (100 - c.entityInfo.evasion) / 100;
@@ -1423,7 +1412,7 @@ public class Battle
                         for(Combatant c : sideB.values()) {
                             if (c.entity.getId() != next.entity.getId()) {
                                 int hitChance = next.entityInfo.attackProbability;
-                                if (c.entity instanceof PlayerEntity) {
+                                if (c.entity instanceof Player) {
                                     hitChance = hitChance * (100 - TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion()) / 100;
                                 } else {
                                     hitChance = hitChance * (100 - c.entityInfo.evasion) / 100;
@@ -1464,7 +1453,7 @@ public class Battle
                                 }
                             }
                         }
-                        ((CreeperEntity)nextEntity).setSwellDir(1000000);
+                        ((Creeper)nextEntity).setSwellDir(1000000);
                     }
                         break;
                     }
@@ -1509,20 +1498,20 @@ public class Battle
 
     private void defuseCreepers() {
         for(Combatant c : sideA.values()) {
-            if(c.entity instanceof CreeperEntity) {
+            if(c.entity instanceof Creeper) {
                 if(c.creeperTurns <= TurnBasedMinecraftMod.proxy.getConfig().getCreeperExplodeTurn()) {
-                    ((CreeperEntity)c.entity).setSwellDir(-10);
+                    ((Creeper)c.entity).setSwellDir(-10);
                 } else {
-                    ((CreeperEntity)c.entity).setSwellDir(1000000);
+                    ((Creeper)c.entity).setSwellDir(1000000);
                 }
             }
         }
         for(Combatant c : sideB.values()) {
-            if(c.entity instanceof CreeperEntity) {
+            if(c.entity instanceof Creeper) {
                 if(c.creeperTurns <= TurnBasedMinecraftMod.proxy.getConfig().getCreeperExplodeTurn()) {
-                    ((CreeperEntity)c.entity).setSwellDir(-10);
+                    ((Creeper)c.entity).setSwellDir(-10);
                 } else {
-                    ((CreeperEntity) c.entity).setSwellDir(1000000);
+                    ((Creeper) c.entity).setSwellDir(1000000);
                 }
             }
         }
index d76a4303c77ce2a7308672feebc3c76ef286b4c6..01d8668a6398ba9fde292eb2e8f260ce7d374f2f 100644 (file)
@@ -1,26 +1,19 @@
 package com.burnedkirby.TurnBasedMinecraft.common;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import net.minecraft.entity.monster.CreeperEntity;
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.entity.player.ServerPlayerEntity;
-import net.minecraft.item.ItemGroup;
-import net.minecraft.util.RegistryKey;
-import net.minecraft.world.World;
-import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.fml.network.PacketDistributor;
-import org.apache.logging.log4j.Logger;
-
 import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketGeneralMessage;
-
-import net.minecraft.entity.Entity;
+import net.minecraft.resources.ResourceKey;
+import net.minecraft.server.level.ServerPlayer;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.entity.monster.Creeper;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.level.Level;
+import net.minecraftforge.common.MinecraftForge;
 import net.minecraftforge.event.entity.living.LivingAttackEvent;
 import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
+import net.minecraftforge.network.PacketDistributor;
+import org.apache.logging.log4j.Logger;
+
+import java.util.*;
 
 public class BattleManager
 {
@@ -30,8 +23,7 @@ public class BattleManager
     private Map<Integer, Combatant> recentlyLeftBattle;
     private BattleUpdater battleUpdater;
     private Map<EntityIDDimPair, Integer> entityToBattleMap;
-    private static Collection<ItemGroup> otherFoodItemGroups = new ArrayList<>();
-    
+
     public BattleManager(Logger logger)
     {
         this.logger = logger;
@@ -75,9 +67,9 @@ public class BattleManager
         }
 
         // 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 Player && !((Player)event.getEntity()).isCreative())
                 || (config.getEntityInfoReference(receiverClassName) != null || config.getCustomEntityInfoReference(receiverCustomName) != null))
-            || !((event.getSource().getEntity() instanceof PlayerEntity && !((PlayerEntity)event.getSource().getEntity()).isCreative())
+            || !((event.getSource().getEntity() instanceof Player && !((Player)event.getSource().getEntity()).isCreative())
                 || (config.getEntityInfoReference(attackerClassName) != null || config.getCustomEntityInfoReference(attackerCustomName) != null)))
         {
 //            logger.debug("BattleManager: Failed first check, attacker is \"" + attackerClassName + "\", defender is \"" + receiverClassName + "\"");
@@ -138,7 +130,7 @@ public class BattleManager
             return true;
         } else if(attackerBattle == null && defenderBattle == null) {
             // neither entity is in battle
-            if(event.getEntity() instanceof PlayerEntity || event.getSource().getEntity() instanceof PlayerEntity)
+            if(event.getEntity() instanceof Player || event.getSource().getEntity() instanceof Player)
             {
                 // at least one of the entities is a player, create Battle
                 Collection<Entity> sideA = new ArrayList<Entity>(1);
@@ -204,7 +196,7 @@ public class BattleManager
         }
 
         EntityInfo targetedInfo;
-        if(event.getTarget() instanceof PlayerEntity)
+        if(event.getTarget() instanceof Player)
         {
             targetedInfo = null;
         }
@@ -216,7 +208,7 @@ public class BattleManager
                 targetedInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(event.getTarget());
             }
         }
-        if((event.getTarget() instanceof PlayerEntity && ((PlayerEntity)event.getTarget()).isCreative())
+        if((event.getTarget() instanceof Player && ((Player)event.getTarget()).isCreative())
                 || attackerInfo == null
                 || attackerInfo.ignoreBattle
                 || TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType(attackerInfo.category)
@@ -241,7 +233,7 @@ public class BattleManager
             return;
         } else if(attackerBattle == null && defenderBattle == null) {
             // neither in battle
-            if(event.getEntity() instanceof PlayerEntity || event.getTarget() instanceof PlayerEntity)
+            if(event.getEntity() instanceof Player || event.getTarget() instanceof Player)
             {
                 // at least one is a player, create battle
                 Collection<Entity> sideA = new ArrayList<Entity>(1);
@@ -277,7 +269,7 @@ public class BattleManager
         }
     }
     
-    private Battle createBattle(Collection<Entity> sideA, Collection<Entity> sideB, RegistryKey<World> dimension)
+    private Battle createBattle(Collection<Entity> sideA, Collection<Entity> sideB, ResourceKey<Level> dimension)
     {
         Battle newBattle = null;
         while(battleMap.containsKey(IDCounter))
@@ -313,8 +305,8 @@ public class BattleManager
     {
         c.time = System.nanoTime();
         Config config = TurnBasedMinecraftMod.proxy.getConfig();
-        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!"));
+        if(c.entity instanceof ServerPlayer) {
+            TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(()->(ServerPlayer) c.entity), new PacketGeneralMessage("You just left battle! " + config.getLeaveBattleCooldownSeconds() + " seconds until you can attack/be-attacked again!"));
         }
         recentlyLeftBattle.put(c.entity.getId(), c);
         entityToBattleMap.remove(new EntityIDDimPair(c.entity));
@@ -326,15 +318,15 @@ public class BattleManager
         for(Iterator<Map.Entry<Integer, Combatant>> iter = recentlyLeftBattle.entrySet().iterator(); iter.hasNext();)
         {
             Map.Entry<Integer, Combatant> entry = iter.next();
-            if(entry.getValue().entity instanceof CreeperEntity && TurnBasedMinecraftMod.proxy.getConfig().getCreeperStopExplodeOnLeaveBattle()) {
-                ((CreeperEntity)entry.getValue().entity).setSwellDir(-10);
+            if(entry.getValue().entity instanceof Creeper && TurnBasedMinecraftMod.proxy.getConfig().getCreeperStopExplodeOnLeaveBattle()) {
+                ((Creeper)entry.getValue().entity).setSwellDir(-10);
             }
             if(current - entry.getValue().time > TurnBasedMinecraftMod.proxy.getConfig().getLeaveBattleCooldownNanos())
             {
                 iter.remove();
-                if(entry.getValue().entity instanceof ServerPlayerEntity)
+                if(entry.getValue().entity instanceof ServerPlayer)
                 {
-                    TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(()->(ServerPlayerEntity)entry.getValue().entity), new PacketGeneralMessage("Timer ended, you can now attack/be-attacked again."));
+                    TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(()->(ServerPlayer)entry.getValue().entity), new PacketGeneralMessage("Timer ended, you can now attack/be-attacked again."));
                 }
             }
         }
@@ -358,12 +350,4 @@ public class BattleManager
         }
         return result;
     }
-
-    public static void addOtherModItemGroup(ItemGroup itemGroup) {
-        otherFoodItemGroups.add(itemGroup);
-    }
-
-    public static Collection<ItemGroup> getOtherFoodItemGroups() {
-        return otherFoodItemGroups;
-    }
 }
\ No newline at end of file
index 0141ea5e15939c08790fd74cf7f3c75d61a35b53..28bc88fc26a9627ca3be64085b67c9bf30883f99 100644 (file)
@@ -2,11 +2,11 @@ package com.burnedkirby.TurnBasedMinecraft.common;
 
 import java.util.Comparator;
 
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.LivingEntity;
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.potion.EffectInstance;
-import net.minecraft.potion.Effects;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.entity.LivingEntity;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.effect.MobEffectInstance;
+import net.minecraft.world.effect.MobEffects;
 
 public class Combatant
 {
@@ -53,18 +53,18 @@ public class Combatant
         @Override
         public int compare(Combatant c0, Combatant c1)
         {
-            if(c0.entity instanceof PlayerEntity && c0.recalcSpeedOnCompare)
+            if(c0.entity instanceof Player && c0.recalcSpeedOnCompare)
             {
                 LivingEntity c0Entity = (LivingEntity)c0.entity;
                 boolean isHaste = false;
                 boolean isSlow = false;
-                for(EffectInstance e : c0Entity.getActiveEffects())
+                for(MobEffectInstance e : c0Entity.getActiveEffects())
                 {
-                    if(e.getEffect().equals(Effects.MOVEMENT_SPEED) || e.getEffect().equals(Effects.DIG_SPEED))
+                    if(e.getEffect().equals(MobEffects.MOVEMENT_SPEED) || e.getEffect().equals(MobEffects.DIG_SPEED))
                     {
                         isHaste = true;
                     }
-                    else if(e.getEffect().equals(Effects.MOVEMENT_SLOWDOWN) || e.getEffect().equals(Effects.DIG_SLOWDOWN))
+                    else if(e.getEffect().equals(MobEffects.MOVEMENT_SLOWDOWN) || e.getEffect().equals(MobEffects.DIG_SLOWDOWN))
                     {
                         isSlow = true;
                     }
@@ -87,18 +87,18 @@ public class Combatant
                 }
             }
             
-            if(c1.entity instanceof PlayerEntity && c1.recalcSpeedOnCompare)
+            if(c1.entity instanceof Player && c1.recalcSpeedOnCompare)
             {
                 LivingEntity c1Entity = (LivingEntity)c1.entity;
                 boolean isHaste = false;
                 boolean isSlow = false;
-                for(EffectInstance e : c1Entity.getActiveEffects())
+                for(MobEffectInstance e : c1Entity.getActiveEffects())
                 {
-                    if(e.getEffect().equals(Effects.MOVEMENT_SPEED))
+                    if(e.getEffect().equals(MobEffects.MOVEMENT_SPEED))
                     {
                         isHaste = true;
                     }
-                    else if(e.getEffect().equals(Effects.MOVEMENT_SLOWDOWN))
+                    else if(e.getEffect().equals(MobEffects.MOVEMENT_SLOWDOWN))
                     {
                         isSlow = true;
                     }
index 3074f6914902a092d70cba8a2dbacd8d2a425b31..69e8ef4fe6d6d7d48a843f0201d1536af6439c0a 100644 (file)
@@ -1,20 +1,19 @@
 package com.burnedkirby.TurnBasedMinecraft.common;
 
-import java.lang.reflect.Field;
-import java.util.*;
-
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.item.ItemGroup;
-import net.minecraft.util.RegistryKey;
-import net.minecraft.util.text.ITextComponent;
-import net.minecraft.world.DimensionType;
-import net.minecraft.world.World;
-import net.minecraftforge.fml.ModContainer;
-import net.minecraftforge.fml.ModList;
-import net.minecraftforge.fml.server.ServerLifecycleHooks;
+import net.minecraft.network.chat.TextComponent;
+import net.minecraft.resources.ResourceKey;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.level.Level;
+import net.minecraftforge.network.NetworkEvent;
+import net.minecraftforge.server.ServerLifecycleHooks;
 import org.apache.logging.log4j.Logger;
 
-import net.minecraft.entity.Entity;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Supplier;
 
 public class CommonProxy
 {
@@ -75,96 +74,11 @@ public class CommonProxy
     {
         config = new Config(logger);
         postInitClient();
-        pamsFoodIntegrationLoading();
         logger.debug("postInit proxy for com_burnedkirby_turnbasedminecraft");
     }
     
     protected void postInitClient() {}
 
-    private final void pamsFoodIntegrationLoading() {
-        // TODO: generalize other mod's food loading via config with a list of mod ids
-
-        // pamhc2foodcore
-        {
-            ModList modList = ModList.get();
-            Optional<? extends ModContainer> pamsFoodCoreContainer = modList.getModContainerById("pamhc2foodcore");
-            if (pamsFoodCoreContainer.isPresent()) {
-                Object pamsFoodCore = pamsFoodCoreContainer.get().getMod();
-                try {
-                    Field itemGroupField = pamsFoodCore.getClass().getField("ITEM_GROUP");
-                    ItemGroup foodItemGroup = (ItemGroup) itemGroupField.get(null);
-                    if(foodItemGroup != null) {
-                        BattleManager.addOtherModItemGroup(foodItemGroup);
-                    } else {
-                        throw new NullPointerException();
-                    }
-                } catch (Exception e) {
-                    TurnBasedMinecraftMod.logger.info("Failed to get pamhc2foodcore ITEM_GROUP");
-                }
-            }
-        }
-
-        // pamhc2crops
-        {
-            ModList modList = ModList.get();
-            Optional<? extends ModContainer> pamsFoodCoreContainer = modList.getModContainerById("pamhc2crops");
-            if (pamsFoodCoreContainer.isPresent()) {
-                Object pamsFoodCore = pamsFoodCoreContainer.get().getMod();
-                try {
-                    Field itemGroupField = pamsFoodCore.getClass().getField("ITEM_GROUP");
-                    ItemGroup foodItemGroup = (ItemGroup) itemGroupField.get(null);
-                    if(foodItemGroup != null) {
-                        BattleManager.addOtherModItemGroup(foodItemGroup);
-                    } else {
-                        throw new NullPointerException();
-                    }
-                } catch (Exception e) {
-                    TurnBasedMinecraftMod.logger.info("Failed to get pamhc2crops ITEM_GROUP");
-                }
-            }
-        }
-
-        // pamhc2trees
-        {
-            ModList modList = ModList.get();
-            Optional<? extends ModContainer> pamsFoodCoreContainer = modList.getModContainerById("pamhc2trees");
-            if (pamsFoodCoreContainer.isPresent()) {
-                Object pamsFoodCore = pamsFoodCoreContainer.get().getMod();
-                try {
-                    Field itemGroupField = pamsFoodCore.getClass().getField("ITEM_GROUP");
-                    ItemGroup foodItemGroup = (ItemGroup) itemGroupField.get(null);
-                    if(foodItemGroup != null) {
-                        BattleManager.addOtherModItemGroup(foodItemGroup);
-                    } else {
-                        throw new NullPointerException();
-                    }
-                } catch (Exception e) {
-                    TurnBasedMinecraftMod.logger.info("Failed to get pamhc2trees ITEM_GROUP");
-                }
-            }
-        }
-
-        // pamhc2foodextended
-        {
-            ModList modList = ModList.get();
-            Optional<? extends ModContainer> pamsFoodCoreContainer = modList.getModContainerById("pamhc2foodextended");
-            if (pamsFoodCoreContainer.isPresent()) {
-                Object pamsFoodCore = pamsFoodCoreContainer.get().getMod();
-                try {
-                    Field itemGroupField = pamsFoodCore.getClass().getField("ITEM_GROUP");
-                    ItemGroup foodItemGroup = (ItemGroup) itemGroupField.get(null);
-                    if(foodItemGroup != null) {
-                        BattleManager.addOtherModItemGroup(foodItemGroup);
-                    } else {
-                        throw new NullPointerException();
-                    }
-                } catch (Exception e) {
-                    TurnBasedMinecraftMod.logger.info("Failed to get pamhc2foodextended ITEM_GROUP");
-                }
-            }
-        }
-    }
-    
     public final void setLogger(Logger logger)
     {
         this.logger = logger;
@@ -182,7 +96,7 @@ public class CommonProxy
     
     public void displayString(String message) {}
 
-    public void displayTextComponent(ITextComponent textComponent) {}
+    public void displayTextComponent(TextComponent textComponent) {}
     
     public final boolean isServerRunning()
     {
@@ -241,7 +155,7 @@ public class CommonProxy
         return editingPlayers.get(id);
     }
 
-    protected final EditingInfo setEditingPlayer(PlayerEntity player)
+    protected final EditingInfo setEditingPlayer(Player player)
     {
         return editingPlayers.put(player.getId(), new EditingInfo(player));
     }
@@ -251,7 +165,9 @@ public class CommonProxy
         return editingPlayers.remove(id);
     }
 
-    public Entity getEntity(int id, RegistryKey<World> dim) {
+    public Entity getEntity(int id, ResourceKey<Level> dim) {
         return ServerLifecycleHooks.getCurrentServer().getLevel(dim).getEntity(id);
     }
+
+    public <MSG> void handlePacket(MSG msg, Supplier<NetworkEvent.Context> ctx) {}
 }
index 2c2122693b1b32f750eb76764a3af01af2a7929a..bcc34818f9278f9ff5a1ba2deafb9803f8115805 100644 (file)
@@ -1,10 +1,10 @@
 package com.burnedkirby.TurnBasedMinecraft.common;
 
 import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketGeneralMessage;
-import net.minecraft.entity.player.ServerPlayerEntity;
+import net.minecraft.server.level.ServerPlayer;
 import net.minecraftforge.event.entity.EntityTravelToDimensionEvent;
 import net.minecraftforge.eventbus.api.SubscribeEvent;
-import net.minecraftforge.fml.network.PacketDistributor;
+import net.minecraftforge.network.PacketDistributor;
 
 public class DimensionChangedHandler {
     @SubscribeEvent
@@ -13,9 +13,9 @@ public class DimensionChangedHandler {
             return;
         }
         if(TurnBasedMinecraftMod.proxy.getBattleManager().forceLeaveBattle(new EntityIDDimPair(event.getEntity()))
-                && event.getEntity() instanceof ServerPlayerEntity) {
+                && event.getEntity() instanceof ServerPlayer) {
             TurnBasedMinecraftMod.getHandler().send(
-                    PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity)event.getEntity()),
+                    PacketDistributor.PLAYER.with(() -> (ServerPlayer)event.getEntity()),
                     new PacketGeneralMessage("Left battle due to moving to a different dimension"));
         }
     }
index a81b9a6ce4c5e09da202cbe55118b8821494998e..d2d2609f33912c2e2c0d7a54c9fb79f3c8c1bb93 100644 (file)
@@ -1,10 +1,10 @@
 package com.burnedkirby.TurnBasedMinecraft.common;
 
-import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.world.entity.player.Player;
 
 public class EditingInfo
 {
-    public PlayerEntity editor;
+    public Player editor;
     public EntityInfo entityInfo;
     public boolean isPendingEntitySelection;
     public boolean isEditingCustomName;
@@ -17,7 +17,7 @@ public class EditingInfo
         isEditingCustomName = false;
     }
 
-    public EditingInfo(PlayerEntity player)
+    public EditingInfo(Player player)
     {
         editor = player;
         entityInfo = null;
index f25874611dbb9b98d29b0b2701b608296f12e55c..81778a3ed36a8655331ef5539fe3bc6ace90429b 100644 (file)
@@ -1,13 +1,12 @@
 package com.burnedkirby.TurnBasedMinecraft.common;
 
-import net.minecraft.client.Minecraft;
-import net.minecraft.entity.Entity;
-import net.minecraft.util.RegistryKey;
-import net.minecraft.world.World;
+import net.minecraft.resources.ResourceKey;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.level.Level;
 
 public class EntityIDDimPair {
     public int id;
-    public RegistryKey<World> dim;
+    public ResourceKey<Level> dim;
 
     EntityIDDimPair() {
         id = 0;
@@ -15,7 +14,7 @@ public class EntityIDDimPair {
         dim = null;
     }
 
-    EntityIDDimPair(int id, RegistryKey<World> dim) {
+    EntityIDDimPair(int id, ResourceKey<Level> dim) {
         this.id = id;
         this.dim = dim;
     }
index 8415b5f6ab76561bf00a3767d3ec092533a1be2b..57bd4148006e5c18684adbd1050f1105af49fc08 100644 (file)
@@ -1,8 +1,8 @@
 package com.burnedkirby.TurnBasedMinecraft.common;
 
-import net.minecraft.entity.LivingEntity;
-import net.minecraft.potion.EffectInstance;
-import net.minecraft.potion.Effects;
+import net.minecraft.world.effect.MobEffectInstance;
+import net.minecraft.world.effect.MobEffects;
+import net.minecraft.world.entity.LivingEntity;
 
 public class EntityInfo
 {
@@ -194,71 +194,71 @@ public class EntityInfo
             }
         }
         
-        public EffectInstance getPotionEffect()
+        public MobEffectInstance getPotionEffect()
         {
             return getPotionEffect(20 * 7, 0);
         }
         
-        public EffectInstance getPotionEffect(int duration, int amplifier) {
+        public MobEffectInstance getPotionEffect(int duration, int amplifier) {
             switch(this) {
             case SPEED:
-                return new EffectInstance(Effects.MOVEMENT_SPEED, duration, amplifier);
+                return new MobEffectInstance(MobEffects.MOVEMENT_SPEED, duration, amplifier);
             case SLOW:
-                return new EffectInstance(Effects.MOVEMENT_SLOWDOWN, duration, amplifier);
+                return new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, duration, amplifier);
             case HASTE:
-                return new EffectInstance(Effects.DIG_SPEED, duration, amplifier);
+                return new MobEffectInstance(MobEffects.DIG_SPEED, duration, amplifier);
             case MINING_FATIGUE:
-                return new EffectInstance(Effects.DIG_SLOWDOWN, duration, amplifier);
+                return new MobEffectInstance(MobEffects.DIG_SLOWDOWN, duration, amplifier);
             case STRENGTH:
-                return new EffectInstance(Effects.DAMAGE_BOOST, duration, amplifier);
+                return new MobEffectInstance(MobEffects.DAMAGE_BOOST, duration, amplifier);
             case JUMP_BOOST:
-                return new EffectInstance(Effects.JUMP, duration, amplifier);
+                return new MobEffectInstance(MobEffects.JUMP, duration, amplifier);
             case NAUSEA:
-                return new EffectInstance(Effects.CONFUSION, duration, amplifier);
+                return new MobEffectInstance(MobEffects.CONFUSION, duration, amplifier);
             case REGENERATION:
-                return new EffectInstance(Effects.REGENERATION, duration, amplifier);
+                return new MobEffectInstance(MobEffects.REGENERATION, duration, amplifier);
             case RESISTANCE:
-                return new EffectInstance(Effects.DAMAGE_RESISTANCE, duration, amplifier);
+                return new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, duration, amplifier);
             case FIRE_RESISTANCE:
-                return new EffectInstance(Effects.FIRE_RESISTANCE, duration, amplifier);
+                return new MobEffectInstance(MobEffects.FIRE_RESISTANCE, duration, amplifier);
             case WATER_BREATHING:
-                return new EffectInstance(Effects.WATER_BREATHING, duration, amplifier);
+                return new MobEffectInstance(MobEffects.WATER_BREATHING, duration, amplifier);
             case INVISIBILITY:
-                return new EffectInstance(Effects.INVISIBILITY, duration, amplifier);
+                return new MobEffectInstance(MobEffects.INVISIBILITY, duration, amplifier);
             case BLINDNESS:
-                return new EffectInstance(Effects.BLINDNESS, duration, amplifier);
+                return new MobEffectInstance(MobEffects.BLINDNESS, duration, amplifier);
             case NIGHT_VISION:
-                return new EffectInstance(Effects.NIGHT_VISION, duration, amplifier);
+                return new MobEffectInstance(MobEffects.NIGHT_VISION, duration, amplifier);
             case HUNGER:
-                return new EffectInstance(Effects.HUNGER, duration, amplifier);
+                return new MobEffectInstance(MobEffects.HUNGER, duration, amplifier);
             case WEAKNESS:
-                return new EffectInstance(Effects.WEAKNESS, duration, amplifier);
+                return new MobEffectInstance(MobEffects.WEAKNESS, duration, amplifier);
             case POISON:
-                return new EffectInstance(Effects.POISON, duration, amplifier);
+                return new MobEffectInstance(MobEffects.POISON, duration, amplifier);
             case WITHER:
-                return new EffectInstance(Effects.WITHER, duration, amplifier);
+                return new MobEffectInstance(MobEffects.WITHER, duration, amplifier);
             case HEALTH_BOOST:
-                return new EffectInstance(Effects.HEALTH_BOOST, duration, amplifier);
+                return new MobEffectInstance(MobEffects.HEALTH_BOOST, duration, amplifier);
             case ABSORPTION:
-                return new EffectInstance(Effects.ABSORPTION, duration, amplifier);
+                return new MobEffectInstance(MobEffects.ABSORPTION, duration, amplifier);
             case SATURATION:
-                return new EffectInstance(Effects.SATURATION, duration, amplifier);
+                return new MobEffectInstance(MobEffects.SATURATION, duration, amplifier);
             case GLOWING:
-                return new EffectInstance(Effects.GLOWING, duration, amplifier);
+                return new MobEffectInstance(MobEffects.GLOWING, duration, amplifier);
             case LEVITATION:
-                return new EffectInstance(Effects.LEVITATION, duration, amplifier);
+                return new MobEffectInstance(MobEffects.LEVITATION, duration, amplifier);
             case LUCK:
-                return new EffectInstance(Effects.LUCK, duration, amplifier);
+                return new MobEffectInstance(MobEffects.LUCK, duration, amplifier);
             case UNLUCK:
-                return new EffectInstance(Effects.UNLUCK, duration, amplifier);
+                return new MobEffectInstance(MobEffects.UNLUCK, duration, amplifier);
             case SLOW_FALLING:
-                return new EffectInstance(Effects.SLOW_FALLING, duration, amplifier);
+                return new MobEffectInstance(MobEffects.SLOW_FALLING, duration, amplifier);
             case CONDUIT_POWER:
-                return new EffectInstance(Effects.CONDUIT_POWER, duration, amplifier);
+                return new MobEffectInstance(MobEffects.CONDUIT_POWER, duration, amplifier);
             case DOLPHINS_GRACE:
-                return new EffectInstance(Effects.DOLPHINS_GRACE, duration, amplifier);
+                return new MobEffectInstance(MobEffects.DOLPHINS_GRACE, duration, amplifier);
             case BAD_OMEN:
-                return new EffectInstance(Effects.BAD_OMEN, duration, amplifier);
+                return new MobEffectInstance(MobEffects.BAD_OMEN, duration, amplifier);
             case FIRE:
                 // FIRE is not a PotionEffect and must be applied directly to the Entity
                 return null;
index 775204f634beca175fb428fb17f46d0c21ff54ae..b115629291c223281e093721d4fcb76fbfa9f65c 100644 (file)
@@ -1,6 +1,6 @@
 package com.burnedkirby.TurnBasedMinecraft.common;
 
-import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.world.entity.player.Player;
 import net.minecraftforge.event.entity.EntityJoinWorldEvent;
 import net.minecraftforge.eventbus.api.SubscribeEvent;
 
@@ -13,7 +13,7 @@ public class PlayerJoinEventHandler
         {
             return;
         }
-        if(event.getEntity() instanceof PlayerEntity && TurnBasedMinecraftMod.proxy.getConfig().getBattleDisabledForAll())
+        if(event.getEntity() instanceof Player && TurnBasedMinecraftMod.proxy.getConfig().getBattleDisabledForAll())
         {
             TurnBasedMinecraftMod.proxy.getConfig().addBattleIgnoringPlayer(event.getEntity().getId());
         }
index 2deee8f254606db40ac482dcd8686fe2aaaafd52..4ca7222a9ef1e26604947de6dde7cd4f41b0910a 100644 (file)
@@ -9,33 +9,33 @@ import com.mojang.brigadier.arguments.IntegerArgumentType;
 import com.mojang.brigadier.arguments.StringArgumentType;
 import com.mojang.brigadier.exceptions.CommandSyntaxException;
 import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
-import net.minecraft.command.Commands;
-import net.minecraft.command.arguments.EntityArgument;
-import net.minecraft.entity.player.ServerPlayerEntity;
-import net.minecraft.util.ResourceLocation;
-import net.minecraft.util.text.StringTextComponent;
+import net.minecraft.commands.Commands;
+import net.minecraft.commands.arguments.EntityArgument;
+import net.minecraft.network.chat.TextComponent;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.server.level.ServerPlayer;
 import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.RegisterCommandsEvent;
+import net.minecraftforge.event.server.ServerStartingEvent;
+import net.minecraftforge.event.server.ServerStoppingEvent;
 import net.minecraftforge.eventbus.api.SubscribeEvent;
 import net.minecraftforge.fml.DistExecutor;
 import net.minecraftforge.fml.common.Mod;
 import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
 import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
 import net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent;
-import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
-import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
 import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
-import net.minecraftforge.fml.network.NetworkRegistry;
-import net.minecraftforge.fml.network.PacketDistributor;
-import net.minecraftforge.fml.network.simple.SimpleChannel;
+import net.minecraftforge.network.NetworkRegistry;
+import net.minecraftforge.network.PacketDistributor;
+import net.minecraftforge.network.simple.SimpleChannel;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
 @Mod(TurnBasedMinecraftMod.MODID)
-public class TurnBasedMinecraftMod
-{
+public class TurnBasedMinecraftMod {
     public static final String MODID = "com_burnedkirby_turnbasedminecraft";
     public static final String NAME = "Turn Based Minecraft Mod";
-    public static final String VERSION = "1.17.2";
+    public static final String VERSION = "1.18.0";
     public static final String CONFIG_FILENAME = "TBM_Config.toml";
     public static final String DEFAULT_CONFIG_FILENAME = "TBM_Config_DEFAULT.toml";
     public static final String CONFIG_DIRECTORY = "config/TurnBasedMinecraft/";
@@ -45,25 +45,25 @@ public class TurnBasedMinecraftMod
     public static final String MUSIC_ROOT = CONFIG_DIRECTORY + "Music/";
     public static final String MUSIC_SILLY = MUSIC_ROOT + "silly/";
     public static final String MUSIC_BATTLE = MUSIC_ROOT + "battle/";
-    
+
     private static final String PROTOCOL_VERSION = Integer.toString(1);
     private static final ResourceLocation HANDLER_ID = new ResourceLocation(MODID, "main_channel");
     private static final SimpleChannel HANDLER = NetworkRegistry.ChannelBuilder
-               .named(HANDLER_ID)
-               .clientAcceptedVersions(PROTOCOL_VERSION::equals)
-               .serverAcceptedVersions(PROTOCOL_VERSION::equals)
-               .networkProtocolVersion(() -> PROTOCOL_VERSION)
-               .simpleChannel();
+        .named(HANDLER_ID)
+        .clientAcceptedVersions(PROTOCOL_VERSION::equals)
+        .serverAcceptedVersions(PROTOCOL_VERSION::equals)
+        .networkProtocolVersion(() -> PROTOCOL_VERSION)
+        .simpleChannel();
     protected static Logger logger = LogManager.getLogger();
-    
+
     public static ResourceLocation getNetResourceLocation() {
-       return HANDLER_ID;
+        return HANDLER_ID;
     }
-    
+
     public static SimpleChannel getHandler() {
-       return HANDLER;
+        return HANDLER;
     }
-    
+
     public static CommonProxy proxy;
 
     public TurnBasedMinecraftMod() {
@@ -74,51 +74,50 @@ public class TurnBasedMinecraftMod
         MinecraftForge.EVENT_BUS.register(this);
     }
 
-    private void firstInit(final FMLCommonSetupEvent event)
-    {
-       proxy = DistExecutor.safeRunForDist(()-> ClientProxy::new, ()-> CommonProxy::new);
+    private void firstInit(final FMLCommonSetupEvent event) {
+        proxy = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> CommonProxy::new);
         proxy.setLogger(logger);
         proxy.initialize();
 
         // register packets
         int packetHandlerID = 0;
         HANDLER.registerMessage(
-               packetHandlerID++,
-               PacketBattleInfo.class,
-               PacketBattleInfo::encode,
-               PacketBattleInfo::decode,
-               PacketBattleInfo.Handler::handle);
+            packetHandlerID++,
+            PacketBattleInfo.class,
+            PacketBattleInfo::encode,
+            PacketBattleInfo::decode,
+            PacketBattleInfo::handle);
         HANDLER.registerMessage(
-               packetHandlerID++,
-               PacketBattleRequestInfo.class,
-               PacketBattleRequestInfo::encode,
-               PacketBattleRequestInfo::decode,
-               PacketBattleRequestInfo.Handler::handle);
+            packetHandlerID++,
+            PacketBattleRequestInfo.class,
+            PacketBattleRequestInfo::encode,
+            PacketBattleRequestInfo::decode,
+            PacketBattleRequestInfo::handle);
         HANDLER.registerMessage(
-               packetHandlerID++,
-               PacketBattleDecision.class,
-               PacketBattleDecision::encode,
-               PacketBattleDecision::decode,
-               PacketBattleDecision.Handler::handle);
+            packetHandlerID++,
+            PacketBattleDecision.class,
+            PacketBattleDecision::encode,
+            PacketBattleDecision::decode,
+            PacketBattleDecision::handle);
         HANDLER.registerMessage(
-               packetHandlerID++,
-               PacketBattleMessage.class,
-               PacketBattleMessage::encode,
-               PacketBattleMessage::decode,
-               PacketBattleMessage.Handler::handle);
+            packetHandlerID++,
+            PacketBattleMessage.class,
+            PacketBattleMessage::encode,
+            PacketBattleMessage::decode,
+            PacketBattleMessage::handle);
         HANDLER.registerMessage(
-               packetHandlerID++,
-               PacketGeneralMessage.class,
-               PacketGeneralMessage::encode,
-               PacketGeneralMessage::decode,
-               PacketGeneralMessage.Handler::handle);
+            packetHandlerID++,
+            PacketGeneralMessage.class,
+            PacketGeneralMessage::encode,
+            PacketGeneralMessage::decode,
+            PacketGeneralMessage::handle);
         HANDLER.registerMessage(
-               packetHandlerID++,
-               PacketEditingMessage.class,
-               PacketEditingMessage::encode,
-               PacketEditingMessage::decode,
-               PacketEditingMessage.Handler::handle);
-        
+            packetHandlerID++,
+            PacketEditingMessage.class,
+            PacketEditingMessage::encode,
+            PacketEditingMessage::decode,
+            PacketEditingMessage::handle);
+
         // register event handler(s)
         MinecraftForge.EVENT_BUS.register(new AttackEventHandler());
         MinecraftForge.EVENT_BUS.register(new PlayerJoinEventHandler());
@@ -127,108 +126,106 @@ public class TurnBasedMinecraftMod
         logger.debug("Init com_burnedkirby_turnbasedminecraft");
     }
 
-    private void secondInitClient(final FMLClientSetupEvent event)
-    {
-       proxy.postInit();
+    private void secondInitClient(final FMLClientSetupEvent event) {
+        proxy.postInit();
     }
-    
-    private void secondInitServer(final FMLDedicatedServerSetupEvent event)
-    {
-       proxy.postInit();
+
+    private void secondInitServer(final FMLDedicatedServerSetupEvent event) {
+        proxy.postInit();
     }
-    
+
     @SubscribeEvent
-    public void serverStarting(FMLServerStartingEvent event)
-    {
+    public void serverStarting(ServerStartingEvent event) {
         logger.debug("About to initialize BattleManager");
-        if(proxy.initializeBattleManager())
-        {
+        if (proxy.initializeBattleManager()) {
             logger.debug("Initialized BattleManager");
         }
-        
+
         proxy.getConfig().clearBattleIgnoringPlayers();
-        
-        // register commands
+    }
+
+    @SubscribeEvent
+    public void registerCommands(RegisterCommandsEvent event) {
         // tbm-disable
-        event.getServer().getCommands().getDispatcher().register(
+        event.getDispatcher().register(
             Commands.literal("tbm-disable")
                 .requires(c -> {
                     return !proxy.getConfig().getIfOnlyOPsCanDisableTurnBasedForSelf() || c.hasPermission(2);
                 })
-                .executes( c -> {
+                .executes(c -> {
                     proxy.getConfig().addBattleIgnoringPlayer(c.getSource().getPlayerOrException().getId());
-                    c.getSource().sendSuccess(new StringTextComponent("Disabled turn-based-combat for current player"), true);
+                    c.getSource().sendSuccess(new TextComponent("Disabled turn-based-combat for current player"), true);
                     return 1;
                 }));
         // tbm-disable-all
-        event.getServer().getCommands().getDispatcher().register(
+        event.getDispatcher().register(
             Commands.literal("tbm-disable-all")
                 .requires(c -> {
                     return c.hasPermission(2);
                 })
                 .executes(c -> {
                     proxy.getConfig().setBattleDisabledForAll(true);
-                    for(ServerPlayerEntity player : c.getSource().getServer().getPlayerList().getPlayers()) {
+                    for (ServerPlayer player : c.getSource().getServer().getPlayerList().getPlayers()) {
                         proxy.getConfig().addBattleIgnoringPlayer(player.getId());
                         getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP disabled turn-based-combat for everyone"));
                     }
                     return 1;
                 }));
         // tbm-enable
-        event.getServer().getCommands().getDispatcher().register(
+        event.getDispatcher().register(
             Commands.literal("tbm-enable")
                 .requires(c -> !proxy.getConfig().getIfOnlyOPsCanDisableTurnBasedForSelf() || c.hasPermission(2))
                 .executes(c -> {
                     proxy.getConfig().removeBattleIgnoringPlayer(c.getSource().getPlayerOrException().getId());
-                    c.getSource().sendSuccess(new StringTextComponent("Enabled turn-based-combat for current player"), true);
+                    c.getSource().sendSuccess(new TextComponent("Enabled turn-based-combat for current player"), true);
                     return 1;
                 }));
         // tbm-enable-all
-        event.getServer().getCommands().getDispatcher().register(
+        event.getDispatcher().register(
             Commands.literal("tbm-enable-all")
                 .requires(c -> c.hasPermission(2))
                 .executes(c -> {
                     proxy.getConfig().setBattleDisabledForAll(false);
                     proxy.getConfig().clearBattleIgnoringPlayers();
-                    for(ServerPlayerEntity player: c.getSource().getServer().getPlayerList().getPlayers()) {
+                    for (ServerPlayer player : c.getSource().getServer().getPlayerList().getPlayers()) {
                         getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP enabled turn-based-combat for everyone"));
                     }
                     return 1;
                 }));
         // tbm-set-enable
-        event.getServer().getCommands().getDispatcher().register(
+        event.getDispatcher().register(
             Commands.literal("tbm-set-enable")
                 .requires(c -> c.hasPermission(2))
                 .then(Commands.argument("targets", EntityArgument.players()).executes(c -> {
-                    for(ServerPlayerEntity player : EntityArgument.getPlayers(c, "targets")) {
+                    for (ServerPlayer player : EntityArgument.getPlayers(c, "targets")) {
                         proxy.getConfig().addBattleIgnoringPlayer(player.getId());
                         getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP enabled turn-based-combat for you"));
-                        c.getSource().sendSuccess(new StringTextComponent("Enabled turn-based-combat for " + player.getDisplayName().getString()), true);
+                        c.getSource().sendSuccess(new TextComponent("Enabled turn-based-combat for " + player.getDisplayName().getString()), true);
                     }
                     return 1;
                 })));
         // tbm-set-disable
-        event.getServer().getCommands().getDispatcher().register(
+        event.getDispatcher().register(
             Commands.literal("tbm-set-disable")
                 .requires(c -> c.hasPermission(2))
                 .then(Commands.argument("targets", EntityArgument.players()).executes(c -> {
-                    for(ServerPlayerEntity player : EntityArgument.getPlayers(c, "targets")) {
+                    for (ServerPlayer player : EntityArgument.getPlayers(c, "targets")) {
                         proxy.getConfig().removeBattleIgnoringPlayer(player.getId());
                         getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP disabled turn-based-combat for you"));
-                        c.getSource().sendSuccess(new StringTextComponent("Disabled turn-based-combat for " + player.getDisplayName().getString()), true);
+                        c.getSource().sendSuccess(new TextComponent("Disabled turn-based-combat for " + player.getDisplayName().getString()), true);
                     }
                     return 1;
                 })));
         // tbm-edit
-        event.getServer().getCommands().getDispatcher().register(
+        event.getDispatcher().register(
             Commands.literal("tbm-edit")
                 .requires(c -> c.hasPermission(2))
                 .executes(c -> {
-                    ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                    ServerPlayer player = c.getSource().getPlayerOrException();
                     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));
-                    } else if(editingInfo != null) {
+                    } else if (editingInfo != null) {
                         getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                     } else {
                         proxy.setEditingPlayer(player);
@@ -239,17 +236,17 @@ public class TurnBasedMinecraftMod
                 })
                 .then(Commands.literal("finish")
                     .executes(c -> {
-                        ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                        ServerPlayer player = c.getSource().getPlayerOrException();
                         EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
-                        if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
-                            if(!proxy.getConfig().editEntityEntry(editingInfo.entityInfo)) {
+                        if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
+                            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"));
                                 proxy.removeEditingInfo(player.getId());
                             } else {
                                 proxy.removeEditingInfo(player.getId());
                                 getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("Entity info saved in config and loaded."));
                             }
-                        } else if(editingInfo != null) {
+                        } else if (editingInfo != null) {
                             getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                         } else {
                             Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -259,9 +256,9 @@ public class TurnBasedMinecraftMod
                     }))
                 .then(Commands.literal("cancel")
                     .executes(c -> {
-                        ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                        ServerPlayer player = c.getSource().getPlayerOrException();
                         EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
-                        if(editingInfo != null) {
+                        if (editingInfo != null) {
                             proxy.removeEditingInfo(player.getId());
                             getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("Cancelled editing entry."));
                         }
@@ -269,12 +266,12 @@ public class TurnBasedMinecraftMod
                     }))
                 .then(Commands.literal("custom")
                     .executes(c -> {
-                        ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                        ServerPlayer player = c.getSource().getPlayerOrException();
                         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");
                             throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
-                        } else if(editingInfo != null) {
+                        } else if (editingInfo != null) {
                             getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                         } else {
                             proxy.setEditingPlayer(player);
@@ -286,11 +283,11 @@ public class TurnBasedMinecraftMod
                     }))
                 .then(Commands.literal("edit")
                     .executes(c -> {
-                        ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                        ServerPlayer player = c.getSource().getPlayerOrException();
                         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));
-                        } else if(editingInfo != null){
+                        } else if (editingInfo != null) {
                             getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                         } else {
                             Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -300,11 +297,11 @@ public class TurnBasedMinecraftMod
                     })
                     .then(Commands.literal("ignoreBattle")
                         .executes(c -> {
-                            ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                            ServerPlayer player = c.getSource().getPlayerOrException();
                             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));
-                            } else if(editingInfo != null) {
+                            } else if (editingInfo != null) {
                                 getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                             } else {
                                 Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -314,13 +311,13 @@ public class TurnBasedMinecraftMod
                         })
                         .then(Commands.argument("ignoreBattle", BoolArgumentType.bool())
                             .executes(c -> {
-                                ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                                ServerPlayer player = c.getSource().getPlayerOrException();
                                 EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
                                 boolean ignoreBattle = BoolArgumentType.getBool(c, "ignoreBattle");
-                                if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+                                if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
                                     editingInfo.entityInfo.ignoreBattle = ignoreBattle;
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
-                                } else if(editingInfo != null) {
+                                } else if (editingInfo != null) {
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                                 } else {
                                     Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -331,11 +328,11 @@ public class TurnBasedMinecraftMod
                     )
                     .then(Commands.literal("attackPower")
                         .executes(c -> {
-                            ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                            ServerPlayer player = c.getSource().getPlayerOrException();
                             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));
-                            } else if(editingInfo != null) {
+                            } else if (editingInfo != null) {
                                 getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                             } else {
                                 Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -345,16 +342,16 @@ public class TurnBasedMinecraftMod
                         })
                         .then(Commands.argument("attackPower", IntegerArgumentType.integer())
                             .executes(c -> {
-                                ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                                ServerPlayer player = c.getSource().getPlayerOrException();
                                 EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
                                 int attackPower = IntegerArgumentType.getInteger(c, "attackPower");
-                                if(attackPower < 0) {
+                                if (attackPower < 0) {
                                     attackPower = 0;
                                 }
-                                if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+                                if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
                                     editingInfo.entityInfo.attackPower = attackPower;
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
-                                } else if(editingInfo != null) {
+                                } else if (editingInfo != null) {
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                                 } else {
                                     Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -365,11 +362,11 @@ public class TurnBasedMinecraftMod
                     )
                     .then(Commands.literal("attackProbability")
                         .executes(c -> {
-                            ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                            ServerPlayer player = c.getSource().getPlayerOrException();
                             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));
-                            } else if(editingInfo != null) {
+                            } else if (editingInfo != null) {
                                 getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                             } else {
                                 Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -379,18 +376,18 @@ public class TurnBasedMinecraftMod
                         })
                         .then(Commands.argument("attackProbability", IntegerArgumentType.integer())
                             .executes(c -> {
-                                ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                                ServerPlayer player = c.getSource().getPlayerOrException();
                                 EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
                                 int attackProbability = IntegerArgumentType.getInteger(c, "attackProbability");
-                                if(attackProbability < 0) {
+                                if (attackProbability < 0) {
                                     attackProbability = 0;
-                                } else if(attackProbability > 100) {
+                                } else if (attackProbability > 100) {
                                     attackProbability = 100;
                                 }
-                                if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+                                if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
                                     editingInfo.entityInfo.attackProbability = attackProbability;
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
-                                } else if(editingInfo != null) {
+                                } else if (editingInfo != null) {
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                                 } else {
                                     Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -401,11 +398,11 @@ public class TurnBasedMinecraftMod
                     )
                     .then(Commands.literal("attackVariance")
                         .executes(c -> {
-                            ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                            ServerPlayer player = c.getSource().getPlayerOrException();
                             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));
-                            } else if(editingInfo != null) {
+                            } else if (editingInfo != null) {
                                 getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                             } else {
                                 Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -415,16 +412,16 @@ public class TurnBasedMinecraftMod
                         })
                         .then(Commands.argument("attackVariance", IntegerArgumentType.integer())
                             .executes(c -> {
-                                ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                                ServerPlayer player = c.getSource().getPlayerOrException();
                                 EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
                                 int attackVariance = IntegerArgumentType.getInteger(c, "attackVariance");
-                                if(attackVariance < 0) {
+                                if (attackVariance < 0) {
                                     attackVariance = 0;
                                 }
-                                if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+                                if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
                                     editingInfo.entityInfo.attackVariance = attackVariance;
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
-                                } else if(editingInfo != null) {
+                                } else if (editingInfo != null) {
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                                 } else {
                                     Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -435,11 +432,11 @@ public class TurnBasedMinecraftMod
                     )
                     .then(Commands.literal("attackEffect")
                         .executes(c -> {
-                            ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                            ServerPlayer player = c.getSource().getPlayerOrException();
                             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));
-                            } else if(editingInfo != null) {
+                            } else if (editingInfo != null) {
                                 getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                             } else {
                                 Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -449,13 +446,13 @@ public class TurnBasedMinecraftMod
                         })
                         .then(Commands.argument("attackEffect", StringArgumentType.word())
                             .executes(c -> {
-                                ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                                ServerPlayer player = c.getSource().getPlayerOrException();
                                 EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
                                 EntityInfo.Effect effect = EntityInfo.Effect.fromString(StringArgumentType.getString(c, "attackEffect"));
-                                if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+                                if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
                                     editingInfo.entityInfo.attackEffect = effect;
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
-                                } else if(editingInfo != null) {
+                                } else if (editingInfo != null) {
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                                 } else {
                                     Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -466,11 +463,11 @@ public class TurnBasedMinecraftMod
                     )
                     .then(Commands.literal("attackEffectProbability")
                         .executes(c -> {
-                            ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                            ServerPlayer player = c.getSource().getPlayerOrException();
                             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));
-                            } else if(editingInfo != null) {
+                            } else if (editingInfo != null) {
                                 getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                             } else {
                                 Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -480,18 +477,18 @@ public class TurnBasedMinecraftMod
                         })
                         .then(Commands.argument("attackEffectProbability", IntegerArgumentType.integer())
                             .executes(c -> {
-                                ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                                ServerPlayer player = c.getSource().getPlayerOrException();
                                 EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
                                 int attackEffectProbability = IntegerArgumentType.getInteger(c, "attackEffectProbability");
-                                if(attackEffectProbability < 0) {
+                                if (attackEffectProbability < 0) {
                                     attackEffectProbability = 0;
-                                } else if(attackEffectProbability > 100) {
+                                } else if (attackEffectProbability > 100) {
                                     attackEffectProbability = 100;
                                 }
-                                if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+                                if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
                                     editingInfo.entityInfo.attackEffectProbability = attackEffectProbability;
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
-                                } else if(editingInfo != null) {
+                                } else if (editingInfo != null) {
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                                 } else {
                                     Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -502,11 +499,11 @@ public class TurnBasedMinecraftMod
                     )
                     .then(Commands.literal("defenseDamage")
                         .executes(c -> {
-                            ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                            ServerPlayer player = c.getSource().getPlayerOrException();
                             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));
-                            } else if(editingInfo != null) {
+                            } else if (editingInfo != null) {
                                 getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                             } else {
                                 Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -516,16 +513,16 @@ public class TurnBasedMinecraftMod
                         })
                         .then(Commands.argument("defenseDamage", IntegerArgumentType.integer())
                             .executes(c -> {
-                                ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                                ServerPlayer player = c.getSource().getPlayerOrException();
                                 EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
                                 int defenseDamage = IntegerArgumentType.getInteger(c, "defenseDamage");
-                                if(defenseDamage < 0) {
+                                if (defenseDamage < 0) {
                                     defenseDamage = 0;
                                 }
-                                if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+                                if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
                                     editingInfo.entityInfo.defenseDamage = defenseDamage;
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
-                                } else if(editingInfo != null) {
+                                } else if (editingInfo != null) {
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                                 } else {
                                     Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -536,11 +533,11 @@ public class TurnBasedMinecraftMod
                     )
                     .then(Commands.literal("defenseDamageProbability")
                         .executes(c -> {
-                            ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                            ServerPlayer player = c.getSource().getPlayerOrException();
                             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));
-                            } else if(editingInfo != null) {
+                            } else if (editingInfo != null) {
                                 getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                             } else {
                                 Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -550,18 +547,18 @@ public class TurnBasedMinecraftMod
                         })
                         .then(Commands.argument("defenseDamageProbability", IntegerArgumentType.integer())
                             .executes(c -> {
-                                ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                                ServerPlayer player = c.getSource().getPlayerOrException();
                                 EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
                                 int defenseDamageProbability = IntegerArgumentType.getInteger(c, "defenseDamageProbability");
-                                if(defenseDamageProbability < 0) {
+                                if (defenseDamageProbability < 0) {
                                     defenseDamageProbability = 0;
-                                } else if(defenseDamageProbability > 100) {
+                                } else if (defenseDamageProbability > 100) {
                                     defenseDamageProbability = 100;
                                 }
-                                if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+                                if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
                                     editingInfo.entityInfo.defenseDamageProbability = defenseDamageProbability;
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
-                                } else if(editingInfo != null) {
+                                } else if (editingInfo != null) {
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                                 } else {
                                     Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -572,11 +569,11 @@ public class TurnBasedMinecraftMod
                     )
                     .then(Commands.literal("evasion")
                         .executes(c -> {
-                            ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                            ServerPlayer player = c.getSource().getPlayerOrException();
                             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));
-                            } else if(editingInfo != null) {
+                            } else if (editingInfo != null) {
                                 getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                             } else {
                                 Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -586,18 +583,18 @@ public class TurnBasedMinecraftMod
                         })
                         .then(Commands.argument("evasion", IntegerArgumentType.integer())
                             .executes(c -> {
-                                ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                                ServerPlayer player = c.getSource().getPlayerOrException();
                                 EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
                                 int evasion = IntegerArgumentType.getInteger(c, "evasion");
-                                if(evasion < 0) {
+                                if (evasion < 0) {
                                     evasion = 0;
-                                } else if(evasion > 100) {
+                                } else if (evasion > 100) {
                                     evasion = 100;
                                 }
-                                if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+                                if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
                                     editingInfo.entityInfo.evasion = evasion;
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
-                                } else if(editingInfo != null) {
+                                } else if (editingInfo != null) {
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                                 } else {
                                     Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -608,11 +605,11 @@ public class TurnBasedMinecraftMod
                     )
                     .then(Commands.literal("speed")
                         .executes(c -> {
-                            ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                            ServerPlayer player = c.getSource().getPlayerOrException();
                             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));
-                            } else if(editingInfo != null) {
+                            } else if (editingInfo != null) {
                                 getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                             } else {
                                 Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -622,16 +619,16 @@ public class TurnBasedMinecraftMod
                         })
                         .then(Commands.argument("speed", IntegerArgumentType.integer())
                             .executes(c -> {
-                                ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                                ServerPlayer player = c.getSource().getPlayerOrException();
                                 EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
                                 int speed = IntegerArgumentType.getInteger(c, "speed");
-                                if(speed < 0) {
+                                if (speed < 0) {
                                     speed = 0;
                                 }
-                                if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+                                if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
                                     editingInfo.entityInfo.speed = speed;
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
-                                } else if(editingInfo != null) {
+                                } else if (editingInfo != null) {
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                                 } else {
                                     Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -642,11 +639,11 @@ public class TurnBasedMinecraftMod
                     )
                     .then(Commands.literal("category")
                         .executes(c -> {
-                            ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                            ServerPlayer player = c.getSource().getPlayerOrException();
                             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));
-                            } else if(editingInfo != null) {
+                            } else if (editingInfo != null) {
                                 getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                             } else {
                                 Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -656,13 +653,13 @@ public class TurnBasedMinecraftMod
                         })
                         .then(Commands.argument("category", StringArgumentType.word())
                             .executes(c -> {
-                                ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                                ServerPlayer player = c.getSource().getPlayerOrException();
                                 EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
                                 String category = StringArgumentType.getString(c, "category");
-                                if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+                                if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
                                     editingInfo.entityInfo.category = category;
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
-                                } else if(editingInfo != null) {
+                                } else if (editingInfo != null) {
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                                 } else {
                                     Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -673,11 +670,11 @@ public class TurnBasedMinecraftMod
                     )
                     .then(Commands.literal("decisionAttack")
                         .executes(c -> {
-                            ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                            ServerPlayer player = c.getSource().getPlayerOrException();
                             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));
-                            } else if(editingInfo != null) {
+                            } else if (editingInfo != null) {
                                 getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                             } else {
                                 Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -687,18 +684,18 @@ public class TurnBasedMinecraftMod
                         })
                         .then(Commands.argument("decisionAttack", IntegerArgumentType.integer())
                             .executes(c -> {
-                                ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                                ServerPlayer player = c.getSource().getPlayerOrException();
                                 EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
                                 int decisionAttack = IntegerArgumentType.getInteger(c, "decisionAttack");
-                                if(decisionAttack < 0) {
+                                if (decisionAttack < 0) {
                                     decisionAttack = 0;
-                                } else if(decisionAttack > 100) {
+                                } else if (decisionAttack > 100) {
                                     decisionAttack = 100;
                                 }
-                                if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+                                if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
                                     editingInfo.entityInfo.decisionAttack = decisionAttack;
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
-                                } else if(editingInfo != null) {
+                                } else if (editingInfo != null) {
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                                 } else {
                                     Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -709,11 +706,11 @@ public class TurnBasedMinecraftMod
                     )
                     .then(Commands.literal("decisionDefend")
                         .executes(c -> {
-                            ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                            ServerPlayer player = c.getSource().getPlayerOrException();
                             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));
-                            } else if(editingInfo != null) {
+                            } else if (editingInfo != null) {
                                 getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                             } else {
                                 Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -723,18 +720,18 @@ public class TurnBasedMinecraftMod
                         })
                         .then(Commands.argument("decisionDefend", IntegerArgumentType.integer())
                             .executes(c -> {
-                                ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                                ServerPlayer player = c.getSource().getPlayerOrException();
                                 EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
                                 int decisionDefend = IntegerArgumentType.getInteger(c, "decisionDefend");
-                                if(decisionDefend < 0) {
+                                if (decisionDefend < 0) {
                                     decisionDefend = 0;
-                                } else if(decisionDefend > 100) {
+                                } else if (decisionDefend > 100) {
                                     decisionDefend = 100;
                                 }
-                                if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+                                if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
                                     editingInfo.entityInfo.decisionDefend = decisionDefend;
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
-                                } else if(editingInfo != null) {
+                                } else if (editingInfo != null) {
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                                 } else {
                                     Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -745,11 +742,11 @@ public class TurnBasedMinecraftMod
                     )
                     .then(Commands.literal("decisionFlee")
                         .executes(c -> {
-                            ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                            ServerPlayer player = c.getSource().getPlayerOrException();
                             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));
-                            } else if(editingInfo != null) {
+                            } else if (editingInfo != null) {
                                 getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                             } else {
                                 Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -759,13 +756,13 @@ public class TurnBasedMinecraftMod
                         })
                         .then(Commands.argument("decisionFlee", IntegerArgumentType.integer())
                             .executes(c -> {
-                                ServerPlayerEntity player = c.getSource().getPlayerOrException();
+                                ServerPlayer player = c.getSource().getPlayerOrException();
                                 EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
                                 int decisionFlee = IntegerArgumentType.getInteger(c, "decisionFlee");
-                                if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+                                if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
                                     editingInfo.entityInfo.decisionFlee = decisionFlee;
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
-                                } else if(editingInfo != null) {
+                                } else if (editingInfo != null) {
                                     getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
                                 } else {
                                     Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@@ -777,13 +774,11 @@ public class TurnBasedMinecraftMod
                 )
         );
     }
-    
+
     @SubscribeEvent
-    public void serverStopping(FMLServerStoppingEvent event)
-    {
+    public void serverStopping(ServerStoppingEvent event) {
         logger.debug("About to cleanup BattleManager");
-        if(proxy.cleanupBattleManager())
-        {
+        if (proxy.cleanupBattleManager()) {
             logger.debug("Cleaned up BattleManager");
         }
     }
index a3571aff9c229c2a0cb18eb83e04388ef8dd3c8d..2a783f3be7d2813013a324870d4b2e3482af0002 100644 (file)
@@ -1,12 +1,12 @@
 package com.burnedkirby.TurnBasedMinecraft.common;
 
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.item.ArrowItem;
-import net.minecraft.util.RegistryKey;
-import net.minecraft.util.ResourceLocation;
-import net.minecraft.util.registry.Registry;
-import net.minecraft.world.World;
+import net.minecraft.core.Registry;
+import net.minecraft.resources.ResourceKey;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.item.ArrowItem;
+import net.minecraft.world.level.Level;
 
 public class Utility
 {
@@ -37,11 +37,11 @@ public class Utility
         }
     }
     
-    public static boolean doesPlayerHaveArrows(PlayerEntity player)
+    public static boolean doesPlayerHaveArrows(Player player)
     {
-        for(int i = 0; i < player.inventory.getContainerSize(); ++i)
+        for(int i = 0; i < player.getInventory().getContainerSize(); ++i)
         {
-            if(player.inventory.getItem(i).getItem() instanceof ArrowItem)
+            if(player.getInventory().getItem(i).getItem() instanceof ArrowItem)
             {
                 return true;
             }
@@ -54,12 +54,12 @@ public class Utility
         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(ResourceKey<Level> dimObject) {
         return dimObject.getRegistryName().toString();
     }
 
-    public static RegistryKey<World> deserializeDimension(String dimString) {
+    public static ResourceKey<Level> deserializeDimension(String dimString) {
         ResourceLocation dimRes = new ResourceLocation(dimString);
-        return RegistryKey.create(Registry.DIMENSION_REGISTRY, dimRes);
+        return ResourceKey.create(Registry.DIMENSION_REGISTRY, dimRes);
     }
 }
index 7b5f391c710208a45b988923f0063cc94ffb064e..517ecd084858b39e9e663e87a00c23273bb23fe1 100644 (file)
@@ -6,9 +6,9 @@ import com.burnedkirby.TurnBasedMinecraft.common.Battle;
 import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
 import com.burnedkirby.TurnBasedMinecraft.common.Battle.Decision;
 
-import net.minecraft.entity.player.ServerPlayerEntity;
-import net.minecraft.network.PacketBuffer;
-import net.minecraftforge.fml.network.NetworkEvent;
+import net.minecraft.server.level.ServerPlayer;
+import net.minecraft.network.FriendlyByteBuf;
+import net.minecraftforge.network.NetworkEvent;
 
 public class PacketBattleDecision
 {
@@ -25,27 +25,25 @@ public class PacketBattleDecision
         this.targetIDOrItemID = targetIDOrItemID;
     }
     
-    public static void encode(PacketBattleDecision pkt, PacketBuffer buf) {
+    public static void encode(PacketBattleDecision pkt, FriendlyByteBuf buf) {
        buf.writeInt(pkt.battleID);
        buf.writeInt(pkt.decision.getValue());
        buf.writeInt(pkt.targetIDOrItemID);
     }
     
-    public static PacketBattleDecision decode(PacketBuffer buf) {
+    public static PacketBattleDecision decode(FriendlyByteBuf buf) {
        return new PacketBattleDecision(buf.readInt(), Decision.valueOf(buf.readInt()), buf.readInt());
     }
     
-    public static class Handler {
-       public static void handle(final PacketBattleDecision pkt, Supplier<NetworkEvent.Context> ctx) {
-               ctx.get().enqueueWork(() -> {
-                Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
-                if(b != null)
-                {
-                    ServerPlayerEntity player = ctx.get().getSender();
-                    b.setDecision(player.getId(), pkt.decision, pkt.targetIDOrItemID);
-                }
-               });
-               ctx.get().setPacketHandled(true);
-       }
+    public static void handle(final PacketBattleDecision pkt, Supplier<NetworkEvent.Context> ctx) {
+        ctx.get().enqueueWork(() -> {
+            Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
+            if(b != null)
+            {
+                ServerPlayer player = ctx.get().getSender();
+                b.setDecision(player.getId(), pkt.decision, pkt.targetIDOrItemID);
+            }
+        });
+        ctx.get().setPacketHandled(true);
     }
 }
index 568f6ddd8e1fc4a234ae70e7cc8f815868ca255e..698dc995f67e8597d9765777fa13a54058ee0475 100644 (file)
@@ -7,9 +7,9 @@ import java.util.function.Supplier;
 import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
 
 import net.minecraft.client.Minecraft;
-import net.minecraft.entity.Entity;
-import net.minecraft.network.PacketBuffer;
-import net.minecraftforge.fml.network.NetworkEvent;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.network.FriendlyByteBuf;
+import net.minecraftforge.network.NetworkEvent;
 
 public class PacketBattleInfo
 {
@@ -23,27 +23,27 @@ public class PacketBattleInfo
         sideB = new ArrayList<Integer>();
         decisionNanos = TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos();
     }
-    
+
     public PacketBattleInfo(Collection<Integer> sideA, Collection<Integer> sideB, long decisionNanos)
     {
         this.sideA = sideA;
         this.sideB = sideB;
         this.decisionNanos = decisionNanos;
     }
-    
-    public static void encode(PacketBattleInfo pkt, PacketBuffer buf) {
-       buf.writeInt(pkt.sideA.size());
-       buf.writeInt(pkt.sideB.size());
-       for(Integer id : pkt.sideA) {
+
+    public static void encode(PacketBattleInfo msg, FriendlyByteBuf buf) {
+       buf.writeInt(msg.sideA.size());
+       buf.writeInt(msg.sideB.size());
+       for(Integer id : msg.sideA) {
                buf.writeInt(id);
        }
-       for(Integer id : pkt.sideB) {
+       for(Integer id : msg.sideB) {
                buf.writeInt(id);
        }
-       buf.writeLong(pkt.decisionNanos);
+       buf.writeLong(msg.decisionNanos);
     }
-    
-    public static PacketBattleInfo decode(PacketBuffer buf) {
+
+    public static PacketBattleInfo decode(FriendlyByteBuf buf) {
        int sideACount = buf.readInt();
        int sideBCount = buf.readInt();
        Collection<Integer> sideA = new ArrayList<Integer>(sideACount);
@@ -58,34 +58,32 @@ public class PacketBattleInfo
        return new PacketBattleInfo(sideA, sideB, decisionNanos);
     }
     
-    public static class Handler {
-       public static void handle(final PacketBattleInfo pkt, Supplier<NetworkEvent.Context> ctx) {
-               ctx.get().enqueueWork(() -> {
-                if(TurnBasedMinecraftMod.proxy.getLocalBattle() == null)
-                {
-                    return;
-                }
-                TurnBasedMinecraftMod.proxy.getLocalBattle().clearCombatants();
-                for(Integer id : pkt.sideA)
+    public static void handle(final PacketBattleInfo pkt, Supplier<NetworkEvent.Context> ctx) {
+        ctx.get().enqueueWork(() -> {
+            if(TurnBasedMinecraftMod.proxy.getLocalBattle() == null)
+            {
+                return;
+            }
+            TurnBasedMinecraftMod.proxy.getLocalBattle().clearCombatants();
+            for(Integer id : pkt.sideA)
+            {
+                Entity e = Minecraft.getInstance().level.getEntity(id);
+                if(e != null)
                 {
-                    Entity e = Minecraft.getInstance().level.getEntity(id);
-                    if(e != null)
-                    {
-                        TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideA(e);
-                    }
+                    TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideA(e);
                 }
-                for(Integer id : pkt.sideB)
+            }
+            for(Integer id : pkt.sideB)
+            {
+                Entity e = Minecraft.getInstance().level.getEntity(id);
+                if(e != null)
                 {
-                    Entity e = Minecraft.getInstance().level.getEntity(id);
-                    if(e != null)
-                    {
-                        TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideB(e);
-                    }
+                    TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideB(e);
                 }
-                TurnBasedMinecraftMod.proxy.setBattleGuiTime((int)(pkt.decisionNanos / 1000000000L));
-                TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
-               });
-               ctx.get().setPacketHandled(true);
-       }
+            }
+            TurnBasedMinecraftMod.proxy.setBattleGuiTime((int)(pkt.decisionNanos / 1000000000L));
+            TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
+        });
+        ctx.get().setPacketHandled(true);
     }
 }
index 3e93d90c81fd0099646fc11293c636011901c090..1011284b5b25c091339c5bd93494495a93eacb9d 100644 (file)
@@ -7,13 +7,12 @@ import java.util.function.Supplier;
 import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
 
 import com.burnedkirby.TurnBasedMinecraft.common.Utility;
-import net.minecraft.entity.Entity;
-import net.minecraft.network.PacketBuffer;
-import net.minecraft.util.RegistryKey;
-import net.minecraft.util.text.Color;
-import net.minecraft.util.text.StringTextComponent;
-import net.minecraft.world.World;
-import net.minecraftforge.fml.network.NetworkEvent;
+import net.minecraft.network.FriendlyByteBuf;
+import net.minecraft.resources.ResourceKey;
+import net.minecraft.world.level.Level;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.fml.DistExecutor;
+import net.minecraftforge.network.NetworkEvent;
 
 public class PacketBattleMessage
 {
@@ -102,17 +101,40 @@ public class PacketBattleMessage
             return map.get(value);
         }
     }
-    
+
     MessageType messageType;
     int entityIDFrom;
     int entityIDTo;
     int amount;
     String custom;
-    RegistryKey<World> dimension;
-    
+    ResourceKey<Level> dimension;
+
+    public MessageType getMessageType() {
+        return messageType;
+    }
+
+    public int getEntityIDFrom() {
+        return entityIDFrom;
+    }
+
+    public int getEntityIDTo() {
+        return entityIDTo;
+    }
+
+    public int getAmount() {
+        return amount;
+    }
+
+    public String getCustom() {
+        return custom;
+    }
+
+    public ResourceKey<Level> getDimension() {
+        return dimension;
+    }
     public PacketBattleMessage() { custom = new String(); }
     
-    public PacketBattleMessage(MessageType messageType, int entityIDFrom, int entityIDTo, RegistryKey<World> dimension, int amount)
+    public PacketBattleMessage(MessageType messageType, int entityIDFrom, int entityIDTo, ResourceKey<Level> dimension, int amount)
     {
         this.messageType = messageType;
         this.entityIDFrom = entityIDFrom;
@@ -122,7 +144,7 @@ public class PacketBattleMessage
         custom = new String();
     }
     
-    public PacketBattleMessage(MessageType messageType, int entityIDFrom, int entityIDTo, RegistryKey<World> dimension, int amount, String custom)
+    public PacketBattleMessage(MessageType messageType, int entityIDFrom, int entityIDTo, ResourceKey<Level> dimension, int amount, String custom)
     {
         this.messageType = messageType;
         this.entityIDFrom = entityIDFrom;
@@ -132,7 +154,7 @@ public class PacketBattleMessage
         this.custom = custom;
     }
     
-    public static void encode(PacketBattleMessage pkt, PacketBuffer buf) {
+    public static void encode(PacketBattleMessage pkt, FriendlyByteBuf buf) {
         buf.writeInt(pkt.messageType.getValue());
         buf.writeInt(pkt.entityIDFrom);
         buf.writeInt(pkt.entityIDTo);
@@ -141,7 +163,7 @@ public class PacketBattleMessage
         buf.writeUtf(pkt.custom);
     }
     
-    public static PacketBattleMessage decode(PacketBuffer buf) {
+    public static PacketBattleMessage decode(FriendlyByteBuf buf) {
        return new PacketBattleMessage(
                MessageType.valueOf(
                        buf.readInt()),
@@ -152,183 +174,10 @@ public class PacketBattleMessage
                        buf.readUtf());
     }
     
-    public static class Handler {
-       public static void handle(final PacketBattleMessage pkt, Supplier<NetworkEvent.Context> ctx) {
-               ctx.get().enqueueWork(() -> {
-                Entity fromEntity = TurnBasedMinecraftMod.proxy.getEntity(pkt.entityIDFrom, pkt.dimension);
-                String from = "Unknown";
-                if(fromEntity != null)
-                {
-                       from = fromEntity.getDisplayName().getString();
-                }
-                else if(TurnBasedMinecraftMod.proxy.getLocalBattle() != null)
-                {
-                    fromEntity = TurnBasedMinecraftMod.proxy.getLocalBattle().getCombatantEntity(pkt.entityIDFrom);
-                    if(fromEntity != null)
-                    {
-                       from = fromEntity.getDisplayName().getString();
-                    }
-                }
-                Entity toEntity = TurnBasedMinecraftMod.proxy.getEntity(pkt.entityIDTo, pkt.dimension);
-                String to = "Unknown";
-                if(toEntity != null)
-                {
-                       to = toEntity.getDisplayName().getString();
-                }
-                else if(TurnBasedMinecraftMod.proxy.getLocalBattle() != null)
-                {
-                    toEntity = TurnBasedMinecraftMod.proxy.getLocalBattle().getCombatantEntity(pkt.entityIDTo);
-                    if(toEntity != null)
-                    {
-                        to = toEntity.getDisplayName().getString();
-                    }
-                }
-                
-                switch(pkt.messageType)
-                {
-                case ENTERED:
-                    TurnBasedMinecraftMod.proxy.displayString(from + " entered battle!");
-                    if(TurnBasedMinecraftMod.proxy.getLocalBattle() == null || TurnBasedMinecraftMod.proxy.getLocalBattle().getId() != pkt.amount)
-                    {
-                        TurnBasedMinecraftMod.proxy.createLocalBattle(pkt.amount);
-                    }
-                    TurnBasedMinecraftMod.proxy.battleStarted();
-                    TurnBasedMinecraftMod.proxy.typeEnteredBattle(pkt.custom);
-                    break;
-                case FLEE:
-                    if(pkt.amount != 0)
-                    {
-                        TurnBasedMinecraftMod.proxy.displayString(from + " fled battle!");
-                        TurnBasedMinecraftMod.proxy.typeLeftBattle(pkt.custom);
-                    }
-                    else
-                    {
-                        TurnBasedMinecraftMod.proxy.displayString(from + " tried to flee battle but failed!");
-                    }
-                    break;
-                case DIED:
-                    TurnBasedMinecraftMod.proxy.displayString(from + " died in battle!");
-                    TurnBasedMinecraftMod.proxy.typeLeftBattle(pkt.custom);
-                    break;
-                case ENDED:
-                    TurnBasedMinecraftMod.proxy.displayString("Battle has ended!");
-                    TurnBasedMinecraftMod.proxy.battleEnded();
-                    break;
-                case ATTACK:
-                    TurnBasedMinecraftMod.proxy.displayString(from + " attacked " + to + " and dealt " + pkt.amount + " damage!");
-                    break;
-                case DEFEND:
-                    TurnBasedMinecraftMod.proxy.displayString(from + " blocked " + to + "'s attack!");
-                    break;
-                case DEFENSE_DAMAGE:
-                    TurnBasedMinecraftMod.proxy.displayString(from + " retaliated from " + to + "'s attack and dealt " + pkt.amount + " damage!");
-                    break;
-                case MISS:
-                    TurnBasedMinecraftMod.proxy.displayString(from + " attacked " + to + " but missed!");
-                    break;
-                case DEFENDING:
-                    TurnBasedMinecraftMod.proxy.displayString(from + " is defending!");
-                    break;
-                case DID_NOTHING:
-                    TurnBasedMinecraftMod.proxy.displayString(from + " did nothing!");
-                    break;
-                case USED_ITEM:
-                    switch(UsedItemAction.valueOf(pkt.amount))
-                    {
-                    case USED_NOTHING:
-                        TurnBasedMinecraftMod.proxy.displayString(from + " tried to use nothing!");
-                        break;
-                    case USED_INVALID:
-                        if(pkt.custom.length() > 0)
-                        {
-                            TurnBasedMinecraftMod.proxy.displayString(from + " tried to consume " + pkt.custom + " and failed!");
-                        }
-                        else
-                        {
-                            TurnBasedMinecraftMod.proxy.displayString(from + " tried to consume an invalid item and failed!");
-                        }
-                        break;
-                    case USED_FOOD:
-                        TurnBasedMinecraftMod.proxy.displayString(from + " ate a " + pkt.custom + "!");
-                        break;
-                    case USED_POTION:
-                        TurnBasedMinecraftMod.proxy.displayString(from + " drank a " + pkt.custom + "!");
-                        break;
-                    }
-                    break;
-                case TURN_BEGIN:
-                    TurnBasedMinecraftMod.proxy.displayString("The turn begins!");
-                    TurnBasedMinecraftMod.proxy.battleGuiTurnBegin();
-                    break;
-                case TURN_END:
-                    if(TurnBasedMinecraftMod.proxy.getLocalBattle() != null)
-                    {
-                        if(pkt.amount == 0)
-                        {
-                            TurnBasedMinecraftMod.proxy.displayString("The turn ended!");
-                        }
-                        else
-                        {
-                            TurnBasedMinecraftMod.proxy.displayString("The turn ended (abnormally due to internal error)!");
-                        }
-                    }
-                    TurnBasedMinecraftMod.proxy.battleGuiTurnEnd();
-                    break;
-                case SWITCHED_ITEM:
-                    if(pkt.amount != 0)
-                    {
-                        TurnBasedMinecraftMod.proxy.displayString(from + " switched to a different item!");
-                    }
-                    else
-                    {
-                        TurnBasedMinecraftMod.proxy.displayString(from + " switched to a different item but failed because it was invalid!");
-                    }
-                    break;
-                case WAS_AFFECTED:
-                    TurnBasedMinecraftMod.proxy.displayString(to + " was " + pkt.custom + " by " + from + "!");
-                    break;
-                case BECAME_CREATIVE:
-                    TurnBasedMinecraftMod.proxy.displayString(from + " entered creative mode and left battle!");
-                    break;
-                case FIRED_ARROW:
-                    TurnBasedMinecraftMod.proxy.displayString(from + " let loose an arrow towards " + to + "!");
-                    break;
-                case ARROW_HIT:
-                    TurnBasedMinecraftMod.proxy.displayString(to + " was hit by " + from + "'s arrow!");
-                    break;
-                case BOW_NO_AMMO:
-                    TurnBasedMinecraftMod.proxy.displayString(from + " tried to use their bow but ran out of ammo!");
-                    break;
-                case CREEPER_WAIT: {
-                    StringTextComponent prefix = new StringTextComponent("TBM: ");
-                    prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
-                    StringTextComponent message = new StringTextComponent(from + " is charging up!");
-                    message.setStyle(message.getStyle().withColor(Color.fromRgb(0xFFFFFF00)));
-                    prefix.getSiblings().add(message);
-                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
-                }
-                    break;
-                case CREEPER_WAIT_FINAL: {
-                    StringTextComponent prefix = new StringTextComponent("TBM: ");
-                    prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
-                    StringTextComponent message = new StringTextComponent(from + " is about to explode!");
-                    message.setStyle(message.getStyle().withColor(Color.fromRgb(0xFFFF5050)));
-                    prefix.getSiblings().add(message);
-                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
-                }
-                    break;
-                case CREEPER_EXPLODE: {
-                    StringTextComponent prefix = new StringTextComponent("TBM: ");
-                    prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
-                    StringTextComponent message = new StringTextComponent(from + " exploded!");
-                    message.setStyle(message.getStyle().withColor(Color.fromRgb(0xFFFF0000)));
-                    prefix.getSiblings().add(message);
-                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
-                }
-                    break;
-                }
-               });
-               ctx.get().setPacketHandled(true);
-       }
+    public static void handle(final PacketBattleMessage pkt, Supplier<NetworkEvent.Context> ctx) {
+        ctx.get().enqueueWork(() -> {
+            DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
+        });
+        ctx.get().setPacketHandled(true);
     }
 }
index 9d267eed419347b1d4556a9192801c105105417b..b78896bf422035650707716bfa4d80909e4157fe 100644 (file)
@@ -6,8 +6,8 @@ import com.burnedkirby.TurnBasedMinecraft.common.Battle;
 import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
 
 import io.netty.buffer.Unpooled;
-import net.minecraft.network.PacketBuffer;
-import net.minecraftforge.fml.network.NetworkEvent;
+import net.minecraft.network.FriendlyByteBuf;
+import net.minecraftforge.network.NetworkEvent;
 
 public class PacketBattleRequestInfo
 {
@@ -20,24 +20,22 @@ public class PacketBattleRequestInfo
         this.battleID = battleID;
     }
     
-    public static void encode(PacketBattleRequestInfo pkt, PacketBuffer buf) {
+    public static void encode(PacketBattleRequestInfo pkt, FriendlyByteBuf buf) {
        buf.writeInt(pkt.battleID);
     }
     
-    public static PacketBattleRequestInfo decode(PacketBuffer buf) {
+    public static PacketBattleRequestInfo decode(FriendlyByteBuf buf) {
        return new PacketBattleRequestInfo(buf.readInt());
     }
     
-    public static class Handler {
-       public static void handle(final PacketBattleRequestInfo pkt, Supplier<NetworkEvent.Context> ctx) {
-               ctx.get().enqueueWork(() -> {
-                Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
-                if(b == null) {
-                       return;
-                }
-                TurnBasedMinecraftMod.getHandler().reply(new PacketBattleInfo(b.getSideAIDs(), b.getSideBIDs(), b.getTimerSeconds()), ctx.get());
-               });
-               ctx.get().setPacketHandled(true);
-       }
+    public static void handle(final PacketBattleRequestInfo pkt, Supplier<NetworkEvent.Context> ctx) {
+        ctx.get().enqueueWork(() -> {
+            Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
+            if(b == null) {
+                return;
+            }
+            TurnBasedMinecraftMod.getHandler().reply(new PacketBattleInfo(b.getSideAIDs(), b.getSideBIDs(), b.getTimerSeconds()), ctx.get());
+        });
+        ctx.get().setPacketHandled(true);
     }
 }
index 654507cbdfb450f8fb7e80f46f96699df809d755..4cdddaa6698203a90f6f00193ce8b0fe35140d88 100644 (file)
@@ -2,13 +2,10 @@ package com.burnedkirby.TurnBasedMinecraft.common.networking;
 
 import com.burnedkirby.TurnBasedMinecraft.common.EntityInfo;
 import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
-import net.minecraft.network.PacketBuffer;
-import net.minecraft.util.text.Color;
-import net.minecraft.util.text.ITextComponent;
-import net.minecraft.util.text.StringTextComponent;
-import net.minecraft.util.text.event.ClickEvent;
-import net.minecraft.util.text.event.HoverEvent;
-import net.minecraftforge.fml.network.NetworkEvent;
+import net.minecraft.network.FriendlyByteBuf;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.fml.DistExecutor;
+import net.minecraftforge.network.NetworkEvent;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -66,6 +63,14 @@ public class PacketEditingMessage
     Type type = Type.ATTACK_ENTITY;
     EntityInfo entityInfo = new EntityInfo();
 
+    public Type getType() {
+        return type;
+    }
+
+    public EntityInfo getEntityInfo() {
+        return entityInfo;
+    }
+
     public PacketEditingMessage() {}
 
     public PacketEditingMessage(Type type)
@@ -82,7 +87,7 @@ public class PacketEditingMessage
         }
     }
     
-    public static void encode(PacketEditingMessage pkt, PacketBuffer buf) {
+    public static void encode(PacketEditingMessage pkt, FriendlyByteBuf buf) {
        buf.writeInt(pkt.type.getValue());
        if(pkt.entityInfo.classType != null) {
                buf.writeUtf(pkt.entityInfo.classType.getName());
@@ -106,7 +111,7 @@ public class PacketEditingMessage
        buf.writeUtf(pkt.entityInfo.customName);
     }
     
-    public static PacketEditingMessage decode(PacketBuffer buf) {
+    public static PacketEditingMessage decode(FriendlyByteBuf buf) {
        Type type = Type.valueOf(buf.readInt());
        EntityInfo einfo = new EntityInfo();
        try {
@@ -130,603 +135,10 @@ public class PacketEditingMessage
        return new PacketEditingMessage(type, einfo);
     }
 
-    public static class Handler {
-       public static void handle(final PacketEditingMessage pkt, Supplier<NetworkEvent.Context> ctx) {
-               ctx.get().enqueueWork(() -> {
-                       switch(pkt.type)
-                {
-                case ATTACK_ENTITY:
-                {
-                    StringTextComponent prefix = new StringTextComponent("TBM: ");
-                    prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
-                    StringTextComponent text = new StringTextComponent("Attack the entity you want to edit for TurnBasedMinecraftMod. ");
-                    text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
-
-                    StringTextComponent cancel = new StringTextComponent("Cancel");
-                    cancel.setStyle(cancel.getStyle().withColor(Color.fromRgb(0xFFFF0000)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit cancel")));
-                    text.getSiblings().add(cancel);
-
-                    prefix.getSiblings().add(text);
-                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
-                    break;
-                }
-                case PICK_EDIT:
-                {
-                    StringTextComponent prefix = new StringTextComponent("TBM: ");
-                    prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
-                    StringTextComponent text = new StringTextComponent("Edit what value? ");
-                    text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
-
-                    StringTextComponent option = new StringTextComponent("IgB");
-                    // HoverEvent.Action.SHOW_TEXT is probably SHOW_TEXT
-                    option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle"))
-                        .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("IgnoreBattle"))));
-                    StringTextComponent value = new StringTextComponent("(" + pkt.entityInfo.ignoreBattle + ") ");
-                    value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                    option.getSiblings().add(value);
-                    text.getSiblings().add(option);
-
-                    option = new StringTextComponent("AP");
-                    option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackPower"))
-                        .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("AttackPower"))));
-                    value = new StringTextComponent("(" + pkt.entityInfo.attackPower + ") ");
-                    value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                    option.getSiblings().add(value);
-                    text.getSiblings().add(option);
-
-                    option = new StringTextComponent("APr");
-                    option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackProbability"))
-                        .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("AttackProbability"))));
-                    value = new StringTextComponent("(" + pkt.entityInfo.attackProbability + "%) ");
-                    value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                    option.getSiblings().add(value);
-                    text.getSiblings().add(option);
-
-                    option = new StringTextComponent("AV");
-                    option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackVariance"))
-                        .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("AttackVariance"))));
-                    value = new StringTextComponent("(" + pkt.entityInfo.attackVariance + ") ");
-                    value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                    option.getSiblings().add(value);
-                    text.getSiblings().add(option);
-
-                    option = new StringTextComponent("AE");
-                    option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffect"))
-                        .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("AttackEffect"))));
-                    value = new StringTextComponent("(" + pkt.entityInfo.attackEffect.toString() + ") ");
-                    value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                    option.getSiblings().add(value);
-                    text.getSiblings().add(option);
-
-                    option = new StringTextComponent("AEPr");
-                    option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffectProbability"))
-                        .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("AttackEffectProbability"))));
-                    value = new StringTextComponent("(" + pkt.entityInfo.attackEffectProbability + "%) ");
-                    value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                    option.getSiblings().add(value);
-                    text.getSiblings().add(option);
-
-                    option = new StringTextComponent("DD");
-                    option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamage"))
-                        .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("DefenseDamage"))));
-                    value = new StringTextComponent("(" + pkt.entityInfo.defenseDamage + ") ");
-                    value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                    option.getSiblings().add(value);
-                    text.getSiblings().add(option);
-
-                    option = new StringTextComponent("DDPr");
-                    option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamageProbability"))
-                        .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("DefenseDamageProbability"))));
-                    value = new StringTextComponent("(" + pkt.entityInfo.defenseDamageProbability + "%) ");
-                    value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                    option.getSiblings().add(value);
-                    text.getSiblings().add(option);
-
-                    option = new StringTextComponent("E");
-                    option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit evasion"))
-                        .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("Evasion"))));
-                    value = new StringTextComponent("(" + pkt.entityInfo.evasion + "%) ");
-                    value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                    option.getSiblings().add(value);
-                    text.getSiblings().add(option);
-
-                    option = new StringTextComponent("S");
-                    option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit speed"))
-                        .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("Speed"))));
-                    value = new StringTextComponent("(" + pkt.entityInfo.speed + ") ");
-                    value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                    option.getSiblings().add(value);
-                    text.getSiblings().add(option);
-
-                    option = new StringTextComponent("C");
-                    option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category"))
-                        .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("Category"))));
-                    value = new StringTextComponent("(" + pkt.entityInfo.category + ") ");
-                    value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                    option.getSiblings().add(value);
-                    text.getSiblings().add(option);
-
-                    option = new StringTextComponent("DecA");
-                    option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionAttack"))
-                        .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("DecisionAttack"))));
-                    value = new StringTextComponent("(" + pkt.entityInfo.decisionAttack + "%) ");
-                    value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                    option.getSiblings().add(value);
-                    text.getSiblings().add(option);
-
-                    option = new StringTextComponent("DecD");
-                    option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionDefend"))
-                        .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("DecisionDefend"))));
-                    value = new StringTextComponent("(" + pkt.entityInfo.decisionDefend + "%) ");
-                    value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                    option.getSiblings().add(value);
-                    text.getSiblings().add(option);
-
-                    option = new StringTextComponent("DecF");
-                    option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionFlee"))
-                        .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("DecisionFlee"))));
-                    value = new StringTextComponent("(" + pkt.entityInfo.decisionFlee + "%) ");
-                    value.setStyle(value.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                    option.getSiblings().add(value);
-                    text.getSiblings().add(option);
-
-                    option = new StringTextComponent("Finished Editing");
-                    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(new StringTextComponent(" "));
-
-                    option = new StringTextComponent("Cancel");
-                    option.setStyle(option.getStyle().withColor(Color.fromRgb(0xFFFF0000)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit cancel")));
-                    text.getSiblings().add(option);
-
-                    prefix.getSiblings().add(text);
-                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
-                    break;
-                }
-                case EDIT_IGNORE_BATTLE:
-                {
-                    StringTextComponent prefix = new StringTextComponent("TBM: ");
-                    prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
-                    StringTextComponent text = new StringTextComponent("ignoreBattle: ");
-                    text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
-
-                    StringTextComponent option = new StringTextComponent("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(new StringTextComponent(" "));
-
-                    option = new StringTextComponent("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);
-
-                    prefix.getSiblings().add(text);
-                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
-                    break;
-                }
-                case EDIT_ATTACK_POWER:
-                {
-                    StringTextComponent prefix = new StringTextComponent("TBM: ");
-                    prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
-                    StringTextComponent text = new StringTextComponent("attackPower: ");
-                    text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
-
-                    for(int i = 0; i <= 15; ++i)
-                    {
-                        StringTextComponent option = new StringTextComponent(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);
-                        if(i < 15)
-                        {
-                            text.getSiblings().add(new StringTextComponent(", "));
-                        }
-                    }
-
-                    text.getSiblings().add(new StringTextComponent(" (or use command \"/tbm-edit edit attackPower <integer>\")"));
-
-                    prefix.getSiblings().add(text);
-                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
-                    break;
-                }
-                case EDIT_ATTACK_PROBABILITY:
-                {
-                    StringTextComponent prefix = new StringTextComponent("TBM: ");
-                    prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
-                    StringTextComponent text = new StringTextComponent("attackProbability: ");
-                    text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
-
-                    for(int i = 10; i <= 100; i += 10)
-                    {
-                        StringTextComponent option = new StringTextComponent(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);
-                        if(i < 100)
-                        {
-                            text.getSiblings().add(new StringTextComponent(", "));
-                        }
-                    }
-
-                    text.getSiblings().add(new StringTextComponent(" (or use command \"/tbm-edit edit attackProbability <percentage-integer>\")"));
-
-                    prefix.getSiblings().add(text);
-                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
-                    break;
-                }
-                case EDIT_ATTACK_VARIANCE:
-                {
-                    StringTextComponent prefix = new StringTextComponent("TBM: ");
-                    prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
-                    StringTextComponent text = new StringTextComponent("attackVariance: ");
-                    text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
-
-                    for(int i = 0; i <= 10; ++i)
-                    {
-                        StringTextComponent option = new StringTextComponent(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);
-                        if(i < 10)
-                        {
-                            text.getSiblings().add(new StringTextComponent(", "));
-                        }
-                    }
-
-                    text.getSiblings().add(new StringTextComponent(" (or use command \"/tbm-edit edit attackVariance <integer>\")"));
-
-                    prefix.getSiblings().add(text);
-                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
-                    break;
-                }
-                case EDIT_ATTACK_EFFECT:
-                {
-                    StringTextComponent prefix = new StringTextComponent("TBM: ");
-                    prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
-                    StringTextComponent text = new StringTextComponent("attackEffect: ");
-                    text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
-
-                    for(EntityInfo.Effect e : EntityInfo.Effect.values())
-                    {
-                        StringTextComponent option = new StringTextComponent(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);
-                        if(e != EntityInfo.Effect.UNKNOWN)
-                        {
-                            // TODO find a better way to handle printing comma for items before last
-                            text.getSiblings().add(new StringTextComponent(", "));
-                        }
-                    }
-
-                    prefix.getSiblings().add(text);
-                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
-                    break;
-                }
-                case EDIT_ATTACK_EFFECT_PROBABILITY:
-                {
-                    StringTextComponent prefix = new StringTextComponent("TBM: ");
-                    prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
-                    StringTextComponent text = new StringTextComponent("attackEffectProbability: ");
-                    text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
-
-                    for(int i = 0; i <= 100; i += 10)
-                    {
-                        StringTextComponent option = new StringTextComponent(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);
-                        if(i < 100)
-                        {
-                            text.getSiblings().add(new StringTextComponent(", "));
-                        }
-                    }
-
-                    text.getSiblings().add(new StringTextComponent(" (or use command \"/tbm-edit edit attackEffectProbability <percentage-integer>\")"));
-
-                    prefix.getSiblings().add(text);
-                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
-                    break;
-                }
-                case EDIT_DEFENSE_DAMAGE:
-                {
-                    StringTextComponent prefix = new StringTextComponent("TBM: ");
-                    prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
-                    StringTextComponent text = new StringTextComponent("defenseDamage: ");
-                    text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
-
-                    for(int i = 0; i <= 15; ++i)
-                    {
-                        StringTextComponent option = new StringTextComponent(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);
-                        if(i < 15)
-                        {
-                            text.getSiblings().add(new StringTextComponent(", "));
-                        }
-                    }
-
-                    text.getSiblings().add(new StringTextComponent(" (or use command \"/tbm-edit edit defenseDamage <integer>\")"));
-
-                    prefix.getSiblings().add(text);
-                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
-                    break;
-                }
-                case EDIT_DEFENSE_DAMAGE_PROBABILITY:
-                {
-                    StringTextComponent prefix = new StringTextComponent("TBM: ");
-                    prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
-                    StringTextComponent text = new StringTextComponent("defenseDamageProbability: ");
-                    text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
-
-                    for(int i = 0; i <= 100; i += 10)
-                    {
-                        StringTextComponent option = new StringTextComponent(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);
-                        if(i < 100)
-                        {
-                            text.getSiblings().add(new StringTextComponent(", "));
-                        }
-                    }
-
-                    text.getSiblings().add(new StringTextComponent(" (or use command \"/tbm-edit edit defenseDamageProbability <percentage-integer>\")"));
-
-                    prefix.getSiblings().add(text);
-                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
-                    break;
-                }
-                case EDIT_EVASION:
-                {
-                    StringTextComponent prefix = new StringTextComponent("TBM: ");
-                    prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
-                    StringTextComponent text = new StringTextComponent("evasion: ");
-                    text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
-
-                    for(int i = 0; i <= 100; i += 10)
-                    {
-                        StringTextComponent option = new StringTextComponent(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);
-                        if(i < 100)
-                        {
-                            text.getSiblings().add(new StringTextComponent(", "));
-                        }
-                    }
-
-                    text.getSiblings().add(new StringTextComponent(" (or use command \"/tbm-edit edit evasion <percentage-integer>\")"));
-
-                    prefix.getSiblings().add(text);
-                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
-                    break;
-                }
-                case EDIT_SPEED:
-                {
-                    StringTextComponent prefix = new StringTextComponent("TBM: ");
-                    prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
-                    StringTextComponent text = new StringTextComponent("speed: ");
-                    text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
-
-                    for(int i = 0; i <= 100; i += 10)
-                    {
-                        StringTextComponent option = new StringTextComponent(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);
-                        if(i < 100)
-                        {
-                            text.getSiblings().add(new StringTextComponent(", "));
-                        }
-                    }
-
-                    text.getSiblings().add(new StringTextComponent(" (or use command \"/tbm-edit edit speed <integer>\")"));
-
-                    prefix.getSiblings().add(text);
-                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
-                    break;
-                }
-                case EDIT_CATEGORY:
-                {
-                    StringTextComponent prefix = new StringTextComponent("TBM: ");
-                    prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
-                    StringTextComponent text = new StringTextComponent("category: ");
-                    text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
-
-                    StringTextComponent option = new StringTextComponent("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"))
-                    {
-                        StringTextComponent optionInfo = new StringTextComponent("(battle-");
-                        optionInfo.setStyle(optionInfo.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                        StringTextComponent optionInfoBool = new StringTextComponent("disabled");
-                        optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(Color.fromRgb(0xFFFF0000)));
-                        optionInfo.getSiblings().add(optionInfoBool);
-                        optionInfo.getSiblings().add(new StringTextComponent(")"));
-                        option.getSiblings().add(optionInfo);
-                    }
-                    else
-                    {
-                        StringTextComponent optionInfo = new StringTextComponent("(battle-");
-                        optionInfo.setStyle(optionInfo.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                        StringTextComponent optionInfoBool = new StringTextComponent("enabled");
-                        optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(Color.fromRgb(0xFF00FF00)));
-                        optionInfo.getSiblings().add(optionInfoBool);
-                        optionInfo.getSiblings().add(new StringTextComponent(")"));
-                        option.getSiblings().add(optionInfo);
-                    }
-                    text.getSiblings().add(option);
-                    text.getSiblings().add(new StringTextComponent(", "));
-
-                    option = new StringTextComponent("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"))
-                    {
-                        StringTextComponent optionInfo = new StringTextComponent("(battle-");
-                        optionInfo.setStyle(optionInfo.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                        StringTextComponent optionInfoBool = new StringTextComponent("disabled");
-                        optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(Color.fromRgb(0xFFFF0000)));
-                        optionInfo.getSiblings().add(optionInfoBool);
-                        optionInfo.getSiblings().add(new StringTextComponent(")"));
-                        option.getSiblings().add(optionInfo);
-                    }
-                    else
-                    {
-                        StringTextComponent optionInfo = new StringTextComponent("(battle-");
-                        optionInfo.setStyle(optionInfo.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                        StringTextComponent optionInfoBool = new StringTextComponent("enabled");
-                        optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(Color.fromRgb(0xFF00FF00)));
-                        optionInfo.getSiblings().add(optionInfoBool);
-                        optionInfo.getSiblings().add(new StringTextComponent(")"));
-                        option.getSiblings().add(optionInfo);
-                    }
-                    text.getSiblings().add(option);
-                    text.getSiblings().add(new StringTextComponent(", "));
-
-                    option = new StringTextComponent("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"))
-                    {
-                        StringTextComponent optionInfo = new StringTextComponent("(battle-");
-                        optionInfo.setStyle(optionInfo.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                        StringTextComponent optionInfoBool = new StringTextComponent("disabled");
-                        optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(Color.fromRgb(0xFFFF0000)));
-                        optionInfo.getSiblings().add(optionInfoBool);
-                        optionInfo.getSiblings().add(new StringTextComponent(")"));
-                        option.getSiblings().add(optionInfo);
-                    }
-                    else
-                    {
-                        StringTextComponent optionInfo = new StringTextComponent("(battle-");
-                        optionInfo.setStyle(optionInfo.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                        StringTextComponent optionInfoBool = new StringTextComponent("enabled");
-                        optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(Color.fromRgb(0xFF00FF00)));
-                        optionInfo.getSiblings().add(optionInfoBool);
-                        optionInfo.getSiblings().add(new StringTextComponent(")"));
-                        option.getSiblings().add(optionInfo);
-                    }
-                    text.getSiblings().add(option);
-                    text.getSiblings().add(new StringTextComponent(", "));
-
-                    option = new StringTextComponent("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"))
-                    {
-                        StringTextComponent optionInfo = new StringTextComponent("(battle-");
-                        optionInfo.setStyle(optionInfo.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                        StringTextComponent optionInfoBool = new StringTextComponent("disabled");
-                        optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(Color.fromRgb(0xFFFF0000)));
-                        optionInfo.getSiblings().add(optionInfoBool);
-                        optionInfo.getSiblings().add(new StringTextComponent(")"));
-                        option.getSiblings().add(optionInfo);
-                    }
-                    else
-                    {
-                        StringTextComponent optionInfo = new StringTextComponent("(battle-");
-                        optionInfo.setStyle(optionInfo.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                        StringTextComponent optionInfoBool = new StringTextComponent("enabled");
-                        optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(Color.fromRgb(0xFF00FF00)));
-                        optionInfo.getSiblings().add(optionInfoBool);
-                        optionInfo.getSiblings().add(new StringTextComponent(")"));
-                        option.getSiblings().add(optionInfo);
-                    }
-                    text.getSiblings().add(option);
-                    text.getSiblings().add(new StringTextComponent(", "));
-
-                    option = new StringTextComponent("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"))
-                    {
-                        StringTextComponent optionInfo = new StringTextComponent("(battle-");
-                        optionInfo.setStyle(optionInfo.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                        StringTextComponent optionInfoBool = new StringTextComponent("disabled");
-                        optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(Color.fromRgb(0xFFFF0000)));
-                        optionInfo.getSiblings().add(optionInfoBool);
-                        optionInfo.getSiblings().add(new StringTextComponent(")"));
-                        option.getSiblings().add(optionInfo);
-                    }
-                    else
-                    {
-                        StringTextComponent optionInfo = new StringTextComponent("(battle-");
-                        optionInfo.setStyle(optionInfo.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)));
-                        StringTextComponent optionInfoBool = new StringTextComponent("enabled");
-                        optionInfoBool.setStyle(optionInfoBool.getStyle().withColor(Color.fromRgb(0xFF00FF00)));
-                        optionInfo.getSiblings().add(optionInfoBool);
-                        optionInfo.getSiblings().add(new StringTextComponent(")"));
-                        option.getSiblings().add(optionInfo);
-                    }
-                    text.getSiblings().add(option);
-
-                    text.getSiblings().add(new StringTextComponent(" (or use command \"/tbm-edit edit category <string>\")"));
-
-                    prefix.getSiblings().add(text);
-                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
-                    break;
-                }
-                case EDIT_DECISION_ATTACK:
-                {
-                    StringTextComponent prefix = new StringTextComponent("TBM: ");
-                    prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
-                    StringTextComponent text = new StringTextComponent("decisionAttack: ");
-                    text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
-
-                    for(int i = 0; i <= 100; i += 10)
-                    {
-                        StringTextComponent option = new StringTextComponent(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);
-                        if(i < 100)
-                        {
-                            text.getSiblings().add(new StringTextComponent(", "));
-                        }
-                    }
-
-                    prefix.getSiblings().add(text);
-                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
-                    break;
-                }
-                case EDIT_DECISION_DEFEND:
-                {
-                    StringTextComponent prefix = new StringTextComponent("TBM: ");
-                    prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
-                    StringTextComponent text = new StringTextComponent("decisionDefend: ");
-                    text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
-
-                    for(int i = 0; i <= 100; i += 10)
-                    {
-                        StringTextComponent option = new StringTextComponent(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);
-                        if(i < 100)
-                        {
-                            text.getSiblings().add(new StringTextComponent(", "));
-                        }
-                    }
-
-                    prefix.getSiblings().add(text);
-                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
-                    break;
-                }
-                case EDIT_DECISION_FLEE:
-                {
-                    StringTextComponent prefix = new StringTextComponent("TBM: ");
-                    prefix.setStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
-                    StringTextComponent text = new StringTextComponent("decisionFlee: ");
-                    text.setStyle(text.getStyle().withColor(Color.fromRgb(0xFFFFFFFF)).withBold(false));
-
-                    for(int i = 0; i <= 100; i += 10)
-                    {
-                        StringTextComponent option = new StringTextComponent(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);
-                        if(i < 100)
-                        {
-                            text.getSiblings().add(new StringTextComponent(", "));
-                        }
-                    }
-
-                    prefix.getSiblings().add(text);
-                    TurnBasedMinecraftMod.proxy.displayTextComponent(prefix);
-                    break;
-                }
-                default:
-                    break;
-                }
-               });
-               ctx.get().setPacketHandled(true);
-       }
+    public static void handle(final PacketEditingMessage pkt, Supplier<NetworkEvent.Context> ctx) {
+        ctx.get().enqueueWork(() -> {
+            DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
+        });
+        ctx.get().setPacketHandled(true);
     }
 }
index a14392c5c3abeca6e3adf8f4c7c8c3ff40d6a259..374a6b333cd3380d0292b5663c45ee30f1f8ee42 100644 (file)
@@ -4,12 +4,18 @@ import java.util.function.Supplier;
 
 import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
 
-import net.minecraft.network.PacketBuffer;
-import net.minecraftforge.fml.network.NetworkEvent;
+import net.minecraft.network.FriendlyByteBuf;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.fml.DistExecutor;
+import net.minecraftforge.network.NetworkEvent;
 
 public class PacketGeneralMessage
 {
     String message;
+
+    public String getMessage() {
+        return message;
+    }
     
     public PacketGeneralMessage()
     {
@@ -21,20 +27,18 @@ public class PacketGeneralMessage
         this.message = message;
     }
     
-    public static void encode(PacketGeneralMessage pkt, PacketBuffer buf) {
+    public static void encode(PacketGeneralMessage pkt, FriendlyByteBuf buf) {
        buf.writeUtf(pkt.message);
     }
     
-    public static PacketGeneralMessage decode(PacketBuffer buf) {
+    public static PacketGeneralMessage decode(FriendlyByteBuf buf) {
        return new PacketGeneralMessage(buf.readUtf());
     }
     
-    public static class Handler {
-       public static void handle(final PacketGeneralMessage pkt, Supplier<NetworkEvent.Context> ctx) {
-               ctx.get().enqueueWork(() -> {
-                       TurnBasedMinecraftMod.proxy.displayString(pkt.message);
-               });
-               ctx.get().setPacketHandled(true);
-       }
+    public static void handle(final PacketGeneralMessage pkt, Supplier<NetworkEvent.Context> ctx) {
+        ctx.get().enqueueWork(() -> {
+            DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
+        });
+        ctx.get().setPacketHandled(true);
     }
 }
index 99b8c7816fdbbed62a9f235a0c3f59a33b9c1c22..55cd4579b34f0a585d07ff5c0e0bc414d2c7cebe 100644 (file)
@@ -6,7 +6,7 @@
 # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
 modLoader="javafml" #mandatory
 # A version range to match for said mod loader - for regular FML @Mod it will be the forge version
-loaderVersion="[34,)" #mandatory (34 is current forge version)
+loaderVersion="[40,)" #mandatory (34 is current forge version)
 # A URL to refer people to when problems occur with this mod
 issueTrackerURL="https://github.com/Stephen-Seo/TurnBasedMinecraftMod/issues" #optional
 license="MIT"
@@ -15,7 +15,7 @@ license="MIT"
 # The modid of the mod
 modId="com_burnedkirby_turnbasedminecraft" #mandatory
 # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
-version="1.17.2" #mandatory
+version="1.18.0" #mandatory
  # A display name for the mod
 displayName="TurnBasedMinecraftMod" #mandatory
 # 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
     mandatory=true #mandatory
     # The version range of the dependency
-    versionRange="[36,)" #mandatory
+    versionRange="[40,)" #mandatory
     # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
     ordering="NONE"
     # Side this dependency is applied on - BOTH, CLIENT or SERVER
@@ -48,6 +48,6 @@ Implements turn-based-battle in Minecraft.
 [[dependencies.com_burnedkirby_turnbasedminecraft]]
     modId="minecraft"
     mandatory=true
-    versionRange="[1.16.5,1.17)"
+    versionRange="[1.18.2,1.19)"
     ordering="NONE"
     side="BOTH"
index 686f3a824b42ee2d3f5f7e1a55ec29da16151553..b5823aa4594d94b23820046127d5ec781d7568bf 100644 (file)
@@ -1,6 +1,6 @@
 # Please do not change this option, the mod uses this to keep track of what new
 # changes to add to the config.
-version = 6
+version = 7
 do_not_overwrite = false
 
 [client_config]
@@ -98,7 +98,7 @@ creeper_always_allow_damage = true
 # decision_flee_probability: Percentage of entity choosing to flee on turn.
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.BlazeEntity"
+name = "net.minecraft.world.entity.monster.Blaze"
 attack_power = 5
 attack_probability = 50
 attack_effect = "fire"
@@ -111,7 +111,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.CaveSpiderEntity"
+name = "net.minecraft.world.entity.monster.CaveSpider"
 attack_power = 2
 attack_probability = 75
 attack_effect = "poison"
@@ -124,7 +124,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.CreeperEntity"
+name = "net.minecraft.world.entity.monster.Creeper"
 ignore_battle = false
 attack_power = 13
 attack_probability = 95
@@ -137,7 +137,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.DrownedEntity"
+name = "net.minecraft.world.entity.monster.Drowned"
 attack_power = 3
 attack_probability = 70
 attack_variance = 2
@@ -149,7 +149,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.ElderGuardianEntity"
+name = "net.minecraft.world.entity.monster.ElderGuardian"
 attack_power = 8
 attack_probability = 65
 defense_damage = 2
@@ -162,7 +162,7 @@ decision_defend_probability = 20
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.EndermanEntity"
+name = "net.minecraft.world.entity.monster.EnderMan"
 attack_power = 7
 attack_probability = 80
 evasion = 40
@@ -173,7 +173,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.EndermiteEntity"
+name = "net.minecraft.world.entity.monster.Endermite"
 attack_power = 2
 attack_probability = 80
 evasion = 40
@@ -184,7 +184,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.EvokerEntity"
+name = "net.minecraft.world.entity.monster.Evoker"
 attack_power = 6
 attack_probability = 60
 evasion = 35
@@ -195,7 +195,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.GhastEntity"
+name = "net.minecraft.world.entity.monster.Ghast"
 ignore_battle = true
 attack_power = 13
 attack_probability = 20
@@ -207,7 +207,7 @@ decision_defend_probability = 0
 decision_flee_probability = 25
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.GiantEntity"
+name = "net.minecraft.world.entity.monster.Giant"
 attack_power = 11
 attack_probability = 35
 evasion = 2
@@ -218,7 +218,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.GuardianEntity"
+name = "net.minecraft.world.entity.monster.Guardian"
 attack_power = 6
 attack_probability = 55
 defense_damage = 2
@@ -231,7 +231,7 @@ decision_defend_probability = 20
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.HoglinEntity"
+name = "net.minecraft.world.entity.monster.hoglin.Hoglin"
 attack_power = 6
 attack_variance = 2
 attack_probability = 60
@@ -243,7 +243,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.HuskEntity"
+name = "net.minecraft.world.entity.monster.Husk"
 attack_power = 3
 attack_probability = 70
 attack_effect = "hunger"
@@ -256,7 +256,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.IllusionerEntity"
+name = "net.minecraft.world.entity.monster.Illusioner"
 attack_power = 2
 attack_probability = 70
 attack_variance = 2
@@ -268,7 +268,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.IronGolemEntity"
+name = "net.minecraft.world.entity.animal.IronGolem"
 attack_power = 14
 attack_probability = 85
 attack_variance = 7
@@ -280,7 +280,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.MagmaCubeEntity"
+name = "net.minecraft.world.entity.monster.MagmaCube"
 attack_power = 3
 attack_probability = 35
 evasion = 12
@@ -291,7 +291,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.piglin.PiglinEntity"
+name = "net.minecraft.world.entity.monster.piglin.Piglin"
 attack_power = 5
 attack_variance = 2
 attack_probability = 70
@@ -303,7 +303,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.piglin.PiglinBruteEntity"
+name = "net.minecraft.world.entity.monster.piglin.PiglinBrute"
 attack_power = 10
 attack_variance = 2
 attack_probability = 75
@@ -315,7 +315,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.PhantomEntity"
+name = "net.minecraft.world.entity.monster.Phantom"
 attack_power = 2
 attack_probability = 90
 attack_variance = 1
@@ -327,7 +327,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.PillagerEntity"
+name = "net.minecraft.world.entity.monster.Pillager"
 attack_power = 3
 attack_probability = 60
 attack_variance = 1
@@ -339,7 +339,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.RavagerEntity"
+name = "net.minecraft.world.entity.monster.Ravager"
 attack_power = 12
 attack_probability = 70
 attack_variance = 4
@@ -351,7 +351,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.ShulkerEntity"
+name = "net.minecraft.world.entity.monster.Shulker"
 attack_power = 4
 attack_probability = 80
 evasion = 15
@@ -362,7 +362,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.SilverfishEntity"
+name = "net.minecraft.world.entity.monster.Silverfish"
 attack_power = 1
 attack_probability = 85
 evasion = 37
@@ -373,7 +373,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.SkeletonEntity"
+name = "net.minecraft.world.entity.monster.Skeleton"
 attack_power = 3
 attack_probability = 75
 attack_variance = 1
@@ -385,7 +385,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.SlimeEntity"
+name = "net.minecraft.world.entity.monster.Slime"
 attack_power = 2
 attack_probability = 35
 evasion = 10
@@ -396,7 +396,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.SpiderEntity"
+name = "net.minecraft.world.entity.monster.Spider"
 attack_power = 2
 attack_probability = 70
 evasion = 25
@@ -407,7 +407,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.StrayEntity"
+name = "net.minecraft.world.entity.monster.Stray"
 attack_power = 3
 attack_probability = 75
 attack_variance = 1
@@ -421,7 +421,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.VexEntity"
+name = "net.minecraft.world.entity.monster.Vex"
 attack_power = 9
 attack_probability = 65
 evasion = 30
@@ -432,7 +432,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.VindicatorEntity"
+name = "net.minecraft.world.entity.monster.Vindicator"
 attack_power = 13
 attack_probability = 70
 evasion = 10
@@ -443,7 +443,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.WitchEntity"
+name = "net.minecraft.world.entity.monster.Witch"
 attack_power = 5
 attack_probability = 75
 attack_variance = 1
@@ -455,7 +455,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.WitherSkeletonEntity"
+name = "net.minecraft.world.entity.monster.WitherSkeleton"
 attack_power = 8
 attack_probability = 70
 attack_effect = "wither"
@@ -468,7 +468,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.ZoglinEntity"
+name = "net.minecraft.world.entity.monster.Zoglin"
 attack_power = 6
 attack_variance = 2
 attack_probability = 60
@@ -480,7 +480,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.ZombieEntity"
+name = "net.minecraft.world.entity.monster.Zombie"
 attack_power = 3
 attack_probability = 70
 evasion = 5
@@ -491,7 +491,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.ZombifiedPiglinEntity"
+name = "net.minecraft.world.entity.monster.ZombifiedPiglin"
 attack_power = 8
 attack_probability = 70
 evasion = 10
@@ -502,7 +502,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.monster.ZombieVillagerEntity"
+name = "net.minecraft.world.entity.monster.ZombieVillager"
 attack_power = 3
 attack_probability = 70
 evasion = 5
@@ -513,7 +513,18 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.BatEntity"
+name = "net.minecraft.world.entity.animal.axolotl.Axolotl"
+attack_power = 2
+attack_probability = 70
+evasion = 25
+category = "passive"
+speed = 65
+decision_attack_probability = 70
+decision_defend_probability = 20
+decision_flee_probability = 10
+
+[[server_config.entity]]
+name = "net.minecraft.world.entity.ambient.Bat"
 attack_power = 0
 attack_probability = 70
 evasion = 35
@@ -524,7 +535,7 @@ decision_defend_probability = 0
 decision_flee_probability = 90
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.BeeEntity"
+name = "net.minecraft.world.entity.animal.Bee"
 attack_power = 2
 attack_probability = 65
 evasion = 30
@@ -537,7 +548,19 @@ attack_effect = "poison"
 attack_effect_probability = 50
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.ChickenEntity"
+name = "net.minecraft.world.entity.animal.Cat"
+attack_power = 1
+attack_probability = 70
+attack_variance = 1
+evasion = 30
+category = "passive"
+speed = 75
+decision_attack_probability = 0
+decision_defend_probability = 0
+decision_flee_probability = 90
+
+[[server_config.entity]]
+name = "net.minecraft.world.entity.animal.Chicken"
 attack_power = 0
 attack_probability = 70
 evasion = 10
@@ -548,7 +571,7 @@ decision_defend_probability = 0
 decision_flee_probability = 90
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.CowEntity"
+name = "net.minecraft.world.entity.animal.Cow"
 attack_power = 0
 attack_probability = 50
 evasion = 1
@@ -559,7 +582,7 @@ decision_defend_probability = 10
 decision_flee_probability = 80
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.DolphinEntity"
+name = "net.minecraft.world.entity.animal.Dolphin"
 attack_power = 3
 attack_probability = 80
 attack_variance = 1
@@ -571,7 +594,7 @@ decision_defend_probability = 0
 decision_flee_probability = 30
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.FoxEntity"
+name = "net.minecraft.world.entity.animal.Fox"
 attack_power = 2
 attack_probability = 70
 evasion = 65
@@ -582,7 +605,7 @@ decision_defend_probability = 0
 decision_flee_probability = 25
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.horse.DonkeyEntity"
+name = "net.minecraft.world.entity.animal.horse.Donkey"
 attack_power = 0
 attack_probability = 70
 evasion = 10
@@ -593,7 +616,7 @@ decision_defend_probability = 0
 decision_flee_probability = 90
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.horse.HorseEntity"
+name = "net.minecraft.world.entity.animal.horse.Horse"
 attack_power = 0
 attack_probability = 70
 evasion = 10
@@ -604,7 +627,18 @@ decision_defend_probability = 0
 decision_flee_probability = 90
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.horse.LlamaEntity"
+name = "net.minecraft.world.entity.animal.goat.Goat"
+attack_power = 2
+attack_probability = 70
+evasion = 30
+category = "passive"
+speed = 60
+decision_attack_probability = 75
+decision_defend_probability = 20
+decision_flee_probability = 5
+
+[[server_config.entity]]
+name = "net.minecraft.world.entity.animal.horse.Llama"
 attack_power = 1
 attack_probability = 70
 evasion = 10
@@ -615,7 +649,7 @@ decision_defend_probability = 0
 decision_flee_probability = 25
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.MooshroomEntity"
+name = "net.minecraft.world.entity.animal.MushroomCow"
 attack_power = 0
 attack_probability = 70
 evasion = 1
@@ -626,7 +660,7 @@ decision_defend_probability = 10
 decision_flee_probability = 80
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.horse.MuleEntity"
+name = "net.minecraft.world.entity.animal.horse.Mule"
 attack_power = 0
 attack_probability = 70
 evasion = 10
@@ -637,7 +671,7 @@ decision_defend_probability = 0
 decision_flee_probability = 90
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.OcelotEntity"
+name = "net.minecraft.world.entity.animal.Ocelot"
 attack_power = 1
 attack_probability = 70
 attack_variance = 1
@@ -649,7 +683,7 @@ decision_defend_probability = 0
 decision_flee_probability = 90
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.PandaEntity"
+name = "net.minecraft.world.entity.animal.Panda"
 attack_power = 6
 attack_probability = 60
 evasion = 10
@@ -660,7 +694,7 @@ decision_defend_probability = 25
 decision_flee_probability = 30
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.ParrotEntity"
+name = "net.minecraft.world.entity.animal.Parrot"
 attack_power = 0
 attack_probability = 70
 evasion = 35
@@ -671,7 +705,7 @@ decision_defend_probability = 0
 decision_flee_probability = 90
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.PigEntity"
+name = "net.minecraft.world.entity.animal.Pig"
 attack_power = 0
 attack_probability = 70
 evasion = 10
@@ -682,7 +716,7 @@ decision_defend_probability = 5
 decision_flee_probability = 85
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.PolarBearEntity"
+name = "net.minecraft.world.entity.animal.PolarBear"
 attack_power = 6
 attack_probability = 67
 evasion = 5
@@ -693,7 +727,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.RabbitEntity"
+name = "net.minecraft.world.entity.animal.Rabbit"
 attack_power = 0
 attack_probability = 70
 evasion = 40
@@ -704,7 +738,7 @@ decision_defend_probability = 0
 decision_flee_probability = 100
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.SheepEntity"
+name = "net.minecraft.world.entity.animal.Sheep"
 attack_power = 0
 attack_probability = 70
 evasion = 5
@@ -715,7 +749,7 @@ decision_defend_probability = 0
 decision_flee_probability = 90
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.horse.SkeletonHorseEntity"
+name = "net.minecraft.world.entity.animal.horse.SkeletonHorse"
 attack_power = 0
 attack_probability = 70
 evasion = 5
@@ -726,7 +760,7 @@ decision_defend_probability = 0
 decision_flee_probability = 90
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.SnowGolemEntity"
+name = "net.minecraft.world.entity.animal.SnowGolem"
 attack_power = 0
 attack_probability = 80
 evasion = 5
@@ -737,7 +771,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.SquidEntity"
+name = "net.minecraft.world.entity.animal.Squid"
 attack_power = 0
 attack_probability = 70
 evasion = 15
@@ -748,7 +782,7 @@ decision_defend_probability = 0
 decision_flee_probability = 90
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.horse.TraderLlamaEntity"
+name = "net.minecraft.world.entity.animal.horse.TraderLlama"
 attack_power = 1
 attack_probability = 70
 evasion = 10
@@ -759,7 +793,7 @@ decision_defend_probability = 0
 decision_flee_probability = 25
 
 [[server_config.entity]]
-name = "net.minecraft.entity.merchant.villager.VillagerEntity"
+name = "net.minecraft.world.entity.npc.Villager"
 attack_power = 0
 attack_probability = 70
 evasion = 5
@@ -770,7 +804,7 @@ decision_defend_probability = 10
 decision_flee_probability = 80
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.WolfEntity"
+name = "net.minecraft.world.entity.animal.Wolf"
 attack_power = 4
 attack_probability = 70
 evasion = 20
@@ -781,7 +815,7 @@ decision_defend_probability = 15
 decision_flee_probability = 5
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.horse.ZombieHorseEntity"
+name = "net.minecraft.world.entity.animal.horse.ZombieHorse"
 attack_power = 0
 attack_probability = 70
 evasion = 8
@@ -792,7 +826,7 @@ decision_defend_probability = 0
 decision_flee_probability = 90
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.fish.CodEntity"
+name = "net.minecraft.world.entity.animal.Cod"
 attack_power = 0
 attack_probability = 50
 evasion = 50
@@ -803,7 +837,7 @@ decision_defend_probability = 0
 decision_flee_probability = 75
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.fish.PufferfishEntity"
+name = "net.minecraft.world.entity.animal.Pufferfish"
 attack_power = 0
 attack_probability = 50
 defense_damage = 3
@@ -816,7 +850,7 @@ decision_defend_probability = 0
 decision_flee_probability = 65
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.fish.SalmonEntity"
+name = "net.minecraft.world.entity.animal.Salmon"
 attack_power = 0
 attack_probability = 50
 evasion = 50
@@ -827,7 +861,7 @@ decision_defend_probability = 0
 decision_flee_probability = 75
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.StriderEntity"
+name = "net.minecraft.world.entity.monster.Strider"
 attack_power = 0
 attack_probability = 50
 evasion = 35
@@ -838,7 +872,7 @@ decision_defend_probability = 10
 decision_flee_probability = 90
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.fish.TropicalFishEntity"
+name = "net.minecraft.world.entity.animal.TropicalFish"
 attack_power = 0
 attack_probability = 50
 evasion = 50
@@ -849,7 +883,7 @@ decision_defend_probability = 0
 decision_flee_probability = 75
 
 [[server_config.entity]]
-name = "net.minecraft.entity.passive.TurtleEntity"
+name = "net.minecraft.world.entity.animal.Turtle"
 attack_power = 0
 attack_probability = 20
 evasion = 35
@@ -860,7 +894,7 @@ decision_defend_probability = 40
 decision_flee_probability = 60
 
 [[server_config.entity]]
-name = "net.minecraft.entity.merchant.villager.WanderingTraderEntity"
+name = "net.minecraft.world.entity.npc.WanderingTrader"
 attack_power = 0
 attack_probability = 70
 evasion = 5
@@ -871,7 +905,7 @@ decision_defend_probability = 10
 decision_flee_probability = 80
 
 [[server_config.entity]]
-name = "net.minecraft.entity.boss.dragon.EnderDragonEntity"
+name = "net.minecraft.world.entity.boss.enderdragon.EnderDragon"
 attack_power = 10
 attack_probability = 70
 attack_variance = 2
@@ -883,7 +917,7 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 
 [[server_config.entity]]
-name = "net.minecraft.entity.boss.WitherEntity"
+name = "net.minecraft.world.entity.boss.wither.WitherBoss"
 attack_power = 8
 attack_probability = 70
 attack_effect = "wither"
index b61db108df121d8a0a45987d6cb003f957459652..14779bf78566707b639f24838dff17b0b17dce0f 100644 (file)
@@ -3,8 +3,8 @@
   "modid": "com_burnedkirby_turnbasedminecraft",
   "name": "Turn Based Minecraft",
   "description": "Changes battles to be turn-based.",
-  "version": "1.17.2",
-  "mcversion": "1.16.3",
+  "version": "1.18.0",
+  "mcversion": "1.18.2",
   "url": "",
   "updateUrl": "",
   "authorList": ["Stephen Seo"],