Update for forge-1.18.2-40.1.0 (mod ver 1.18.0)

This commit is contained in:
Stephen Seo 2022-05-17 14:47:42 +09:00
parent 4306072329
commit bc080b2f6f
34 changed files with 2086 additions and 2029 deletions

View file

@ -1,5 +1,10 @@
# Upcoming changes # 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 # Version 1.17.2
(try to) Fix potential freeze bug when an entity leaves battle. (try to) Fix potential freeze bug when an entity leaves battle.

View file

@ -57,7 +57,7 @@ configured for them.)
# Building # Building
Simply invoke `./gradlew build` in the mod directory and after some time the 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 # Other notes

View file

@ -1,169 +1,223 @@
buildscript { buildscript {
repositories { repositories {
maven { url = "https://files.minecraftforge.net/maven" } maven { url = "https://maven.minecraftforge.net" }
jcenter() jcenter()
mavenCentral() mavenCentral()
} gradlePluginPortal()
dependencies { }
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' 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: 'net.minecraftforge.gradle'
//apply plugin: 'maven-publish' //apply plugin: 'eclipse'
apply plugin: 'com.github.johnrengelman.shadow' //apply plugin: 'maven-publish'
version = "1.17.2" version = "1.18.0"
group = "com.burnedkirby.TurnBasedMinecraft" group = "com.burnedkirby.TurnBasedMinecraft"
archivesBaseName = "TurnBasedMinecraft" archivesBaseName = "TurnBasedMinecraft"
java.toolchain.languageVersion = JavaLanguageVersion.of(8) 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')) println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
minecraft { minecraft {
// The mappings can be changed at any time, and must be in the following format. // The mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD Snapshot are built nightly. // snapshot_YYYYMMDD Snapshot are built nightly.
// stable_# Stables are built at the discretion of the MCP team. // stable_# Stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work. // Use non-default mappings at your own risk. they may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace. // Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'official', version: '1.16.5' mappings channel: 'official', version: '1.18.2'
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
// Default run configurations. // Default run configurations.
// These can be tweaked, removed, or duplicated as needed. // These can be tweaked, removed, or duplicated as needed.
runs { runs {
client { client {
workingDirectory project.file('run') workingDirectory project.file('run')
// Recommended logging data for a userdev environment // Recommended logging data for a userdev environment
property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.markers', 'REGISTRIES'
// Recommended logging level for the console // Recommended logging level for the console
property 'forge.logging.console.level', 'debug' property 'forge.logging.console.level', 'debug'
mods { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
TurnBasedMinecraftMod { property 'forge.enabledGameTestNamespaces', 'TurnBasedMinecraftMod'
source sourceSets.main
} mods {
} TurnBasedMinecraftMod {
} source sourceSets.main
}
server { }
workingDirectory project.file('run') }
// Recommended logging data for a userdev environment server {
property 'forge.logging.markers', 'REGISTRIES' workingDirectory project.file('run')
// Recommended logging level for the console // Recommended logging data for a userdev environment
property 'forge.logging.console.level', 'debug' property 'forge.logging.markers', 'REGISTRIES'
mods { // Recommended logging level for the console
TurnBasedMinecraftMod { property 'forge.logging.console.level', 'debug'
source sourceSets.main
} // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
} property 'forge.enabledGameTestNamespaces', 'TurnBasedMinecraftMod'
}
mods {
data { TurnBasedMinecraftMod {
workingDirectory project.file('run') source sourceSets.main
}
// Recommended logging data for a userdev environment }
property 'forge.logging.markers', 'REGISTRIES' }
// Recommended logging level for the console // This run config launches GameTestServer and runs all registered gametests, then exits.
property 'forge.logging.console.level', 'debug' // 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.
args '--mod', 'TurnBasedMinecraftMod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources') gameTestServer {
workingDirectory project.file('run')
mods {
TurnBasedMinecraftMod { // Recommended logging data for a userdev environment
source sourceSets.main // 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
// Include resources generated by data generators. // You can set various levels here.
sourceSets.main.resources { srcDir 'src/generated/resources' } // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
property 'forge.logging.console.level', 'debug'
dependencies {
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied. property 'forge.enabledGameTestNamespaces', 'TurnBasedMinecraftMod'
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft 'net.minecraftforge:forge:1.16.5-36.1.0' mods {
TurnBasedMinecraftMod {
// You may put jars on which you depend on in ./libs or you may define them like so.. source sourceSets.main
// compile "some.group:artifact:version:classifier" }
// compile "some.group:artifact:version" }
}
// Real examples
// compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env data {
// compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env workingDirectory project.file('run')
// The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime. // Recommended logging data for a userdev environment
// provided 'com.mod-buildcraft:buildcraft:6.0.8:dev' property 'forge.logging.markers', 'REGISTRIES'
// These dependencies get remapped to your current MCP mappings // Recommended logging level for the console
// deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev' property 'forge.logging.console.level', 'debug'
// For more info... args '--mod', 'TurnBasedMinecraftMod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources')
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html mods {
TurnBasedMinecraftMod {
compile files('libs/javamp3-1.0.3.jar') source sourceSets.main
}
shadow files('libs/javamp3-1.0.3.jar') }
} }
}
shadowJar { }
project.configurations.shadow.setTransitive(true);
configurations = [project.configurations.shadow] // Include resources generated by data generators.
relocate 'fr.delthas', 'com.burnedkirby.tbm_repack.fr.delthas' sourceSets.main.resources { srcDir 'src/generated/resources' }
classifier '' // replace the default jar
} //repositories {
// // Put repositories for dependencies here
reobf { // // ForgeGradle automatically adds the Forge maven and Maven Central for you
shadowJar {} // reobfuscate the shadowed jar //
} // // If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
// // flatDir {
// Example for how to get properties into the manifest for reading by the runtime.. // // dir 'libs'
jar { // // }
manifest { // mavenCentral()
attributes([ // jcenter()
"Specification-Title": "TurnBasedMinecraftMod", //
"Specification-Vendor": "TurnBasedMinecraftMod_BK", // dependencies {
"Specification-Version": "1", // We are version 1 of ourselves // classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4'
"Implementation-Title": project.name, // }
"Implementation-Version": "${version}", //}
"Implementation-Vendor" :"TurnBasedMinecraftMod_BK",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), apply plugin: 'com.github.johnrengelman.shadow'
// "ContainedDeps": "javamp3-1.0.3.jar"
]) configurations {
} shade
} impelmentation.extendsFrom shade
}
// Example configuration to allow publishing using the maven-publish task
// we define a custom artifact that is sourced from the reobfJar output task dependencies {
// and then declare that to be published // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
// Note you'll need to add a repository here // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
//def reobfFile = file("$buildDir/reobfJar/output.jar") // The userdev artifact is a special name and will get all sorts of transformations applied to it.
//def reobfArtifact = artifacts.add('default', reobfFile) { minecraft 'net.minecraftforge:forge:1.18.2-40.1.0'
// type 'jar'
// builtBy 'reobfJar' // 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
//publishing { // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
// publications { // implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency
// mavenJava(MavenPublication) {
// artifact reobfArtifact // Examples using mod jars from ./libs
// } // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
// }
// repositories { // For more info...
// maven { // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// url "file:///${project.projectDir}/mcmodsrepo" // 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"
// }
// }
//}

1
gradle.properties Normal file
View file

@ -0,0 +1 @@
org.gradle.jvmargs=-Xmx4096m

Binary file not shown.

View file

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

269
gradlew vendored
View file

@ -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"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -17,67 +17,101 @@
# #
############################################################################## ##############################################################################
## #
## 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 # Attempt to set APP_HOME
# Resolve links: $0 may be a link # Resolve links: $0 may be a link
PRG="$0" app_path=$0
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do # Need this for daisy-chained symlinks.
ls=`ls -ld "$PRG"` while
link=`expr "$ls" : '.*-> \(.*\)$'` APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
if expr "$link" : '/.*' > /dev/null; then [ -h "$app_path" ]
PRG="$link" do
else ls=$( ls -ld "$app_path" )
PRG=`dirname "$PRG"`"/$link" link=${ls#*' -> '}
fi case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle" 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. # 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"' DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD=maximum
warn () { warn () {
echo "$*" echo "$*"
} } >&2
die () { die () {
echo echo
echo "$*" echo "$*"
echo echo
exit 1 exit 1
} } >&2
# OS specific support (must be 'true' or 'false'). # OS specific support (must be 'true' or 'false').
cygwin=false cygwin=false
msys=false msys=false
darwin=false darwin=false
nonstop=false nonstop=false
case "`uname`" in case "$( uname )" in #(
CYGWIN* ) CYGWIN* ) cygwin=true ;; #(
cygwin=true Darwin* ) darwin=true ;; #(
;; MSYS* | MINGW* ) msys=true ;; #(
Darwin* ) NONSTOP* ) nonstop=true ;;
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 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 [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables # IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java" JAVACMD=$JAVA_HOME/jre/sh/java
else else
JAVACMD="$JAVA_HOME/bin/java" JAVACMD=$JAVA_HOME/bin/java
fi fi
if [ ! -x "$JAVACMD" ] ; then if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 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." location of your Java installation."
fi fi
else 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. 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 Please set the JAVA_HOME variable in your environment to match the
@ -106,80 +140,95 @@ location of your Java installation."
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
MAX_FD_LIMIT=`ulimit -H -n` case $MAX_FD in #(
if [ $? -eq 0 ] ; then max*)
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then MAX_FD=$( ulimit -H -n ) ||
MAX_FD="$MAX_FD_LIMIT" warn "Could not query maximum file descriptor limit"
fi esac
ulimit -n $MAX_FD case $MAX_FD in #(
if [ $? -ne 0 ] ; then '' | soft) :;; #(
warn "Could not set maximum file descriptor limit: $MAX_FD" *)
fi ulimit -n "$MAX_FD" ||
else warn "Could not set maximum file descriptor limit to $MAX_FD"
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin 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
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac esac
fi fi
# Escape application args # Collect all arguments for the java command, stacking in reverse order:
save () { # * args from the command line
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done # * the main class name
echo " " # * -classpath
} # * -D...appname settings
APP_ARGS=`save "$@"` # * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# Collect all arguments for the java command, following the shell quoting and substitution rules # For Cygwin or MSYS, switch paths to Windows format before running java
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 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
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
# 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
fi
# 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.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@" exec "$JAVACMD" "$@"

View file

@ -1,24 +1,20 @@
package com.burnedkirby.TurnBasedMinecraft.client; 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.Battle;
import com.burnedkirby.TurnBasedMinecraft.common.Combatant; import com.burnedkirby.TurnBasedMinecraft.common.Combatant;
import com.burnedkirby.TurnBasedMinecraft.common.Config; import com.burnedkirby.TurnBasedMinecraft.common.Config;
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod; import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleDecision; import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleDecision;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.widget.button.Button; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.network.chat.TextComponent;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.math.vector.Matrix4f; import java.util.ConcurrentModificationException;
import net.minecraft.util.text.StringTextComponent; import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
public class BattleGui extends Screen { public class BattleGui extends Screen {
private AtomicInteger timeRemaining; private AtomicInteger timeRemaining;
@ -27,7 +23,6 @@ public class BattleGui extends Screen {
private MenuState state; private MenuState state;
private boolean stateChanged; private boolean stateChanged;
private String info; private String info;
private Matrix4f identity;
private enum MenuState { private enum MenuState {
MAIN_MENU(0), ATTACK_TARGET(1), ITEM_ACTION(2), WAITING(3), SWITCH_ITEM(4), USE_ITEM(5); 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() { public BattleGui() {
super(new StringTextComponent("Battle Gui")); super(new TextComponent("Battle Gui"));
timeRemaining = new AtomicInteger((int) (Config.BATTLE_DECISION_DURATION_NANO_DEFAULT / 1000000000L)); timeRemaining = new AtomicInteger((int) (Config.BATTLE_DECISION_DURATION_NANO_DEFAULT / 1000000000L));
lastInstant = System.nanoTime(); lastInstant = System.nanoTime();
elapsedTime = 0; elapsedTime = 0;
state = MenuState.MAIN_MENU; state = MenuState.MAIN_MENU;
stateChanged = true; stateChanged = true;
identity = new Matrix4f();
identity.setIdentity();
} }
private void setState(MenuState state) { private void setState(MenuState state) {
@ -126,21 +119,20 @@ public class BattleGui extends Screen {
} }
stateChanged = false; stateChanged = false;
buttons.clear(); clearWidgets();
children.clear();
switch (state) { switch (state) {
case MAIN_MENU: case MAIN_MENU:
info = "What will you do?"; 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); 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); 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); 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); buttonActionEvent(button, ButtonAction.FLEE);
})); }));
break; break;
@ -151,11 +143,11 @@ public class BattleGui extends Screen {
for (Map.Entry<Integer, Combatant> e : TurnBasedMinecraftMod.proxy.getLocalBattle() for (Map.Entry<Integer, Combatant> e : TurnBasedMinecraftMod.proxy.getLocalBattle()
.getSideAEntrySet()) { .getSideAEntrySet()) {
if (e.getValue().entity != null) { if (e.getValue().entity != null) {
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); buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
})); }));
} else { } 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); buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
})); }));
} }
@ -169,11 +161,11 @@ public class BattleGui extends Screen {
for (Map.Entry<Integer, Combatant> e : TurnBasedMinecraftMod.proxy.getLocalBattle() for (Map.Entry<Integer, Combatant> e : TurnBasedMinecraftMod.proxy.getLocalBattle()
.getSideBEntrySet()) { .getSideBEntrySet()) {
if (e.getValue().entity != null) { if (e.getValue().entity != null) {
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); buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
})); }));
} else { } 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); buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
})); }));
} }
@ -182,19 +174,19 @@ public class BattleGui extends Screen {
} catch (ConcurrentModificationException e) { } catch (ConcurrentModificationException e) {
// ignored // 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); buttonActionEvent(button, ButtonAction.CANCEL);
})); }));
break; break;
case ITEM_ACTION: case ITEM_ACTION:
info = "What will you do with an item?"; info = "What will you do with an item?";
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); 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); 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); buttonActionEvent(button, ButtonAction.CANCEL);
})); }));
break; break;
@ -204,22 +196,22 @@ public class BattleGui extends Screen {
case SWITCH_ITEM: case SWITCH_ITEM:
info = "To which item will you switch to?"; info = "To which item will you switch to?";
for (int i = 0; i < 9; ++i) { for (int i = 0; i < 9; ++i) {
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); 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); buttonActionEvent(button, ButtonAction.CANCEL);
})); }));
break; break;
case USE_ITEM: case USE_ITEM:
info = "Which item will you use?"; info = "Which item will you use?";
for (int i = 0; i < 9; ++i) { for (int i = 0; i < 9; ++i) {
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); 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); buttonActionEvent(button, ButtonAction.CANCEL);
})); }));
break; break;
@ -227,10 +219,10 @@ public class BattleGui extends Screen {
} }
@Override @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) { if (TurnBasedMinecraftMod.proxy.getLocalBattle() == null) {
// drawHoveringText("Waiting...", width / 2 - 50, height / 2); // 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; return;
} }
if (TurnBasedMinecraftMod.proxy.getLocalBattle().getState() == Battle.State.DECISION if (TurnBasedMinecraftMod.proxy.getLocalBattle().getState() == Battle.State.DECISION
@ -246,7 +238,7 @@ public class BattleGui extends Screen {
updateState(); updateState();
super.render(matrixStack, mouseX, mouseY, partialTicks); super.render(poseStack, mouseX, mouseY, partialTicks);
String timeRemainingString = "Time remaining: "; String timeRemainingString = "Time remaining: ";
int timeRemainingInt = timeRemaining.get(); int timeRemainingInt = timeRemaining.get();
@ -259,11 +251,11 @@ public class BattleGui extends Screen {
} }
timeRemainingString += Integer.toString(timeRemainingInt); timeRemainingString += Integer.toString(timeRemainingInt);
int stringWidth = font.width(timeRemainingString); int stringWidth = font.width(timeRemainingString);
fill(matrixStack, width / 2 - stringWidth / 2, 5, width / 2 + stringWidth / 2, 15, 0x70000000); fill(poseStack, width / 2 - stringWidth / 2, 5, width / 2 + stringWidth / 2, 15, 0x70000000);
drawString(matrixStack, timeRemainingString, width / 2 - stringWidth / 2, 5, 0xFFFFFFFF); drawString(poseStack, timeRemainingString, width / 2 - stringWidth / 2, 5, 0xFFFFFFFF);
stringWidth = font.width(info); stringWidth = font.width(info);
fill(matrixStack, width / 2 - stringWidth / 2, 20, width / 2 + stringWidth / 2, 30, 0x70000000); fill(poseStack, width / 2 - stringWidth / 2, 20, width / 2 + stringWidth / 2, 30, 0x70000000);
drawString(matrixStack, info, width / 2 - stringWidth / 2, 20, 0xFFFFFFFF); drawString(poseStack, info, width / 2 - stringWidth / 2, 20, 0xFFFFFFFF);
} }
protected void buttonActionEvent(Button button, ButtonAction action) { protected void buttonActionEvent(Button button, ButtonAction action) {
@ -309,7 +301,7 @@ public class BattleGui extends Screen {
.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), .sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(),
Battle.Decision.SWITCH_ITEM, ((ItemSelectionButton) button).getID())); Battle.Decision.SWITCH_ITEM, ((ItemSelectionButton) button).getID()));
if (((ItemSelectionButton) button).getID() >= 0 && ((ItemSelectionButton) button).getID() < 9) { if (((ItemSelectionButton) button).getID() >= 0 && ((ItemSelectionButton) button).getID() < 9) {
Minecraft.getInstance().player.inventory.selected = ((ItemSelectionButton) button).getID(); Minecraft.getInstance().player.getInventory().selected = ((ItemSelectionButton) button).getID();
} }
setState(MenuState.WAITING); setState(MenuState.WAITING);
} else { } else {
@ -354,7 +346,7 @@ public class BattleGui extends Screen {
timeRemaining.set(remaining); timeRemaining.set(remaining);
} }
private void drawString(MatrixStack matrixStack, String string, int x, int y, int color) { private void drawString(PoseStack poseStack, String string, int x, int y, int color) {
font.draw(matrixStack, string, x, y, color); font.draw(poseStack, string, x, y, color);
} }
} }

View file

@ -1,21 +1,18 @@
package com.burnedkirby.TurnBasedMinecraft.client; package com.burnedkirby.TurnBasedMinecraft.client;
import java.io.*; import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
import java.util.ArrayList; import fr.delthas.javamp3.Sound;
import java.util.concurrent.atomic.AtomicBoolean; import net.minecraft.client.Minecraft;
import org.apache.logging.log4j.Logger;
import javax.sound.midi.MidiChannel; import javax.sound.midi.MidiChannel;
import javax.sound.midi.MidiSystem; import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException; import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Sequencer; import javax.sound.midi.Sequencer;
import javax.sound.sampled.*; import javax.sound.sampled.*;
import java.io.*;
import fr.delthas.javamp3.Sound; import java.util.ArrayList;
import org.apache.logging.log4j.Logger; import java.util.concurrent.atomic.AtomicBoolean;
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
import net.minecraft.client.Minecraft;
public class BattleMusic public class BattleMusic
{ {

View file

@ -2,18 +2,25 @@ package com.burnedkirby.TurnBasedMinecraft.client;
import com.burnedkirby.TurnBasedMinecraft.common.Battle; import com.burnedkirby.TurnBasedMinecraft.common.Battle;
import com.burnedkirby.TurnBasedMinecraft.common.CommonProxy; import com.burnedkirby.TurnBasedMinecraft.common.CommonProxy;
import com.burnedkirby.TurnBasedMinecraft.common.EntityInfo;
import net.minecraft.client.GameSettings; 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.client.Minecraft;
import net.minecraft.entity.Entity; import net.minecraft.client.Options;
import net.minecraft.util.RegistryKey; import net.minecraft.network.chat.ClickEvent;
import net.minecraft.util.SoundCategory; import net.minecraft.network.chat.HoverEvent;
import net.minecraft.util.text.Color; import net.minecraft.network.chat.TextColor;
import net.minecraft.util.text.ITextComponent; import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.text.StringTextComponent; import net.minecraft.resources.ResourceKey;
import net.minecraft.world.World; 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.UUID;
import java.util.function.Supplier;
public class ClientProxy extends CommonProxy public class ClientProxy extends CommonProxy
{ {
@ -93,15 +100,15 @@ public class ClientProxy extends CommonProxy
@Override @Override
public void playBattleMusic() public void playBattleMusic()
{ {
GameSettings gs = Minecraft.getInstance().options; Options gs = Minecraft.getInstance().options;
battleMusic.playBattle(gs.getSoundSourceVolume(SoundCategory.MUSIC) * gs.getSoundSourceVolume(SoundCategory.MASTER)); battleMusic.playBattle(gs.getSoundSourceVolume(SoundSource.MUSIC) * gs.getSoundSourceVolume(SoundSource.MASTER));
} }
@Override @Override
public void playSillyMusic() public void playSillyMusic()
{ {
GameSettings gs = Minecraft.getInstance().options; Options gs = Minecraft.getInstance().options;
battleMusic.playSilly(gs.getSoundSourceVolume(SoundCategory.MUSIC) * gs.getSoundSourceVolume(SoundCategory.MASTER)); battleMusic.playSilly(gs.getSoundSourceVolume(SoundSource.MUSIC) * gs.getSoundSourceVolume(SoundSource.MASTER));
} }
@Override @Override
@ -149,17 +156,17 @@ public class ClientProxy extends CommonProxy
@Override @Override
public void displayString(String message) public void displayString(String message)
{ {
StringTextComponent prefix = new StringTextComponent("TBM: "); TextComponent prefix = new TextComponent("TBM: ");
prefix.withStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true)); prefix.withStyle(prefix.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withBold(true));
StringTextComponent text = new StringTextComponent(message); TextComponent text = new TextComponent(message);
prefix.getSiblings().add(text); 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 // UUID is required by sendMessage, but appears to be unused, so just give dummy UUID
Minecraft.getInstance().player.sendMessage(prefix, UUID.randomUUID()); Minecraft.getInstance().player.sendMessage(prefix, UUID.randomUUID());
} }
@Override @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 // UUID is required by sendMessage, but appears to be unused, so just give dummy UUID
Minecraft.getInstance().player.sendMessage(text, UUID.randomUUID()); Minecraft.getInstance().player.sendMessage(text, UUID.randomUUID());
@ -231,7 +238,783 @@ public class ClientProxy extends CommonProxy
} }
@Override @Override
public Entity getEntity(int id, RegistryKey<World> dim) { public Entity getEntity(int id, ResourceKey<Level> dim) {
return Minecraft.getInstance().level.getEntity(id); 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;
}
}
}
} }

View file

@ -1,18 +1,18 @@
package com.burnedkirby.TurnBasedMinecraft.client; 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.Minecraft;
import net.minecraft.client.gui.widget.button.Button; import net.minecraft.client.gui.components.Button;
import net.minecraft.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.util.text.StringTextComponent; import net.minecraft.network.chat.TextComponent;
public class EntitySelectionButton extends Button { public class EntitySelectionButton extends Button {
private int entityID; private int entityID;
private boolean isSideA; private boolean isSideA;
public EntitySelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int entityID, boolean isSideA, Button.IPressable 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 StringTextComponent(buttonText), onPress); super(x, y, widthIn, heightIn, new TextComponent(buttonText), onPress);
this.entityID = entityID; this.entityID = entityID;
this.isSideA = isSideA; this.isSideA = isSideA;
} }
@ -26,8 +26,8 @@ public class EntitySelectionButton extends Button {
} }
@Override @Override
public void renderButton(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { public void renderButton(PoseStack poseStack, int mouseX, int mouseY, float partialTicks) {
super.renderButton(matrixStack, mouseX, mouseY, partialTicks); super.renderButton(poseStack, mouseX, mouseY, partialTicks);
Entity e = Minecraft.getInstance().level.getEntity(entityID); Entity e = Minecraft.getInstance().level.getEntity(entityID);
if (e != null && e instanceof LivingEntity && ((LivingEntity) e).isAlive()) { if (e != null && e instanceof LivingEntity && ((LivingEntity) e).isAlive()) {
int health = (int) (((LivingEntity) e).getHealth() + 0.5f); int health = (int) (((LivingEntity) e).getHealth() + 0.5f);
@ -41,38 +41,38 @@ public class EntitySelectionButton extends Button {
xoffset = -4; xoffset = -4;
} }
if (health > 200) { if (health > 200) {
fill(matrixStack, xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000); fill(poseStack, 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() * 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() * 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() / 5, xpos + 2, getY() + getHeight() * 2 / 5, 0xFF00FFFF);
fill(matrixStack, xpos, getY(), xpos + 2, getY() + getHeight() / 5, 0xFF0000FF); fill(poseStack, xpos, getY(), xpos + 2, getY() + getHeight() / 5, 0xFF0000FF);
int healthHeight = ((health - 200) * getHeight() / 100); 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) { } else if (health > 100) {
fill(matrixStack, xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000); fill(poseStack, 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() * 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() * 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() / 5, xpos + 2, getY() + getHeight() * 2 / 5, 0xFF00FFFF);
int healthHeight = ((health - 100) * getHeight() / 100); 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) { } else if (health > 50) {
fill(matrixStack, xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000); fill(poseStack, 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() * 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() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
int healthHeight = ((health - 50) * getHeight() / 50); 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) { } else if (health > 20) {
fill(matrixStack, xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000); fill(poseStack, 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() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
int healthHeight = ((health - 20) * getHeight() / 30); 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) { } 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); 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 { } else {
int healthHeight = (health * getHeight() / 10); 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);
} }
} }
} }

View file

@ -1,14 +1,14 @@
package com.burnedkirby.TurnBasedMinecraft.client; package com.burnedkirby.TurnBasedMinecraft.client;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.widget.button.Button; import net.minecraft.client.gui.components.Button;
import net.minecraft.util.text.StringTextComponent; import net.minecraft.network.chat.TextComponent;
public class ItemSelectionButton extends Button { public class ItemSelectionButton extends Button {
private int itemStackID; private int itemStackID;
public ItemSelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int itemStackID, Button.IPressable onPress) { public ItemSelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int itemStackID, Button.OnPress onPress) {
super(x, y, widthIn, heightIn, new StringTextComponent(buttonText), onPress); super(x, y, widthIn, heightIn, new TextComponent(buttonText), onPress);
this.itemStackID = itemStackID; this.itemStackID = itemStackID;
} }
@ -17,13 +17,13 @@ public class ItemSelectionButton extends Button {
} }
@Override @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) { if (visible) {
boolean hovered = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + getWidth() && mouseY < getY() + getHeight(); boolean hovered = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + getWidth() && mouseY < getY() + getHeight();
if (hovered) { if (hovered) {
fill(matrixStack, getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x80FFFFFF); fill(poseStack, getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x80FFFFFF);
} else { } else {
fill(matrixStack, getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x20707070); fill(poseStack, getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x20707070);
} }
} }
} }

View 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.PacketEditingMessage;
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketGeneralMessage; import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketGeneralMessage;
import net.minecraft.entity.monster.CreeperEntity; import net.minecraft.world.entity.monster.Creeper;
import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.event.entity.living.LivingAttackEvent; import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.network.PacketDistributor; import net.minecraftforge.network.PacketDistributor;
public class AttackEventHandler public class AttackEventHandler
{ {
@ -81,7 +81,7 @@ public class AttackEventHandler
if(!event.getEntity().hasCustomName()) if(!event.getEntity().hasCustomName())
{ {
TurnBasedMinecraftMod.logger.error("Cannot edit custom name from entity without custom name"); 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; return;
} }
editingInfo.entityInfo = config.getCustomEntityInfo(event.getEntity().getCustomName().getString()); editingInfo.entityInfo = config.getCustomEntityInfo(event.getEntity().getCustomName().getString());
@ -90,9 +90,9 @@ public class AttackEventHandler
editingInfo.entityInfo = new EntityInfo(); editingInfo.entityInfo = new EntityInfo();
editingInfo.entityInfo.customName = event.getEntity().getCustomName().getString(); editingInfo.entityInfo.customName = event.getEntity().getCustomName().getString();
} }
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity)editingInfo.editor), new PacketGeneralMessage("Editing custom name \"" + event.getEntity().getCustomName().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.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 else
{ {
@ -106,9 +106,9 @@ public class AttackEventHandler
{ {
editingInfo.entityInfo = editingInfo.entityInfo.clone(); 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.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; 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.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); event.setCanceled(false);
} else { } else {
// TurnBasedMinecraftMod.logger.debug("Canceled attack"); // TurnBasedMinecraftMod.logger.debug("Canceled attack");

View file

@ -1,6 +1,6 @@
package com.burnedkirby.TurnBasedMinecraft.common; package com.burnedkirby.TurnBasedMinecraft.common;
import net.minecraft.entity.Entity; import net.minecraft.world.entity.Entity;
public class AttackerViaBow public class AttackerViaBow
{ {

View file

@ -1,24 +1,23 @@
package com.burnedkirby.TurnBasedMinecraft.common; package com.burnedkirby.TurnBasedMinecraft.common;
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 java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleInfo;
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleMessage;
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;
public class Battle public class Battle
{ {
private final int id; private final int id;
@ -44,7 +43,7 @@ public class Battle
public String debugLog; // TODO remove after freeze bug has been found public String debugLog; // TODO remove after freeze bug has been found
private RegistryKey<World> dimension; private ResourceKey<Level> dimension;
public enum State 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.battleManager = battleManager;
this.isServer = isServer; this.isServer = isServer;
@ -147,7 +146,7 @@ public class Battle
entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(e); 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; continue;
} }
@ -155,7 +154,7 @@ public class Battle
newCombatant.isSideA = true; newCombatant.isSideA = true;
newCombatant.battleID = getId(); newCombatant.battleID = getId();
this.sideA.put(e.getId(), newCombatant); this.sideA.put(e.getId(), newCombatant);
if(e instanceof PlayerEntity) if(e instanceof Player)
{ {
newCombatant.recalcSpeedOnCompare = true; newCombatant.recalcSpeedOnCompare = true;
playerCount.incrementAndGet(); playerCount.incrementAndGet();
@ -165,8 +164,8 @@ public class Battle
{ {
newCombatant.x = e.getX(); newCombatant.x = e.getX();
newCombatant.z = e.getZ(); newCombatant.z = e.getZ();
newCombatant.yaw = e.xRot; newCombatant.yaw = e.getXRot();
newCombatant.pitch = e.yRot; newCombatant.pitch = e.getYRot();
} }
} }
} }
@ -185,7 +184,7 @@ public class Battle
entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(e); 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; continue;
} }
@ -193,7 +192,7 @@ public class Battle
newCombatant.isSideA = false; newCombatant.isSideA = false;
newCombatant.battleID = getId(); newCombatant.battleID = getId();
this.sideB.put(e.getId(), newCombatant); this.sideB.put(e.getId(), newCombatant);
if(e instanceof PlayerEntity) if(e instanceof Player)
{ {
newCombatant.recalcSpeedOnCompare = true; newCombatant.recalcSpeedOnCompare = true;
playerCount.incrementAndGet(); playerCount.incrementAndGet();
@ -203,8 +202,8 @@ public class Battle
{ {
newCombatant.x = e.getX(); newCombatant.x = e.getX();
newCombatant.z = e.getZ(); newCombatant.z = e.getZ();
newCombatant.yaw = e.xRot; newCombatant.yaw = e.getXRot();
newCombatant.pitch = e.yRot; newCombatant.pitch = e.getYRot();
} }
} }
} }
@ -217,7 +216,7 @@ public class Battle
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getId(), 0, id, c.entityInfo.category); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getId(), 0, id, c.entityInfo.category);
} }
else if(c.entity instanceof PlayerEntity) else if(c.entity instanceof Player)
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getId(), 0, id, "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); 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"); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getId(), 0, id, "player");
} }
@ -316,7 +315,7 @@ public class Battle
entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(e); 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; return;
} }
@ -331,7 +330,7 @@ public class Battle
{ {
sideA.put(e.getId(), newCombatant); sideA.put(e.getId(), newCombatant);
} }
if(e instanceof PlayerEntity) if(e instanceof Player)
{ {
newCombatant.recalcSpeedOnCompare = true; newCombatant.recalcSpeedOnCompare = true;
playerCount.incrementAndGet(); playerCount.incrementAndGet();
@ -345,8 +344,8 @@ public class Battle
{ {
newCombatant.x = e.getX(); newCombatant.x = e.getX();
newCombatant.z = e.getZ(); newCombatant.z = e.getZ();
newCombatant.yaw = e.xRot; newCombatant.yaw = e.getXRot();
newCombatant.pitch = e.yRot; newCombatant.pitch = e.getYRot();
} }
if(isServer) if(isServer)
{ {
@ -354,7 +353,7 @@ public class Battle
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getId(), 0, id, newCombatant.entityInfo.category); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getId(), 0, id, newCombatant.entityInfo.category);
} }
else if(newCombatant.entity instanceof PlayerEntity) else if(newCombatant.entity instanceof Player)
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getId(), 0, id, "player"); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getId(), 0, id, "player");
} }
@ -379,7 +378,7 @@ public class Battle
entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(e); 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; return;
} }
@ -394,7 +393,7 @@ public class Battle
{ {
sideB.put(e.getId(), newCombatant); sideB.put(e.getId(), newCombatant);
} }
if(e instanceof PlayerEntity) if(e instanceof Player)
{ {
newCombatant.recalcSpeedOnCompare = true; newCombatant.recalcSpeedOnCompare = true;
playerCount.incrementAndGet(); playerCount.incrementAndGet();
@ -408,8 +407,8 @@ public class Battle
{ {
newCombatant.x = e.getX(); newCombatant.x = e.getX();
newCombatant.z = e.getZ(); newCombatant.z = e.getZ();
newCombatant.yaw = e.xRot; newCombatant.yaw = e.getXRot();
newCombatant.pitch = e.yRot; newCombatant.pitch = e.getYRot();
} }
if(isServer) if(isServer)
{ {
@ -417,7 +416,7 @@ public class Battle
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getId(), 0, id, newCombatant.entityInfo.category); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getId(), 0, id, newCombatant.entityInfo.category);
} }
else if(newCombatant.entity instanceof PlayerEntity) else if(newCombatant.entity instanceof Player)
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getId(), 0, id, "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); PacketBattleInfo infoPacket = new PacketBattleInfo(getSideAIDs(), getSideBIDs(), timer);
for(Combatant p : players.values()) 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()) 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; category = entry.getValue().entityInfo.category;
} }
else if(entry.getValue().entity instanceof PlayerEntity) else if(entry.getValue().entity instanceof Player)
{ {
category = "player"; category = "player";
} }
@ -611,7 +610,7 @@ public class Battle
{ {
category = entry.getValue().entityInfo.category; category = entry.getValue().entityInfo.category;
} }
else if(entry.getValue().entity instanceof PlayerEntity) else if(entry.getValue().entity instanceof Player)
{ {
category = "player"; category = "player";
} }
@ -639,7 +638,7 @@ public class Battle
for(Iterator<Map.Entry<Integer, Combatant>> iter = players.entrySet().iterator(); iter.hasNext();) for(Iterator<Map.Entry<Integer, Combatant>> iter = players.entrySet().iterator(); iter.hasNext();)
{ {
Map.Entry<Integer, Combatant> entry = iter.next(); Map.Entry<Integer, Combatant> entry = iter.next();
if(entry.getValue().entity != null && ((PlayerEntity)entry.getValue().entity).isCreative()) if(entry.getValue().entity != null && ((Player)entry.getValue().entity).isCreative())
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.BECAME_CREATIVE, entry.getValue().entity.getId(), 0, 0); sendMessageToAllPlayers(PacketBattleMessage.MessageType.BECAME_CREATIVE, entry.getValue().entity.getId(), 0, 0);
iter.remove(); iter.remove();
@ -702,9 +701,9 @@ public class Battle
private void removeCombatantPostRemove(Combatant c) 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); battleManager.addRecentlyLeftBattle(c);
} }
@ -831,9 +830,9 @@ public class Battle
for(Combatant c : sideA.values()) for(Combatant c : sideA.values())
{ {
// picking decision for sideA non-players // 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()) { if(c.creeperTurns++ < TurnBasedMinecraftMod.proxy.getConfig().getCreeperExplodeTurn()) {
c.decision = Decision.CREEPER_WAIT; c.decision = Decision.CREEPER_WAIT;
} else { } else {
@ -858,9 +857,9 @@ public class Battle
} }
for(Combatant c : sideB.values()) 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()) { if(c.creeperTurns++ < TurnBasedMinecraftMod.proxy.getConfig().getCreeperExplodeTurn()) {
c.decision = Decision.CREEPER_WAIT; c.decision = Decision.CREEPER_WAIT;
} else { } else {
@ -934,7 +933,7 @@ public class Battle
case ATTACK: case ATTACK:
debugLog += " attack"; debugLog += " attack";
Combatant target = null; Combatant target = null;
if(next.entity instanceof PlayerEntity) if(next.entity instanceof Player)
{ {
debugLog += " as player"; debugLog += " as player";
target = sideA.get(next.targetEntityID); target = sideA.get(next.targetEntityID);
@ -946,11 +945,11 @@ public class Battle
{ {
continue; continue;
} }
ItemStack heldItemStack = ((PlayerEntity)next.entity).getMainHandItem(); ItemStack heldItemStack = ((Player)next.entity).getMainHandItem();
if(heldItemStack.getItem() instanceof BowItem) if(heldItemStack.getItem() instanceof BowItem)
{ {
debugLog += " with bow"; debugLog += " with bow";
if(Utility.doesPlayerHaveArrows((PlayerEntity)next.entity)) if(Utility.doesPlayerHaveArrows((Player)next.entity))
{ {
final Entity nextEntity = next.entity; final Entity nextEntity = next.entity;
final Entity targetEntity = target.entity; final Entity targetEntity = target.entity;
@ -963,10 +962,10 @@ public class Battle
next.pitch = pitchDirection; next.pitch = pitchDirection;
} }
// have player look at attack target // 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(); BowItem itemBow = (BowItem)heldItemStack.getItem();
TurnBasedMinecraftMod.proxy.getAttackerViaBowSet().add(new AttackerViaBow(nextEntity, getId())); 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); sendMessageToAllPlayers(PacketBattleMessage.MessageType.FIRED_ARROW, nextEntity.getId(), targetEntity.getId(), 0);
} }
else else
@ -977,7 +976,7 @@ public class Battle
} }
debugLog += " without bow"; debugLog += " without bow";
int hitChance = TurnBasedMinecraftMod.proxy.getConfig().getPlayerAttackProbability(); int hitChance = TurnBasedMinecraftMod.proxy.getConfig().getPlayerAttackProbability();
if(target.entity instanceof PlayerEntity) if(target.entity instanceof Player)
{ {
hitChance = hitChance * (100 - TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion()) / 100; 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 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 float pitchDirection = Utility.pitchDirection(next.entity.getX(), next.entity.getY(), next.entity.getZ(), target.entity.getX(), target.entity.getY(), target.entity.getZ());
final boolean defenseDamageTriggered; final boolean defenseDamageTriggered;
if(!(targetEntity instanceof PlayerEntity) && targetEntityInfo.defenseDamage > 0 && targetEntityInfo.defenseDamageProbability > 0) if(!(targetEntity instanceof Player) && targetEntityInfo.defenseDamage > 0 && targetEntityInfo.defenseDamageProbability > 0)
{ {
if(random.nextInt(100) < targetEntityInfo.defenseDamageProbability) if(random.nextInt(100) < targetEntityInfo.defenseDamageProbability)
{ {
@ -1022,10 +1021,10 @@ public class Battle
next.pitch = pitchDirection; next.pitch = pitchDirection;
} }
// have player look at attack target // 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.setAttackingEntity(nextEntity);
TurnBasedMinecraftMod.proxy.setAttackingDamage(0); TurnBasedMinecraftMod.proxy.setAttackingDamage(0);
((PlayerEntity)nextEntity).attack(targetEntity); ((Player)nextEntity).attack(targetEntity);
TurnBasedMinecraftMod.proxy.setAttackingEntity(null); TurnBasedMinecraftMod.proxy.setAttackingEntity(null);
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ATTACK, nextEntity.getId(), targetEntity.getId(), TurnBasedMinecraftMod.proxy.getAttackingDamage()); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ATTACK, nextEntity.getId(), targetEntity.getId(), TurnBasedMinecraftMod.proxy.getAttackingDamage());
if(defenseDamageTriggered) if(defenseDamageTriggered)
@ -1056,7 +1055,7 @@ public class Battle
else else
{ {
debugLog += " as mob"; debugLog += " as mob";
LivingEntity attackTarget = ((MobEntity)next.entity).getTarget(); LivingEntity attackTarget = ((Mob)next.entity).getTarget();
if(attackTarget != null && hasCombatant(attackTarget.getId())) if(attackTarget != null && hasCombatant(attackTarget.getId()))
{ {
debugLog += " to targeted"; debugLog += " to targeted";
@ -1101,7 +1100,7 @@ public class Battle
continue; continue;
} }
int hitChance = next.entityInfo.attackProbability; int hitChance = next.entityInfo.attackProbability;
if(target.entity instanceof PlayerEntity) if(target.entity instanceof Player)
{ {
hitChance = hitChance * (100 - TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion()) / 100; hitChance = hitChance * (100 - TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion()) / 100;
} }
@ -1137,7 +1136,7 @@ public class Battle
final boolean defenseDamageTriggered; final boolean defenseDamageTriggered;
final boolean attackEffectTriggered; 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) if(random.nextInt(100) < targetEntityInfo.defenseDamageProbability)
{ {
@ -1217,7 +1216,7 @@ public class Battle
{ {
for(Combatant c : sideB.values()) for(Combatant c : sideB.values())
{ {
if(c.entity instanceof PlayerEntity) if(c.entity instanceof Player)
{ {
if(TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed() > fastestEnemySpeed) if(TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed() > fastestEnemySpeed)
{ {
@ -1237,7 +1236,7 @@ public class Battle
{ {
for(Combatant c : sideA.values()) for(Combatant c : sideA.values())
{ {
if(c.entity instanceof PlayerEntity) if(c.entity instanceof Player)
{ {
if(TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed() > fastestEnemySpeed) if(TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed() > fastestEnemySpeed)
{ {
@ -1254,7 +1253,7 @@ public class Battle
} }
} }
int fleeProbability = 0; int fleeProbability = 0;
if(next.entity instanceof PlayerEntity) if(next.entity instanceof Player)
{ {
if(fastestEnemySpeed >= TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed()) if(fastestEnemySpeed >= TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed())
{ {
@ -1286,7 +1285,7 @@ public class Battle
{ {
fleeingCategory = next.entityInfo.category; fleeingCategory = next.entityInfo.category;
} }
else if(next.entity instanceof PlayerEntity) else if(next.entity instanceof Player)
{ {
fleeingCategory = "player"; fleeingCategory = "player";
} }
@ -1308,43 +1307,33 @@ public class Battle
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_INVALID.getValue()); sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_INVALID.getValue());
break; break;
} }
ItemStack targetItemStack = ((PlayerEntity)next.entity).inventory.getItem(next.itemToUse); ItemStack targetItemStack = ((Player) next.entity).getInventory().getItem(next.itemToUse);
Item targetItem = targetItemStack.getItem(); Item targetItem = targetItemStack.getItem();
if(targetItem == null) if(targetItem == null)
{ {
debugLog += " null"; debugLog += " null";
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_NOTHING.getValue()); sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_NOTHING.getValue());
break; break;
} } else if(targetItem.isEdible()) {
// 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) {
debugLog += " food"; debugLog += " food";
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_FOOD.getValue(), targetItemStack.getDisplayName().getString()); sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_FOOD.getValue(), targetItemStack.getDisplayName().getString());
final Entity nextEntity = next.entity; final Entity nextEntity = next.entity;
final int nextItemToUse = next.itemToUse; final int nextItemToUse = next.itemToUse;
((PlayerEntity)nextEntity).inventory.setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level, (LivingEntity)nextEntity)); ((Player) nextEntity).getInventory().setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level, (LivingEntity)nextEntity));
} else { } else {
// then check vanilla foods // then check vanilla foods
if (targetItem.getItemCategory() == ItemGroup.TAB_FOOD && targetItem.isEdible()) { if (targetItem.getItemCategory() == CreativeModeTab.TAB_FOOD && targetItem.isEdible()) {
debugLog += " food"; debugLog += " food";
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_FOOD.getValue(), targetItemStack.getDisplayName().getString()); sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_FOOD.getValue(), targetItemStack.getDisplayName().getString());
final Entity nextEntity = next.entity; final Entity nextEntity = next.entity;
final int nextItemToUse = next.itemToUse; final int nextItemToUse = next.itemToUse;
((PlayerEntity) nextEntity).inventory.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) { } else if (targetItem instanceof PotionItem) {
debugLog += " potion"; debugLog += " potion";
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_POTION.getValue(), targetItemStack.getDisplayName().getString()); sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_POTION.getValue(), targetItemStack.getDisplayName().getString());
final Entity nextEntity = next.entity; final Entity nextEntity = next.entity;
final int nextItemToUse = next.itemToUse; final int nextItemToUse = next.itemToUse;
((PlayerEntity) nextEntity).inventory.setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level, (LivingEntity) nextEntity)); ((Player) nextEntity).getInventory().setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level, (LivingEntity) nextEntity));
} else { } else {
debugLog += " non-consumable"; debugLog += " non-consumable";
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_INVALID.getValue(), targetItemStack.getDisplayName().getString()); sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_INVALID.getValue(), targetItemStack.getDisplayName().getString());
@ -1359,7 +1348,7 @@ public class Battle
} }
final Entity nextEntity = next.entity; final Entity nextEntity = next.entity;
final int nextItemToUse = next.itemToUse; 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); sendMessageToAllPlayers(PacketBattleMessage.MessageType.SWITCHED_ITEM, next.entity.getId(), 0, 1);
} }
break; break;
@ -1379,7 +1368,7 @@ public class Battle
for (Combatant c : sideA.values()) { for (Combatant c : sideA.values()) {
if (c.entity.getId() != next.entity.getId()) { if (c.entity.getId() != next.entity.getId()) {
int hitChance = next.entityInfo.attackProbability; int hitChance = next.entityInfo.attackProbability;
if (c.entity instanceof PlayerEntity) { if (c.entity instanceof Player) {
hitChance = hitChance * (100 - TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion()) / 100; hitChance = hitChance * (100 - TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion()) / 100;
} else { } else {
hitChance = hitChance * (100 - c.entityInfo.evasion) / 100; hitChance = hitChance * (100 - c.entityInfo.evasion) / 100;
@ -1423,7 +1412,7 @@ public class Battle
for(Combatant c : sideB.values()) { for(Combatant c : sideB.values()) {
if (c.entity.getId() != next.entity.getId()) { if (c.entity.getId() != next.entity.getId()) {
int hitChance = next.entityInfo.attackProbability; int hitChance = next.entityInfo.attackProbability;
if (c.entity instanceof PlayerEntity) { if (c.entity instanceof Player) {
hitChance = hitChance * (100 - TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion()) / 100; hitChance = hitChance * (100 - TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion()) / 100;
} else { } else {
hitChance = hitChance * (100 - c.entityInfo.evasion) / 100; hitChance = hitChance * (100 - c.entityInfo.evasion) / 100;
@ -1464,7 +1453,7 @@ public class Battle
} }
} }
} }
((CreeperEntity)nextEntity).setSwellDir(1000000); ((Creeper)nextEntity).setSwellDir(1000000);
} }
break; break;
} }
@ -1509,20 +1498,20 @@ public class Battle
private void defuseCreepers() { private void defuseCreepers() {
for(Combatant c : sideA.values()) { for(Combatant c : sideA.values()) {
if(c.entity instanceof CreeperEntity) { if(c.entity instanceof Creeper) {
if(c.creeperTurns <= TurnBasedMinecraftMod.proxy.getConfig().getCreeperExplodeTurn()) { if(c.creeperTurns <= TurnBasedMinecraftMod.proxy.getConfig().getCreeperExplodeTurn()) {
((CreeperEntity)c.entity).setSwellDir(-10); ((Creeper)c.entity).setSwellDir(-10);
} else { } else {
((CreeperEntity)c.entity).setSwellDir(1000000); ((Creeper)c.entity).setSwellDir(1000000);
} }
} }
} }
for(Combatant c : sideB.values()) { for(Combatant c : sideB.values()) {
if(c.entity instanceof CreeperEntity) { if(c.entity instanceof Creeper) {
if(c.creeperTurns <= TurnBasedMinecraftMod.proxy.getConfig().getCreeperExplodeTurn()) { if(c.creeperTurns <= TurnBasedMinecraftMod.proxy.getConfig().getCreeperExplodeTurn()) {
((CreeperEntity)c.entity).setSwellDir(-10); ((Creeper)c.entity).setSwellDir(-10);
} else { } else {
((CreeperEntity) c.entity).setSwellDir(1000000); ((Creeper) c.entity).setSwellDir(1000000);
} }
} }
} }

View file

@ -1,26 +1,19 @@
package com.burnedkirby.TurnBasedMinecraft.common; 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 com.burnedkirby.TurnBasedMinecraft.common.networking.PacketGeneralMessage;
import net.minecraft.resources.ResourceKey;
import net.minecraft.entity.Entity; 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.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
import net.minecraftforge.network.PacketDistributor;
import org.apache.logging.log4j.Logger;
import java.util.*;
public class BattleManager public class BattleManager
{ {
@ -30,8 +23,7 @@ public class BattleManager
private Map<Integer, Combatant> recentlyLeftBattle; private Map<Integer, Combatant> recentlyLeftBattle;
private BattleUpdater battleUpdater; private BattleUpdater battleUpdater;
private Map<EntityIDDimPair, Integer> entityToBattleMap; private Map<EntityIDDimPair, Integer> entityToBattleMap;
private static Collection<ItemGroup> otherFoodItemGroups = new ArrayList<>();
public BattleManager(Logger logger) public BattleManager(Logger logger)
{ {
this.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 // 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)) || (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))) || (config.getEntityInfoReference(attackerClassName) != null || config.getCustomEntityInfoReference(attackerCustomName) != null)))
{ {
// logger.debug("BattleManager: Failed first check, attacker is \"" + attackerClassName + "\", defender is \"" + receiverClassName + "\""); // logger.debug("BattleManager: Failed first check, attacker is \"" + attackerClassName + "\", defender is \"" + receiverClassName + "\"");
@ -138,7 +130,7 @@ public class BattleManager
return true; return true;
} else if(attackerBattle == null && defenderBattle == null) { } else if(attackerBattle == null && defenderBattle == null) {
// neither entity is in battle // neither entity is in battle
if(event.getEntity() instanceof PlayerEntity || event.getSource().getEntity() instanceof PlayerEntity) if(event.getEntity() instanceof Player || event.getSource().getEntity() instanceof Player)
{ {
// at least one of the entities is a player, create Battle // at least one of the entities is a player, create Battle
Collection<Entity> sideA = new ArrayList<Entity>(1); Collection<Entity> sideA = new ArrayList<Entity>(1);
@ -204,7 +196,7 @@ public class BattleManager
} }
EntityInfo targetedInfo; EntityInfo targetedInfo;
if(event.getTarget() instanceof PlayerEntity) if(event.getTarget() instanceof Player)
{ {
targetedInfo = null; targetedInfo = null;
} }
@ -216,7 +208,7 @@ public class BattleManager
targetedInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(event.getTarget()); 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 == null
|| attackerInfo.ignoreBattle || attackerInfo.ignoreBattle
|| TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType(attackerInfo.category) || TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType(attackerInfo.category)
@ -241,7 +233,7 @@ public class BattleManager
return; return;
} else if(attackerBattle == null && defenderBattle == null) { } else if(attackerBattle == null && defenderBattle == null) {
// neither in battle // 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 // at least one is a player, create battle
Collection<Entity> sideA = new ArrayList<Entity>(1); 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; Battle newBattle = null;
while(battleMap.containsKey(IDCounter)) while(battleMap.containsKey(IDCounter))
@ -313,8 +305,8 @@ public class BattleManager
{ {
c.time = System.nanoTime(); c.time = System.nanoTime();
Config config = TurnBasedMinecraftMod.proxy.getConfig(); Config config = TurnBasedMinecraftMod.proxy.getConfig();
if(c.entity instanceof ServerPlayerEntity) { if(c.entity instanceof ServerPlayer) {
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(()->(ServerPlayerEntity) c.entity), new PacketGeneralMessage("You just left battle! " + config.getLeaveBattleCooldownSeconds() + " seconds until you can attack/be-attacked again!")); TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(()->(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); recentlyLeftBattle.put(c.entity.getId(), c);
entityToBattleMap.remove(new EntityIDDimPair(c.entity)); 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();) for(Iterator<Map.Entry<Integer, Combatant>> iter = recentlyLeftBattle.entrySet().iterator(); iter.hasNext();)
{ {
Map.Entry<Integer, Combatant> entry = iter.next(); Map.Entry<Integer, Combatant> entry = iter.next();
if(entry.getValue().entity instanceof CreeperEntity && TurnBasedMinecraftMod.proxy.getConfig().getCreeperStopExplodeOnLeaveBattle()) { if(entry.getValue().entity instanceof Creeper && TurnBasedMinecraftMod.proxy.getConfig().getCreeperStopExplodeOnLeaveBattle()) {
((CreeperEntity)entry.getValue().entity).setSwellDir(-10); ((Creeper)entry.getValue().entity).setSwellDir(-10);
} }
if(current - entry.getValue().time > TurnBasedMinecraftMod.proxy.getConfig().getLeaveBattleCooldownNanos()) if(current - entry.getValue().time > TurnBasedMinecraftMod.proxy.getConfig().getLeaveBattleCooldownNanos())
{ {
iter.remove(); 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; return result;
} }
public static void addOtherModItemGroup(ItemGroup itemGroup) {
otherFoodItemGroups.add(itemGroup);
}
public static Collection<ItemGroup> getOtherFoodItemGroups() {
return otherFoodItemGroups;
}
} }

View file

@ -2,11 +2,11 @@ package com.burnedkirby.TurnBasedMinecraft.common;
import java.util.Comparator; import java.util.Comparator;
import net.minecraft.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.world.entity.player.Player;
import net.minecraft.potion.EffectInstance; import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.potion.Effects; import net.minecraft.world.effect.MobEffects;
public class Combatant public class Combatant
{ {
@ -53,18 +53,18 @@ public class Combatant
@Override @Override
public int compare(Combatant c0, Combatant c1) 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; LivingEntity c0Entity = (LivingEntity)c0.entity;
boolean isHaste = false; boolean isHaste = false;
boolean isSlow = 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; 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; 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; LivingEntity c1Entity = (LivingEntity)c1.entity;
boolean isHaste = false; boolean isHaste = false;
boolean isSlow = 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; isHaste = true;
} }
else if(e.getEffect().equals(Effects.MOVEMENT_SLOWDOWN)) else if(e.getEffect().equals(MobEffects.MOVEMENT_SLOWDOWN))
{ {
isSlow = true; isSlow = true;
} }

View file

@ -1,20 +1,19 @@
package com.burnedkirby.TurnBasedMinecraft.common; package com.burnedkirby.TurnBasedMinecraft.common;
import java.lang.reflect.Field; import net.minecraft.network.chat.TextComponent;
import java.util.*; import net.minecraft.resources.ResourceKey;
import net.minecraft.world.entity.Entity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.world.entity.player.Player;
import net.minecraft.item.ItemGroup; import net.minecraft.world.level.Level;
import net.minecraft.util.RegistryKey; import net.minecraftforge.network.NetworkEvent;
import net.minecraft.util.text.ITextComponent; import net.minecraftforge.server.ServerLifecycleHooks;
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 org.apache.logging.log4j.Logger; 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 public class CommonProxy
{ {
@ -75,96 +74,11 @@ public class CommonProxy
{ {
config = new Config(logger); config = new Config(logger);
postInitClient(); postInitClient();
pamsFoodIntegrationLoading();
logger.debug("postInit proxy for com_burnedkirby_turnbasedminecraft"); logger.debug("postInit proxy for com_burnedkirby_turnbasedminecraft");
} }
protected void postInitClient() {} 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) public final void setLogger(Logger logger)
{ {
this.logger = logger; this.logger = logger;
@ -182,7 +96,7 @@ public class CommonProxy
public void displayString(String message) {} public void displayString(String message) {}
public void displayTextComponent(ITextComponent textComponent) {} public void displayTextComponent(TextComponent textComponent) {}
public final boolean isServerRunning() public final boolean isServerRunning()
{ {
@ -241,7 +155,7 @@ public class CommonProxy
return editingPlayers.get(id); return editingPlayers.get(id);
} }
protected final EditingInfo setEditingPlayer(PlayerEntity player) protected final EditingInfo setEditingPlayer(Player player)
{ {
return editingPlayers.put(player.getId(), new EditingInfo(player)); return editingPlayers.put(player.getId(), new EditingInfo(player));
} }
@ -251,7 +165,9 @@ public class CommonProxy
return editingPlayers.remove(id); 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); return ServerLifecycleHooks.getCurrentServer().getLevel(dim).getEntity(id);
} }
public <MSG> void handlePacket(MSG msg, Supplier<NetworkEvent.Context> ctx) {}
} }

View file

@ -1,10 +1,10 @@
package com.burnedkirby.TurnBasedMinecraft.common; package com.burnedkirby.TurnBasedMinecraft.common;
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketGeneralMessage; 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.event.entity.EntityTravelToDimensionEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.network.PacketDistributor; import net.minecraftforge.network.PacketDistributor;
public class DimensionChangedHandler { public class DimensionChangedHandler {
@SubscribeEvent @SubscribeEvent
@ -13,9 +13,9 @@ public class DimensionChangedHandler {
return; return;
} }
if(TurnBasedMinecraftMod.proxy.getBattleManager().forceLeaveBattle(new EntityIDDimPair(event.getEntity())) if(TurnBasedMinecraftMod.proxy.getBattleManager().forceLeaveBattle(new EntityIDDimPair(event.getEntity()))
&& event.getEntity() instanceof ServerPlayerEntity) { && event.getEntity() instanceof ServerPlayer) {
TurnBasedMinecraftMod.getHandler().send( 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")); new PacketGeneralMessage("Left battle due to moving to a different dimension"));
} }
} }

View file

@ -1,10 +1,10 @@
package com.burnedkirby.TurnBasedMinecraft.common; package com.burnedkirby.TurnBasedMinecraft.common;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.world.entity.player.Player;
public class EditingInfo public class EditingInfo
{ {
public PlayerEntity editor; public Player editor;
public EntityInfo entityInfo; public EntityInfo entityInfo;
public boolean isPendingEntitySelection; public boolean isPendingEntitySelection;
public boolean isEditingCustomName; public boolean isEditingCustomName;
@ -17,7 +17,7 @@ public class EditingInfo
isEditingCustomName = false; isEditingCustomName = false;
} }
public EditingInfo(PlayerEntity player) public EditingInfo(Player player)
{ {
editor = player; editor = player;
entityInfo = null; entityInfo = null;

View file

@ -1,13 +1,12 @@
package com.burnedkirby.TurnBasedMinecraft.common; package com.burnedkirby.TurnBasedMinecraft.common;
import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceKey;
import net.minecraft.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.util.RegistryKey; import net.minecraft.world.level.Level;
import net.minecraft.world.World;
public class EntityIDDimPair { public class EntityIDDimPair {
public int id; public int id;
public RegistryKey<World> dim; public ResourceKey<Level> dim;
EntityIDDimPair() { EntityIDDimPair() {
id = 0; id = 0;
@ -15,7 +14,7 @@ public class EntityIDDimPair {
dim = null; dim = null;
} }
EntityIDDimPair(int id, RegistryKey<World> dim) { EntityIDDimPair(int id, ResourceKey<Level> dim) {
this.id = id; this.id = id;
this.dim = dim; this.dim = dim;
} }

View file

@ -1,8 +1,8 @@
package com.burnedkirby.TurnBasedMinecraft.common; package com.burnedkirby.TurnBasedMinecraft.common;
import net.minecraft.entity.LivingEntity; import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.potion.EffectInstance; import net.minecraft.world.effect.MobEffects;
import net.minecraft.potion.Effects; import net.minecraft.world.entity.LivingEntity;
public class EntityInfo public class EntityInfo
{ {
@ -194,71 +194,71 @@ public class EntityInfo
} }
} }
public EffectInstance getPotionEffect() public MobEffectInstance getPotionEffect()
{ {
return getPotionEffect(20 * 7, 0); return getPotionEffect(20 * 7, 0);
} }
public EffectInstance getPotionEffect(int duration, int amplifier) { public MobEffectInstance getPotionEffect(int duration, int amplifier) {
switch(this) { switch(this) {
case SPEED: case SPEED:
return new EffectInstance(Effects.MOVEMENT_SPEED, duration, amplifier); return new MobEffectInstance(MobEffects.MOVEMENT_SPEED, duration, amplifier);
case SLOW: case SLOW:
return new EffectInstance(Effects.MOVEMENT_SLOWDOWN, duration, amplifier); return new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, duration, amplifier);
case HASTE: case HASTE:
return new EffectInstance(Effects.DIG_SPEED, duration, amplifier); return new MobEffectInstance(MobEffects.DIG_SPEED, duration, amplifier);
case MINING_FATIGUE: case MINING_FATIGUE:
return new EffectInstance(Effects.DIG_SLOWDOWN, duration, amplifier); return new MobEffectInstance(MobEffects.DIG_SLOWDOWN, duration, amplifier);
case STRENGTH: case STRENGTH:
return new EffectInstance(Effects.DAMAGE_BOOST, duration, amplifier); return new MobEffectInstance(MobEffects.DAMAGE_BOOST, duration, amplifier);
case JUMP_BOOST: case JUMP_BOOST:
return new EffectInstance(Effects.JUMP, duration, amplifier); return new MobEffectInstance(MobEffects.JUMP, duration, amplifier);
case NAUSEA: case NAUSEA:
return new EffectInstance(Effects.CONFUSION, duration, amplifier); return new MobEffectInstance(MobEffects.CONFUSION, duration, amplifier);
case REGENERATION: case REGENERATION:
return new EffectInstance(Effects.REGENERATION, duration, amplifier); return new MobEffectInstance(MobEffects.REGENERATION, duration, amplifier);
case RESISTANCE: case RESISTANCE:
return new EffectInstance(Effects.DAMAGE_RESISTANCE, duration, amplifier); return new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, duration, amplifier);
case FIRE_RESISTANCE: case FIRE_RESISTANCE:
return new EffectInstance(Effects.FIRE_RESISTANCE, duration, amplifier); return new MobEffectInstance(MobEffects.FIRE_RESISTANCE, duration, amplifier);
case WATER_BREATHING: case WATER_BREATHING:
return new EffectInstance(Effects.WATER_BREATHING, duration, amplifier); return new MobEffectInstance(MobEffects.WATER_BREATHING, duration, amplifier);
case INVISIBILITY: case INVISIBILITY:
return new EffectInstance(Effects.INVISIBILITY, duration, amplifier); return new MobEffectInstance(MobEffects.INVISIBILITY, duration, amplifier);
case BLINDNESS: case BLINDNESS:
return new EffectInstance(Effects.BLINDNESS, duration, amplifier); return new MobEffectInstance(MobEffects.BLINDNESS, duration, amplifier);
case NIGHT_VISION: case NIGHT_VISION:
return new EffectInstance(Effects.NIGHT_VISION, duration, amplifier); return new MobEffectInstance(MobEffects.NIGHT_VISION, duration, amplifier);
case HUNGER: case HUNGER:
return new EffectInstance(Effects.HUNGER, duration, amplifier); return new MobEffectInstance(MobEffects.HUNGER, duration, amplifier);
case WEAKNESS: case WEAKNESS:
return new EffectInstance(Effects.WEAKNESS, duration, amplifier); return new MobEffectInstance(MobEffects.WEAKNESS, duration, amplifier);
case POISON: case POISON:
return new EffectInstance(Effects.POISON, duration, amplifier); return new MobEffectInstance(MobEffects.POISON, duration, amplifier);
case WITHER: case WITHER:
return new EffectInstance(Effects.WITHER, duration, amplifier); return new MobEffectInstance(MobEffects.WITHER, duration, amplifier);
case HEALTH_BOOST: case HEALTH_BOOST:
return new EffectInstance(Effects.HEALTH_BOOST, duration, amplifier); return new MobEffectInstance(MobEffects.HEALTH_BOOST, duration, amplifier);
case ABSORPTION: case ABSORPTION:
return new EffectInstance(Effects.ABSORPTION, duration, amplifier); return new MobEffectInstance(MobEffects.ABSORPTION, duration, amplifier);
case SATURATION: case SATURATION:
return new EffectInstance(Effects.SATURATION, duration, amplifier); return new MobEffectInstance(MobEffects.SATURATION, duration, amplifier);
case GLOWING: case GLOWING:
return new EffectInstance(Effects.GLOWING, duration, amplifier); return new MobEffectInstance(MobEffects.GLOWING, duration, amplifier);
case LEVITATION: case LEVITATION:
return new EffectInstance(Effects.LEVITATION, duration, amplifier); return new MobEffectInstance(MobEffects.LEVITATION, duration, amplifier);
case LUCK: case LUCK:
return new EffectInstance(Effects.LUCK, duration, amplifier); return new MobEffectInstance(MobEffects.LUCK, duration, amplifier);
case UNLUCK: case UNLUCK:
return new EffectInstance(Effects.UNLUCK, duration, amplifier); return new MobEffectInstance(MobEffects.UNLUCK, duration, amplifier);
case SLOW_FALLING: case SLOW_FALLING:
return new EffectInstance(Effects.SLOW_FALLING, duration, amplifier); return new MobEffectInstance(MobEffects.SLOW_FALLING, duration, amplifier);
case CONDUIT_POWER: case CONDUIT_POWER:
return new EffectInstance(Effects.CONDUIT_POWER, duration, amplifier); return new MobEffectInstance(MobEffects.CONDUIT_POWER, duration, amplifier);
case DOLPHINS_GRACE: case DOLPHINS_GRACE:
return new EffectInstance(Effects.DOLPHINS_GRACE, duration, amplifier); return new MobEffectInstance(MobEffects.DOLPHINS_GRACE, duration, amplifier);
case BAD_OMEN: case BAD_OMEN:
return new EffectInstance(Effects.BAD_OMEN, duration, amplifier); return new MobEffectInstance(MobEffects.BAD_OMEN, duration, amplifier);
case FIRE: case FIRE:
// FIRE is not a PotionEffect and must be applied directly to the Entity // FIRE is not a PotionEffect and must be applied directly to the Entity
return null; return null;

View file

@ -1,6 +1,6 @@
package com.burnedkirby.TurnBasedMinecraft.common; 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.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
@ -13,7 +13,7 @@ public class PlayerJoinEventHandler
{ {
return; 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()); TurnBasedMinecraftMod.proxy.getConfig().addBattleIgnoringPlayer(event.getEntity().getId());
} }

View file

@ -9,33 +9,33 @@ import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import net.minecraft.command.Commands; import net.minecraft.commands.Commands;
import net.minecraft.command.arguments.EntityArgument; import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.text.StringTextComponent; import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.common.MinecraftForge; 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.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent; 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.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.network.NetworkRegistry; import net.minecraftforge.network.NetworkRegistry;
import net.minecraftforge.fml.network.PacketDistributor; import net.minecraftforge.network.PacketDistributor;
import net.minecraftforge.fml.network.simple.SimpleChannel; import net.minecraftforge.network.simple.SimpleChannel;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@Mod(TurnBasedMinecraftMod.MODID) @Mod(TurnBasedMinecraftMod.MODID)
public class TurnBasedMinecraftMod public class TurnBasedMinecraftMod {
{
public static final String MODID = "com_burnedkirby_turnbasedminecraft"; public static final String MODID = "com_burnedkirby_turnbasedminecraft";
public static final String NAME = "Turn Based Minecraft Mod"; public static final String NAME = "Turn Based Minecraft Mod";
public static final String VERSION = "1.17.2"; public static final String VERSION = "1.18.0";
public static final String CONFIG_FILENAME = "TBM_Config.toml"; public static final String CONFIG_FILENAME = "TBM_Config.toml";
public static final String DEFAULT_CONFIG_FILENAME = "TBM_Config_DEFAULT.toml"; public static final String DEFAULT_CONFIG_FILENAME = "TBM_Config_DEFAULT.toml";
public static final String CONFIG_DIRECTORY = "config/TurnBasedMinecraft/"; public static final String CONFIG_DIRECTORY = "config/TurnBasedMinecraft/";
@ -45,25 +45,25 @@ public class TurnBasedMinecraftMod
public static final String MUSIC_ROOT = CONFIG_DIRECTORY + "Music/"; public static final String MUSIC_ROOT = CONFIG_DIRECTORY + "Music/";
public static final String MUSIC_SILLY = MUSIC_ROOT + "silly/"; public static final String MUSIC_SILLY = MUSIC_ROOT + "silly/";
public static final String MUSIC_BATTLE = MUSIC_ROOT + "battle/"; public static final String MUSIC_BATTLE = MUSIC_ROOT + "battle/";
private static final String PROTOCOL_VERSION = Integer.toString(1); private static final String PROTOCOL_VERSION = Integer.toString(1);
private static final ResourceLocation HANDLER_ID = new ResourceLocation(MODID, "main_channel"); private static final ResourceLocation HANDLER_ID = new ResourceLocation(MODID, "main_channel");
private static final SimpleChannel HANDLER = NetworkRegistry.ChannelBuilder private static final SimpleChannel HANDLER = NetworkRegistry.ChannelBuilder
.named(HANDLER_ID) .named(HANDLER_ID)
.clientAcceptedVersions(PROTOCOL_VERSION::equals) .clientAcceptedVersions(PROTOCOL_VERSION::equals)
.serverAcceptedVersions(PROTOCOL_VERSION::equals) .serverAcceptedVersions(PROTOCOL_VERSION::equals)
.networkProtocolVersion(() -> PROTOCOL_VERSION) .networkProtocolVersion(() -> PROTOCOL_VERSION)
.simpleChannel(); .simpleChannel();
protected static Logger logger = LogManager.getLogger(); protected static Logger logger = LogManager.getLogger();
public static ResourceLocation getNetResourceLocation() { public static ResourceLocation getNetResourceLocation() {
return HANDLER_ID; return HANDLER_ID;
} }
public static SimpleChannel getHandler() { public static SimpleChannel getHandler() {
return HANDLER; return HANDLER;
} }
public static CommonProxy proxy; public static CommonProxy proxy;
public TurnBasedMinecraftMod() { public TurnBasedMinecraftMod() {
@ -74,51 +74,50 @@ public class TurnBasedMinecraftMod
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }
private void firstInit(final FMLCommonSetupEvent event) private void firstInit(final FMLCommonSetupEvent event) {
{ proxy = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> CommonProxy::new);
proxy = DistExecutor.safeRunForDist(()-> ClientProxy::new, ()-> CommonProxy::new);
proxy.setLogger(logger); proxy.setLogger(logger);
proxy.initialize(); proxy.initialize();
// register packets // register packets
int packetHandlerID = 0; int packetHandlerID = 0;
HANDLER.registerMessage( HANDLER.registerMessage(
packetHandlerID++, packetHandlerID++,
PacketBattleInfo.class, PacketBattleInfo.class,
PacketBattleInfo::encode, PacketBattleInfo::encode,
PacketBattleInfo::decode, PacketBattleInfo::decode,
PacketBattleInfo.Handler::handle); PacketBattleInfo::handle);
HANDLER.registerMessage( HANDLER.registerMessage(
packetHandlerID++, packetHandlerID++,
PacketBattleRequestInfo.class, PacketBattleRequestInfo.class,
PacketBattleRequestInfo::encode, PacketBattleRequestInfo::encode,
PacketBattleRequestInfo::decode, PacketBattleRequestInfo::decode,
PacketBattleRequestInfo.Handler::handle); PacketBattleRequestInfo::handle);
HANDLER.registerMessage( HANDLER.registerMessage(
packetHandlerID++, packetHandlerID++,
PacketBattleDecision.class, PacketBattleDecision.class,
PacketBattleDecision::encode, PacketBattleDecision::encode,
PacketBattleDecision::decode, PacketBattleDecision::decode,
PacketBattleDecision.Handler::handle); PacketBattleDecision::handle);
HANDLER.registerMessage( HANDLER.registerMessage(
packetHandlerID++, packetHandlerID++,
PacketBattleMessage.class, PacketBattleMessage.class,
PacketBattleMessage::encode, PacketBattleMessage::encode,
PacketBattleMessage::decode, PacketBattleMessage::decode,
PacketBattleMessage.Handler::handle); PacketBattleMessage::handle);
HANDLER.registerMessage( HANDLER.registerMessage(
packetHandlerID++, packetHandlerID++,
PacketGeneralMessage.class, PacketGeneralMessage.class,
PacketGeneralMessage::encode, PacketGeneralMessage::encode,
PacketGeneralMessage::decode, PacketGeneralMessage::decode,
PacketGeneralMessage.Handler::handle); PacketGeneralMessage::handle);
HANDLER.registerMessage( HANDLER.registerMessage(
packetHandlerID++, packetHandlerID++,
PacketEditingMessage.class, PacketEditingMessage.class,
PacketEditingMessage::encode, PacketEditingMessage::encode,
PacketEditingMessage::decode, PacketEditingMessage::decode,
PacketEditingMessage.Handler::handle); PacketEditingMessage::handle);
// register event handler(s) // register event handler(s)
MinecraftForge.EVENT_BUS.register(new AttackEventHandler()); MinecraftForge.EVENT_BUS.register(new AttackEventHandler());
MinecraftForge.EVENT_BUS.register(new PlayerJoinEventHandler()); MinecraftForge.EVENT_BUS.register(new PlayerJoinEventHandler());
@ -127,108 +126,106 @@ public class TurnBasedMinecraftMod
logger.debug("Init com_burnedkirby_turnbasedminecraft"); logger.debug("Init com_burnedkirby_turnbasedminecraft");
} }
private void secondInitClient(final FMLClientSetupEvent event) private void secondInitClient(final FMLClientSetupEvent event) {
{ proxy.postInit();
proxy.postInit();
} }
private void secondInitServer(final FMLDedicatedServerSetupEvent event) private void secondInitServer(final FMLDedicatedServerSetupEvent event) {
{ proxy.postInit();
proxy.postInit();
} }
@SubscribeEvent @SubscribeEvent
public void serverStarting(FMLServerStartingEvent event) public void serverStarting(ServerStartingEvent event) {
{
logger.debug("About to initialize BattleManager"); logger.debug("About to initialize BattleManager");
if(proxy.initializeBattleManager()) if (proxy.initializeBattleManager()) {
{
logger.debug("Initialized BattleManager"); logger.debug("Initialized BattleManager");
} }
proxy.getConfig().clearBattleIgnoringPlayers(); proxy.getConfig().clearBattleIgnoringPlayers();
}
// register commands
@SubscribeEvent
public void registerCommands(RegisterCommandsEvent event) {
// tbm-disable // tbm-disable
event.getServer().getCommands().getDispatcher().register( event.getDispatcher().register(
Commands.literal("tbm-disable") Commands.literal("tbm-disable")
.requires(c -> { .requires(c -> {
return !proxy.getConfig().getIfOnlyOPsCanDisableTurnBasedForSelf() || c.hasPermission(2); return !proxy.getConfig().getIfOnlyOPsCanDisableTurnBasedForSelf() || c.hasPermission(2);
}) })
.executes( c -> { .executes(c -> {
proxy.getConfig().addBattleIgnoringPlayer(c.getSource().getPlayerOrException().getId()); 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; return 1;
})); }));
// tbm-disable-all // tbm-disable-all
event.getServer().getCommands().getDispatcher().register( event.getDispatcher().register(
Commands.literal("tbm-disable-all") Commands.literal("tbm-disable-all")
.requires(c -> { .requires(c -> {
return c.hasPermission(2); return c.hasPermission(2);
}) })
.executes(c -> { .executes(c -> {
proxy.getConfig().setBattleDisabledForAll(true); proxy.getConfig().setBattleDisabledForAll(true);
for(ServerPlayerEntity player : c.getSource().getServer().getPlayerList().getPlayers()) { for (ServerPlayer player : c.getSource().getServer().getPlayerList().getPlayers()) {
proxy.getConfig().addBattleIgnoringPlayer(player.getId()); proxy.getConfig().addBattleIgnoringPlayer(player.getId());
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP disabled turn-based-combat for everyone")); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP disabled turn-based-combat for everyone"));
} }
return 1; return 1;
})); }));
// tbm-enable // tbm-enable
event.getServer().getCommands().getDispatcher().register( event.getDispatcher().register(
Commands.literal("tbm-enable") Commands.literal("tbm-enable")
.requires(c -> !proxy.getConfig().getIfOnlyOPsCanDisableTurnBasedForSelf() || c.hasPermission(2)) .requires(c -> !proxy.getConfig().getIfOnlyOPsCanDisableTurnBasedForSelf() || c.hasPermission(2))
.executes(c -> { .executes(c -> {
proxy.getConfig().removeBattleIgnoringPlayer(c.getSource().getPlayerOrException().getId()); 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; return 1;
})); }));
// tbm-enable-all // tbm-enable-all
event.getServer().getCommands().getDispatcher().register( event.getDispatcher().register(
Commands.literal("tbm-enable-all") Commands.literal("tbm-enable-all")
.requires(c -> c.hasPermission(2)) .requires(c -> c.hasPermission(2))
.executes(c -> { .executes(c -> {
proxy.getConfig().setBattleDisabledForAll(false); proxy.getConfig().setBattleDisabledForAll(false);
proxy.getConfig().clearBattleIgnoringPlayers(); 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")); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP enabled turn-based-combat for everyone"));
} }
return 1; return 1;
})); }));
// tbm-set-enable // tbm-set-enable
event.getServer().getCommands().getDispatcher().register( event.getDispatcher().register(
Commands.literal("tbm-set-enable") Commands.literal("tbm-set-enable")
.requires(c -> c.hasPermission(2)) .requires(c -> c.hasPermission(2))
.then(Commands.argument("targets", EntityArgument.players()).executes(c -> { .then(Commands.argument("targets", EntityArgument.players()).executes(c -> {
for(ServerPlayerEntity player : EntityArgument.getPlayers(c, "targets")) { for (ServerPlayer player : EntityArgument.getPlayers(c, "targets")) {
proxy.getConfig().addBattleIgnoringPlayer(player.getId()); proxy.getConfig().addBattleIgnoringPlayer(player.getId());
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP enabled turn-based-combat for you")); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP enabled turn-based-combat for you"));
c.getSource().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; return 1;
}))); })));
// tbm-set-disable // tbm-set-disable
event.getServer().getCommands().getDispatcher().register( event.getDispatcher().register(
Commands.literal("tbm-set-disable") Commands.literal("tbm-set-disable")
.requires(c -> c.hasPermission(2)) .requires(c -> c.hasPermission(2))
.then(Commands.argument("targets", EntityArgument.players()).executes(c -> { .then(Commands.argument("targets", EntityArgument.players()).executes(c -> {
for(ServerPlayerEntity player : EntityArgument.getPlayers(c, "targets")) { for (ServerPlayer player : EntityArgument.getPlayers(c, "targets")) {
proxy.getConfig().removeBattleIgnoringPlayer(player.getId()); proxy.getConfig().removeBattleIgnoringPlayer(player.getId());
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP disabled turn-based-combat for you")); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP disabled turn-based-combat for you"));
c.getSource().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; return 1;
}))); })));
// tbm-edit // tbm-edit
event.getServer().getCommands().getDispatcher().register( event.getDispatcher().register(
Commands.literal("tbm-edit") Commands.literal("tbm-edit")
.requires(c -> c.hasPermission(2)) .requires(c -> c.hasPermission(2))
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
proxy.setEditingPlayer(player); proxy.setEditingPlayer(player);
@ -239,17 +236,17 @@ public class TurnBasedMinecraftMod
}) })
.then(Commands.literal("finish") .then(Commands.literal("finish")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
if(!proxy.getConfig().editEntityEntry(editingInfo.entityInfo)) { if (!proxy.getConfig().editEntityEntry(editingInfo.entityInfo)) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("An error occurred while attempting to save an entry to the config")); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("An error occurred while attempting to save an entry to the config"));
proxy.removeEditingInfo(player.getId()); proxy.removeEditingInfo(player.getId());
} else { } else {
proxy.removeEditingInfo(player.getId()); proxy.removeEditingInfo(player.getId());
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("Entity info saved in config and loaded.")); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("Entity info saved in config and loaded."));
} }
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@ -259,9 +256,9 @@ public class TurnBasedMinecraftMod
})) }))
.then(Commands.literal("cancel") .then(Commands.literal("cancel")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null) { if (editingInfo != null) {
proxy.removeEditingInfo(player.getId()); proxy.removeEditingInfo(player.getId());
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("Cancelled editing entry.")); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("Cancelled editing entry."));
} }
@ -269,12 +266,12 @@ public class TurnBasedMinecraftMod
})) }))
.then(Commands.literal("custom") .then(Commands.literal("custom")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
Message exceptionMessage = new LiteralMessage("Invalid action for tbm-edit"); Message exceptionMessage = new LiteralMessage("Invalid action for tbm-edit");
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage); throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
proxy.setEditingPlayer(player); proxy.setEditingPlayer(player);
@ -286,11 +283,11 @@ public class TurnBasedMinecraftMod
})) }))
.then(Commands.literal("edit") .then(Commands.literal("edit")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if(editingInfo != null){ } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@ -300,11 +297,11 @@ public class TurnBasedMinecraftMod
}) })
.then(Commands.literal("ignoreBattle") .then(Commands.literal("ignoreBattle")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_IGNORE_BATTLE)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_IGNORE_BATTLE));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); 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()) .then(Commands.argument("ignoreBattle", BoolArgumentType.bool())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
boolean ignoreBattle = BoolArgumentType.getBool(c, "ignoreBattle"); boolean ignoreBattle = BoolArgumentType.getBool(c, "ignoreBattle");
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
editingInfo.entityInfo.ignoreBattle = ignoreBattle; editingInfo.entityInfo.ignoreBattle = ignoreBattle;
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@ -331,11 +328,11 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("attackPower") .then(Commands.literal("attackPower")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_POWER)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_POWER));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); 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()) .then(Commands.argument("attackPower", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int attackPower = IntegerArgumentType.getInteger(c, "attackPower"); int attackPower = IntegerArgumentType.getInteger(c, "attackPower");
if(attackPower < 0) { if (attackPower < 0) {
attackPower = 0; attackPower = 0;
} }
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
editingInfo.entityInfo.attackPower = attackPower; editingInfo.entityInfo.attackPower = attackPower;
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@ -365,11 +362,11 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("attackProbability") .then(Commands.literal("attackProbability")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_PROBABILITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_PROBABILITY));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); 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()) .then(Commands.argument("attackProbability", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int attackProbability = IntegerArgumentType.getInteger(c, "attackProbability"); int attackProbability = IntegerArgumentType.getInteger(c, "attackProbability");
if(attackProbability < 0) { if (attackProbability < 0) {
attackProbability = 0; attackProbability = 0;
} else if(attackProbability > 100) { } else if (attackProbability > 100) {
attackProbability = 100; attackProbability = 100;
} }
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
editingInfo.entityInfo.attackProbability = attackProbability; editingInfo.entityInfo.attackProbability = attackProbability;
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@ -401,11 +398,11 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("attackVariance") .then(Commands.literal("attackVariance")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_VARIANCE)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_VARIANCE));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); 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()) .then(Commands.argument("attackVariance", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int attackVariance = IntegerArgumentType.getInteger(c, "attackVariance"); int attackVariance = IntegerArgumentType.getInteger(c, "attackVariance");
if(attackVariance < 0) { if (attackVariance < 0) {
attackVariance = 0; attackVariance = 0;
} }
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
editingInfo.entityInfo.attackVariance = attackVariance; editingInfo.entityInfo.attackVariance = attackVariance;
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@ -435,11 +432,11 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("attackEffect") .then(Commands.literal("attackEffect")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); 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()) .then(Commands.argument("attackEffect", StringArgumentType.word())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
EntityInfo.Effect effect = EntityInfo.Effect.fromString(StringArgumentType.getString(c, "attackEffect")); EntityInfo.Effect effect = EntityInfo.Effect.fromString(StringArgumentType.getString(c, "attackEffect"));
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
editingInfo.entityInfo.attackEffect = effect; editingInfo.entityInfo.attackEffect = effect;
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@ -466,11 +463,11 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("attackEffectProbability") .then(Commands.literal("attackEffectProbability")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT_PROBABILITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT_PROBABILITY));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); 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()) .then(Commands.argument("attackEffectProbability", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int attackEffectProbability = IntegerArgumentType.getInteger(c, "attackEffectProbability"); int attackEffectProbability = IntegerArgumentType.getInteger(c, "attackEffectProbability");
if(attackEffectProbability < 0) { if (attackEffectProbability < 0) {
attackEffectProbability = 0; attackEffectProbability = 0;
} else if(attackEffectProbability > 100) { } else if (attackEffectProbability > 100) {
attackEffectProbability = 100; attackEffectProbability = 100;
} }
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
editingInfo.entityInfo.attackEffectProbability = attackEffectProbability; editingInfo.entityInfo.attackEffectProbability = attackEffectProbability;
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@ -502,11 +499,11 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("defenseDamage") .then(Commands.literal("defenseDamage")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); 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()) .then(Commands.argument("defenseDamage", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int defenseDamage = IntegerArgumentType.getInteger(c, "defenseDamage"); int defenseDamage = IntegerArgumentType.getInteger(c, "defenseDamage");
if(defenseDamage < 0) { if (defenseDamage < 0) {
defenseDamage = 0; defenseDamage = 0;
} }
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
editingInfo.entityInfo.defenseDamage = defenseDamage; editingInfo.entityInfo.defenseDamage = defenseDamage;
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@ -536,11 +533,11 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("defenseDamageProbability") .then(Commands.literal("defenseDamageProbability")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE_PROBABILITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE_PROBABILITY));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); 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()) .then(Commands.argument("defenseDamageProbability", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int defenseDamageProbability = IntegerArgumentType.getInteger(c, "defenseDamageProbability"); int defenseDamageProbability = IntegerArgumentType.getInteger(c, "defenseDamageProbability");
if(defenseDamageProbability < 0) { if (defenseDamageProbability < 0) {
defenseDamageProbability = 0; defenseDamageProbability = 0;
} else if(defenseDamageProbability > 100) { } else if (defenseDamageProbability > 100) {
defenseDamageProbability = 100; defenseDamageProbability = 100;
} }
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
editingInfo.entityInfo.defenseDamageProbability = defenseDamageProbability; editingInfo.entityInfo.defenseDamageProbability = defenseDamageProbability;
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@ -572,11 +569,11 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("evasion") .then(Commands.literal("evasion")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_EVASION)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_EVASION));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); 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()) .then(Commands.argument("evasion", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int evasion = IntegerArgumentType.getInteger(c, "evasion"); int evasion = IntegerArgumentType.getInteger(c, "evasion");
if(evasion < 0) { if (evasion < 0) {
evasion = 0; evasion = 0;
} else if(evasion > 100) { } else if (evasion > 100) {
evasion = 100; evasion = 100;
} }
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
editingInfo.entityInfo.evasion = evasion; editingInfo.entityInfo.evasion = evasion;
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@ -608,11 +605,11 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("speed") .then(Commands.literal("speed")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SPEED)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SPEED));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); 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()) .then(Commands.argument("speed", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int speed = IntegerArgumentType.getInteger(c, "speed"); int speed = IntegerArgumentType.getInteger(c, "speed");
if(speed < 0) { if (speed < 0) {
speed = 0; speed = 0;
} }
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
editingInfo.entityInfo.speed = speed; editingInfo.entityInfo.speed = speed;
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@ -642,11 +639,11 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("category") .then(Commands.literal("category")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_CATEGORY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_CATEGORY));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); 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()) .then(Commands.argument("category", StringArgumentType.word())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
String category = StringArgumentType.getString(c, "category"); String category = StringArgumentType.getString(c, "category");
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
editingInfo.entityInfo.category = category; editingInfo.entityInfo.category = category;
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@ -673,11 +670,11 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("decisionAttack") .then(Commands.literal("decisionAttack")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_ATTACK)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_ATTACK));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); 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()) .then(Commands.argument("decisionAttack", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int decisionAttack = IntegerArgumentType.getInteger(c, "decisionAttack"); int decisionAttack = IntegerArgumentType.getInteger(c, "decisionAttack");
if(decisionAttack < 0) { if (decisionAttack < 0) {
decisionAttack = 0; decisionAttack = 0;
} else if(decisionAttack > 100) { } else if (decisionAttack > 100) {
decisionAttack = 100; decisionAttack = 100;
} }
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
editingInfo.entityInfo.decisionAttack = decisionAttack; editingInfo.entityInfo.decisionAttack = decisionAttack;
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@ -709,11 +706,11 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("decisionDefend") .then(Commands.literal("decisionDefend")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_DEFEND)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_DEFEND));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); 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()) .then(Commands.argument("decisionDefend", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int decisionDefend = IntegerArgumentType.getInteger(c, "decisionDefend"); int decisionDefend = IntegerArgumentType.getInteger(c, "decisionDefend");
if(decisionDefend < 0) { if (decisionDefend < 0) {
decisionDefend = 0; decisionDefend = 0;
} else if(decisionDefend > 100) { } else if (decisionDefend > 100) {
decisionDefend = 100; decisionDefend = 100;
} }
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
editingInfo.entityInfo.decisionDefend = decisionDefend; editingInfo.entityInfo.decisionDefend = decisionDefend;
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@ -745,11 +742,11 @@ public class TurnBasedMinecraftMod
) )
.then(Commands.literal("decisionFlee") .then(Commands.literal("decisionFlee")
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_FLEE)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_FLEE));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); 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()) .then(Commands.argument("decisionFlee", IntegerArgumentType.integer())
.executes(c -> { .executes(c -> {
ServerPlayerEntity player = c.getSource().getPlayerOrException(); ServerPlayer player = c.getSource().getPlayerOrException();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId()); EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
int decisionFlee = IntegerArgumentType.getInteger(c, "decisionFlee"); int decisionFlee = IntegerArgumentType.getInteger(c, "decisionFlee");
if(editingInfo != null && !editingInfo.isPendingEntitySelection) { if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
editingInfo.entityInfo.decisionFlee = decisionFlee; editingInfo.entityInfo.decisionFlee = decisionFlee;
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if(editingInfo != null) { } else if (editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY)); getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else { } else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\")."); Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
@ -777,13 +774,11 @@ public class TurnBasedMinecraftMod
) )
); );
} }
@SubscribeEvent @SubscribeEvent
public void serverStopping(FMLServerStoppingEvent event) public void serverStopping(ServerStoppingEvent event) {
{
logger.debug("About to cleanup BattleManager"); logger.debug("About to cleanup BattleManager");
if(proxy.cleanupBattleManager()) if (proxy.cleanupBattleManager()) {
{
logger.debug("Cleaned up BattleManager"); logger.debug("Cleaned up BattleManager");
} }
} }

View file

@ -1,12 +1,12 @@
package com.burnedkirby.TurnBasedMinecraft.common; package com.burnedkirby.TurnBasedMinecraft.common;
import net.minecraft.entity.Entity; import net.minecraft.core.Registry;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.resources.ResourceKey;
import net.minecraft.item.ArrowItem; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.RegistryKey; import net.minecraft.world.entity.Entity;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.registry.Registry; import net.minecraft.world.item.ArrowItem;
import net.minecraft.world.World; import net.minecraft.world.level.Level;
public class Utility 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; 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)); 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(); return dimObject.getRegistryName().toString();
} }
public static RegistryKey<World> deserializeDimension(String dimString) { public static ResourceKey<Level> deserializeDimension(String dimString) {
ResourceLocation dimRes = new ResourceLocation(dimString); ResourceLocation dimRes = new ResourceLocation(dimString);
return RegistryKey.create(Registry.DIMENSION_REGISTRY, dimRes); return ResourceKey.create(Registry.DIMENSION_REGISTRY, dimRes);
} }
} }

View file

@ -6,9 +6,9 @@ import com.burnedkirby.TurnBasedMinecraft.common.Battle;
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod; import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
import com.burnedkirby.TurnBasedMinecraft.common.Battle.Decision; import com.burnedkirby.TurnBasedMinecraft.common.Battle.Decision;
import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.fml.network.NetworkEvent; import net.minecraftforge.network.NetworkEvent;
public class PacketBattleDecision public class PacketBattleDecision
{ {
@ -25,27 +25,25 @@ public class PacketBattleDecision
this.targetIDOrItemID = targetIDOrItemID; 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.battleID);
buf.writeInt(pkt.decision.getValue()); buf.writeInt(pkt.decision.getValue());
buf.writeInt(pkt.targetIDOrItemID); 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()); 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) {
public static void handle(final PacketBattleDecision pkt, Supplier<NetworkEvent.Context> ctx) { ctx.get().enqueueWork(() -> {
ctx.get().enqueueWork(() -> { Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID); if(b != null)
if(b != null) {
{ ServerPlayer player = ctx.get().getSender();
ServerPlayerEntity player = ctx.get().getSender(); b.setDecision(player.getId(), pkt.decision, pkt.targetIDOrItemID);
b.setDecision(player.getId(), pkt.decision, pkt.targetIDOrItemID); }
} });
}); ctx.get().setPacketHandled(true);
ctx.get().setPacketHandled(true);
}
} }
} }

View file

@ -7,9 +7,9 @@ import java.util.function.Supplier;
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod; import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.fml.network.NetworkEvent; import net.minecraftforge.network.NetworkEvent;
public class PacketBattleInfo public class PacketBattleInfo
{ {
@ -23,27 +23,27 @@ public class PacketBattleInfo
sideB = new ArrayList<Integer>(); sideB = new ArrayList<Integer>();
decisionNanos = TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos(); decisionNanos = TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos();
} }
public PacketBattleInfo(Collection<Integer> sideA, Collection<Integer> sideB, long decisionNanos) public PacketBattleInfo(Collection<Integer> sideA, Collection<Integer> sideB, long decisionNanos)
{ {
this.sideA = sideA; this.sideA = sideA;
this.sideB = sideB; this.sideB = sideB;
this.decisionNanos = decisionNanos; this.decisionNanos = decisionNanos;
} }
public static void encode(PacketBattleInfo pkt, PacketBuffer buf) { public static void encode(PacketBattleInfo msg, FriendlyByteBuf buf) {
buf.writeInt(pkt.sideA.size()); buf.writeInt(msg.sideA.size());
buf.writeInt(pkt.sideB.size()); buf.writeInt(msg.sideB.size());
for(Integer id : pkt.sideA) { for(Integer id : msg.sideA) {
buf.writeInt(id); buf.writeInt(id);
} }
for(Integer id : pkt.sideB) { for(Integer id : msg.sideB) {
buf.writeInt(id); 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 sideACount = buf.readInt();
int sideBCount = buf.readInt(); int sideBCount = buf.readInt();
Collection<Integer> sideA = new ArrayList<Integer>(sideACount); Collection<Integer> sideA = new ArrayList<Integer>(sideACount);
@ -58,34 +58,32 @@ public class PacketBattleInfo
return new PacketBattleInfo(sideA, sideB, decisionNanos); return new PacketBattleInfo(sideA, sideB, decisionNanos);
} }
public static class Handler { public static void handle(final PacketBattleInfo pkt, Supplier<NetworkEvent.Context> ctx) {
public static void handle(final PacketBattleInfo pkt, Supplier<NetworkEvent.Context> ctx) { ctx.get().enqueueWork(() -> {
ctx.get().enqueueWork(() -> { if(TurnBasedMinecraftMod.proxy.getLocalBattle() == null)
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)
{ {
return; TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideA(e);
} }
TurnBasedMinecraftMod.proxy.getLocalBattle().clearCombatants(); }
for(Integer id : pkt.sideA) for(Integer id : pkt.sideB)
{
Entity e = Minecraft.getInstance().level.getEntity(id);
if(e != null)
{ {
Entity e = Minecraft.getInstance().level.getEntity(id); TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideB(e);
if(e != null)
{
TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideA(e);
}
} }
for(Integer id : pkt.sideB) }
{ TurnBasedMinecraftMod.proxy.setBattleGuiTime((int)(pkt.decisionNanos / 1000000000L));
Entity e = Minecraft.getInstance().level.getEntity(id); TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
if(e != null) });
{ ctx.get().setPacketHandled(true);
TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideB(e);
}
}
TurnBasedMinecraftMod.proxy.setBattleGuiTime((int)(pkt.decisionNanos / 1000000000L));
TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
});
ctx.get().setPacketHandled(true);
}
} }
} }

View file

@ -7,13 +7,12 @@ import java.util.function.Supplier;
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod; import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
import com.burnedkirby.TurnBasedMinecraft.common.Utility; import com.burnedkirby.TurnBasedMinecraft.common.Utility;
import net.minecraft.entity.Entity; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.PacketBuffer; import net.minecraft.resources.ResourceKey;
import net.minecraft.util.RegistryKey; import net.minecraft.world.level.Level;
import net.minecraft.util.text.Color; import net.minecraftforge.api.distmarker.Dist;
import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.fml.DistExecutor;
import net.minecraft.world.World; import net.minecraftforge.network.NetworkEvent;
import net.minecraftforge.fml.network.NetworkEvent;
public class PacketBattleMessage public class PacketBattleMessage
{ {
@ -102,17 +101,40 @@ public class PacketBattleMessage
return map.get(value); return map.get(value);
} }
} }
MessageType messageType; MessageType messageType;
int entityIDFrom; int entityIDFrom;
int entityIDTo; int entityIDTo;
int amount; int amount;
String custom; 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() { 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.messageType = messageType;
this.entityIDFrom = entityIDFrom; this.entityIDFrom = entityIDFrom;
@ -122,7 +144,7 @@ public class PacketBattleMessage
custom = new String(); 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.messageType = messageType;
this.entityIDFrom = entityIDFrom; this.entityIDFrom = entityIDFrom;
@ -132,7 +154,7 @@ public class PacketBattleMessage
this.custom = custom; 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.messageType.getValue());
buf.writeInt(pkt.entityIDFrom); buf.writeInt(pkt.entityIDFrom);
buf.writeInt(pkt.entityIDTo); buf.writeInt(pkt.entityIDTo);
@ -141,7 +163,7 @@ public class PacketBattleMessage
buf.writeUtf(pkt.custom); buf.writeUtf(pkt.custom);
} }
public static PacketBattleMessage decode(PacketBuffer buf) { public static PacketBattleMessage decode(FriendlyByteBuf buf) {
return new PacketBattleMessage( return new PacketBattleMessage(
MessageType.valueOf( MessageType.valueOf(
buf.readInt()), buf.readInt()),
@ -152,183 +174,10 @@ public class PacketBattleMessage
buf.readUtf()); buf.readUtf());
} }
public static class Handler { public static void handle(final PacketBattleMessage pkt, Supplier<NetworkEvent.Context> ctx) {
public static void handle(final PacketBattleMessage pkt, Supplier<NetworkEvent.Context> ctx) { ctx.get().enqueueWork(() -> {
ctx.get().enqueueWork(() -> { DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
Entity fromEntity = TurnBasedMinecraftMod.proxy.getEntity(pkt.entityIDFrom, pkt.dimension); });
String from = "Unknown"; ctx.get().setPacketHandled(true);
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);
}
} }
} }

View file

@ -6,8 +6,8 @@ import com.burnedkirby.TurnBasedMinecraft.common.Battle;
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod; import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.fml.network.NetworkEvent; import net.minecraftforge.network.NetworkEvent;
public class PacketBattleRequestInfo public class PacketBattleRequestInfo
{ {
@ -20,24 +20,22 @@ public class PacketBattleRequestInfo
this.battleID = battleID; this.battleID = battleID;
} }
public static void encode(PacketBattleRequestInfo pkt, PacketBuffer buf) { public static void encode(PacketBattleRequestInfo pkt, FriendlyByteBuf buf) {
buf.writeInt(pkt.battleID); buf.writeInt(pkt.battleID);
} }
public static PacketBattleRequestInfo decode(PacketBuffer buf) { public static PacketBattleRequestInfo decode(FriendlyByteBuf buf) {
return new PacketBattleRequestInfo(buf.readInt()); return new PacketBattleRequestInfo(buf.readInt());
} }
public static class Handler { public static void handle(final PacketBattleRequestInfo pkt, Supplier<NetworkEvent.Context> ctx) {
public static void handle(final PacketBattleRequestInfo pkt, Supplier<NetworkEvent.Context> ctx) { ctx.get().enqueueWork(() -> {
ctx.get().enqueueWork(() -> { Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID); if(b == null) {
if(b == null) { return;
return; }
} TurnBasedMinecraftMod.getHandler().reply(new PacketBattleInfo(b.getSideAIDs(), b.getSideBIDs(), b.getTimerSeconds()), ctx.get());
TurnBasedMinecraftMod.getHandler().reply(new PacketBattleInfo(b.getSideAIDs(), b.getSideBIDs(), b.getTimerSeconds()), ctx.get()); });
}); ctx.get().setPacketHandled(true);
ctx.get().setPacketHandled(true);
}
} }
} }

View file

@ -2,13 +2,10 @@ package com.burnedkirby.TurnBasedMinecraft.common.networking;
import com.burnedkirby.TurnBasedMinecraft.common.EntityInfo; import com.burnedkirby.TurnBasedMinecraft.common.EntityInfo;
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod; import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.util.text.Color; import net.minecraftforge.api.distmarker.Dist;
import net.minecraft.util.text.ITextComponent; import net.minecraftforge.fml.DistExecutor;
import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.network.NetworkEvent;
import net.minecraft.util.text.event.ClickEvent;
import net.minecraft.util.text.event.HoverEvent;
import net.minecraftforge.fml.network.NetworkEvent;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -66,6 +63,14 @@ public class PacketEditingMessage
Type type = Type.ATTACK_ENTITY; Type type = Type.ATTACK_ENTITY;
EntityInfo entityInfo = new EntityInfo(); EntityInfo entityInfo = new EntityInfo();
public Type getType() {
return type;
}
public EntityInfo getEntityInfo() {
return entityInfo;
}
public PacketEditingMessage() {} public PacketEditingMessage() {}
public PacketEditingMessage(Type type) 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()); buf.writeInt(pkt.type.getValue());
if(pkt.entityInfo.classType != null) { if(pkt.entityInfo.classType != null) {
buf.writeUtf(pkt.entityInfo.classType.getName()); buf.writeUtf(pkt.entityInfo.classType.getName());
@ -106,7 +111,7 @@ public class PacketEditingMessage
buf.writeUtf(pkt.entityInfo.customName); buf.writeUtf(pkt.entityInfo.customName);
} }
public static PacketEditingMessage decode(PacketBuffer buf) { public static PacketEditingMessage decode(FriendlyByteBuf buf) {
Type type = Type.valueOf(buf.readInt()); Type type = Type.valueOf(buf.readInt());
EntityInfo einfo = new EntityInfo(); EntityInfo einfo = new EntityInfo();
try { try {
@ -130,603 +135,10 @@ public class PacketEditingMessage
return new PacketEditingMessage(type, einfo); return new PacketEditingMessage(type, einfo);
} }
public static class Handler { public static void handle(final PacketEditingMessage pkt, Supplier<NetworkEvent.Context> ctx) {
public static void handle(final PacketEditingMessage pkt, Supplier<NetworkEvent.Context> ctx) { ctx.get().enqueueWork(() -> {
ctx.get().enqueueWork(() -> { DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
switch(pkt.type) });
{ ctx.get().setPacketHandled(true);
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);
}
} }
} }

View file

@ -4,12 +4,18 @@ import java.util.function.Supplier;
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod; import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.fml.network.NetworkEvent; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.network.NetworkEvent;
public class PacketGeneralMessage public class PacketGeneralMessage
{ {
String message; String message;
public String getMessage() {
return message;
}
public PacketGeneralMessage() public PacketGeneralMessage()
{ {
@ -21,20 +27,18 @@ public class PacketGeneralMessage
this.message = message; this.message = message;
} }
public static void encode(PacketGeneralMessage pkt, PacketBuffer buf) { public static void encode(PacketGeneralMessage pkt, FriendlyByteBuf buf) {
buf.writeUtf(pkt.message); buf.writeUtf(pkt.message);
} }
public static PacketGeneralMessage decode(PacketBuffer buf) { public static PacketGeneralMessage decode(FriendlyByteBuf buf) {
return new PacketGeneralMessage(buf.readUtf()); return new PacketGeneralMessage(buf.readUtf());
} }
public static class Handler { public static void handle(final PacketGeneralMessage pkt, Supplier<NetworkEvent.Context> ctx) {
public static void handle(final PacketGeneralMessage pkt, Supplier<NetworkEvent.Context> ctx) { ctx.get().enqueueWork(() -> {
ctx.get().enqueueWork(() -> { DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
TurnBasedMinecraftMod.proxy.displayString(pkt.message); });
}); ctx.get().setPacketHandled(true);
ctx.get().setPacketHandled(true);
}
} }
} }

View file

@ -6,7 +6,7 @@
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader="javafml" #mandatory modLoader="javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version # 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 # A URL to refer people to when problems occur with this mod
issueTrackerURL="https://github.com/Stephen-Seo/TurnBasedMinecraftMod/issues" #optional issueTrackerURL="https://github.com/Stephen-Seo/TurnBasedMinecraftMod/issues" #optional
license="MIT" license="MIT"
@ -15,7 +15,7 @@ license="MIT"
# The modid of the mod # The modid of the mod
modId="com_burnedkirby_turnbasedminecraft" #mandatory modId="com_burnedkirby_turnbasedminecraft" #mandatory
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
version="1.17.2" #mandatory version="1.18.0" #mandatory
# A display name for the mod # A display name for the mod
displayName="TurnBasedMinecraftMod" #mandatory displayName="TurnBasedMinecraftMod" #mandatory
# A URL to query for updates for this mod. See the JSON update specification <here> # A URL to query for updates for this mod. See the JSON update specification <here>
@ -39,7 +39,7 @@ Implements turn-based-battle in Minecraft.
# Does this dependency have to exist - if not, ordering below must be specified # Does this dependency have to exist - if not, ordering below must be specified
mandatory=true #mandatory mandatory=true #mandatory
# The version range of the dependency # The version range of the dependency
versionRange="[36,)" #mandatory versionRange="[40,)" #mandatory
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
ordering="NONE" ordering="NONE"
# Side this dependency is applied on - BOTH, CLIENT or SERVER # Side this dependency is applied on - BOTH, CLIENT or SERVER
@ -48,6 +48,6 @@ Implements turn-based-battle in Minecraft.
[[dependencies.com_burnedkirby_turnbasedminecraft]] [[dependencies.com_burnedkirby_turnbasedminecraft]]
modId="minecraft" modId="minecraft"
mandatory=true mandatory=true
versionRange="[1.16.5,1.17)" versionRange="[1.18.2,1.19)"
ordering="NONE" ordering="NONE"
side="BOTH" side="BOTH"

View file

@ -1,6 +1,6 @@
# Please do not change this option, the mod uses this to keep track of what new # Please do not change this option, the mod uses this to keep track of what new
# changes to add to the config. # changes to add to the config.
version = 6 version = 7
do_not_overwrite = false do_not_overwrite = false
[client_config] [client_config]
@ -98,7 +98,7 @@ creeper_always_allow_damage = true
# decision_flee_probability: Percentage of entity choosing to flee on turn. # decision_flee_probability: Percentage of entity choosing to flee on turn.
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.BlazeEntity" name = "net.minecraft.world.entity.monster.Blaze"
attack_power = 5 attack_power = 5
attack_probability = 50 attack_probability = 50
attack_effect = "fire" attack_effect = "fire"
@ -111,7 +111,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.CaveSpiderEntity" name = "net.minecraft.world.entity.monster.CaveSpider"
attack_power = 2 attack_power = 2
attack_probability = 75 attack_probability = 75
attack_effect = "poison" attack_effect = "poison"
@ -124,7 +124,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.CreeperEntity" name = "net.minecraft.world.entity.monster.Creeper"
ignore_battle = false ignore_battle = false
attack_power = 13 attack_power = 13
attack_probability = 95 attack_probability = 95
@ -137,7 +137,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.DrownedEntity" name = "net.minecraft.world.entity.monster.Drowned"
attack_power = 3 attack_power = 3
attack_probability = 70 attack_probability = 70
attack_variance = 2 attack_variance = 2
@ -149,7 +149,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.ElderGuardianEntity" name = "net.minecraft.world.entity.monster.ElderGuardian"
attack_power = 8 attack_power = 8
attack_probability = 65 attack_probability = 65
defense_damage = 2 defense_damage = 2
@ -162,7 +162,7 @@ decision_defend_probability = 20
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.EndermanEntity" name = "net.minecraft.world.entity.monster.EnderMan"
attack_power = 7 attack_power = 7
attack_probability = 80 attack_probability = 80
evasion = 40 evasion = 40
@ -173,7 +173,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.EndermiteEntity" name = "net.minecraft.world.entity.monster.Endermite"
attack_power = 2 attack_power = 2
attack_probability = 80 attack_probability = 80
evasion = 40 evasion = 40
@ -184,7 +184,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.EvokerEntity" name = "net.minecraft.world.entity.monster.Evoker"
attack_power = 6 attack_power = 6
attack_probability = 60 attack_probability = 60
evasion = 35 evasion = 35
@ -195,7 +195,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.GhastEntity" name = "net.minecraft.world.entity.monster.Ghast"
ignore_battle = true ignore_battle = true
attack_power = 13 attack_power = 13
attack_probability = 20 attack_probability = 20
@ -207,7 +207,7 @@ decision_defend_probability = 0
decision_flee_probability = 25 decision_flee_probability = 25
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.GiantEntity" name = "net.minecraft.world.entity.monster.Giant"
attack_power = 11 attack_power = 11
attack_probability = 35 attack_probability = 35
evasion = 2 evasion = 2
@ -218,7 +218,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.GuardianEntity" name = "net.minecraft.world.entity.monster.Guardian"
attack_power = 6 attack_power = 6
attack_probability = 55 attack_probability = 55
defense_damage = 2 defense_damage = 2
@ -231,7 +231,7 @@ decision_defend_probability = 20
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.HoglinEntity" name = "net.minecraft.world.entity.monster.hoglin.Hoglin"
attack_power = 6 attack_power = 6
attack_variance = 2 attack_variance = 2
attack_probability = 60 attack_probability = 60
@ -243,7 +243,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.HuskEntity" name = "net.minecraft.world.entity.monster.Husk"
attack_power = 3 attack_power = 3
attack_probability = 70 attack_probability = 70
attack_effect = "hunger" attack_effect = "hunger"
@ -256,7 +256,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.IllusionerEntity" name = "net.minecraft.world.entity.monster.Illusioner"
attack_power = 2 attack_power = 2
attack_probability = 70 attack_probability = 70
attack_variance = 2 attack_variance = 2
@ -268,7 +268,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.passive.IronGolemEntity" name = "net.minecraft.world.entity.animal.IronGolem"
attack_power = 14 attack_power = 14
attack_probability = 85 attack_probability = 85
attack_variance = 7 attack_variance = 7
@ -280,7 +280,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.MagmaCubeEntity" name = "net.minecraft.world.entity.monster.MagmaCube"
attack_power = 3 attack_power = 3
attack_probability = 35 attack_probability = 35
evasion = 12 evasion = 12
@ -291,7 +291,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.piglin.PiglinEntity" name = "net.minecraft.world.entity.monster.piglin.Piglin"
attack_power = 5 attack_power = 5
attack_variance = 2 attack_variance = 2
attack_probability = 70 attack_probability = 70
@ -303,7 +303,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.piglin.PiglinBruteEntity" name = "net.minecraft.world.entity.monster.piglin.PiglinBrute"
attack_power = 10 attack_power = 10
attack_variance = 2 attack_variance = 2
attack_probability = 75 attack_probability = 75
@ -315,7 +315,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.PhantomEntity" name = "net.minecraft.world.entity.monster.Phantom"
attack_power = 2 attack_power = 2
attack_probability = 90 attack_probability = 90
attack_variance = 1 attack_variance = 1
@ -327,7 +327,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.PillagerEntity" name = "net.minecraft.world.entity.monster.Pillager"
attack_power = 3 attack_power = 3
attack_probability = 60 attack_probability = 60
attack_variance = 1 attack_variance = 1
@ -339,7 +339,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.RavagerEntity" name = "net.minecraft.world.entity.monster.Ravager"
attack_power = 12 attack_power = 12
attack_probability = 70 attack_probability = 70
attack_variance = 4 attack_variance = 4
@ -351,7 +351,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.ShulkerEntity" name = "net.minecraft.world.entity.monster.Shulker"
attack_power = 4 attack_power = 4
attack_probability = 80 attack_probability = 80
evasion = 15 evasion = 15
@ -362,7 +362,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.SilverfishEntity" name = "net.minecraft.world.entity.monster.Silverfish"
attack_power = 1 attack_power = 1
attack_probability = 85 attack_probability = 85
evasion = 37 evasion = 37
@ -373,7 +373,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.SkeletonEntity" name = "net.minecraft.world.entity.monster.Skeleton"
attack_power = 3 attack_power = 3
attack_probability = 75 attack_probability = 75
attack_variance = 1 attack_variance = 1
@ -385,7 +385,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.SlimeEntity" name = "net.minecraft.world.entity.monster.Slime"
attack_power = 2 attack_power = 2
attack_probability = 35 attack_probability = 35
evasion = 10 evasion = 10
@ -396,7 +396,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.SpiderEntity" name = "net.minecraft.world.entity.monster.Spider"
attack_power = 2 attack_power = 2
attack_probability = 70 attack_probability = 70
evasion = 25 evasion = 25
@ -407,7 +407,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.StrayEntity" name = "net.minecraft.world.entity.monster.Stray"
attack_power = 3 attack_power = 3
attack_probability = 75 attack_probability = 75
attack_variance = 1 attack_variance = 1
@ -421,7 +421,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.VexEntity" name = "net.minecraft.world.entity.monster.Vex"
attack_power = 9 attack_power = 9
attack_probability = 65 attack_probability = 65
evasion = 30 evasion = 30
@ -432,7 +432,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.VindicatorEntity" name = "net.minecraft.world.entity.monster.Vindicator"
attack_power = 13 attack_power = 13
attack_probability = 70 attack_probability = 70
evasion = 10 evasion = 10
@ -443,7 +443,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.WitchEntity" name = "net.minecraft.world.entity.monster.Witch"
attack_power = 5 attack_power = 5
attack_probability = 75 attack_probability = 75
attack_variance = 1 attack_variance = 1
@ -455,7 +455,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.WitherSkeletonEntity" name = "net.minecraft.world.entity.monster.WitherSkeleton"
attack_power = 8 attack_power = 8
attack_probability = 70 attack_probability = 70
attack_effect = "wither" attack_effect = "wither"
@ -468,7 +468,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.ZoglinEntity" name = "net.minecraft.world.entity.monster.Zoglin"
attack_power = 6 attack_power = 6
attack_variance = 2 attack_variance = 2
attack_probability = 60 attack_probability = 60
@ -480,7 +480,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.ZombieEntity" name = "net.minecraft.world.entity.monster.Zombie"
attack_power = 3 attack_power = 3
attack_probability = 70 attack_probability = 70
evasion = 5 evasion = 5
@ -491,7 +491,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.ZombifiedPiglinEntity" name = "net.minecraft.world.entity.monster.ZombifiedPiglin"
attack_power = 8 attack_power = 8
attack_probability = 70 attack_probability = 70
evasion = 10 evasion = 10
@ -502,7 +502,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.monster.ZombieVillagerEntity" name = "net.minecraft.world.entity.monster.ZombieVillager"
attack_power = 3 attack_power = 3
attack_probability = 70 attack_probability = 70
evasion = 5 evasion = 5
@ -513,7 +513,18 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[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_power = 0
attack_probability = 70 attack_probability = 70
evasion = 35 evasion = 35
@ -524,7 +535,7 @@ decision_defend_probability = 0
decision_flee_probability = 90 decision_flee_probability = 90
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.passive.BeeEntity" name = "net.minecraft.world.entity.animal.Bee"
attack_power = 2 attack_power = 2
attack_probability = 65 attack_probability = 65
evasion = 30 evasion = 30
@ -537,107 +548,7 @@ attack_effect = "poison"
attack_effect_probability = 50 attack_effect_probability = 50
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.passive.ChickenEntity" name = "net.minecraft.world.entity.animal.Cat"
attack_power = 0
attack_probability = 70
evasion = 10
category = "passive"
speed = 35
decision_attack_probability = 0
decision_defend_probability = 0
decision_flee_probability = 90
[[server_config.entity]]
name = "net.minecraft.entity.passive.CowEntity"
attack_power = 0
attack_probability = 50
evasion = 1
category = "passive"
speed = 20
decision_attack_probability = 0
decision_defend_probability = 10
decision_flee_probability = 80
[[server_config.entity]]
name = "net.minecraft.entity.passive.DolphinEntity"
attack_power = 3
attack_probability = 80
attack_variance = 1
evasion = 45
category = "passive"
speed = 75
decision_attack_probability = 70
decision_defend_probability = 0
decision_flee_probability = 30
[[server_config.entity]]
name = "net.minecraft.entity.passive.FoxEntity"
attack_power = 2
attack_probability = 70
evasion = 65
category = "animal"
speed = 65
decision_attack_probability = 70
decision_defend_probability = 0
decision_flee_probability = 25
[[server_config.entity]]
name = "net.minecraft.entity.passive.horse.DonkeyEntity"
attack_power = 0
attack_probability = 70
evasion = 10
category = "passive"
speed = 65
decision_attack_probability = 0
decision_defend_probability = 0
decision_flee_probability = 90
[[server_config.entity]]
name = "net.minecraft.entity.passive.horse.HorseEntity"
attack_power = 0
attack_probability = 70
evasion = 10
category = "passive"
speed = 65
decision_attack_probability = 0
decision_defend_probability = 0
decision_flee_probability = 90
[[server_config.entity]]
name = "net.minecraft.entity.passive.horse.LlamaEntity"
attack_power = 1
attack_probability = 70
evasion = 10
category = "passive"
speed = 50
decision_attack_probability = 65
decision_defend_probability = 0
decision_flee_probability = 25
[[server_config.entity]]
name = "net.minecraft.entity.passive.MooshroomEntity"
attack_power = 0
attack_probability = 70
evasion = 1
category = "passive"
speed = 20
decision_attack_probability = 0
decision_defend_probability = 10
decision_flee_probability = 80
[[server_config.entity]]
name = "net.minecraft.entity.passive.horse.MuleEntity"
attack_power = 0
attack_probability = 70
evasion = 10
category = "passive"
speed = 50
decision_attack_probability = 0
decision_defend_probability = 0
decision_flee_probability = 90
[[server_config.entity]]
name = "net.minecraft.entity.passive.OcelotEntity"
attack_power = 1 attack_power = 1
attack_probability = 70 attack_probability = 70
attack_variance = 1 attack_variance = 1
@ -649,106 +560,85 @@ decision_defend_probability = 0
decision_flee_probability = 90 decision_flee_probability = 90
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.passive.PandaEntity" name = "net.minecraft.world.entity.animal.Chicken"
attack_power = 6 attack_power = 0
attack_probability = 60 attack_probability = 70
evasion = 10 evasion = 10
category = "passive" category = "passive"
speed = 30 speed = 35
decision_attack_probability = 45 decision_attack_probability = 0
decision_defend_probability = 25 decision_defend_probability = 0
decision_flee_probability = 90
[[server_config.entity]]
name = "net.minecraft.world.entity.animal.Cow"
attack_power = 0
attack_probability = 50
evasion = 1
category = "passive"
speed = 20
decision_attack_probability = 0
decision_defend_probability = 10
decision_flee_probability = 80
[[server_config.entity]]
name = "net.minecraft.world.entity.animal.Dolphin"
attack_power = 3
attack_probability = 80
attack_variance = 1
evasion = 45
category = "passive"
speed = 75
decision_attack_probability = 70
decision_defend_probability = 0
decision_flee_probability = 30 decision_flee_probability = 30
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.passive.ParrotEntity" name = "net.minecraft.world.entity.animal.Fox"
attack_power = 0 attack_power = 2
attack_probability = 70 attack_probability = 70
evasion = 35 evasion = 65
category = "passive" category = "animal"
speed = 70 speed = 65
decision_attack_probability = 0 decision_attack_probability = 70
decision_defend_probability = 0 decision_defend_probability = 0
decision_flee_probability = 90 decision_flee_probability = 25
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.passive.PigEntity" name = "net.minecraft.world.entity.animal.horse.Donkey"
attack_power = 0 attack_power = 0
attack_probability = 70 attack_probability = 70
evasion = 10 evasion = 10
category = "passive" category = "passive"
speed = 30
decision_attack_probability = 0
decision_defend_probability = 5
decision_flee_probability = 85
[[server_config.entity]]
name = "net.minecraft.entity.passive.PolarBearEntity"
attack_power = 6
attack_probability = 67
evasion = 5
category = "animal"
speed = 35
decision_attack_probability = 100
decision_defend_probability = 0
decision_flee_probability = 0
[[server_config.entity]]
name = "net.minecraft.entity.passive.RabbitEntity"
attack_power = 0
attack_probability = 70
evasion = 40
category = "passive"
speed = 75
decision_attack_probability = 0
decision_defend_probability = 0
decision_flee_probability = 100
[[server_config.entity]]
name = "net.minecraft.entity.passive.SheepEntity"
attack_power = 0
attack_probability = 70
evasion = 5
category = "passive"
speed = 30
decision_attack_probability = 0
decision_defend_probability = 0
decision_flee_probability = 90
[[server_config.entity]]
name = "net.minecraft.entity.passive.horse.SkeletonHorseEntity"
attack_power = 0
attack_probability = 70
evasion = 5
category = "passive"
speed = 65 speed = 65
decision_attack_probability = 0 decision_attack_probability = 0
decision_defend_probability = 0 decision_defend_probability = 0
decision_flee_probability = 90 decision_flee_probability = 90
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.passive.SnowGolemEntity" name = "net.minecraft.world.entity.animal.horse.Horse"
attack_power = 0
attack_probability = 80
evasion = 5
category = "passive"
speed = 60
decision_attack_probability = 100
decision_defend_probability = 0
decision_flee_probability = 0
[[server_config.entity]]
name = "net.minecraft.entity.passive.SquidEntity"
attack_power = 0 attack_power = 0
attack_probability = 70 attack_probability = 70
evasion = 15 evasion = 10
category = "passive" category = "passive"
speed = 40 speed = 65
decision_attack_probability = 0 decision_attack_probability = 0
decision_defend_probability = 0 decision_defend_probability = 0
decision_flee_probability = 90 decision_flee_probability = 90
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.passive.horse.TraderLlamaEntity" 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_power = 1
attack_probability = 70 attack_probability = 70
evasion = 10 evasion = 10
@ -759,7 +649,151 @@ decision_defend_probability = 0
decision_flee_probability = 25 decision_flee_probability = 25
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.merchant.villager.VillagerEntity" name = "net.minecraft.world.entity.animal.MushroomCow"
attack_power = 0
attack_probability = 70
evasion = 1
category = "passive"
speed = 20
decision_attack_probability = 0
decision_defend_probability = 10
decision_flee_probability = 80
[[server_config.entity]]
name = "net.minecraft.world.entity.animal.horse.Mule"
attack_power = 0
attack_probability = 70
evasion = 10
category = "passive"
speed = 50
decision_attack_probability = 0
decision_defend_probability = 0
decision_flee_probability = 90
[[server_config.entity]]
name = "net.minecraft.world.entity.animal.Ocelot"
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.Panda"
attack_power = 6
attack_probability = 60
evasion = 10
category = "passive"
speed = 30
decision_attack_probability = 45
decision_defend_probability = 25
decision_flee_probability = 30
[[server_config.entity]]
name = "net.minecraft.world.entity.animal.Parrot"
attack_power = 0
attack_probability = 70
evasion = 35
category = "passive"
speed = 70
decision_attack_probability = 0
decision_defend_probability = 0
decision_flee_probability = 90
[[server_config.entity]]
name = "net.minecraft.world.entity.animal.Pig"
attack_power = 0
attack_probability = 70
evasion = 10
category = "passive"
speed = 30
decision_attack_probability = 0
decision_defend_probability = 5
decision_flee_probability = 85
[[server_config.entity]]
name = "net.minecraft.world.entity.animal.PolarBear"
attack_power = 6
attack_probability = 67
evasion = 5
category = "animal"
speed = 35
decision_attack_probability = 100
decision_defend_probability = 0
decision_flee_probability = 0
[[server_config.entity]]
name = "net.minecraft.world.entity.animal.Rabbit"
attack_power = 0
attack_probability = 70
evasion = 40
category = "passive"
speed = 75
decision_attack_probability = 0
decision_defend_probability = 0
decision_flee_probability = 100
[[server_config.entity]]
name = "net.minecraft.world.entity.animal.Sheep"
attack_power = 0
attack_probability = 70
evasion = 5
category = "passive"
speed = 30
decision_attack_probability = 0
decision_defend_probability = 0
decision_flee_probability = 90
[[server_config.entity]]
name = "net.minecraft.world.entity.animal.horse.SkeletonHorse"
attack_power = 0
attack_probability = 70
evasion = 5
category = "passive"
speed = 65
decision_attack_probability = 0
decision_defend_probability = 0
decision_flee_probability = 90
[[server_config.entity]]
name = "net.minecraft.world.entity.animal.SnowGolem"
attack_power = 0
attack_probability = 80
evasion = 5
category = "passive"
speed = 60
decision_attack_probability = 100
decision_defend_probability = 0
decision_flee_probability = 0
[[server_config.entity]]
name = "net.minecraft.world.entity.animal.Squid"
attack_power = 0
attack_probability = 70
evasion = 15
category = "passive"
speed = 40
decision_attack_probability = 0
decision_defend_probability = 0
decision_flee_probability = 90
[[server_config.entity]]
name = "net.minecraft.world.entity.animal.horse.TraderLlama"
attack_power = 1
attack_probability = 70
evasion = 10
category = "passive"
speed = 50
decision_attack_probability = 65
decision_defend_probability = 0
decision_flee_probability = 25
[[server_config.entity]]
name = "net.minecraft.world.entity.npc.Villager"
attack_power = 0 attack_power = 0
attack_probability = 70 attack_probability = 70
evasion = 5 evasion = 5
@ -770,7 +804,7 @@ decision_defend_probability = 10
decision_flee_probability = 80 decision_flee_probability = 80
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.passive.WolfEntity" name = "net.minecraft.world.entity.animal.Wolf"
attack_power = 4 attack_power = 4
attack_probability = 70 attack_probability = 70
evasion = 20 evasion = 20
@ -781,7 +815,7 @@ decision_defend_probability = 15
decision_flee_probability = 5 decision_flee_probability = 5
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.passive.horse.ZombieHorseEntity" name = "net.minecraft.world.entity.animal.horse.ZombieHorse"
attack_power = 0 attack_power = 0
attack_probability = 70 attack_probability = 70
evasion = 8 evasion = 8
@ -792,7 +826,7 @@ decision_defend_probability = 0
decision_flee_probability = 90 decision_flee_probability = 90
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.passive.fish.CodEntity" name = "net.minecraft.world.entity.animal.Cod"
attack_power = 0 attack_power = 0
attack_probability = 50 attack_probability = 50
evasion = 50 evasion = 50
@ -803,7 +837,7 @@ decision_defend_probability = 0
decision_flee_probability = 75 decision_flee_probability = 75
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.passive.fish.PufferfishEntity" name = "net.minecraft.world.entity.animal.Pufferfish"
attack_power = 0 attack_power = 0
attack_probability = 50 attack_probability = 50
defense_damage = 3 defense_damage = 3
@ -816,7 +850,7 @@ decision_defend_probability = 0
decision_flee_probability = 65 decision_flee_probability = 65
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.passive.fish.SalmonEntity" name = "net.minecraft.world.entity.animal.Salmon"
attack_power = 0 attack_power = 0
attack_probability = 50 attack_probability = 50
evasion = 50 evasion = 50
@ -827,7 +861,7 @@ decision_defend_probability = 0
decision_flee_probability = 75 decision_flee_probability = 75
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.passive.StriderEntity" name = "net.minecraft.world.entity.monster.Strider"
attack_power = 0 attack_power = 0
attack_probability = 50 attack_probability = 50
evasion = 35 evasion = 35
@ -838,7 +872,7 @@ decision_defend_probability = 10
decision_flee_probability = 90 decision_flee_probability = 90
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.passive.fish.TropicalFishEntity" name = "net.minecraft.world.entity.animal.TropicalFish"
attack_power = 0 attack_power = 0
attack_probability = 50 attack_probability = 50
evasion = 50 evasion = 50
@ -849,7 +883,7 @@ decision_defend_probability = 0
decision_flee_probability = 75 decision_flee_probability = 75
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.passive.TurtleEntity" name = "net.minecraft.world.entity.animal.Turtle"
attack_power = 0 attack_power = 0
attack_probability = 20 attack_probability = 20
evasion = 35 evasion = 35
@ -860,7 +894,7 @@ decision_defend_probability = 40
decision_flee_probability = 60 decision_flee_probability = 60
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.merchant.villager.WanderingTraderEntity" name = "net.minecraft.world.entity.npc.WanderingTrader"
attack_power = 0 attack_power = 0
attack_probability = 70 attack_probability = 70
evasion = 5 evasion = 5
@ -871,7 +905,7 @@ decision_defend_probability = 10
decision_flee_probability = 80 decision_flee_probability = 80
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.boss.dragon.EnderDragonEntity" name = "net.minecraft.world.entity.boss.enderdragon.EnderDragon"
attack_power = 10 attack_power = 10
attack_probability = 70 attack_probability = 70
attack_variance = 2 attack_variance = 2
@ -883,7 +917,7 @@ decision_defend_probability = 0
decision_flee_probability = 0 decision_flee_probability = 0
[[server_config.entity]] [[server_config.entity]]
name = "net.minecraft.entity.boss.WitherEntity" name = "net.minecraft.world.entity.boss.wither.WitherBoss"
attack_power = 8 attack_power = 8
attack_probability = 70 attack_probability = 70
attack_effect = "wither" attack_effect = "wither"

View file

@ -3,8 +3,8 @@
"modid": "com_burnedkirby_turnbasedminecraft", "modid": "com_burnedkirby_turnbasedminecraft",
"name": "Turn Based Minecraft", "name": "Turn Based Minecraft",
"description": "Changes battles to be turn-based.", "description": "Changes battles to be turn-based.",
"version": "1.17.2", "version": "1.18.0",
"mcversion": "1.16.3", "mcversion": "1.18.2",
"url": "", "url": "",
"updateUrl": "", "updateUrl": "",
"authorList": ["Stephen Seo"], "authorList": ["Stephen Seo"],