Compare commits
119 commits
neoforge
...
forge-1.26
Author | SHA1 | Date | |
---|---|---|---|
3aa144fd57 | |||
861574992d | |||
9eac13c79f | |||
4c3739a111 | |||
0222cef6f7 | |||
7d94919286 | |||
5612dde11a | |||
a9df1e3c4d | |||
be78ddc1b6 | |||
42c69e8983 | |||
2572190b07 | |||
2d52e898f4 | |||
b13695d096 | |||
95333b799a | |||
ce72e80cb8 | |||
00f13aba72 | |||
3749aa9308 | |||
48983caf2c | |||
f50f412fd4 | |||
fde09d116d | |||
4c0872b7ad | |||
c1109245e4 | |||
780f2e89ad | |||
150c869dfb | |||
4ff1bafd91 | |||
f5af4c9bdf | |||
36b6673d69 | |||
991406b45b | |||
06ff3fb5ae | |||
ff6b4747ac | |||
4c969a4654 | |||
ecf981fb0c | |||
cf8df83b49 | |||
1b585b4377 | |||
b676a00c1c | |||
252b3a5272 | |||
8e469f1a8a | |||
02f7b179a5 | |||
c65f9bde1c | |||
504329fa88 | |||
8e646cb814 | |||
e6501e4fe3 | |||
4652ecf20e | |||
d5308986e9 | |||
7347437567 | |||
046e6c92bf | |||
f5cc024f2e | |||
7d8c63ea4d | |||
cebc42ff37 | |||
d006474932 | |||
1d12e8c3a7 | |||
e9019245dc | |||
6fb10c6ce1 | |||
dd30766732 | |||
a3a413f5d6 | |||
cbfd354919 | |||
524df98c22 | |||
20fe64ed61 | |||
5372e7a25a | |||
c07828f411 | |||
eef8433df4 | |||
b763720989 | |||
5c59c73332 | |||
f18cd91560 | |||
d57a75d3b2 | |||
fb7d4e39de | |||
71e3796694 | |||
c066e10762 | |||
971c56c69b | |||
b20f8314d0 | |||
e1e462cb6d | |||
84006554e8 | |||
a20d0e0ccb | |||
6815276eef | |||
8476b9b19c | |||
458aeaaf07 | |||
530fdadc07 | |||
be99607226 | |||
00c6ec12a4 | |||
5dda78f3a5 | |||
ae18f2686e | |||
6c3aa48923 | |||
05ab18b572 | |||
768844b05f | |||
c0879e120c | |||
039f27cbc1 | |||
ad78063a16 | |||
4c2bc47007 | |||
be19ce8748 | |||
3a6d800745 | |||
56a9db15ad | |||
18076715e0 | |||
8551aae80b | |||
cc7ef71384 | |||
6d8384ce04 | |||
0d0c0ca08c | |||
74291dde8f | |||
f687dfdaf3 | |||
6e8d3a8d5a | |||
47a2eb9c74 | |||
9680fdb24b | |||
398e8a9218 | |||
c4a8664297 | |||
9daf5c139f | |||
5168f8b346 | |||
304c739a25 | |||
0d8699c420 | |||
8ee3c99846 | |||
e5beef7c98 | |||
56353462f7 | |||
da17601477 | |||
5d905ac55e | |||
d7e35cbf5a | |||
132d16b2bd | |||
24247eab7b | |||
dc7d621d5c | |||
fc34310cbe | |||
601d5bc15d | |||
62576a06c6 |
42 changed files with 984 additions and 1096 deletions
|
@ -23,9 +23,9 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- run: git clone --depth=1 --no-single-branch https://git.seodisparate.com/stephenseo/TurnBasedMinecraftMod.git TurnBasedMinecraftMod
|
- run: git clone --depth=1 --no-single-branch https://git.seodisparate.com/stephenseo/TurnBasedMinecraftMod.git TurnBasedMinecraftMod
|
||||||
- run: cd TurnBasedMinecraftMod && git checkout ${GITHUB_REF_NAME}
|
- run: cd TurnBasedMinecraftMod && git checkout ${GITHUB_REF_NAME}
|
||||||
- run: cd TurnBasedMinecraftMod && sed -i '/org.gradle.jvmargs/s/Xmx[0-9]\+[mMgG]/Xmx1024m/' gradle.properties && echo 'neogradle.subsystems.decompiler.maxThreads=1' >> gradle.properties
|
- run: cd TurnBasedMinecraftMod && sed -i '/org.gradle.jvmargs/s/Xmx[0-9]\+[mMgG]/Xmx1024m/' gradle.properties
|
||||||
- run: cd TurnBasedMinecraftMod && ./gradlew --console=plain build
|
- run: cd TurnBasedMinecraftMod && ./gradlew --console=plain build
|
||||||
- run: cd TurnBasedMinecraftMod/build/libs && find . -type f -regex '.*all.jar$' -exec sha256sum '{}' ';' -exec bash -c 'sha256sum {} >> sha256sums.txt' ';' && java --version >> javaVersion.txt && javac --version >> javaVersion.txt
|
- run: cd TurnBasedMinecraftMod/build/libs && find . -regex '.*all.jar$' -exec sha256sum '{}' ';' -exec bash -c 'sha256sum {} >> sha256sums.txt' ';' && java --version >> javaVersion.txt && javac --version >> javaVersion.txt
|
||||||
- name: Create release and attach jar
|
- name: Create release and attach jar
|
||||||
run: |
|
run: |
|
||||||
curl --fail-with-body -X 'POST' \
|
curl --fail-with-body -X 'POST' \
|
||||||
|
@ -35,7 +35,7 @@ jobs:
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
-d "{
|
-d "{
|
||||||
\"name\": \"TurnBasedMinecraftMod version ${GITHUB_REF_NAME}\",
|
\"name\": \"TurnBasedMinecraftMod version ${GITHUB_REF_NAME}\",
|
||||||
\"body\": \"See the [Changelog](https://git.seodisparate.com/stephenseo/TurnBasedMinecraftMod/src/branch/neoforge/Changelog.md)
|
\"body\": \"See the [Changelog](https://git.seodisparate.com/stephenseo/TurnBasedMinecraftMod/src/branch/forge/Changelog.md)
|
||||||
|
|
||||||
$(java --version | sed -n '1p;2,$s/^/ /p')
|
$(java --version | sed -n '1p;2,$s/^/ /p')
|
||||||
$(javac --version)
|
$(javac --version)
|
||||||
|
|
16
FAQ.md
16
FAQ.md
|
@ -41,16 +41,17 @@ work.
|
||||||
## How do I configure battle music?
|
## How do I configure battle music?
|
||||||
|
|
||||||
There is a way to edit client-config that deals with music settings, like what
|
There is a way to edit client-config that deals with music settings, like what
|
||||||
mob groups trigger battle/silly music and volume. This menu can be opened in two
|
mob groups trigger battle/silly music and volume. This menu can be opened in one
|
||||||
ways.
|
way.
|
||||||
|
|
||||||
- Run the command `/tbm-client-edit` to open the menu.
|
- Run the command `/tbm-client-edit` to open the menu.
|
||||||
- Open the Mod list from the options screen, click on TBMM on the left column
|
|
||||||
and click on "Config". (Note that this way of opening the client-config-gui
|
|
||||||
is unavailable on Forge, and is only available on NeoForge.)
|
|
||||||
|
|
||||||
Note that "Accept" must be clicked on to save the client-config.
|
Note that "Accept" must be clicked on to save the client-config.
|
||||||
|
|
||||||
|
Note that the NeoForge version of this mod can access this menu through the mod
|
||||||
|
list GUI. Minecraft Forge currently does not have this capability, so it can be
|
||||||
|
only accessed via the command.
|
||||||
|
|
||||||
## Why do passive mobs don't start turn-based battle?
|
## Why do passive mobs don't start turn-based battle?
|
||||||
|
|
||||||
By default, the `passive` category is set to "ignore turn-based-battle" in the
|
By default, the `passive` category is set to "ignore turn-based-battle" in the
|
||||||
|
@ -79,11 +80,6 @@ command](https://youtu.be/9xkbHNWkcIY).
|
||||||
|
|
||||||
## I updated the mod, but now my config changes are back to default, what happened?
|
## I updated the mod, but now my config changes are back to default, what happened?
|
||||||
|
|
||||||
*As of Version 1.26.5 and onwards, this should happen less often!*
|
|
||||||
Version 1.26.5 introduces more robust config updating such that entries that
|
|
||||||
exist in the default config, but not in the current config will be appended to
|
|
||||||
the current config.
|
|
||||||
|
|
||||||
Sometimes, I add new mob entries to the config, and increment the version
|
Sometimes, I add new mob entries to the config, and increment the version
|
||||||
number of the config. When the server/client starts, it checks the default
|
number of the config. When the server/client starts, it checks the default
|
||||||
config's version number with the existing config's version number. If the
|
config's version number with the existing config's version number. If the
|
||||||
|
|
25
README.md
25
README.md
|
@ -23,7 +23,7 @@ The `neoforge` branch tracks the version of the mod for Minecraft NeoForge.
|
||||||
|
|
||||||
# What changed in what version
|
# What changed in what version
|
||||||
|
|
||||||
See the [Changelog](https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/neoforge/Changelog.md)
|
See the [Changelog](https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/forge/Changelog.md)
|
||||||
|
|
||||||
# Things you may need to know about this mod
|
# Things you may need to know about this mod
|
||||||
|
|
||||||
|
@ -36,18 +36,13 @@ The config file `.minecraft/config/TurnBasedMinecraft/TBM_Config.toml` is commen
|
||||||
with info on what each option does. ~~It will also be moved if a newer version
|
with info on what each option does. ~~It will also be moved if a newer version
|
||||||
of this mod has a newer version of the config file (usually renamed with a
|
of this mod has a newer version of the config file (usually renamed with a
|
||||||
timestamp).~~ ~~I will try my best to not move the previous version config, but rather
|
timestamp).~~ ~~I will try my best to not move the previous version config, but rather
|
||||||
edit the previous version config to have new options.~~ ~~When a new config version is made,
|
edit the previous version config to have new options.~~ When a new config version is made,
|
||||||
usually because a new entry has been added, the existing config is renamed to a file with
|
usually because a new entry has been added, the existing config is renamed to a file with
|
||||||
a timestamp in the filename of when it was replaced. One can set a config option in the
|
a timestamp in the filename of when it was replaced. One can set a config option in the
|
||||||
config to prevent it being overwritten if necessary.~~
|
config to prevent it being overwritten if necessary.
|
||||||
|
|
||||||
*As of version 1.26.5 of this mod, this should happen less frequently!*
|
Some options in the config file only affect the Server, and ~~some only affect the Client.~~
|
||||||
Version 1.26.5 introduces changes that allow entries that exist in the default
|
[Client-config can only be opened with `/tbm-client-edit`.](https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/forge/FAQ.md#how-do-i-configure-battle-music)
|
||||||
config but not in the current config to be appended in the current config.
|
|
||||||
|
|
||||||
Some options in the config file only affect the Server, and ~~some only affect the Client~~.
|
|
||||||
Client config has been moved to a
|
|
||||||
[separate system provided by NeoForge](https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/neoforge/FAQ.md#how-do-i-configure-battle-music).
|
|
||||||
When playing multiplayer, some configuration of the config on the server may be needed.
|
When playing multiplayer, some configuration of the config on the server may be needed.
|
||||||
|
|
||||||
# Features
|
# Features
|
||||||
|
@ -82,7 +77,7 @@ configured for them.)
|
||||||
|
|
||||||
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
|
finished jar will be saved at
|
||||||
`build/libs/TurnBasedMinecraft-NeoForge-1.26.5-all.jar`
|
`build/libs/TurnBasedMinecraft-Forge-1.26.5-all.jar`
|
||||||
|
|
||||||
# Reproducibility
|
# Reproducibility
|
||||||
|
|
||||||
|
@ -91,16 +86,16 @@ more details.
|
||||||
|
|
||||||
# Other notes
|
# Other notes
|
||||||
|
|
||||||
This mod uses [j-ogg-vorbis](https://github.com/stephengold/j-ogg-all)
|
This mod uses [j-ogg-vorbis](https://github.com/stephengold/j-ogg-all) available
|
||||||
available from [http://www.j-ogg.de](http://www.j-ogg.de) and copyrighted by
|
from [http://www.j-ogg.de](http://www.j-ogg.de) and copyrighted by Tor-Einar
|
||||||
Tor-Einar Jarnbjo.
|
Jarnbjo.
|
||||||
|
|
||||||
This mod also uses [JavaMP3](https://github.com/kevinstadler/JavaMP3)
|
This mod also uses [JavaMP3](https://github.com/kevinstadler/JavaMP3)
|
||||||
which is licensed under the [MIT License](https://github.com/kevinstadler/JavaMP3/blob/master/LICENSE).
|
which is licensed under the [MIT License](https://github.com/kevinstadler/JavaMP3/blob/master/LICENSE).
|
||||||
|
|
||||||
# Frequently Asked Questions
|
# Frequently Asked Questions
|
||||||
|
|
||||||
[See the FAQ page.](https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/neoforge/FAQ.md)
|
[See the FAQ page.](https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/forge/FAQ.md)
|
||||||
|
|
||||||
# Related Videos
|
# Related Videos
|
||||||
|
|
||||||
|
|
|
@ -4,45 +4,6 @@ Starting with version 1.24.0 of this mod, this file will list what version of
|
||||||
Java was used to compile the jars. In theory, using the same version of Java
|
Java was used to compile the jars. In theory, using the same version of Java
|
||||||
should result in an identical jar due to reproducible builds.
|
should result in an identical jar due to reproducible builds.
|
||||||
|
|
||||||
## NeoForge 1.26.5
|
|
||||||
|
|
||||||
$ java --version
|
|
||||||
openjdk 21.0.5 2024-10-15
|
|
||||||
OpenJDK Runtime Environment (build 21.0.5+11)
|
|
||||||
OpenJDK 64-Bit Server VM (build 21.0.5+11, mixed mode, sharing)
|
|
||||||
|
|
||||||
$ javac --version
|
|
||||||
javac 21.0.5
|
|
||||||
|
|
||||||
$ sha256sum build/libs/TurnBasedMinecraft-NeoForge-1.26.5-all.jar
|
|
||||||
b02d0abf6f2fbc5c3b718b548309efacb159ec8f86c7d2d653fc0b73234e761a build/libs/TurnBasedMinecraft-NeoForge-1.26.5-all.jar
|
|
||||||
|
|
||||||
## NeoForge 1.26.5-MC-1.21.1
|
|
||||||
|
|
||||||
$ java --version
|
|
||||||
openjdk 21.0.5 2024-10-15
|
|
||||||
OpenJDK Runtime Environment (build 21.0.5+11)
|
|
||||||
OpenJDK 64-Bit Server VM (build 21.0.5+11, mixed mode, sharing)
|
|
||||||
|
|
||||||
$ javac --version
|
|
||||||
javac 21.0.5
|
|
||||||
|
|
||||||
$ sha256sum build/libs/TurnBasedMinecraft-NeoForge-1.26.5-MC-1.21.1-all.jar
|
|
||||||
c529ebe3dd48608afd27e3393b201036ce84d3be0a850cdf48039fbc4820629e build/libs/TurnBasedMinecraft-NeoForge-1.26.5-MC-1.21.1-all.jar
|
|
||||||
|
|
||||||
## Forge 1.26.5
|
|
||||||
|
|
||||||
$ java --version
|
|
||||||
openjdk 21.0.5 2024-10-15
|
|
||||||
OpenJDK Runtime Environment (build 21.0.5+11)
|
|
||||||
OpenJDK 64-Bit Server VM (build 21.0.5+11, mixed mode, sharing)
|
|
||||||
|
|
||||||
$ javac --version
|
|
||||||
javac 21.0.5
|
|
||||||
|
|
||||||
$ sha256sum build/libs/TurnBasedMinecraft-Forge-1.26.5-all.jar
|
|
||||||
c8ed6e2e9a433c40901d41ec604bc6260fc5b231f5d3859832ecbe76b0f5a9e2 build/libs/TurnBasedMinecraft-Forge-1.26.5-all.jar
|
|
||||||
|
|
||||||
## NeoForge 1.26.4
|
## NeoForge 1.26.4
|
||||||
|
|
||||||
$ java --version
|
$ java --version
|
||||||
|
|
265
build.gradle
265
build.gradle
|
@ -1,106 +1,108 @@
|
||||||
plugins {
|
plugins {
|
||||||
id 'java-library'
|
id 'eclipse'
|
||||||
|
id 'idea'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
id 'net.neoforged.moddev' version '1.0.21'
|
id 'net.minecraftforge.gradle' version '[6.0.24,6.2)'
|
||||||
}
|
|
||||||
|
|
||||||
tasks.named('wrapper', Wrapper).configure {
|
|
||||||
// Define wrapper values here so as to not have to always do so when updating gradlew.properties.
|
|
||||||
// Switching this to Wrapper.DistributionType.ALL will download the full gradle sources that comes with
|
|
||||||
// documentation attached on cursor hover of gradle classes and methods. However, this comes with increased
|
|
||||||
// file size for Gradle. If you do switch this to ALL, run the Gradle wrapper task twice afterwards.
|
|
||||||
// (Verify by checking gradle/wrapper/gradle-wrapper.properties to see if distributionUrl now points to `-all`)
|
|
||||||
distributionType = Wrapper.DistributionType.BIN
|
|
||||||
}
|
}
|
||||||
|
|
||||||
version = mod_version
|
version = mod_version
|
||||||
group = mod_group_id
|
group = mod_group_id
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
|
|
||||||
flatDir {
|
|
||||||
dir 'libs'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
base {
|
base {
|
||||||
archivesName = "TurnBasedMinecraft-NeoForge"
|
archivesName = "TurnBasedMinecraft-Forge"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mojang ships Java 21 to end users starting in 1.20.5, so mods should target Java 21.
|
// Mojang ships Java 21 to end users in 1.20.5+, so your mod should target Java 21.
|
||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
|
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
|
||||||
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'}"
|
||||||
|
|
||||||
neoForge {
|
jarJar.enable()
|
||||||
// Specify the version of NeoForge to use.
|
|
||||||
version = project.neo_version
|
|
||||||
|
|
||||||
parchment {
|
minecraft {
|
||||||
mappingsVersion = project.parchment_mappings_version
|
// The mappings can be changed at any time and must be in the following format.
|
||||||
minecraftVersion = project.parchment_minecraft_version
|
// Channel: Version:
|
||||||
}
|
// official MCVersion Official field/method names from Mojang mapping files
|
||||||
|
// parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official
|
||||||
|
//
|
||||||
|
// You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
|
||||||
|
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
|
||||||
|
//
|
||||||
|
// Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
|
||||||
|
// Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started
|
||||||
|
//
|
||||||
|
// Use non-default mappings at your own risk. They may not always work.
|
||||||
|
// Simply re-run your setup task after changing the mappings to update your workspace.
|
||||||
|
mappings channel: mapping_channel, version: mapping_version
|
||||||
|
|
||||||
// This line is optional. Access Transformers are automatically detected
|
// Tell FG to not automtically create the reobf tasks, as we now use Official mappings at runtime, If you don't use them at dev time then you'll have to fix your reobf yourself.
|
||||||
// accessTransformers = project.files('src/main/resources/META-INF/accesstransformer.cfg')
|
reobf = false
|
||||||
|
|
||||||
|
// When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game.
|
||||||
|
// In most cases, it is not necessary to enable.
|
||||||
|
// enableEclipsePrepareRuns = true
|
||||||
|
// enableIdeaPrepareRuns = true
|
||||||
|
|
||||||
|
// This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
|
||||||
|
// It is REQUIRED to be set to true for this template to function.
|
||||||
|
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
|
||||||
|
copyIdeResources = true
|
||||||
|
|
||||||
|
// When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
|
||||||
|
// The folder name can be set on a run configuration using the "folderName" property.
|
||||||
|
// By default, the folder name of a run configuration is the name of the Gradle project containing it.
|
||||||
|
// generateRunFolders = true
|
||||||
|
|
||||||
|
// This property enables access transformers for use in development.
|
||||||
|
// They will be applied to the Minecraft artifact.
|
||||||
|
// The access transformer file can be anywhere in the project.
|
||||||
|
// However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge.
|
||||||
|
// This default location is a best practice to automatically put the file in the right place in the final jar.
|
||||||
|
// See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information.
|
||||||
|
// 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 {
|
// applies to all the run configs below
|
||||||
client()
|
configureEach {
|
||||||
|
workingDirectory project.file('run')
|
||||||
|
|
||||||
|
// Recommended logging data for a userdev environment
|
||||||
|
// The markers can be added/remove as needed separated by commas.
|
||||||
|
// "SCAN": For mods scan.
|
||||||
|
// "REGISTRIES": For firing of registry events.
|
||||||
|
// "REGISTRYDUMP": For getting the contents of all registries.
|
||||||
|
property 'forge.logging.markers', 'REGISTRIES'
|
||||||
|
|
||||||
|
// Recommended logging level for the console
|
||||||
|
// You can set various levels here.
|
||||||
|
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
|
||||||
|
property 'forge.logging.console.level', 'debug'
|
||||||
|
}
|
||||||
|
|
||||||
|
client {
|
||||||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
||||||
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
|
property 'forge.enabledGameTestNamespaces', mod_id
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
server()
|
property 'forge.enabledGameTestNamespaces', mod_id
|
||||||
programArgument '--nogui'
|
args '--nogui'
|
||||||
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This run config launches GameTestServer and runs all registered gametests, then exits.
|
// This run config launches GameTestServer and runs all registered gametests, then exits.
|
||||||
// By default, the server will crash when no gametests are provided.
|
// 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.
|
// The gametest system is also enabled by default for other run configs under the /test command.
|
||||||
gameTestServer {
|
gameTestServer {
|
||||||
type = "gameTestServer"
|
property 'forge.enabledGameTestNamespaces', mod_id
|
||||||
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data {
|
data {
|
||||||
data()
|
// example of overriding the workingDirectory set in configureEach above
|
||||||
|
workingDirectory project.file('run-data')
|
||||||
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
|
|
||||||
// gameDirectory = project.file('run-data')
|
|
||||||
|
|
||||||
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
|
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
|
||||||
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
|
args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
|
||||||
}
|
|
||||||
|
|
||||||
// applies to all the run configs above
|
|
||||||
configureEach {
|
|
||||||
// Recommended logging data for a userdev environment
|
|
||||||
// The markers can be added/remove as needed separated by commas.
|
|
||||||
// "SCAN": For mods scan.
|
|
||||||
// "REGISTRIES": For firing of registry events.
|
|
||||||
// "REGISTRYDUMP": For getting the contents of all registries.
|
|
||||||
systemProperty 'forge.logging.markers', 'REGISTRIES'
|
|
||||||
|
|
||||||
// Recommended logging level for the console
|
|
||||||
// You can set various levels here.
|
|
||||||
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
|
|
||||||
logLevel = org.slf4j.event.Level.DEBUG
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mods {
|
|
||||||
// define mod <-> source bindings
|
|
||||||
// these are used to tell the game which sources are for which mod
|
|
||||||
// mostly optional in a single mod project
|
|
||||||
// but multi mod projects should define one per mod
|
|
||||||
"${mod_id}" {
|
|
||||||
sourceSet(sourceSets.main)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,102 +110,88 @@ neoForge {
|
||||||
// Include resources generated by data generators.
|
// Include resources generated by data generators.
|
||||||
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||||
|
|
||||||
// Sets up a dependency configuration called 'localRuntime'.
|
repositories {
|
||||||
// This configuration should be used instead of 'runtimeOnly' to declare
|
// Put repositories for dependencies here
|
||||||
// a dependency that will be present for runtime testing but that is
|
// ForgeGradle automatically adds the Forge maven and Maven Central for you
|
||||||
// "optional", meaning it will not be pulled by dependents of this mod.
|
|
||||||
configurations {
|
flatDir {
|
||||||
runtimeClasspath.extendsFrom localRuntime
|
dir 'libs'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// Example optional mod dependency with JEI
|
// Specify the version of Minecraft to use.
|
||||||
|
// Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact.
|
||||||
|
// The "userdev" classifier will be requested and setup by ForgeGradle.
|
||||||
|
// If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
|
||||||
|
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
|
||||||
|
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||||
|
|
||||||
|
// Example mod dependency with JEI
|
||||||
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
|
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
|
||||||
// compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
|
// compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
|
||||||
// compileOnly "mezz.jei:jei-${mc_version}-neoforge-api:${jei_version}"
|
// compileOnly "mezz.jei:jei-${mc_version}-forge-api:${jei_version}"
|
||||||
// We add the full version to localRuntime, not runtimeOnly, so that we do not publish a dependency on it
|
// runtimeOnly "mezz.jei:jei-${mc_version}-forge:${jei_version}"
|
||||||
// localRuntime "mezz.jei:jei-${mc_version}-neoforge:${jei_version}"
|
|
||||||
|
|
||||||
// Example mod dependency using a mod jar from ./libs with a flat dir repository
|
// Example mod dependency using a mod jar from ./libs with a flat dir repository
|
||||||
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
|
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
|
||||||
// The group id is ignored when searching -- in this case, it is "blank"
|
// The group id is ignored when searching -- in this case, it is "blank"
|
||||||
// implementation "blank:coolmod-${mc_version}:${coolmod_version}"
|
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
|
||||||
|
|
||||||
// Example mod dependency using a file as dependency
|
|
||||||
// implementation files("libs/coolmod-${mc_version}-${coolmod_version}.jar")
|
|
||||||
|
|
||||||
// Example project dependency using a sister or child project:
|
|
||||||
// implementation project(":myproject")
|
|
||||||
|
|
||||||
// For more info:
|
// For more info:
|
||||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
||||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
||||||
|
|
||||||
|
// Hack fix for now, force jopt-simple to be exactly 5.0.4 because Mojang ships that version, but some transitive dependencies request 6.0+
|
||||||
|
implementation('net.sf.jopt-simple:jopt-simple:5.0.4') { version { strictly '5.0.4' } }
|
||||||
|
|
||||||
// implementation "net.neoforged:neoforge:${neo_version}"
|
|
||||||
|
|
||||||
// implementation files('libs/javamp3-1.0.3.jar')
|
|
||||||
implementation 'fr.delthas:javamp3:1.0.3'
|
implementation 'fr.delthas:javamp3:1.0.3'
|
||||||
|
|
||||||
implementation 'com.github.stephengold:j-ogg-vorbis:1.0.4'
|
implementation 'com.github.stephengold:j-ogg-vorbis:1.0.4'
|
||||||
|
|
||||||
jarJar(implementation("fr.delthas:javamp3")) {
|
jarJar(group: 'fr.delthas', name: 'javamp3', version: '[1.0.0,2.0.0)') {
|
||||||
version {
|
jarJar.pin(it, '1.0.3')
|
||||||
strictly '[1.0.0,2.0.0)'
|
|
||||||
prefer '1.0.3'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jarJar(implementation("com.github.stephengold:j-ogg-vorbis")) {
|
jarJar(group: 'com.github.stephengold', name: 'j-ogg-vorbis', version: '[1.0.4, 2.0.0)') {
|
||||||
version {
|
jarJar.pin(it, '1.0.4')
|
||||||
strictly '[1.0.4,2.0.0)'
|
|
||||||
prefer '1.0.4'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This block of code expands all declared replace properties in the specified resource targets.
|
// This block of code expands all declared replace properties in the specified resource targets.
|
||||||
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
|
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
|
||||||
var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) {
|
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
|
||||||
|
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
|
||||||
|
tasks.named('processResources', ProcessResources).configure {
|
||||||
var replaceProperties = [
|
var replaceProperties = [
|
||||||
minecraft_version : minecraft_version,
|
minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
|
||||||
minecraft_version_range: minecraft_version_range,
|
forge_version: forge_version, forge_version_range: forge_version_range,
|
||||||
neo_version : neo_version,
|
|
||||||
neo_version_range : neo_version_range,
|
|
||||||
loader_version_range: loader_version_range,
|
loader_version_range: loader_version_range,
|
||||||
mod_id : mod_id,
|
mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
|
||||||
mod_name : mod_name,
|
mod_authors: mod_authors, mod_description: mod_description,
|
||||||
mod_license : mod_license,
|
|
||||||
mod_version : mod_version,
|
|
||||||
mod_authors : mod_authors,
|
|
||||||
mod_description : mod_description
|
|
||||||
]
|
]
|
||||||
inputs.properties replaceProperties
|
inputs.properties replaceProperties
|
||||||
expand replaceProperties
|
|
||||||
from "src/main/templates"
|
|
||||||
into "build/generated/sources/modMetadata"
|
|
||||||
}
|
|
||||||
// Include the output of "generateModMetadata" as an input directory for the build
|
|
||||||
// this works with both building through Gradle and the IDE.
|
|
||||||
sourceSets.main.resources.srcDir generateModMetadata
|
|
||||||
// To avoid having to run "generateModMetadata" manually, make it run on every project reload
|
|
||||||
neoForge.ideSyncTask generateModMetadata
|
|
||||||
|
|
||||||
// Example for how to get properties into the manifest for reading by the runtime..
|
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
|
||||||
jar {
|
expand replaceProperties + [project: project]
|
||||||
archiveClassifier = 'all'
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Example for how to get properties into the manifest for reading at runtime.
|
||||||
|
tasks.named('jar', Jar).configure {
|
||||||
manifest {
|
manifest {
|
||||||
attributes([
|
attributes([
|
||||||
"Specification-Title": "TurnBasedMinecraftMod",
|
'Specification-Title' : mod_id,
|
||||||
"Specification-Vendor": "TurnBasedMinecraftMod_BK",
|
'Specification-Vendor' : mod_authors,
|
||||||
"Specification-Version": "1", // We are version 1 of ourselves
|
'Specification-Version' : '1', // We are version 1 of ourselves
|
||||||
"Implementation-Title": "TurnBasedMinecraftMod",
|
'Implementation-Title' : "TurnBasedMinecraftMod",
|
||||||
"Implementation-Version": "${version}",
|
'Implementation-Version' : project.jar.archiveVersion,
|
||||||
"Implementation-Vendor" :"TurnBasedMinecraftMod_BK",
|
'Implementation-Vendor' : mod_authors
|
||||||
// Do not place timestamp for the sake of reproducible builds
|
|
||||||
// "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is the preferred method to reobfuscate your jar file
|
||||||
|
//finalizedBy 'reobfJar'
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reproducible Builds
|
// Reproducible Builds
|
||||||
|
@ -216,10 +204,17 @@ tasks.withType(JavaCompile).configureEach {
|
||||||
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
||||||
}
|
}
|
||||||
|
|
||||||
// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
|
// Merge the resources and classes into the same directory.
|
||||||
idea {
|
// This is done because java expects modules to be in a single directory.
|
||||||
module {
|
// And if we have it in multiple we have to do performance intensive hacks like having the UnionFileSystem
|
||||||
downloadSources = true
|
// This will eventually be migrated to ForgeGradle so modders don't need to manually do it. But that is later.
|
||||||
downloadJavadoc = true
|
sourceSets.each {
|
||||||
|
def dir = layout.buildDirectory.dir("sourcesSets/$it.name")
|
||||||
|
it.output.resourcesDir = dir
|
||||||
|
it.java.destinationDirectory = dir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure "jarJar" is run after "build"
|
||||||
|
tasks.named("build").configure {
|
||||||
|
finalizedBy "jarJar"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +1,42 @@
|
||||||
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
|
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
|
||||||
org.gradle.jvmargs=-Xmx1G
|
# This is required to provide enough memory for the Minecraft decompilation process.
|
||||||
|
org.gradle.jvmargs=-Xmx3G
|
||||||
org.gradle.daemon=false
|
org.gradle.daemon=false
|
||||||
org.gradle.parallel=true
|
|
||||||
org.gradle.caching=true
|
|
||||||
org.gradle.configuration-cache=true
|
|
||||||
|
|
||||||
#read more on this at https://github.com/neoforged/ModDevGradle?tab=readme-ov-file#better-minecraft-parameter-names--javadoc-parchment
|
|
||||||
# you can also find the latest versions at: https://parchmentmc.org/docs/getting-started
|
|
||||||
parchment_minecraft_version=1.21
|
|
||||||
parchment_mappings_version=2024.07.28
|
|
||||||
|
|
||||||
# Environment Properties
|
## Environment Properties
|
||||||
# You can find the latest versions here: https://projects.neoforged.net/neoforged/neoforge
|
|
||||||
# The Minecraft version must agree with the Neo version to get a valid artifact
|
|
||||||
minecraft_version=1.21.3
|
|
||||||
|
|
||||||
|
# The Minecraft version must agree with the Forge version to get a valid artifact
|
||||||
|
minecraft_version=1.21.1
|
||||||
# The Minecraft version range can use any release version of Minecraft as bounds.
|
# The Minecraft version range can use any release version of Minecraft as bounds.
|
||||||
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
|
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
|
||||||
# as they do not follow standard versioning conventions.
|
# as they do not follow standard versioning conventions.
|
||||||
minecraft_version_range=[1.21.3, 1.22)
|
minecraft_version_range=[1.21.1,1.22)
|
||||||
|
# The Forge version must agree with the Minecraft version to get a valid artifact
|
||||||
|
forge_version=52.0.26
|
||||||
|
# The Forge version range can use any version of Forge as bounds or match the loader version range
|
||||||
|
forge_version_range=[0,)
|
||||||
|
# The loader version range can only use the major version of Forge/FML as bounds
|
||||||
|
loader_version_range=[0,)
|
||||||
|
# The mapping channel to use for mappings.
|
||||||
|
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
|
||||||
|
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
|
||||||
|
#
|
||||||
|
# | Channel | Version | |
|
||||||
|
# |-----------|----------------------|--------------------------------------------------------------------------------|
|
||||||
|
# | official | MCVersion | Official field/method names from Mojang mapping files |
|
||||||
|
# | parchment | YYYY.MM.DD-MCVersion | Open community-sourced parameter names and javadocs layered on top of official |
|
||||||
|
#
|
||||||
|
# You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
|
||||||
|
# See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
|
||||||
|
#
|
||||||
|
# Parchment is an unofficial project maintained by ParchmentMC, separate from Minecraft Forge.
|
||||||
|
# Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started
|
||||||
|
mapping_channel=official
|
||||||
|
# The mapping version to query from the mapping channel.
|
||||||
|
# This must match the format required by the mapping channel.
|
||||||
|
mapping_version=1.21.1
|
||||||
|
|
||||||
# The Neo version must agree with the Minecraft version to get a valid artifact
|
|
||||||
neo_version=21.3.11-beta
|
|
||||||
# The Neo version range can use any version of Neo as bounds
|
|
||||||
neo_version_range=[21.3.0,)
|
|
||||||
# The loader version range can only use the major version of FML as bounds
|
|
||||||
loader_version_range=[4,)
|
|
||||||
|
|
||||||
## Mod Properties
|
## Mod Properties
|
||||||
|
|
||||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,7 +1,6 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
27
gradlew
vendored
27
gradlew
vendored
|
@ -15,8 +15,6 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
|
@ -57,7 +55,7 @@
|
||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (3) This script is generated from the Groovy template
|
||||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
@ -85,9 +83,7 @@ done
|
||||||
# This is normally unused
|
# This is normally unused
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
|
||||||
' "$PWD" ) || exit
|
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -134,21 +130,18 @@ location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
JAVACMD=java
|
||||||
if ! command -v java >/dev/null 2>&1
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
then
|
|
||||||
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
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
# shellcheck disable=SC2039,SC3045
|
# shellcheck disable=SC3045
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
|
@ -156,7 +149,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
'' | soft) :;; #(
|
'' | soft) :;; #(
|
||||||
*)
|
*)
|
||||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
# shellcheck disable=SC2039,SC3045
|
# shellcheck disable=SC3045
|
||||||
ulimit -n "$MAX_FD" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
|
@ -205,11 +198,11 @@ fi
|
||||||
# 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"'
|
||||||
|
|
||||||
# Collect all arguments for the java command:
|
# Collect all arguments for the java command;
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||||
# and any embedded shellness will be escaped.
|
# shell script including quotes and variable substitutions, so put them in
|
||||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
# double quotes to make sure that they get re-expanded; and
|
||||||
# treated as '${Hostname}' itself on the command line.
|
# * put everything else in single quotes, so that it's not re-expanded.
|
||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
|
22
gradlew.bat
vendored
22
gradlew.bat
vendored
|
@ -13,8 +13,6 @@
|
||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
@rem SPDX-License-Identifier: Apache-2.0
|
|
||||||
@rem
|
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
|
@ -45,11 +43,11 @@ set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if %ERRORLEVEL% equ 0 goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation. 1>&2
|
echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
@ -59,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation. 1>&2
|
echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
pluginManagement {
|
pluginManagement {
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
maven {
|
maven {
|
||||||
url = 'https://maven.neoforged.net/releases'
|
name = 'MinecraftForge'
|
||||||
|
url = 'https://maven.minecraftforge.net/'
|
||||||
}
|
}
|
||||||
jcenter()
|
jcenter()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
@ -11,5 +11,5 @@ pluginManagement {
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
|
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.client.gui.screens.inventory.InventoryScreen;
|
import net.minecraft.client.gui.screens.inventory.InventoryScreen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.neoforged.neoforge.network.PacketDistributor;
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
|
|
||||||
import java.util.ConcurrentModificationException;
|
import java.util.ConcurrentModificationException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -256,7 +256,6 @@ public class BattleGui extends Screen {
|
||||||
} else {
|
} else {
|
||||||
waitMissingBattleTicks = null;
|
waitMissingBattleTicks = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TurnBasedMinecraftMod.proxy.getLocalBattle().getState() == Battle.State.DECISION
|
if (TurnBasedMinecraftMod.proxy.getLocalBattle().getState() == Battle.State.DECISION
|
||||||
&& timeRemaining.get() > 0) {
|
&& timeRemaining.get() > 0) {
|
||||||
long nextInstant = System.nanoTime();
|
long nextInstant = System.nanoTime();
|
||||||
|
@ -321,20 +320,22 @@ public class BattleGui extends Screen {
|
||||||
setState(MenuState.ATTACK_TARGET);
|
setState(MenuState.ATTACK_TARGET);
|
||||||
break;
|
break;
|
||||||
case DEFEND:
|
case DEFEND:
|
||||||
PacketDistributor.sendToServer(new PacketBattleDecision(
|
TurnBasedMinecraftMod.getHandler().send(new PacketBattleDecision(
|
||||||
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.DEFEND.getValue(), 0));
|
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.DEFEND, 0),
|
||||||
|
PacketDistributor.SERVER.noArg());
|
||||||
setState(MenuState.WAITING);
|
setState(MenuState.WAITING);
|
||||||
break;
|
break;
|
||||||
case ITEM:
|
case ITEM:
|
||||||
setState(MenuState.ITEM_ACTION);
|
setState(MenuState.ITEM_ACTION);
|
||||||
break;
|
break;
|
||||||
case FLEE:
|
case FLEE:
|
||||||
PacketDistributor.sendToServer(new PacketBattleDecision(
|
TurnBasedMinecraftMod.getHandler().send(new PacketBattleDecision(
|
||||||
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.FLEE.getValue(), 0));
|
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.FLEE, 0),
|
||||||
|
PacketDistributor.SERVER.noArg());
|
||||||
setState(MenuState.WAITING);
|
setState(MenuState.WAITING);
|
||||||
break;
|
break;
|
||||||
case ATTACK_TARGET:
|
case ATTACK_TARGET:
|
||||||
// Invalid, but set menu to main menu anyways.
|
// Invalid but set to main menu anyways.
|
||||||
setState(MenuState.MAIN_MENU);
|
setState(MenuState.MAIN_MENU);
|
||||||
break;
|
break;
|
||||||
case SWITCH_HELD_ITEM:
|
case SWITCH_HELD_ITEM:
|
||||||
|
@ -347,7 +348,7 @@ public class BattleGui extends Screen {
|
||||||
setState(MenuState.MAIN_MENU);
|
setState(MenuState.MAIN_MENU);
|
||||||
break;
|
break;
|
||||||
case DO_ITEM_SWITCH:
|
case DO_ITEM_SWITCH:
|
||||||
// Invalid, but set menu to main menu anyways.
|
// Invalid but set to main menu anyways.
|
||||||
setState(MenuState.MAIN_MENU);
|
setState(MenuState.MAIN_MENU);
|
||||||
break;
|
break;
|
||||||
case DO_USE_ITEM:
|
case DO_USE_ITEM:
|
||||||
|
@ -359,9 +360,9 @@ public class BattleGui extends Screen {
|
||||||
|
|
||||||
protected void entityButtonActionEvent(EntitySelectionButton button, ButtonAction action) {
|
protected void entityButtonActionEvent(EntitySelectionButton button, ButtonAction action) {
|
||||||
if (action.equals(ButtonAction.ATTACK_TARGET)) {
|
if (action.equals(ButtonAction.ATTACK_TARGET)) {
|
||||||
PacketDistributor.sendToServer(
|
TurnBasedMinecraftMod.getHandler().send(new PacketBattleDecision(
|
||||||
new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(),
|
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.ATTACK, button.getID()),
|
||||||
Battle.Decision.ATTACK.getValue(), ((EntitySelectionButton) button).getID()));
|
PacketDistributor.SERVER.noArg());
|
||||||
setState(MenuState.WAITING);
|
setState(MenuState.WAITING);
|
||||||
} else {
|
} else {
|
||||||
setState(MenuState.MAIN_MENU);
|
setState(MenuState.MAIN_MENU);
|
||||||
|
@ -371,18 +372,18 @@ public class BattleGui extends Screen {
|
||||||
protected void itemButtonActionEvent(ItemSelectionButton button, ButtonAction action) {
|
protected void itemButtonActionEvent(ItemSelectionButton button, ButtonAction action) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case DO_ITEM_SWITCH:
|
case DO_ITEM_SWITCH:
|
||||||
PacketDistributor.sendToServer(
|
TurnBasedMinecraftMod.getHandler().send(
|
||||||
new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(),
|
new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.SWITCH_ITEM, button.getID()),
|
||||||
Battle.Decision.SWITCH_ITEM.getValue(), button.getID()));
|
PacketDistributor.SERVER.noArg());
|
||||||
if (button.getID() >= 0 && button.getID() < 9) {
|
if (button.getID() >= 0 && button.getID() < 9) {
|
||||||
Minecraft.getInstance().player.getInventory().selected = button.getID();
|
Minecraft.getInstance().player.getInventory().selected = button.getID();
|
||||||
}
|
}
|
||||||
setState(MenuState.WAITING);
|
setState(MenuState.WAITING);
|
||||||
break;
|
break;
|
||||||
case DO_USE_ITEM:
|
case DO_USE_ITEM:
|
||||||
PacketDistributor.sendToServer(
|
TurnBasedMinecraftMod.getHandler().send(
|
||||||
new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(),
|
new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.USE_ITEM, button.getID()),
|
||||||
Battle.Decision.USE_ITEM.getValue(), button.getID()));
|
PacketDistributor.SERVER.noArg());
|
||||||
setState(MenuState.WAITING);
|
setState(MenuState.WAITING);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -401,13 +402,18 @@ public class BattleGui extends Screen {
|
||||||
if (getMinecraft().player.isCreative()) {
|
if (getMinecraft().player.isCreative()) {
|
||||||
return super.keyPressed(keyCode, b, c);
|
return super.keyPressed(keyCode, b, c);
|
||||||
} else if (keyCode == 256) {
|
} else if (keyCode == 256) {
|
||||||
getMinecraft().setScreen(null);
|
|
||||||
TurnBasedMinecraftMod.proxy.displayString("Leaving GUI, but the battle continues!");
|
TurnBasedMinecraftMod.proxy.displayString("Leaving GUI, but the battle continues!");
|
||||||
|
getMinecraft().setScreen(null);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false; // TODO verify return value
|
return false; // TODO verify return value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderBackground(GuiGraphics p_283688_, int p_299421_, int p_298679_, float p_297268_) {
|
||||||
|
// Left blank to not render background.
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyReleased(int a, int b, int c) {
|
public boolean keyReleased(int a, int b, int c) {
|
||||||
if (getMinecraft().player.isCreative()) {
|
if (getMinecraft().player.isCreative()) {
|
||||||
|
@ -431,9 +437,4 @@ public class BattleGui extends Screen {
|
||||||
public void setTurnTimerMax(int timerMax) {
|
public void setTurnTimerMax(int timerMax) {
|
||||||
this.timerMax = timerMax;
|
this.timerMax = timerMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderBackground(GuiGraphics p_283688_, int p_296369_, int p_296477_, float p_294317_) {
|
|
||||||
// Prevent graying of background.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,7 +259,7 @@ public class BattleMusic
|
||||||
|
|
||||||
// set volume
|
// set volume
|
||||||
FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
|
FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
|
||||||
gainControl.setValue(BattleMusic.percentageToDecibels(volume));
|
gainControl.setValue(BattleMusic.percentageToDecibels(volume)); // in decibels
|
||||||
|
|
||||||
clip.loop(Clip.LOOP_CONTINUOUSLY);
|
clip.loop(Clip.LOOP_CONTINUOUSLY);
|
||||||
clip.start();
|
clip.start();
|
||||||
|
@ -387,7 +387,6 @@ public class BattleMusic
|
||||||
return !sillyMusic.isEmpty();
|
return !sillyMusic.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Percentage must be between 0 and 1.
|
|
||||||
public static float percentageToDecibels(float percentage) {
|
public static float percentageToDecibels(float percentage) {
|
||||||
if (percentage > 1.0F) {
|
if (percentage > 1.0F) {
|
||||||
return 0.0F;
|
return 0.0F;
|
||||||
|
@ -449,7 +448,7 @@ public class BattleMusic
|
||||||
sdl.open(audioFormat);
|
sdl.open(audioFormat);
|
||||||
{
|
{
|
||||||
FloatControl volumeControl = (FloatControl) sdl.getControl(FloatControl.Type.MASTER_GAIN);
|
FloatControl volumeControl = (FloatControl) sdl.getControl(FloatControl.Type.MASTER_GAIN);
|
||||||
volumeControl.setValue(BattleMusic.percentageToDecibels(volume));
|
volumeControl.setValue(BattleMusic.percentageToDecibels(volume)); // in decibels
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
@ -547,7 +546,7 @@ public class BattleMusic
|
||||||
sdl.open(audioFormat);
|
sdl.open(audioFormat);
|
||||||
{
|
{
|
||||||
FloatControl volumeControl = (FloatControl) sdl.getControl(FloatControl.Type.MASTER_GAIN);
|
FloatControl volumeControl = (FloatControl) sdl.getControl(FloatControl.Type.MASTER_GAIN);
|
||||||
volumeControl.setValue(BattleMusic.percentageToDecibels(volume));
|
volumeControl.setValue(BattleMusic.percentageToDecibels(volume)); // in decibels
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioInputStream ais = reader.getAudioInputStream(oggVorbisFile);
|
AudioInputStream ais = reader.getAudioInputStream(oggVorbisFile);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.client;
|
package com.burnedkirby.TurnBasedMinecraft.client;
|
||||||
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||||
import net.neoforged.neoforge.common.ModConfigSpec;
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -9,23 +9,23 @@ import java.util.List;
|
||||||
|
|
||||||
public class ClientConfig {
|
public class ClientConfig {
|
||||||
public static final ClientConfig CLIENT;
|
public static final ClientConfig CLIENT;
|
||||||
public static final ModConfigSpec CLIENT_SPEC;
|
public static final ForgeConfigSpec CLIENT_SPEC;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Pair<ClientConfig, ModConfigSpec> pair =
|
Pair<ClientConfig, ForgeConfigSpec> pair =
|
||||||
new ModConfigSpec.Builder().configure(ClientConfig::new);
|
new ForgeConfigSpec.Builder().configure(ClientConfig::new);
|
||||||
CLIENT = pair.getKey();
|
CLIENT = pair.getKey();
|
||||||
CLIENT_SPEC = pair.getValue();
|
CLIENT_SPEC = pair.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ModConfigSpec.ConfigValue<List<? extends String>> battleMusicList;
|
public final ForgeConfigSpec.ConfigValue<List<? extends String>> battleMusicList;
|
||||||
public final ModConfigSpec.ConfigValue<List<? extends String>> sillyMusicList;
|
public final ForgeConfigSpec.ConfigValue<List<? extends String>> sillyMusicList;
|
||||||
public final ModConfigSpec.DoubleValue sillyMusicThreshold;
|
public final ForgeConfigSpec.DoubleValue sillyMusicThreshold;
|
||||||
public final ModConfigSpec.BooleanValue volumeAffectedByMasterVolume;
|
public final ForgeConfigSpec.BooleanValue volumeAffectedByMasterVolume;
|
||||||
public final ModConfigSpec.BooleanValue volumeAffectedByMusicVolume;
|
public final ForgeConfigSpec.BooleanValue volumeAffectedByMusicVolume;
|
||||||
public final ModConfigSpec.DoubleValue musicVolume;
|
public final ForgeConfigSpec.DoubleValue musicVolume;
|
||||||
|
|
||||||
ClientConfig(ModConfigSpec.Builder builder) {
|
ClientConfig(ForgeConfigSpec.Builder builder) {
|
||||||
//builder.push("music");
|
//builder.push("music");
|
||||||
|
|
||||||
List<String> battleMusicList = new ArrayList<String>(8);
|
List<String> battleMusicList = new ArrayList<String>(8);
|
||||||
|
|
|
@ -5,7 +5,6 @@ import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.components.*;
|
import net.minecraft.client.gui.components.*;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.neoforged.fml.ModContainer;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -20,16 +19,13 @@ public class ClientConfigGui extends net.minecraft.client.gui.screens.Screen {
|
||||||
private Checkbox affectedByMasterVolCheckbox = null;
|
private Checkbox affectedByMasterVolCheckbox = null;
|
||||||
private Checkbox affectedByMusicVolCheckbox = null;
|
private Checkbox affectedByMusicVolCheckbox = null;
|
||||||
private SliderPercentage volumeSlider = null;
|
private SliderPercentage volumeSlider = null;
|
||||||
private Screen parentScreen = null;
|
|
||||||
|
|
||||||
public ClientConfigGui(ModContainer container, Screen parent) {
|
public ClientConfigGui() {
|
||||||
super(Component.literal("TurnBasedMC Client Config"));
|
super(Component.literal("TurnBasedMC Client Config"));
|
||||||
|
|
||||||
dirtyFlag = true;
|
dirtyFlag = true;
|
||||||
|
|
||||||
accepted = false;
|
accepted = false;
|
||||||
|
|
||||||
this.parentScreen = parent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDirty() {
|
public void onDirty() {
|
||||||
|
@ -178,7 +174,7 @@ public class ClientConfigGui extends net.minecraft.client.gui.screens.Screen {
|
||||||
addRenderableWidget(volumeSlider);
|
addRenderableWidget(volumeSlider);
|
||||||
|
|
||||||
addRenderableWidget(Button.builder(Component.literal("Cancel"),
|
addRenderableWidget(Button.builder(Component.literal("Cancel"),
|
||||||
(b) -> Minecraft.getInstance().setScreen(this.parentScreen))
|
(b) -> Minecraft.getInstance().setScreen(null))
|
||||||
.bounds(this.width / 2 - widget_width + widget_x_offset,
|
.bounds(this.width / 2 - widget_width + widget_x_offset,
|
||||||
this.height - widget_height, widget_width, widget_height).build());
|
this.height - widget_height, widget_width, widget_height).build());
|
||||||
addRenderableWidget(Button.builder(Component.literal("Accept"), (b) -> {
|
addRenderableWidget(Button.builder(Component.literal("Accept"), (b) -> {
|
||||||
|
@ -228,7 +224,7 @@ public class ClientConfigGui extends net.minecraft.client.gui.screens.Screen {
|
||||||
public void render(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) {
|
public void render(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) {
|
||||||
if (accepted) {
|
if (accepted) {
|
||||||
doAccepted();
|
doAccepted();
|
||||||
Minecraft.getInstance().setScreen(this.parentScreen);
|
Minecraft.getInstance().setScreen(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (dirtyFlag) {
|
if (dirtyFlag) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||||
|
|
||||||
public class ClientProxy extends CommonProxy {
|
public class ClientProxy extends CommonProxy {
|
||||||
private BattleGui battleGui = null;
|
private BattleGui battleGui = null;
|
||||||
|
@ -168,7 +168,7 @@ public class ClientProxy extends CommonProxy {
|
||||||
parentComponent.getSiblings().add(prefix);
|
parentComponent.getSiblings().add(prefix);
|
||||||
parentComponent.getSiblings().add(text);
|
parentComponent.getSiblings().add(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.displayClientMessage(parentComponent, false);
|
Minecraft.getInstance().player.sendSystemMessage(parentComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -181,7 +181,7 @@ public class ClientProxy extends CommonProxy {
|
||||||
parentComponent.getSiblings().add(prefix);
|
parentComponent.getSiblings().add(prefix);
|
||||||
parentComponent.getSiblings().add(text);
|
parentComponent.getSiblings().add(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.displayClientMessage(parentComponent, false);
|
Minecraft.getInstance().player.sendSystemMessage(parentComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkBattleTypes(boolean entityLeft) {
|
private void checkBattleTypes(boolean entityLeft) {
|
||||||
|
@ -190,16 +190,16 @@ public class ClientProxy extends CommonProxy {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double percentage = 0.0;
|
float percentage = 0.0f;
|
||||||
if (sillyMusicCount == 0 && battleMusicCount == 0) {
|
if (sillyMusicCount == 0 && battleMusicCount == 0) {
|
||||||
percentage = 0.0;
|
percentage = 0.0f;
|
||||||
} else if (battleMusicCount == 0) {
|
} else if (battleMusicCount == 0) {
|
||||||
percentage = 1.0;
|
percentage = 100.0f;
|
||||||
} else {
|
} else {
|
||||||
percentage = (double) sillyMusicCount / (double) (sillyMusicCount + battleMusicCount);
|
percentage = 100.0f * (float) sillyMusicCount / (float) (sillyMusicCount + battleMusicCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (percentage >= ClientConfig.CLIENT.sillyMusicThreshold.get()) {
|
if (percentage >= ClientConfig.CLIENT.sillyMusicThreshold.get().floatValue()) {
|
||||||
if (battleMusic.isPlaying()) {
|
if (battleMusic.isPlaying()) {
|
||||||
if (!battleMusic.isPlayingSilly() && battleMusic.hasSillyMusic()) {
|
if (!battleMusic.isPlayingSilly() && battleMusic.hasSillyMusic()) {
|
||||||
stopMusic(false);
|
stopMusic(false);
|
||||||
|
@ -236,7 +236,7 @@ public class ClientProxy extends CommonProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <MSG> void handlePacket(final MSG msg, final IPayloadContext ctx) {
|
public <MSG> void handlePacket(MSG msg, CustomPayloadEvent.Context ctx) {
|
||||||
if (msg.getClass() == PacketBattleMessage.class) {
|
if (msg.getClass() == PacketBattleMessage.class) {
|
||||||
PacketBattleMessage pkt = (PacketBattleMessage) msg;
|
PacketBattleMessage pkt = (PacketBattleMessage) msg;
|
||||||
Entity fromEntity = getEntity(pkt.getEntityIDFrom(), pkt.getDimension());
|
Entity fromEntity = getEntity(pkt.getEntityIDFrom(), pkt.getDimension());
|
||||||
|
@ -451,6 +451,7 @@ public class ClientProxy extends CommonProxy {
|
||||||
parentComponent.getSiblings().add(message);
|
parentComponent.getSiblings().add(message);
|
||||||
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
|
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case CROSSBOW_NO_AMMO: {
|
case CROSSBOW_NO_AMMO: {
|
||||||
parentComponent.getSiblings().add(from);
|
parentComponent.getSiblings().add(from);
|
||||||
parentComponent.getSiblings().add(Component.literal(" tried to use their crossbow but ran out of ammo!"));
|
parentComponent.getSiblings().add(Component.literal(" tried to use their crossbow but ran out of ammo!"));
|
||||||
|
@ -1549,7 +1550,7 @@ public class ClientProxy extends CommonProxy {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showClientConfigGui() {
|
public void showClientConfigGui() {
|
||||||
Minecraft.getInstance().setScreen(new ClientConfigGui(null, null));
|
Minecraft.getInstance().setScreen(new ClientConfigGui());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,21 +1,22 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.common;
|
package com.burnedkirby.TurnBasedMinecraft.common;
|
||||||
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleMessage;
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketEditingMessage;
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketGeneralMessage;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.world.damagesource.DamageTypes;
|
|
||||||
import net.minecraft.world.entity.monster.Creeper;
|
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
|
||||||
import net.neoforged.neoforge.event.entity.living.LivingChangeTargetEvent;
|
|
||||||
import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent;
|
|
||||||
import net.neoforged.neoforge.network.PacketDistributor;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleMessage;
|
||||||
|
|
||||||
|
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketEditingMessage;
|
||||||
|
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketGeneralMessage;
|
||||||
|
import net.minecraft.world.damagesource.DamageTypes;
|
||||||
|
import net.minecraft.world.entity.monster.Creeper;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||||
|
import net.minecraftforge.event.entity.living.LivingChangeTargetEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
|
|
||||||
public class AttackEventHandler
|
public class AttackEventHandler
|
||||||
{
|
{
|
||||||
private boolean isAttackerValid(LivingIncomingDamageEvent event)
|
private boolean isAttackerValid(LivingAttackEvent event)
|
||||||
{
|
{
|
||||||
if(event.getSource().getEntity() == null)
|
if(event.getSource().getEntity() == null)
|
||||||
{
|
{
|
||||||
|
@ -58,7 +59,7 @@ public class AttackEventHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void entityAttacked(LivingIncomingDamageEvent event)
|
public void entityAttacked(LivingAttackEvent event)
|
||||||
{
|
{
|
||||||
if(event.getEntity().level().isClientSide)
|
if(event.getEntity().level().isClientSide)
|
||||||
{
|
{
|
||||||
|
@ -81,7 +82,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");
|
||||||
PacketDistributor.sendToPlayer((ServerPlayer)editingInfo.editor, new PacketGeneralMessage("Cannot edit custom name from entity without custom name"));
|
TurnBasedMinecraftMod.getHandler().send(new PacketGeneralMessage("Cannot edit custom name from entity without custom name"), PacketDistributor.PLAYER.with((ServerPlayer)editingInfo.editor));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
editingInfo.entityInfo = config.getCustomEntityInfo(event.getEntity().getCustomName().getString());
|
editingInfo.entityInfo = config.getCustomEntityInfo(event.getEntity().getCustomName().getString());
|
||||||
|
@ -90,9 +91,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();
|
||||||
}
|
}
|
||||||
PacketDistributor.sendToPlayer((ServerPlayer)editingInfo.editor, new PacketGeneralMessage("Editing custom name \"" + event.getEntity().getCustomName().getString() + "\""));
|
TurnBasedMinecraftMod.getHandler().send(new PacketGeneralMessage("Editing custom name \"" + event.getEntity().getCustomName().getString() + "\""), PacketDistributor.PLAYER.with((ServerPlayer)editingInfo.editor));
|
||||||
TurnBasedMinecraftMod.logger.info("Begin editing custom \"" + event.getEntity().getCustomName().getString() + "\"");
|
TurnBasedMinecraftMod.logger.info("Begin editing custom \"" + event.getEntity().getCustomName().getString() + "\"");
|
||||||
PacketDistributor.sendToPlayer((ServerPlayer)editingInfo.editor, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
TurnBasedMinecraftMod.getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with((ServerPlayer)editingInfo.editor));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -106,9 +107,9 @@ public class AttackEventHandler
|
||||||
{
|
{
|
||||||
editingInfo.entityInfo = editingInfo.entityInfo.clone();
|
editingInfo.entityInfo = editingInfo.entityInfo.clone();
|
||||||
}
|
}
|
||||||
PacketDistributor.sendToPlayer((ServerPlayer)editingInfo.editor, new PacketGeneralMessage("Editing entity \"" + editingInfo.entityInfo.classType.getName() + "\""));
|
TurnBasedMinecraftMod.getHandler().send(new PacketGeneralMessage("Editing entity \"" + editingInfo.entityInfo.classType.getName() + "\""), PacketDistributor.PLAYER.with((ServerPlayer)editingInfo.editor));
|
||||||
TurnBasedMinecraftMod.logger.info("Begin editing \"" + editingInfo.entityInfo.classType.getName() + "\"");
|
TurnBasedMinecraftMod.logger.info("Begin editing \"" + editingInfo.entityInfo.classType.getName() + "\"");
|
||||||
PacketDistributor.sendToPlayer((ServerPlayer)editingInfo.editor, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
TurnBasedMinecraftMod.getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with((ServerPlayer)editingInfo.editor));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -153,16 +154,16 @@ public class AttackEventHandler
|
||||||
if(event.getEntity().level().isClientSide
|
if(event.getEntity().level().isClientSide
|
||||||
|| config.isOldBattleBehaviorEnabled()
|
|| config.isOldBattleBehaviorEnabled()
|
||||||
|| (event.getEntity() != null && battleManager.isRecentlyLeftBattle(event.getEntity().getId()))
|
|| (event.getEntity() != null && battleManager.isRecentlyLeftBattle(event.getEntity().getId()))
|
||||||
|| (event.getNewAboutToBeSetTarget() != null && battleManager.isRecentlyLeftBattle(event.getNewAboutToBeSetTarget().getId()))
|
|| (event.getNewTarget() != null && battleManager.isRecentlyLeftBattle(event.getNewTarget().getId()))
|
||||||
|| (event.getEntity() != null && event.getNewAboutToBeSetTarget() != null && Utility.distanceBetweenEntities(event.getEntity(), event.getNewAboutToBeSetTarget()) > (double)config.getAggroStartBattleDistance()))
|
|| (event.getEntity() != null && event.getNewTarget() != null && Utility.distanceBetweenEntities(event.getEntity(), event.getNewTarget()) > (double)config.getAggroStartBattleDistance()))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(event.getEntity() != null
|
else if(event.getEntity() != null
|
||||||
&& event.getNewAboutToBeSetTarget() != null
|
&& event.getNewTarget() != null
|
||||||
&& !config.getBattleIgnoringPlayers().contains(event.getEntity().getId())
|
&& !config.getBattleIgnoringPlayers().contains(event.getEntity().getId())
|
||||||
&& !config.getBattleIgnoringPlayers().contains(event.getNewAboutToBeSetTarget().getId())
|
&& !config.getBattleIgnoringPlayers().contains(event.getNewTarget().getId())
|
||||||
&& event.getEntity().level().dimension().equals(event.getNewAboutToBeSetTarget().level().dimension()))
|
&& event.getEntity().level().dimension().equals(event.getNewTarget().level().dimension()))
|
||||||
{
|
{
|
||||||
TurnBasedMinecraftMod.proxy.getBattleManager().checkTargeted(event);
|
TurnBasedMinecraftMod.proxy.getBattleManager().checkTargeted(event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattlePing;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
import net.minecraft.world.effect.MobEffects;
|
import net.minecraft.world.effect.MobEffects;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
@ -16,8 +15,8 @@ import net.minecraft.world.entity.monster.Creeper;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.*;
|
import net.minecraft.world.item.*;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.neoforged.neoforge.common.CreativeModeTabRegistry;
|
import net.minecraftforge.common.CreativeModeTabRegistry;
|
||||||
import net.neoforged.neoforge.network.PacketDistributor;
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
@ -466,7 +465,7 @@ public class Battle {
|
||||||
}
|
}
|
||||||
PacketBattleInfo infoPacket = new PacketBattleInfo(getId(), getSideAIDs(), getSideBIDs(), timer, TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos(), !TurnBasedMinecraftMod.proxy.getConfig().isBattleDecisionDurationForever());
|
PacketBattleInfo infoPacket = new PacketBattleInfo(getId(), getSideAIDs(), getSideBIDs(), timer, TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos(), !TurnBasedMinecraftMod.proxy.getConfig().isBattleDecisionDurationForever());
|
||||||
for (Combatant p : players.values()) {
|
for (Combatant p : players.values()) {
|
||||||
PacketDistributor.sendToPlayer((ServerPlayer)p.entity, infoPacket);
|
TurnBasedMinecraftMod.getHandler().send(infoPacket, PacketDistributor.PLAYER.with((ServerPlayer)p.entity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,7 +475,7 @@ public class Battle {
|
||||||
}
|
}
|
||||||
PacketBattlePing pingPacket = new PacketBattlePing(getId(), (int)(timer / 1000000000L));
|
PacketBattlePing pingPacket = new PacketBattlePing(getId(), (int)(timer / 1000000000L));
|
||||||
for (Combatant p : players.values()) {
|
for (Combatant p : players.values()) {
|
||||||
PacketDistributor.sendToPlayer((ServerPlayer)p.entity, pingPacket);
|
TurnBasedMinecraftMod.getHandler().send(pingPacket, PacketDistributor.PLAYER.with((ServerPlayer)p.entity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,7 +490,7 @@ public class Battle {
|
||||||
PacketBattleMessage packet = new PacketBattleMessage(type, from, to, dimension, amount, custom);
|
PacketBattleMessage packet = new PacketBattleMessage(type, from, to, dimension, amount, custom);
|
||||||
for (Combatant p : players.values()) {
|
for (Combatant p : players.values()) {
|
||||||
if (p.entity.isAlive()) {
|
if (p.entity.isAlive()) {
|
||||||
PacketDistributor.sendToPlayer((ServerPlayer)p.entity, packet);
|
TurnBasedMinecraftMod.getHandler().send(packet, PacketDistributor.PLAYER.with((ServerPlayer)p.entity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -601,7 +600,7 @@ public class Battle {
|
||||||
|
|
||||||
private void removeCombatantPostRemove(Combatant c) {
|
private void removeCombatantPostRemove(Combatant c) {
|
||||||
if (c.entity instanceof Player) {
|
if (c.entity instanceof Player) {
|
||||||
PacketDistributor.sendToPlayer((ServerPlayer)c.entity, new PacketBattleMessage(PacketBattleMessage.MessageType.ENDED, 0, 0, dimension, 0));
|
TurnBasedMinecraftMod.getHandler().send(new PacketBattleMessage(PacketBattleMessage.MessageType.ENDED, 0, 0, dimension, 0), PacketDistributor.PLAYER.with((ServerPlayer)c.entity));
|
||||||
}
|
}
|
||||||
battleManager.addRecentlyLeftBattle(c);
|
battleManager.addRecentlyLeftBattle(c);
|
||||||
}
|
}
|
||||||
|
@ -811,7 +810,7 @@ public class Battle {
|
||||||
final Entity targetEntity = target.entity;
|
final Entity targetEntity = target.entity;
|
||||||
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 int randomTimeLeft = random.nextInt(heldItemStack.getItem().getUseDuration(heldItemStack, player) / 3);
|
final int randomTimeLeft = random.nextInt(heldItemStack.getUseDuration((LivingEntity)next.entity) / 3);
|
||||||
if (TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled()) {
|
if (TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled()) {
|
||||||
next.yaw = yawDirection;
|
next.yaw = yawDirection;
|
||||||
next.pitch = pitchDirection;
|
next.pitch = pitchDirection;
|
||||||
|
@ -828,6 +827,7 @@ public class Battle {
|
||||||
continue;
|
continue;
|
||||||
} else if (heldItemStack.getItem() instanceof CrossbowItem) {
|
} else if (heldItemStack.getItem() instanceof CrossbowItem) {
|
||||||
debugLog += " with crossbow";
|
debugLog += " with crossbow";
|
||||||
|
// Similar to attack with bow.
|
||||||
if (Utility.doesPlayerHaveArrows(player)) {
|
if (Utility.doesPlayerHaveArrows(player)) {
|
||||||
final Entity nextEntity = next.entity;
|
final Entity nextEntity = next.entity;
|
||||||
final Entity targetEntity = target.entity;
|
final Entity targetEntity = target.entity;
|
||||||
|
@ -841,7 +841,7 @@ public class Battle {
|
||||||
((ServerPlayer) nextEntity).connection.teleport(nextEntity.getX(), nextEntity.getY(), nextEntity.getZ(), yawDirection, pitchDirection);
|
((ServerPlayer) nextEntity).connection.teleport(nextEntity.getX(), nextEntity.getY(), nextEntity.getZ(), yawDirection, pitchDirection);
|
||||||
CrossbowItem itemCrossbow = (CrossbowItem) heldItemStack.getItem();
|
CrossbowItem itemCrossbow = (CrossbowItem) heldItemStack.getItem();
|
||||||
TurnBasedMinecraftMod.proxy.getAttackerViaBowSet().add(new AttackerViaBow(nextEntity, getId()));
|
TurnBasedMinecraftMod.proxy.getAttackerViaBowSet().add(new AttackerViaBow(nextEntity, getId()));
|
||||||
itemCrossbow.releaseUsing(heldItemStack, nextEntity.level(), (LivingEntity)nextEntity, -100);
|
itemCrossbow.releaseUsing(player.getMainHandItem(), nextEntity.level(), (LivingEntity) nextEntity, -100);
|
||||||
itemCrossbow.use(nextEntity.level(), (Player)nextEntity, InteractionHand.MAIN_HAND);
|
itemCrossbow.use(nextEntity.level(), (Player)nextEntity, InteractionHand.MAIN_HAND);
|
||||||
sendMessageToAllPlayers(PacketBattleMessage.MessageType.FIRED_ARROW, nextEntity.getId(), targetEntity.getId(), 0);
|
sendMessageToAllPlayers(PacketBattleMessage.MessageType.FIRED_ARROW, nextEntity.getId(), targetEntity.getId(), 0);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1198,7 +1198,7 @@ public class Battle {
|
||||||
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 (Utility.isItemEdible(targetItemStack, (LivingEntity)next.entity)) {
|
} else if (Utility.isItemEdible(targetItemStack)) {
|
||||||
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;
|
||||||
|
@ -1207,7 +1207,7 @@ public class Battle {
|
||||||
} else {
|
} else {
|
||||||
// then check vanilla foods
|
// then check vanilla foods
|
||||||
final CreativeModeTab foodAndDrinksTab = CreativeModeTabRegistry.getTab(CreativeModeTabs.FOOD_AND_DRINKS.location());
|
final CreativeModeTab foodAndDrinksTab = CreativeModeTabRegistry.getTab(CreativeModeTabs.FOOD_AND_DRINKS.location());
|
||||||
if (foodAndDrinksTab.contains(targetItemStack) && Utility.isItemEdible(targetItemStack, (LivingEntity)next.entity)) {
|
if (foodAndDrinksTab.contains(targetItemStack) && Utility.isItemEdible(targetItemStack)) {
|
||||||
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;
|
||||||
|
@ -1226,13 +1226,7 @@ public class Battle {
|
||||||
final int nextItemToUse = next.itemToUse;
|
final int nextItemToUse = next.itemToUse;
|
||||||
final int prevItem = ((Player)nextEntity).getInventory().selected;
|
final int prevItem = ((Player)nextEntity).getInventory().selected;
|
||||||
((Player)nextEntity).getInventory().selected = nextItemToUse;
|
((Player)nextEntity).getInventory().selected = nextItemToUse;
|
||||||
InteractionResult interactionResult = targetItem.use(nextEntity.level(), (Player)nextEntity, InteractionHand.MAIN_HAND);
|
((Player)nextEntity).getInventory().setItem(nextItemToUse, targetItem.use(nextEntity.level(), (Player)nextEntity, InteractionHand.MAIN_HAND).getObject());
|
||||||
if (interactionResult instanceof InteractionResult.Success resultSuccess) {
|
|
||||||
ItemStack transformed = resultSuccess.heldItemTransformedTo();
|
|
||||||
if (transformed != null) {
|
|
||||||
((Player) nextEntity).getInventory().setItem(nextItemToUse, transformed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
((Player)nextEntity).getInventory().selected = prevItem;
|
((Player)nextEntity).getInventory().selected = prevItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,10 @@ import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.monster.Creeper;
|
import net.minecraft.world.entity.monster.Creeper;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.neoforged.neoforge.event.entity.living.LivingChangeTargetEvent;
|
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||||
import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent;
|
import net.minecraftforge.event.entity.living.LivingChangeTargetEvent;
|
||||||
import net.neoforged.neoforge.network.PacketDistributor;
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -32,7 +32,7 @@ public class BattleManager
|
||||||
recentlyLeftBattle = new HashMap<Integer, Combatant>();
|
recentlyLeftBattle = new HashMap<Integer, Combatant>();
|
||||||
battleUpdater = new BattleUpdater(this);
|
battleUpdater = new BattleUpdater(this);
|
||||||
entityToBattleMap = new HashMap<EntityIDDimPair, Integer>();
|
entityToBattleMap = new HashMap<EntityIDDimPair, Integer>();
|
||||||
NeoForge.EVENT_BUS.register(battleUpdater);
|
MinecraftForge.EVENT_BUS.register(battleUpdater);
|
||||||
tempIDPair = new EntityIDDimPair();
|
tempIDPair = new EntityIDDimPair();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ public class BattleManager
|
||||||
* @param event
|
* @param event
|
||||||
* @return True if event should be canceled
|
* @return True if event should be canceled
|
||||||
*/
|
*/
|
||||||
public boolean checkAttack(final LivingIncomingDamageEvent event)
|
public boolean checkAttack(final LivingAttackEvent event)
|
||||||
{
|
{
|
||||||
Config config = TurnBasedMinecraftMod.proxy.getConfig();
|
Config config = TurnBasedMinecraftMod.proxy.getConfig();
|
||||||
String receiverClassName = event.getEntity().getClass().getName();
|
String receiverClassName = event.getEntity().getClass().getName();
|
||||||
|
@ -183,13 +183,13 @@ public class BattleManager
|
||||||
{
|
{
|
||||||
// Check if "player_only_battles" is enabled and if both entities are players.
|
// Check if "player_only_battles" is enabled and if both entities are players.
|
||||||
if (TurnBasedMinecraftMod.proxy.getConfig().isPlayerOnlyBattlesEnabled() &&
|
if (TurnBasedMinecraftMod.proxy.getConfig().isPlayerOnlyBattlesEnabled() &&
|
||||||
(!(event.getEntity() instanceof Player) || !(event.getNewAboutToBeSetTarget() instanceof Player))) {
|
(!(event.getEntity() instanceof Player) || !(event.getNewTarget() instanceof Player))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String targetedCustomName;
|
String targetedCustomName;
|
||||||
try {
|
try {
|
||||||
targetedCustomName = event.getNewAboutToBeSetTarget().getCustomName().getString();
|
targetedCustomName = event.getNewTarget().getCustomName().getString();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
targetedCustomName = null;
|
targetedCustomName = null;
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ public class BattleManager
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityInfo targetedInfo;
|
EntityInfo targetedInfo;
|
||||||
if(event.getNewAboutToBeSetTarget() instanceof Player)
|
if(event.getNewTarget() instanceof Player)
|
||||||
{
|
{
|
||||||
targetedInfo = null;
|
targetedInfo = null;
|
||||||
}
|
}
|
||||||
|
@ -216,10 +216,10 @@ public class BattleManager
|
||||||
targetedInfo = TurnBasedMinecraftMod.proxy.getConfig().getCustomEntityInfoReference(targetedCustomName);
|
targetedInfo = TurnBasedMinecraftMod.proxy.getConfig().getCustomEntityInfoReference(targetedCustomName);
|
||||||
if(targetedInfo == null)
|
if(targetedInfo == null)
|
||||||
{
|
{
|
||||||
targetedInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(event.getNewAboutToBeSetTarget());
|
targetedInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(event.getNewTarget());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if((event.getNewAboutToBeSetTarget() instanceof Player && ((Player)event.getNewAboutToBeSetTarget()).isCreative())
|
if((event.getNewTarget() instanceof Player && ((Player)event.getNewTarget()).isCreative())
|
||||||
|| attackerInfo == null
|
|| attackerInfo == null
|
||||||
|| attackerInfo.ignoreBattle
|
|| attackerInfo.ignoreBattle
|
||||||
|| TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType(attackerInfo.category)
|
|| TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType(attackerInfo.category)
|
||||||
|
@ -235,8 +235,8 @@ public class BattleManager
|
||||||
if(attackerBattle != null && !attackerBattle.hasCombatant(event.getEntity().getId())) {
|
if(attackerBattle != null && !attackerBattle.hasCombatant(event.getEntity().getId())) {
|
||||||
attackerBattle = null;
|
attackerBattle = null;
|
||||||
}
|
}
|
||||||
Battle defenderBattle = battleMap.get(entityToBattleMap.get(new EntityIDDimPair(event.getNewAboutToBeSetTarget())));
|
Battle defenderBattle = battleMap.get(entityToBattleMap.get(new EntityIDDimPair(event.getNewTarget())));
|
||||||
if(defenderBattle != null && !defenderBattle.hasCombatant(event.getNewAboutToBeSetTarget().getId())) {
|
if(defenderBattle != null && !defenderBattle.hasCombatant(event.getNewTarget().getId())) {
|
||||||
defenderBattle = null;
|
defenderBattle = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,13 +244,13 @@ 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 Player || event.getNewAboutToBeSetTarget() instanceof Player)
|
if(event.getEntity() instanceof Player || event.getNewTarget() 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);
|
||||||
Collection<Entity> sideB = new ArrayList<Entity>(1);
|
Collection<Entity> sideB = new ArrayList<Entity>(1);
|
||||||
sideA.add(event.getEntity());
|
sideA.add(event.getEntity());
|
||||||
sideB.add(event.getNewAboutToBeSetTarget());
|
sideB.add(event.getNewTarget());
|
||||||
createBattle(sideA, sideB, event.getEntity().level().dimension());
|
createBattle(sideA, sideB, event.getEntity().level().dimension());
|
||||||
logger.debug("neither in battle, at least one is player, creating new battle");
|
logger.debug("neither in battle, at least one is player, creating new battle");
|
||||||
}
|
}
|
||||||
|
@ -261,16 +261,16 @@ public class BattleManager
|
||||||
// battle max reached, cannot add to battle
|
// battle max reached, cannot add to battle
|
||||||
return;
|
return;
|
||||||
} else if (attackerBattle.hasCombatantInSideA(event.getEntity().getId())) {
|
} else if (attackerBattle.hasCombatantInSideA(event.getEntity().getId())) {
|
||||||
attackerBattle.addCombatantToSideB(event.getNewAboutToBeSetTarget());
|
attackerBattle.addCombatantToSideB(event.getNewTarget());
|
||||||
} else {
|
} else {
|
||||||
attackerBattle.addCombatantToSideA(event.getNewAboutToBeSetTarget());
|
attackerBattle.addCombatantToSideA(event.getNewTarget());
|
||||||
}
|
}
|
||||||
entityToBattleMap.put(new EntityIDDimPair(event.getNewAboutToBeSetTarget()), attackerBattle.getId());
|
entityToBattleMap.put(new EntityIDDimPair(event.getNewTarget()), attackerBattle.getId());
|
||||||
} else {
|
} else {
|
||||||
if (defenderBattle.getSize() >= TurnBasedMinecraftMod.proxy.getConfig().getMaxInBattle()) {
|
if (defenderBattle.getSize() >= TurnBasedMinecraftMod.proxy.getConfig().getMaxInBattle()) {
|
||||||
// battle max reached, cannot add to battle
|
// battle max reached, cannot add to battle
|
||||||
return;
|
return;
|
||||||
} else if (defenderBattle.hasCombatantInSideA(event.getNewAboutToBeSetTarget().getId())) {
|
} else if (defenderBattle.hasCombatantInSideA(event.getNewTarget().getId())) {
|
||||||
defenderBattle.addCombatantToSideB(event.getEntity());
|
defenderBattle.addCombatantToSideB(event.getEntity());
|
||||||
} else {
|
} else {
|
||||||
defenderBattle.addCombatantToSideA(event.getEntity());
|
defenderBattle.addCombatantToSideA(event.getEntity());
|
||||||
|
@ -307,7 +307,7 @@ public class BattleManager
|
||||||
public void cleanup()
|
public void cleanup()
|
||||||
{
|
{
|
||||||
battleUpdater.setRunning(false);
|
battleUpdater.setRunning(false);
|
||||||
NeoForge.EVENT_BUS.unregister(battleUpdater);
|
MinecraftForge.EVENT_BUS.unregister(battleUpdater);
|
||||||
battleMap.clear();
|
battleMap.clear();
|
||||||
battleUpdater = null;
|
battleUpdater = null;
|
||||||
}
|
}
|
||||||
|
@ -317,7 +317,7 @@ 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 ServerPlayer) {
|
if(c.entity instanceof ServerPlayer) {
|
||||||
PacketDistributor.sendToPlayer((ServerPlayer)c.entity, new PacketGeneralMessage("You just left battle! " + config.getLeaveBattleCooldownSeconds() + " seconds until you can attack/be-attacked again!"));
|
TurnBasedMinecraftMod.getHandler().send(new PacketGeneralMessage("You just left battle! " + config.getLeaveBattleCooldownSeconds() + " seconds until you can attack/be-attacked again!"), PacketDistributor.PLAYER.with((ServerPlayer)c.entity));
|
||||||
}
|
}
|
||||||
recentlyLeftBattle.put(c.entity.getId(), c);
|
recentlyLeftBattle.put(c.entity.getId(), c);
|
||||||
entityToBattleMap.remove(new EntityIDDimPair(c.entity));
|
entityToBattleMap.remove(new EntityIDDimPair(c.entity));
|
||||||
|
@ -337,7 +337,7 @@ public class BattleManager
|
||||||
iter.remove();
|
iter.remove();
|
||||||
if(entry.getValue().entity instanceof ServerPlayer)
|
if(entry.getValue().entity instanceof ServerPlayer)
|
||||||
{
|
{
|
||||||
PacketDistributor.sendToPlayer((ServerPlayer)entry.getValue().entity, new PacketGeneralMessage("Timer ended, you can now attack/be-attacked again."));
|
TurnBasedMinecraftMod.getHandler().send(new PacketGeneralMessage("Timer ended, you can now attack/be-attacked again."), PacketDistributor.PLAYER.with((ServerPlayer)entry.getValue().entity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.common;
|
package com.burnedkirby.TurnBasedMinecraft.common;
|
||||||
|
|
||||||
|
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.minecraftforge.event.TickEvent;
|
||||||
import net.neoforged.neoforge.event.tick.ServerTickEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
@ -25,9 +25,8 @@ public class BattleUpdater
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void update(ServerTickEvent.Post tickEvent) {
|
public void update(TickEvent.ServerTickEvent tickEvent) {
|
||||||
//if(tickEvent.phase != TickEvent.Phase.START && isRunning.get() && ++tick > tickLimit) {
|
if(tickEvent.phase != TickEvent.Phase.START && isRunning.get() && ++tick > tickLimit && tickEvent.haveTime()) {
|
||||||
if(isRunning.get() && ++tick > tickLimit && tickEvent.hasTime()) {
|
|
||||||
tick = 0;
|
tick = 0;
|
||||||
manager.battleMap.entrySet().removeIf(entry -> entry.getValue().update());
|
manager.battleMap.entrySet().removeIf(entry -> entry.getValue().update());
|
||||||
manager.updateRecentlyLeftBattle();
|
manager.updateRecentlyLeftBattle();
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.common;
|
package com.burnedkirby.TurnBasedMinecraft.common;
|
||||||
|
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import java.util.Comparator;
|
||||||
import net.minecraft.world.effect.MobEffects;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import java.util.Comparator;
|
import net.minecraft.world.effect.MobEffects;
|
||||||
|
|
||||||
public class Combatant
|
public class Combatant
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.common;
|
package com.burnedkirby.TurnBasedMinecraft.common;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.codec.ByteBufCodecs;
|
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||||
import net.neoforged.neoforge.server.ServerLifecycleHooks;
|
import net.minecraftforge.server.ServerLifecycleHooks;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.HashSet;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class CommonProxy
|
public class CommonProxy
|
||||||
{
|
{
|
||||||
|
@ -172,9 +172,7 @@ public class CommonProxy
|
||||||
return ServerLifecycleHooks.getCurrentServer().getLevel(dim).getEntity(id);
|
return ServerLifecycleHooks.getCurrentServer().getLevel(dim).getEntity(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <MSG> void handlePacket(final MSG msg, final IPayloadContext ctx) {}
|
public <MSG> void handlePacket(MSG msg,CustomPayloadEvent.Context ctx) {}
|
||||||
|
|
||||||
public static final StreamCodec<ByteBuf, Collection<Integer>> COLLECTION_INT_CODEC = ByteBufCodecs.INT.apply(ByteBufCodecs.collection(ArrayList::new));
|
|
||||||
|
|
||||||
public void showClientConfigGui() {}
|
public void showClientConfigGui() {}
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,7 @@ import net.minecraft.data.registries.VanillaRegistries;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -1947,7 +1944,7 @@ public class Config
|
||||||
possibleIgnoreHurtDamageSources.clear();
|
possibleIgnoreHurtDamageSources.clear();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
VanillaRegistries.createLookup().lookupOrThrow(Registries.DAMAGE_TYPE).listElements().forEach(dt -> possibleIgnoreHurtDamageSources.add(dt.value().msgId()));
|
VanillaRegistries.createLookup().lookupOrThrow(Registries.DAMAGE_TYPE).listElements().forEach(dt -> possibleIgnoreHurtDamageSources.add(dt.get().msgId()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("Config failed to load possible DamageSources! Undesired things may happen, like Zombies dying from Fire during battle!");
|
logger.warn("Config failed to load possible DamageSources! Undesired things may happen, like Zombies dying from Fire during battle!");
|
||||||
logger.warn(e);
|
logger.warn(e);
|
||||||
|
|
|
@ -2,9 +2,9 @@ package com.burnedkirby.TurnBasedMinecraft.common;
|
||||||
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketGeneralMessage;
|
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketGeneralMessage;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.minecraftforge.event.entity.EntityTravelToDimensionEvent;
|
||||||
import net.neoforged.neoforge.event.entity.EntityTravelToDimensionEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.neoforged.neoforge.network.PacketDistributor;
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
|
|
||||||
public class DimensionChangedHandler {
|
public class DimensionChangedHandler {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
@ -14,7 +14,9 @@ public class DimensionChangedHandler {
|
||||||
}
|
}
|
||||||
if(TurnBasedMinecraftMod.proxy.getBattleManager().forceLeaveBattle(new EntityIDDimPair(event.getEntity()))
|
if(TurnBasedMinecraftMod.proxy.getBattleManager().forceLeaveBattle(new EntityIDDimPair(event.getEntity()))
|
||||||
&& event.getEntity() instanceof ServerPlayer) {
|
&& event.getEntity() instanceof ServerPlayer) {
|
||||||
PacketDistributor.sendToPlayer((ServerPlayer)event.getEntity(), new PacketGeneralMessage("Left battle due to moving to a different dimension"));
|
TurnBasedMinecraftMod.getHandler().send(
|
||||||
|
new PacketGeneralMessage("Left battle due to moving to a different dimension"),
|
||||||
|
PacketDistributor.PLAYER.with((ServerPlayer)event.getEntity()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.common;
|
package com.burnedkirby.TurnBasedMinecraft.common;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.world.effect.MobEffects;
|
import net.minecraft.world.effect.MobEffects;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
public class EntityInfo
|
public class EntityInfo
|
||||||
{
|
{
|
||||||
public Class classType;
|
public Class classType;
|
||||||
|
@ -378,8 +375,8 @@ public class EntityInfo
|
||||||
decisionAttack = 70;
|
decisionAttack = 70;
|
||||||
decisionDefend = 20;
|
decisionDefend = 20;
|
||||||
decisionFlee = 10;
|
decisionFlee = 10;
|
||||||
customName = new String();
|
customName = "";
|
||||||
playerName = new String();
|
playerName = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityInfo(Class classType, boolean ignoreBattle, int attackPower, int attackProbability, int attackVariance,
|
public EntityInfo(Class classType, boolean ignoreBattle, int attackPower, int attackProbability, int attackVariance,
|
||||||
|
@ -431,113 +428,4 @@ public class EntityInfo
|
||||||
newEntityInfo.playerName = playerName;
|
newEntityInfo.playerName = playerName;
|
||||||
return newEntityInfo;
|
return newEntityInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityInfo(ByteBuf buffer) {
|
|
||||||
int name_bytes_len = buffer.readInt();
|
|
||||||
if (name_bytes_len > 0) {
|
|
||||||
ByteBuf name_bytes = buffer.readBytes(name_bytes_len);
|
|
||||||
try {
|
|
||||||
classType = Class.forName(name_bytes.toString(StandardCharsets.UTF_8));
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
TurnBasedMinecraftMod.logger.warn("Failed to decode EntityInfo.classType", e);
|
|
||||||
classType = null;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
classType = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
ignoreBattle = buffer.readBoolean();
|
|
||||||
attackPower = buffer.readInt();
|
|
||||||
attackProbability = buffer.readInt();
|
|
||||||
attackVariance = buffer.readInt();
|
|
||||||
|
|
||||||
int effect_len = buffer.readInt();
|
|
||||||
ByteBuf effect_bytes = buffer.readBytes(effect_len);
|
|
||||||
attackEffect = Effect.fromString(effect_bytes.toString(StandardCharsets.UTF_8));
|
|
||||||
|
|
||||||
attackEffectProbability = buffer.readInt();
|
|
||||||
defenseDamage = buffer.readInt();
|
|
||||||
defenseDamageProbability = buffer.readInt();
|
|
||||||
evasion = buffer.readInt();
|
|
||||||
speed = buffer.readInt();
|
|
||||||
hasteSpeed = buffer.readInt();
|
|
||||||
slowSpeed = buffer.readInt();
|
|
||||||
|
|
||||||
int category_len = buffer.readInt();
|
|
||||||
ByteBuf category_bytes = buffer.readBytes(category_len);
|
|
||||||
category = category_bytes.toString(StandardCharsets.UTF_8);
|
|
||||||
|
|
||||||
decisionAttack = buffer.readInt();
|
|
||||||
decisionDefend = buffer.readInt();
|
|
||||||
decisionFlee = buffer.readInt();
|
|
||||||
|
|
||||||
int custom_len = buffer.readInt();
|
|
||||||
if (custom_len > 0) {
|
|
||||||
ByteBuf custom_bytes = buffer.readBytes(custom_len);
|
|
||||||
customName = custom_bytes.toString(StandardCharsets.UTF_8);
|
|
||||||
} else {
|
|
||||||
customName = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
int player_len = buffer.readInt();
|
|
||||||
if (player_len > 0) {
|
|
||||||
ByteBuf player_bytes = buffer.readBytes(player_len);
|
|
||||||
playerName = player_bytes.toString(StandardCharsets.UTF_8);
|
|
||||||
} else {
|
|
||||||
playerName = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void encode(ByteBuf buffer) {
|
|
||||||
if (classType == null) {
|
|
||||||
buffer.writeInt(0);
|
|
||||||
} else {
|
|
||||||
String name = classType.getName();
|
|
||||||
byte[] name_bytes = name.getBytes(StandardCharsets.UTF_8);
|
|
||||||
buffer.writeInt(name_bytes.length);
|
|
||||||
buffer.writeBytes(name_bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer.writeBoolean(ignoreBattle);
|
|
||||||
buffer.writeInt(attackPower);
|
|
||||||
buffer.writeInt(attackProbability);
|
|
||||||
buffer.writeInt(attackVariance);
|
|
||||||
|
|
||||||
String effect_name = attackEffect.toString();
|
|
||||||
byte[] effect_bytes = effect_name.getBytes(StandardCharsets.UTF_8);
|
|
||||||
buffer.writeInt(effect_bytes.length);
|
|
||||||
buffer.writeBytes(effect_bytes);
|
|
||||||
|
|
||||||
buffer.writeInt(attackEffectProbability);
|
|
||||||
buffer.writeInt(defenseDamage);
|
|
||||||
buffer.writeInt(defenseDamageProbability);
|
|
||||||
buffer.writeInt(evasion);
|
|
||||||
buffer.writeInt(speed);
|
|
||||||
buffer.writeInt(hasteSpeed);
|
|
||||||
buffer.writeInt(slowSpeed);
|
|
||||||
|
|
||||||
byte[] category_bytes = category.getBytes(StandardCharsets.UTF_8);
|
|
||||||
buffer.writeInt(category_bytes.length);
|
|
||||||
buffer.writeBytes(category_bytes);
|
|
||||||
|
|
||||||
buffer.writeInt(decisionAttack);
|
|
||||||
buffer.writeInt(decisionDefend);
|
|
||||||
buffer.writeInt(decisionFlee);
|
|
||||||
|
|
||||||
if (customName.isEmpty()) {
|
|
||||||
buffer.writeInt(0);
|
|
||||||
} else {
|
|
||||||
byte[] custom_bytes = customName.getBytes(StandardCharsets.UTF_8);
|
|
||||||
buffer.writeInt(custom_bytes.length);
|
|
||||||
buffer.writeBytes(custom_bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (playerName.isEmpty()) {
|
|
||||||
buffer.writeInt(0);
|
|
||||||
} else {
|
|
||||||
byte[] player_bytes = playerName.getBytes(StandardCharsets.UTF_8);
|
|
||||||
buffer.writeInt(player_bytes.length);
|
|
||||||
buffer.writeBytes(player_bytes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.common;
|
package com.burnedkirby.TurnBasedMinecraft.common;
|
||||||
|
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||||
import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
|
||||||
public class HurtEventHandler {
|
public class HurtEventHandler {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void handleHurtEvent(LivingIncomingDamageEvent event) {
|
public void handleHurtEvent(LivingHurtEvent event) {
|
||||||
CommonProxy proxy = TurnBasedMinecraftMod.proxy;
|
CommonProxy proxy = TurnBasedMinecraftMod.proxy;
|
||||||
if (event.getEntity().level().isClientSide || proxy.getBattleManager() == null) {
|
if (event.getEntity().level().isClientSide || proxy.getBattleManager() == null) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.common;
|
package com.burnedkirby.TurnBasedMinecraft.common;
|
||||||
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.minecraftforge.event.entity.EntityJoinLevelEvent;
|
||||||
import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
|
||||||
public class PlayerJoinEventHandler
|
public class PlayerJoinEventHandler
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.common;
|
|
||||||
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.client.ClientConfig;
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.client.ClientConfigGui;
|
|
||||||
import net.neoforged.api.distmarker.Dist;
|
|
||||||
import net.neoforged.fml.ModContainer;
|
|
||||||
import net.neoforged.fml.common.Mod;
|
|
||||||
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
|
||||||
|
|
||||||
@Mod(value = TurnBasedMinecraftMod.MODID, dist = Dist.CLIENT)
|
|
||||||
public class TBMM_Client {
|
|
||||||
public TBMM_Client(ModContainer container) {
|
|
||||||
container.registerExtensionPoint(IConfigScreenFactory.class, ClientConfigGui::new);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -19,21 +19,19 @@ import net.minecraft.network.chat.HoverEvent;
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.neoforged.fml.ModContainer;
|
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||||
import net.neoforged.fml.common.Mod;
|
import net.minecraftforge.event.server.ServerStartingEvent;
|
||||||
import net.neoforged.fml.config.ModConfig;
|
import net.minecraftforge.event.server.ServerStoppingEvent;
|
||||||
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
import net.neoforged.fml.event.lifecycle.FMLDedicatedServerSetupEvent;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.neoforged.fml.loading.FMLEnvironment;
|
import net.minecraftforge.fml.config.ModConfig;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.neoforged.neoforge.event.server.ServerStartingEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent;
|
||||||
import net.neoforged.neoforge.event.server.ServerStoppingEvent;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
import net.neoforged.neoforge.network.PacketDistributor;
|
import net.minecraftforge.network.*;
|
||||||
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
|
|
||||||
import net.neoforged.neoforge.network.registration.PayloadRegistrar;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
@ -52,61 +50,89 @@ public class TurnBasedMinecraftMod {
|
||||||
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(4);
|
private static final Integer PROTOCOL_VERSION = 5;
|
||||||
private static final ResourceLocation HANDLER_ID = ResourceLocation.fromNamespaceAndPath(MODID, "main_channel");
|
private static final ResourceLocation HANDLER_ID = ResourceLocation.fromNamespaceAndPath(MODID, "main_channel");
|
||||||
|
|
||||||
|
private static final SimpleChannel HANDLER = ChannelBuilder
|
||||||
|
.named(HANDLER_ID)
|
||||||
|
.clientAcceptedVersions(Channel.VersionTest.exact(PROTOCOL_VERSION))
|
||||||
|
.serverAcceptedVersions(Channel.VersionTest.exact(PROTOCOL_VERSION))
|
||||||
|
.networkProtocolVersion(PROTOCOL_VERSION)
|
||||||
|
.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 CommonProxy proxy;
|
public static SimpleChannel getHandler() {
|
||||||
|
return HANDLER;
|
||||||
public TurnBasedMinecraftMod(ModContainer container) {
|
|
||||||
container.getEventBus().addListener(this::firstInit);
|
|
||||||
container.getEventBus().addListener(this::secondInitClient);
|
|
||||||
container.getEventBus().addListener(this::secondInitServer);
|
|
||||||
container.getEventBus().addListener(this::registerNetwork);
|
|
||||||
NeoForge.EVENT_BUS.register(this);
|
|
||||||
container.registerConfig(ModConfig.Type.CLIENT, ClientConfig.CLIENT_SPEC);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerNetwork(final RegisterPayloadHandlersEvent event) {
|
public static CommonProxy proxy;
|
||||||
final PayloadRegistrar registrar = event.registrar(PROTOCOL_VERSION);
|
|
||||||
|
|
||||||
registrar.playToServer(PacketBattleDecision.TYPE, PacketBattleDecision.STREAM_CODEC, new PacketBattleDecision.PayloadHandler());
|
public TurnBasedMinecraftMod(FMLJavaModLoadingContext ctx) {
|
||||||
|
ctx.getModEventBus().addListener(this::firstInit);
|
||||||
|
ctx.getModEventBus().addListener(this::secondInitClient);
|
||||||
|
ctx.getModEventBus().addListener(this::secondInitServer);
|
||||||
|
|
||||||
registrar.playToClient(PacketBattleInfo.TYPE, PacketBattleInfo.STREAM_CODEC, new PacketBattleInfo.PayloadHandler());
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
|
||||||
registrar.playToClient(PacketBattleMessage.TYPE, PacketBattleMessage.STREAM_CODEC, new PacketBattleMessage.PayloadHandler());
|
ctx.registerConfig(ModConfig.Type.CLIENT, ClientConfig.CLIENT_SPEC);
|
||||||
|
|
||||||
registrar.playToServer(PacketBattleRequestInfo.TYPE, PacketBattleRequestInfo.STREAM_CODEC, new PacketBattleRequestInfo.PayloadHandler());
|
|
||||||
|
|
||||||
registrar.playToClient(PacketEditingMessage.TYPE, PacketEditingMessage.STREAM_CODEC, new PacketEditingMessage.PayloadHandler());
|
|
||||||
|
|
||||||
registrar.playToClient(PacketGeneralMessage.TYPE, PacketGeneralMessage.STREAM_CODEC, new PacketGeneralMessage.PayloadHandler());
|
|
||||||
|
|
||||||
registrar.playToClient(PacketClientGUI.TYPE, PacketClientGUI.STREAM_CODEC, new PacketClientGUI.PayloadHandler());
|
|
||||||
|
|
||||||
registrar.playToClient(PacketBattlePing.TYPE, PacketBattlePing.STREAM_CODEC, new PacketBattlePing.PayloadHandler());
|
|
||||||
|
|
||||||
logger.debug("Register packets com_burnedkirby_turnbasedminecraft");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void firstInit(final FMLCommonSetupEvent event) {
|
private void firstInit(final FMLCommonSetupEvent event) {
|
||||||
if (FMLEnvironment.dist.isClient()) {
|
proxy = DistExecutor.unsafeRunForDist(() -> () -> new ClientProxy(), () -> () -> new CommonProxy());
|
||||||
proxy = new ClientProxy();
|
|
||||||
} else {
|
|
||||||
proxy = new CommonProxy();
|
|
||||||
}
|
|
||||||
proxy.setLogger(logger);
|
proxy.setLogger(logger);
|
||||||
proxy.initialize();
|
proxy.initialize();
|
||||||
|
|
||||||
|
// register packets
|
||||||
|
HANDLER.messageBuilder(PacketBattleInfo.class, NetworkDirection.PLAY_TO_CLIENT)
|
||||||
|
.encoder(new PacketBattleInfo.Encoder())
|
||||||
|
.decoder(new PacketBattleInfo.Decoder())
|
||||||
|
.consumerNetworkThread(new PacketBattleInfo.Consumer())
|
||||||
|
.add();
|
||||||
|
HANDLER.messageBuilder(PacketBattleRequestInfo.class, NetworkDirection.PLAY_TO_SERVER)
|
||||||
|
.encoder(new PacketBattleRequestInfo.Encoder())
|
||||||
|
.decoder(new PacketBattleRequestInfo.Decoder())
|
||||||
|
.consumerNetworkThread(new PacketBattleRequestInfo.Consumer())
|
||||||
|
.add();
|
||||||
|
HANDLER.messageBuilder(PacketBattleDecision.class, NetworkDirection.PLAY_TO_SERVER)
|
||||||
|
.encoder(new PacketBattleDecision.Encoder())
|
||||||
|
.decoder(new PacketBattleDecision.Decoder())
|
||||||
|
.consumerNetworkThread(new PacketBattleDecision.Consumer())
|
||||||
|
.add();
|
||||||
|
HANDLER.messageBuilder(PacketBattleMessage.class, NetworkDirection.PLAY_TO_CLIENT)
|
||||||
|
.encoder(new PacketBattleMessage.Encoder())
|
||||||
|
.decoder(new PacketBattleMessage.Decoder())
|
||||||
|
.consumerNetworkThread(new PacketBattleMessage.Consumer())
|
||||||
|
.add();
|
||||||
|
HANDLER.messageBuilder(PacketGeneralMessage.class, NetworkDirection.PLAY_TO_CLIENT)
|
||||||
|
.encoder(new PacketGeneralMessage.Encoder())
|
||||||
|
.decoder(new PacketGeneralMessage.Decoder())
|
||||||
|
.consumerNetworkThread(new PacketGeneralMessage.Consumer())
|
||||||
|
.add();
|
||||||
|
HANDLER.messageBuilder(PacketEditingMessage.class, NetworkDirection.PLAY_TO_CLIENT)
|
||||||
|
.encoder(new PacketEditingMessage.Encoder())
|
||||||
|
.decoder(new PacketEditingMessage.Decoder())
|
||||||
|
.consumerNetworkThread(new PacketEditingMessage.Consumer())
|
||||||
|
.add();
|
||||||
|
HANDLER.messageBuilder(PacketClientGui.class, NetworkDirection.PLAY_TO_CLIENT)
|
||||||
|
.encoder(new PacketClientGui.Encoder())
|
||||||
|
.decoder(new PacketClientGui.Decoder())
|
||||||
|
.consumerNetworkThread(new PacketClientGui.Consumer())
|
||||||
|
.add();
|
||||||
|
HANDLER.messageBuilder(PacketBattlePing.class, NetworkDirection.PLAY_TO_CLIENT)
|
||||||
|
.encoder(new PacketBattlePing.Encoder())
|
||||||
|
.decoder(new PacketBattlePing.Decoder())
|
||||||
|
.consumerNetworkThread(new PacketBattlePing.Consumer())
|
||||||
|
.add();
|
||||||
|
|
||||||
// register event handler(s)
|
// register event handler(s)
|
||||||
NeoForge.EVENT_BUS.register(new AttackEventHandler());
|
MinecraftForge.EVENT_BUS.register(new AttackEventHandler());
|
||||||
NeoForge.EVENT_BUS.register(new PlayerJoinEventHandler());
|
MinecraftForge.EVENT_BUS.register(new PlayerJoinEventHandler());
|
||||||
NeoForge.EVENT_BUS.register(new DimensionChangedHandler());
|
MinecraftForge.EVENT_BUS.register(new DimensionChangedHandler());
|
||||||
NeoForge.EVENT_BUS.register(new HurtEventHandler());
|
MinecraftForge.EVENT_BUS.register(new HurtEventHandler());
|
||||||
|
|
||||||
logger.debug("Init com_burnedkirby_turnbasedminecraft");
|
logger.debug("Init com_burnedkirby_turnbasedminecraft");
|
||||||
}
|
}
|
||||||
|
@ -152,7 +178,7 @@ public class TurnBasedMinecraftMod {
|
||||||
proxy.getConfig().setBattleDisabledForAll(true);
|
proxy.getConfig().setBattleDisabledForAll(true);
|
||||||
for (ServerPlayer player : c.getSource().getServer().getPlayerList().getPlayers()) {
|
for (ServerPlayer player : c.getSource().getServer().getPlayerList().getPlayers()) {
|
||||||
proxy.getConfig().addBattleIgnoringPlayer(player.getId());
|
proxy.getConfig().addBattleIgnoringPlayer(player.getId());
|
||||||
PacketDistributor.sendToPlayer(player, new PacketGeneralMessage("OP disabled turn-based-combat for everyone"));
|
getHandler().send(new PacketGeneralMessage("OP disabled turn-based-combat for everyone"), PacketDistributor.PLAYER.with(player));
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}));
|
}));
|
||||||
|
@ -173,7 +199,7 @@ public class TurnBasedMinecraftMod {
|
||||||
proxy.getConfig().setBattleDisabledForAll(false);
|
proxy.getConfig().setBattleDisabledForAll(false);
|
||||||
proxy.getConfig().clearBattleIgnoringPlayers();
|
proxy.getConfig().clearBattleIgnoringPlayers();
|
||||||
for (ServerPlayer player : c.getSource().getServer().getPlayerList().getPlayers()) {
|
for (ServerPlayer player : c.getSource().getServer().getPlayerList().getPlayers()) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketGeneralMessage("OP enabled turn-based-combat for everyone"));
|
getHandler().send(new PacketGeneralMessage("OP enabled turn-based-combat for everyone"), PacketDistributor.PLAYER.with(player));
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}));
|
}));
|
||||||
|
@ -184,7 +210,7 @@ public class TurnBasedMinecraftMod {
|
||||||
.then(Commands.argument("targets", EntityArgument.players()).executes(c -> {
|
.then(Commands.argument("targets", EntityArgument.players()).executes(c -> {
|
||||||
for (ServerPlayer player : EntityArgument.getPlayers(c, "targets")) {
|
for (ServerPlayer player : EntityArgument.getPlayers(c, "targets")) {
|
||||||
proxy.getConfig().addBattleIgnoringPlayer(player.getId());
|
proxy.getConfig().addBattleIgnoringPlayer(player.getId());
|
||||||
PacketDistributor.sendToPlayer(player, new PacketGeneralMessage("OP enabled turn-based-combat for you"));
|
getHandler().send(new PacketGeneralMessage("OP enabled turn-based-combat for you"), PacketDistributor.PLAYER.with(player));
|
||||||
c.getSource().sendSuccess(() -> Component.literal("Enabled turn-based-combat for " + player.getDisplayName().getString()), true);
|
c.getSource().sendSuccess(() -> Component.literal("Enabled turn-based-combat for " + player.getDisplayName().getString()), true);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -196,7 +222,7 @@ public class TurnBasedMinecraftMod {
|
||||||
.then(Commands.argument("targets", EntityArgument.players()).executes(c -> {
|
.then(Commands.argument("targets", EntityArgument.players()).executes(c -> {
|
||||||
for (ServerPlayer player : EntityArgument.getPlayers(c, "targets")) {
|
for (ServerPlayer player : EntityArgument.getPlayers(c, "targets")) {
|
||||||
proxy.getConfig().removeBattleIgnoringPlayer(player.getId());
|
proxy.getConfig().removeBattleIgnoringPlayer(player.getId());
|
||||||
PacketDistributor.sendToPlayer(player, new PacketGeneralMessage("OP disabled turn-based-combat for you"));
|
getHandler().send(new PacketGeneralMessage("OP disabled turn-based-combat for you"), PacketDistributor.PLAYER.with(player));
|
||||||
c.getSource().sendSuccess(() -> Component.literal("Disabled turn-based-combat for " + player.getDisplayName().getString()), true);
|
c.getSource().sendSuccess(() -> Component.literal("Disabled turn-based-combat for " + player.getDisplayName().getString()), true);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -209,12 +235,12 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer 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) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} else {
|
} else {
|
||||||
proxy.setEditingPlayer(player);
|
proxy.setEditingPlayer(player);
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
logger.info("Begin editing TBM Entity for player \"" + player.getDisplayName().getString() + "\" (\"" + c.getSource().getDisplayName() + "\")");
|
logger.info("Begin editing TBM Entity for player \"" + player.getDisplayName().getString() + "\" (\"" + c.getSource().getDisplayName() + "\")");
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -225,14 +251,14 @@ public class TurnBasedMinecraftMod {
|
||||||
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)) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketGeneralMessage("An error occurred while attempting to save an entry to the config"));
|
getHandler().send(new PacketGeneralMessage("An error occurred while attempting to save an entry to the config"), PacketDistributor.PLAYER.with(player));
|
||||||
proxy.removeEditingInfo(player.getId());
|
proxy.removeEditingInfo(player.getId());
|
||||||
} else {
|
} else {
|
||||||
proxy.removeEditingInfo(player.getId());
|
proxy.removeEditingInfo(player.getId());
|
||||||
PacketDistributor.sendToPlayer(player, new PacketGeneralMessage("Entity info saved in config and loaded."));
|
getHandler().send(new PacketGeneralMessage("Entity info saved in config and loaded."), PacketDistributor.PLAYER.with(player));
|
||||||
}
|
}
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -245,7 +271,7 @@ public class TurnBasedMinecraftMod {
|
||||||
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());
|
||||||
PacketDistributor.sendToPlayer(player, new PacketGeneralMessage("Cancelled editing entry."));
|
getHandler().send(new PacketGeneralMessage("Cancelled editing entry."), PacketDistributor.PLAYER.with(player));
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}))
|
}))
|
||||||
|
@ -257,11 +283,11 @@ public class TurnBasedMinecraftMod {
|
||||||
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) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} else {
|
} else {
|
||||||
proxy.setEditingPlayer(player);
|
proxy.setEditingPlayer(player);
|
||||||
proxy.getEditingInfo(player.getId()).isEditingCustomName = true;
|
proxy.getEditingInfo(player.getId()).isEditingCustomName = true;
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
logger.info("Begin editing custom TBM Entity for player \"" + player.getDisplayName().getString() + "\" (\"" + c.getSource().getDisplayName() + "\")");
|
logger.info("Begin editing custom TBM Entity for player \"" + player.getDisplayName().getString() + "\" (\"" + c.getSource().getDisplayName() + "\")");
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -269,13 +295,13 @@ public class TurnBasedMinecraftMod {
|
||||||
.then(Commands.literal("player")
|
.then(Commands.literal("player")
|
||||||
.executes(c -> {
|
.executes(c -> {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_PLAYER));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_PLAYER), PacketDistributor.PLAYER.with(player));
|
||||||
return 1;
|
return 1;
|
||||||
})
|
})
|
||||||
.then(Commands.argument("playerName", StringArgumentType.greedyString()).executes(c -> {
|
.then(Commands.argument("playerName", StringArgumentType.greedyString()).executes(c -> {
|
||||||
String name = StringArgumentType.getString(c, "playerName");
|
String name = StringArgumentType.getString(c, "playerName");
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
PacketDistributor.sendToPlayer(player, new PacketGeneralMessage("Editing player \"" + name + "\""));
|
getHandler().send(new PacketGeneralMessage("Editing player \"" + name + "\""), PacketDistributor.PLAYER.with(player));
|
||||||
TurnBasedMinecraftMod.logger.info("Begin editing player \"" + name + "\"");
|
TurnBasedMinecraftMod.logger.info("Begin editing player \"" + name + "\"");
|
||||||
proxy.setEditingPlayer(player);
|
proxy.setEditingPlayer(player);
|
||||||
EditingInfo editInfo = proxy.getEditingInfo(player.getId());
|
EditingInfo editInfo = proxy.getEditingInfo(player.getId());
|
||||||
|
@ -286,7 +312,7 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
editInfo.entityInfo.playerName = name;
|
editInfo.entityInfo.playerName = name;
|
||||||
editInfo.isPendingEntitySelection = false;
|
editInfo.isPendingEntitySelection = false;
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editInfo.entityInfo));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||||
return 1;
|
return 1;
|
||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
|
@ -295,9 +321,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer 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) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -309,9 +335,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer 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) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_IGNORE_BATTLE));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_IGNORE_BATTLE), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -325,9 +351,9 @@ public class TurnBasedMinecraftMod {
|
||||||
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;
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -340,9 +366,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer 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) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_POWER));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_POWER), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -359,9 +385,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.attackPower = attackPower;
|
editingInfo.entityInfo.attackPower = attackPower;
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -374,9 +400,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer 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) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_PROBABILITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_PROBABILITY), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -395,9 +421,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.attackProbability = attackProbability;
|
editingInfo.entityInfo.attackProbability = attackProbability;
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -410,9 +436,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer 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) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_VARIANCE));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_VARIANCE), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -429,9 +455,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.attackVariance = attackVariance;
|
editingInfo.entityInfo.attackVariance = attackVariance;
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -444,9 +470,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer 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) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -460,9 +486,9 @@ public class TurnBasedMinecraftMod {
|
||||||
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;
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -475,9 +501,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer 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) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT_PROBABILITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT_PROBABILITY), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -496,9 +522,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.attackEffectProbability = attackEffectProbability;
|
editingInfo.entityInfo.attackEffectProbability = attackEffectProbability;
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -511,9 +537,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer 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) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -530,9 +556,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.defenseDamage = defenseDamage;
|
editingInfo.entityInfo.defenseDamage = defenseDamage;
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -545,9 +571,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer 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) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE_PROBABILITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE_PROBABILITY), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -566,9 +592,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.defenseDamageProbability = defenseDamageProbability;
|
editingInfo.entityInfo.defenseDamageProbability = defenseDamageProbability;
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -581,9 +607,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer 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) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_EVASION));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_EVASION), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -602,9 +628,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.evasion = evasion;
|
editingInfo.entityInfo.evasion = evasion;
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -617,9 +643,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer 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) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SPEED));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SPEED), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -636,9 +662,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.speed = speed;
|
editingInfo.entityInfo.speed = speed;
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -651,9 +677,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer 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) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_HASTE_SPEED));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_HASTE_SPEED), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -670,9 +696,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.hasteSpeed = hasteSpeed;
|
editingInfo.entityInfo.hasteSpeed = hasteSpeed;
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -685,9 +711,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer 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) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SLOW_SPEED));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SLOW_SPEED), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -704,9 +730,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.slowSpeed = slowSpeed;
|
editingInfo.entityInfo.slowSpeed = slowSpeed;
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -719,9 +745,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer 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) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_CATEGORY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_CATEGORY), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -735,9 +761,9 @@ public class TurnBasedMinecraftMod {
|
||||||
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;
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -750,9 +776,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer 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) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_ATTACK));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_ATTACK), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -771,9 +797,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.decisionAttack = decisionAttack;
|
editingInfo.entityInfo.decisionAttack = decisionAttack;
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -786,9 +812,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer 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) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_DEFEND));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_DEFEND), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -807,9 +833,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.decisionDefend = decisionDefend;
|
editingInfo.entityInfo.decisionDefend = decisionDefend;
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -822,9 +848,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer 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) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_FLEE));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_FLEE), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -838,9 +864,9 @@ public class TurnBasedMinecraftMod {
|
||||||
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;
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||||
} 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\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -856,7 +882,7 @@ public class TurnBasedMinecraftMod {
|
||||||
.requires(c -> c.hasPermission(2))
|
.requires(c -> c.hasPermission(2))
|
||||||
.executes(c -> {
|
.executes(c -> {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.SERVER_EDIT));
|
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.SERVER_EDIT), PacketDistributor.PLAYER.with(player));
|
||||||
return 1;
|
return 1;
|
||||||
})
|
})
|
||||||
.then(Commands.literal("leave_battle_cooldown").executes(c -> {
|
.then(Commands.literal("leave_battle_cooldown").executes(c -> {
|
||||||
|
@ -1768,7 +1794,7 @@ public class TurnBasedMinecraftMod {
|
||||||
event.getDispatcher().register(
|
event.getDispatcher().register(
|
||||||
Commands.literal("tbm-client-edit").executes(c -> {
|
Commands.literal("tbm-client-edit").executes(c -> {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
PacketDistributor.sendToPlayer(player, new PacketClientGUI(0));
|
getHandler().send(new PacketClientGui(), PacketDistributor.PLAYER.with(player));
|
||||||
return 1;
|
return 1;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
@ -5,14 +5,11 @@ import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ArrowItem;
|
import net.minecraft.world.item.ArrowItem;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class Utility
|
public class Utility
|
||||||
{
|
{
|
||||||
public static float yawDirection(double posX, double posZ, double targetX, double targetZ)
|
public static float yawDirection(double posX, double posZ, double targetX, double targetZ)
|
||||||
|
@ -68,7 +65,7 @@ public class Utility
|
||||||
return ResourceKey.create(Registries.DIMENSION, dimRes);
|
return ResourceKey.create(Registries.DIMENSION, dimRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isItemEdible(ItemStack itemStack, @Nullable LivingEntity entity) {
|
public static boolean isItemEdible(ItemStack itemStack) {
|
||||||
return itemStack.get(DataComponents.CONSUMABLE) != null;
|
return itemStack.get(DataComponents.FOOD) != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,50 +1,64 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||||
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.Battle;
|
import com.burnedkirby.TurnBasedMinecraft.common.Battle;
|
||||||
|
import com.burnedkirby.TurnBasedMinecraft.common.Battle.Decision;
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||||
import io.netty.buffer.ByteBuf;
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.network.codec.ByteBufCodecs;
|
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadHandler;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public record PacketBattleDecision(int battleID, int decision, int targetIDorItemID) implements CustomPacketPayload
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class PacketBattleDecision
|
||||||
{
|
{
|
||||||
public static final CustomPacketPayload.Type<PacketBattleDecision> TYPE = new CustomPacketPayload.Type<>(ResourceLocation.fromNamespaceAndPath(TurnBasedMinecraftMod.MODID, "network_packetbattledecision"));
|
private int battleID;
|
||||||
|
private Battle.Decision decision;
|
||||||
|
private int targetIDOrItemID;
|
||||||
|
|
||||||
public static final StreamCodec<ByteBuf, PacketBattleDecision> STREAM_CODEC = StreamCodec.composite(
|
public PacketBattleDecision() {}
|
||||||
ByteBufCodecs.INT,
|
|
||||||
PacketBattleDecision::battleID,
|
|
||||||
ByteBufCodecs.VAR_INT,
|
|
||||||
PacketBattleDecision::decision,
|
|
||||||
ByteBufCodecs.INT,
|
|
||||||
PacketBattleDecision::targetIDorItemID,
|
|
||||||
PacketBattleDecision::new
|
|
||||||
);
|
|
||||||
|
|
||||||
@Override
|
public PacketBattleDecision(int battleID, Battle.Decision decision, int targetIDOrItemID)
|
||||||
public Type<? extends CustomPacketPayload> type() {
|
{
|
||||||
return TYPE;
|
this.battleID = battleID;
|
||||||
|
this.decision = decision;
|
||||||
|
this.targetIDOrItemID = targetIDOrItemID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PayloadHandler implements IPayloadHandler<PacketBattleDecision> {
|
public static class Encoder implements BiConsumer<PacketBattleDecision, RegistryFriendlyByteBuf> {
|
||||||
|
public Encoder() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(final @NotNull PacketBattleDecision pkt, final IPayloadContext ctx) {
|
public void accept(PacketBattleDecision pkt, RegistryFriendlyByteBuf buf) {
|
||||||
|
buf.writeInt(pkt.battleID);
|
||||||
|
buf.writeInt(pkt.decision.getValue());
|
||||||
|
buf.writeInt(pkt.targetIDOrItemID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketBattleDecision> {
|
||||||
|
public Decoder() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PacketBattleDecision apply(RegistryFriendlyByteBuf buf) {
|
||||||
|
return new PacketBattleDecision(buf.readInt(), Decision.valueOf(buf.readInt()), buf.readInt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Consumer implements BiConsumer<PacketBattleDecision, CustomPayloadEvent.Context> {
|
||||||
|
public Consumer() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accept(PacketBattleDecision pkt, CustomPayloadEvent.Context ctx) {
|
||||||
ctx.enqueueWork(() -> {
|
ctx.enqueueWork(() -> {
|
||||||
Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
|
Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
|
||||||
if(b != null) {
|
if(b != null)
|
||||||
Player player = ctx.player();
|
{
|
||||||
b.setDecision(player.getId(), Battle.Decision.valueOf(pkt.decision), pkt.targetIDorItemID);
|
ServerPlayer player = ctx.getSender();
|
||||||
|
b.setDecision(player.getId(), pkt.decision, pkt.targetIDOrItemID);
|
||||||
}
|
}
|
||||||
}).exceptionally(e -> {
|
|
||||||
ctx.disconnect(Component.literal("Exception handling PacketBattleDecision! " + e.getMessage()));
|
|
||||||
return null;
|
|
||||||
});
|
});
|
||||||
|
ctx.setPacketHandled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,49 +1,94 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||||
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.CommonProxy;
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
import net.minecraft.network.codec.ByteBufCodecs;
|
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadHandler;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
public record PacketBattleInfo(int battleID, Collection<Integer> sideA, Collection<Integer> sideB, long decisionNanos, long maxDecisionNanos, boolean turnTimerEnabled) implements CustomPacketPayload
|
public class PacketBattleInfo
|
||||||
{
|
{
|
||||||
public static final CustomPacketPayload.Type<PacketBattleInfo> TYPE = new CustomPacketPayload.Type<>(ResourceLocation.fromNamespaceAndPath(TurnBasedMinecraftMod.MODID, "network_packetbattleinfo"));
|
private int battleID;
|
||||||
|
private Collection<Integer> sideA;
|
||||||
|
private Collection<Integer> sideB;
|
||||||
|
private long decisionNanos;
|
||||||
|
|
||||||
public static final StreamCodec<ByteBuf, PacketBattleInfo> STREAM_CODEC = StreamCodec.composite(
|
private long maxDecisionNanos;
|
||||||
ByteBufCodecs.INT,
|
private boolean turnTimerEnabled;
|
||||||
PacketBattleInfo::battleID,
|
|
||||||
CommonProxy.COLLECTION_INT_CODEC,
|
|
||||||
PacketBattleInfo::sideA,
|
|
||||||
CommonProxy.COLLECTION_INT_CODEC,
|
|
||||||
PacketBattleInfo::sideB,
|
|
||||||
ByteBufCodecs.VAR_LONG,
|
|
||||||
PacketBattleInfo::decisionNanos,
|
|
||||||
ByteBufCodecs.VAR_LONG,
|
|
||||||
PacketBattleInfo::maxDecisionNanos,
|
|
||||||
ByteBufCodecs.BOOL,
|
|
||||||
PacketBattleInfo::turnTimerEnabled,
|
|
||||||
PacketBattleInfo::new
|
|
||||||
);
|
|
||||||
|
|
||||||
@Override
|
public PacketBattleInfo()
|
||||||
public Type<? extends CustomPacketPayload> type() {
|
{
|
||||||
return TYPE;
|
battleID = 0;
|
||||||
|
sideA = new ArrayList<Integer>();
|
||||||
|
sideB = new ArrayList<Integer>();
|
||||||
|
decisionNanos = TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos();
|
||||||
|
maxDecisionNanos = decisionNanos;
|
||||||
|
turnTimerEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PayloadHandler implements IPayloadHandler<PacketBattleInfo> {
|
public PacketBattleInfo(int battleID, Collection<Integer> sideA, Collection<Integer> sideB, long decisionNanos, long maxDecisionNanos, boolean turnTimerEnabled)
|
||||||
|
{
|
||||||
|
this.battleID = battleID;
|
||||||
|
this.sideA = sideA;
|
||||||
|
this.sideB = sideB;
|
||||||
|
this.decisionNanos = decisionNanos;
|
||||||
|
this.maxDecisionNanos = maxDecisionNanos;
|
||||||
|
this.turnTimerEnabled = turnTimerEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Encoder implements BiConsumer<PacketBattleInfo, RegistryFriendlyByteBuf> {
|
||||||
|
public Encoder() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(final @NotNull PacketBattleInfo pkt, final IPayloadContext ctx) {
|
public void accept(PacketBattleInfo msg, RegistryFriendlyByteBuf buf) {
|
||||||
|
buf.writeInt(msg.battleID);
|
||||||
|
buf.writeInt(msg.sideA.size());
|
||||||
|
buf.writeInt(msg.sideB.size());
|
||||||
|
for(Integer id : msg.sideA) {
|
||||||
|
buf.writeInt(id);
|
||||||
|
}
|
||||||
|
for(Integer id : msg.sideB) {
|
||||||
|
buf.writeInt(id);
|
||||||
|
}
|
||||||
|
buf.writeLong(msg.decisionNanos);
|
||||||
|
buf.writeLong(msg.maxDecisionNanos);
|
||||||
|
buf.writeBoolean(msg.turnTimerEnabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketBattleInfo> {
|
||||||
|
public Decoder() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PacketBattleInfo apply(RegistryFriendlyByteBuf buf) {
|
||||||
|
int battleID = buf.readInt();
|
||||||
|
int sideACount = buf.readInt();
|
||||||
|
int sideBCount = buf.readInt();
|
||||||
|
Collection<Integer> sideA = new ArrayList<Integer>(sideACount);
|
||||||
|
Collection<Integer> sideB = new ArrayList<Integer>(sideBCount);
|
||||||
|
for(int i = 0; i < sideACount; ++i) {
|
||||||
|
sideA.add(buf.readInt());
|
||||||
|
}
|
||||||
|
for(int i = 0; i < sideBCount; ++i) {
|
||||||
|
sideB.add(buf.readInt());
|
||||||
|
}
|
||||||
|
long decisionNanos = buf.readLong();
|
||||||
|
long maxDecisionNanos = buf.readLong();
|
||||||
|
boolean turnTimerEnabled = buf.readBoolean();
|
||||||
|
return new PacketBattleInfo(battleID, sideA, sideB, decisionNanos, maxDecisionNanos, turnTimerEnabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Consumer implements BiConsumer<PacketBattleInfo, CustomPayloadEvent.Context> {
|
||||||
|
public Consumer() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accept(PacketBattleInfo pkt, CustomPayloadEvent.Context ctx) {
|
||||||
ctx.enqueueWork(() -> {
|
ctx.enqueueWork(() -> {
|
||||||
if(TurnBasedMinecraftMod.proxy.getLocalBattle() == null)
|
if(TurnBasedMinecraftMod.proxy.getLocalBattle() == null)
|
||||||
{
|
{
|
||||||
|
@ -71,10 +116,8 @@ public record PacketBattleInfo(int battleID, Collection<Integer> sideA, Collecti
|
||||||
TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
|
TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
|
||||||
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerEnabled(pkt.turnTimerEnabled);
|
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerEnabled(pkt.turnTimerEnabled);
|
||||||
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerMax((int)(pkt.maxDecisionNanos / 1000000000L));
|
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerMax((int)(pkt.maxDecisionNanos / 1000000000L));
|
||||||
}).exceptionally(e -> {
|
|
||||||
ctx.disconnect(Component.literal("Exception handling PacketBattleInfo! " + e.getMessage()));
|
|
||||||
return null;
|
|
||||||
});
|
});
|
||||||
|
ctx.setPacketHandled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,47 +2,20 @@ package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||||
|
|
||||||
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 io.netty.buffer.ByteBuf;
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.network.codec.ByteBufCodecs;
|
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.neoforged.fml.loading.FMLEnvironment;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadHandler;
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class PacketBattleMessage implements CustomPacketPayload
|
public class PacketBattleMessage
|
||||||
{
|
{
|
||||||
public static final CustomPacketPayload.Type<PacketBattleMessage> TYPE = new CustomPacketPayload.Type<>(ResourceLocation.fromNamespaceAndPath(TurnBasedMinecraftMod.MODID, "network_packetbattlemessage"));
|
|
||||||
|
|
||||||
public static final StreamCodec<ByteBuf, PacketBattleMessage> STREAM_CODEC = StreamCodec.composite(
|
|
||||||
ByteBufCodecs.VAR_INT.map(MessageType::valueOf, MessageType::getValue),
|
|
||||||
PacketBattleMessage::getMessageType,
|
|
||||||
ByteBufCodecs.INT,
|
|
||||||
PacketBattleMessage::getEntityIDFrom,
|
|
||||||
ByteBufCodecs.INT,
|
|
||||||
PacketBattleMessage::getEntityIDTo,
|
|
||||||
ByteBufCodecs.STRING_UTF8.map(Utility::deserializeDimension, Utility::serializeDimension),
|
|
||||||
PacketBattleMessage::getDimension,
|
|
||||||
ByteBufCodecs.INT,
|
|
||||||
PacketBattleMessage::getAmount,
|
|
||||||
ByteBufCodecs.STRING_UTF8,
|
|
||||||
PacketBattleMessage::getCustom,
|
|
||||||
PacketBattleMessage::new
|
|
||||||
);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type<? extends CustomPacketPayload> type() {
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum MessageType
|
public enum MessageType
|
||||||
{
|
{
|
||||||
ENTERED(0),
|
ENTERED(0),
|
||||||
|
@ -160,11 +133,6 @@ public class PacketBattleMessage implements CustomPacketPayload
|
||||||
public ResourceKey<Level> getDimension() {
|
public ResourceKey<Level> getDimension() {
|
||||||
return dimension;
|
return dimension;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDimensionSerialized() {
|
|
||||||
return Utility.serializeDimension(dimension);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PacketBattleMessage() { custom = new String(); }
|
public PacketBattleMessage() { custom = new String(); }
|
||||||
|
|
||||||
public PacketBattleMessage(MessageType messageType, int entityIDFrom, int entityIDTo, ResourceKey<Level> dimension, int amount)
|
public PacketBattleMessage(MessageType messageType, int entityIDFrom, int entityIDTo, ResourceKey<Level> dimension, int amount)
|
||||||
|
@ -187,17 +155,45 @@ public class PacketBattleMessage implements CustomPacketPayload
|
||||||
this.custom = custom;
|
this.custom = custom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PayloadHandler implements IPayloadHandler<PacketBattleMessage> {
|
public static class Encoder implements BiConsumer<PacketBattleMessage, RegistryFriendlyByteBuf> {
|
||||||
|
public Encoder() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(final @NotNull PacketBattleMessage pkt, final IPayloadContext ctx) {
|
public void accept(PacketBattleMessage pkt, RegistryFriendlyByteBuf buf) {
|
||||||
|
buf.writeInt(pkt.messageType.getValue());
|
||||||
|
buf.writeInt(pkt.entityIDFrom);
|
||||||
|
buf.writeInt(pkt.entityIDTo);
|
||||||
|
buf.writeUtf(Utility.serializeDimension(pkt.dimension));
|
||||||
|
buf.writeInt(pkt.amount);
|
||||||
|
buf.writeUtf(pkt.custom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketBattleMessage> {
|
||||||
|
public Decoder() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PacketBattleMessage apply(RegistryFriendlyByteBuf buf) {
|
||||||
|
return new PacketBattleMessage(
|
||||||
|
MessageType.valueOf(
|
||||||
|
buf.readInt()),
|
||||||
|
buf.readInt(),
|
||||||
|
buf.readInt(),
|
||||||
|
Utility.deserializeDimension(buf.readUtf()),
|
||||||
|
buf.readInt(),
|
||||||
|
buf.readUtf());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Consumer implements BiConsumer<PacketBattleMessage, CustomPayloadEvent.Context> {
|
||||||
|
public Consumer() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accept(PacketBattleMessage pkt, CustomPayloadEvent.Context ctx) {
|
||||||
ctx.enqueueWork(() -> {
|
ctx.enqueueWork(() -> {
|
||||||
if (FMLEnvironment.dist.isClient()) {
|
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
|
||||||
TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx);
|
|
||||||
}
|
|
||||||
}).exceptionally(e -> {
|
|
||||||
ctx.disconnect(Component.literal("Exception handling PacketBattleMessage! " + e.getMessage()));
|
|
||||||
return null;
|
|
||||||
});
|
});
|
||||||
|
ctx.setPacketHandled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,46 +1,59 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||||
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||||
import io.netty.buffer.ByteBuf;
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||||
import net.minecraft.network.codec.ByteBufCodecs;
|
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadHandler;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public record PacketBattlePing(int battleID, int remainingSeconds) implements CustomPacketPayload {
|
import java.util.function.BiConsumer;
|
||||||
public static final CustomPacketPayload.Type<PacketBattlePing> TYPE = new CustomPacketPayload.Type<>(ResourceLocation.fromNamespaceAndPath(TurnBasedMinecraftMod.MODID, "network_packetbattleping"));
|
import java.util.function.Function;
|
||||||
|
|
||||||
public static final StreamCodec<ByteBuf, PacketBattlePing> STREAM_CODEC = StreamCodec.composite(
|
public class PacketBattlePing {
|
||||||
ByteBufCodecs.INT,
|
private int battleID;
|
||||||
PacketBattlePing::battleID,
|
private int decisionSeconds;
|
||||||
ByteBufCodecs.VAR_INT,
|
|
||||||
PacketBattlePing::remainingSeconds,
|
|
||||||
PacketBattlePing::new
|
|
||||||
);
|
|
||||||
|
|
||||||
@Override
|
public PacketBattlePing() {
|
||||||
public Type<? extends CustomPacketPayload> type() {
|
battleID = 0;
|
||||||
return TYPE;
|
decisionSeconds = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PayloadHandler implements IPayloadHandler<PacketBattlePing> {
|
public PacketBattlePing(int battleID, int decisionSeconds) {
|
||||||
|
this.battleID = battleID;
|
||||||
|
this.decisionSeconds = decisionSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Encoder implements BiConsumer<PacketBattlePing, RegistryFriendlyByteBuf> {
|
||||||
|
public Encoder() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(final @NotNull PacketBattlePing pkt, IPayloadContext ctx) {
|
public void accept(PacketBattlePing pkt, RegistryFriendlyByteBuf buf) {
|
||||||
|
buf.writeInt(pkt.battleID);
|
||||||
|
buf.writeInt(pkt.decisionSeconds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketBattlePing> {
|
||||||
|
public Decoder() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PacketBattlePing apply(RegistryFriendlyByteBuf buf) {
|
||||||
|
return new PacketBattlePing(buf.readInt(), buf.readInt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Consumer implements BiConsumer<PacketBattlePing, CustomPayloadEvent.Context> {
|
||||||
|
public Consumer() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accept(PacketBattlePing pkt, CustomPayloadEvent.Context ctx) {
|
||||||
ctx.enqueueWork(() -> {
|
ctx.enqueueWork(() -> {
|
||||||
if (TurnBasedMinecraftMod.proxy.getLocalBattle() != null) {
|
if (TurnBasedMinecraftMod.proxy.getLocalBattle() != null) {
|
||||||
TurnBasedMinecraftMod.proxy.setBattleGuiAsGui();
|
TurnBasedMinecraftMod.proxy.setBattleGuiAsGui();
|
||||||
TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
|
TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
|
||||||
TurnBasedMinecraftMod.proxy.setBattleGuiTime(pkt.remainingSeconds);
|
TurnBasedMinecraftMod.proxy.setBattleGuiTime(pkt.decisionSeconds);
|
||||||
TurnBasedMinecraftMod.proxy.pauseMCMusic();
|
TurnBasedMinecraftMod.proxy.pauseMCMusic();
|
||||||
}
|
}
|
||||||
}).exceptionally(e -> {
|
|
||||||
ctx.disconnect(Component.literal("Exception handling PacketBattlePing! " + e.getMessage()));
|
|
||||||
return null;
|
|
||||||
});
|
});
|
||||||
|
ctx.setPacketHandled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,55 +2,54 @@ package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||||
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.Battle;
|
import com.burnedkirby.TurnBasedMinecraft.common.Battle;
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||||
import io.netty.buffer.ByteBuf;
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||||
import net.minecraft.network.codec.ByteBufCodecs;
|
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadHandler;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public record PacketBattleRequestInfo(int battleID) implements CustomPacketPayload
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class PacketBattleRequestInfo
|
||||||
{
|
{
|
||||||
public static final CustomPacketPayload.Type<PacketBattleRequestInfo> TYPE = new CustomPacketPayload.Type<>(ResourceLocation.fromNamespaceAndPath(TurnBasedMinecraftMod.MODID, "network_packetbattlerequestinfo"));
|
private int battleID;
|
||||||
|
|
||||||
public static final StreamCodec<ByteBuf, PacketBattleRequestInfo> STREAM_CODEC = StreamCodec.composite(
|
public PacketBattleRequestInfo() {}
|
||||||
ByteBufCodecs.INT,
|
|
||||||
PacketBattleRequestInfo::battleID,
|
|
||||||
PacketBattleRequestInfo::new
|
|
||||||
);
|
|
||||||
|
|
||||||
public PacketBattleRequestInfo(int battleID)
|
public PacketBattleRequestInfo(int battleID)
|
||||||
{
|
{
|
||||||
this.battleID = battleID;
|
this.battleID = battleID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class Encoder implements BiConsumer<PacketBattleRequestInfo, RegistryFriendlyByteBuf> {
|
||||||
|
public Encoder() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type<? extends CustomPacketPayload> type() {
|
public void accept(PacketBattleRequestInfo pkt, RegistryFriendlyByteBuf buf) {
|
||||||
return TYPE;
|
buf.writeInt(pkt.battleID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PayloadHandler implements IPayloadHandler<PacketBattleRequestInfo> {
|
public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketBattleRequestInfo> {
|
||||||
|
public Decoder() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(final @NotNull PacketBattleRequestInfo pkt, final IPayloadContext ctx) {
|
public PacketBattleRequestInfo apply(RegistryFriendlyByteBuf buf) {
|
||||||
|
return new PacketBattleRequestInfo(buf.readInt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Consumer implements BiConsumer<PacketBattleRequestInfo, CustomPayloadEvent.Context> {
|
||||||
|
public Consumer() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accept(PacketBattleRequestInfo pkt, CustomPayloadEvent.Context ctx) {
|
||||||
ctx.enqueueWork(() -> {
|
ctx.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;
|
||||||
}
|
}
|
||||||
ctx.reply(new PacketBattleInfo(
|
TurnBasedMinecraftMod.getHandler().reply(new PacketBattleInfo(b.getId(), b.getSideAIDs(), b.getSideBIDs(), b.getTimerNanos(), TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos(), !TurnBasedMinecraftMod.proxy.getConfig().isBattleDecisionDurationForever()), ctx);
|
||||||
b.getId(),
|
|
||||||
b.getSideAIDs(),
|
|
||||||
b.getSideBIDs(),
|
|
||||||
b.getTimerNanos(),
|
|
||||||
TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos(),
|
|
||||||
!TurnBasedMinecraftMod.proxy.getConfig().isBattleDecisionDurationForever()));
|
|
||||||
}).exceptionally(e -> {
|
|
||||||
ctx.disconnect(Component.literal("Exception handling PacketBattleRequestInfo! " + e.getMessage()));
|
|
||||||
return null;
|
|
||||||
});
|
});
|
||||||
|
ctx.setPacketHandled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
|
||||||
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.network.codec.ByteBufCodecs;
|
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.neoforged.fml.loading.FMLEnvironment;
|
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadHandler;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public record PacketClientGUI(int reserved) implements CustomPacketPayload {
|
|
||||||
public static final CustomPacketPayload.Type<PacketClientGUI> TYPE = new CustomPacketPayload.Type<>(ResourceLocation.fromNamespaceAndPath(TurnBasedMinecraftMod.MODID, "network_packetclientgui"));
|
|
||||||
|
|
||||||
public static final StreamCodec<ByteBuf, PacketClientGUI> STREAM_CODEC = StreamCodec.composite(
|
|
||||||
ByteBufCodecs.VAR_INT,
|
|
||||||
PacketClientGUI::reserved,
|
|
||||||
PacketClientGUI::new
|
|
||||||
);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type<? extends CustomPacketPayload> type() {
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class PayloadHandler implements IPayloadHandler<PacketClientGUI> {
|
|
||||||
@Override
|
|
||||||
public void handle(final @NotNull PacketClientGUI pkt, final IPayloadContext ctx) {
|
|
||||||
ctx.enqueueWork(() -> {
|
|
||||||
if (FMLEnvironment.dist.isClient()) {
|
|
||||||
TurnBasedMinecraftMod.proxy.showClientConfigGui();
|
|
||||||
}
|
|
||||||
}).exceptionally(e -> {
|
|
||||||
ctx.disconnect(Component.literal("Exception handling PacketClientGUI! " + e.getMessage()));
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||||
|
|
||||||
|
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||||
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||||
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
|
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class PacketClientGui {
|
||||||
|
int reserved;
|
||||||
|
|
||||||
|
public PacketClientGui() {
|
||||||
|
reserved = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PacketClientGui(int reserved) {
|
||||||
|
this.reserved = reserved;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Encoder implements BiConsumer<PacketClientGui, RegistryFriendlyByteBuf> {
|
||||||
|
public Encoder() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accept(PacketClientGui pkt, RegistryFriendlyByteBuf buf) {
|
||||||
|
buf.writeInt(pkt.reserved);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketClientGui> {
|
||||||
|
public Decoder() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PacketClientGui apply(RegistryFriendlyByteBuf registryFriendlyByteBuf) {
|
||||||
|
return new PacketClientGui(registryFriendlyByteBuf.readInt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Consumer implements BiConsumer<PacketClientGui, CustomPayloadEvent.Context> {
|
||||||
|
public Consumer() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accept(PacketClientGui pkt, CustomPayloadEvent.Context ctx) {
|
||||||
|
ctx.enqueueWork(() -> {
|
||||||
|
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.showClientConfigGui());
|
||||||
|
});
|
||||||
|
ctx.setPacketHandled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,38 +2,18 @@ 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 io.netty.buffer.ByteBuf;
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||||
import net.minecraft.network.codec.ByteBufCodecs;
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.neoforged.fml.loading.FMLEnvironment;
|
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadHandler;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class PacketEditingMessage implements CustomPacketPayload
|
public class PacketEditingMessage
|
||||||
{
|
{
|
||||||
public static final CustomPacketPayload.Type<PacketEditingMessage> TYPE = new CustomPacketPayload.Type<>(ResourceLocation.fromNamespaceAndPath(TurnBasedMinecraftMod.MODID, "network_packeteditingmessage"));
|
|
||||||
|
|
||||||
public static final StreamCodec<ByteBuf, PacketEditingMessage> STREAM_CODEC = StreamCodec.composite(
|
|
||||||
ByteBufCodecs.INT.map(Type::valueOf, Type::getValue),
|
|
||||||
PacketEditingMessage::getType,
|
|
||||||
StreamCodec.ofMember(EntityInfo::encode, EntityInfo::new),
|
|
||||||
PacketEditingMessage::getEntityInfo,
|
|
||||||
PacketEditingMessage::new
|
|
||||||
);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CustomPacketPayload.Type<? extends CustomPacketPayload> type() {
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Type
|
public enum Type
|
||||||
{
|
{
|
||||||
ATTACK_ENTITY(0),
|
ATTACK_ENTITY(0),
|
||||||
|
@ -112,40 +92,79 @@ public class PacketEditingMessage implements CustomPacketPayload
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketEditingMessage(final FriendlyByteBuf buf) {
|
public static class Encoder implements BiConsumer<PacketEditingMessage, RegistryFriendlyByteBuf> {
|
||||||
this.type = Type.valueOf(buf.readInt());
|
public Encoder() {}
|
||||||
this.entityInfo = new EntityInfo();
|
|
||||||
try {
|
@Override
|
||||||
this.entityInfo.classType = this.entityInfo.getClass().getClassLoader().loadClass(buf.readUtf());
|
public void accept(PacketEditingMessage pkt, RegistryFriendlyByteBuf buf) {
|
||||||
} catch (ClassNotFoundException e) { /* ignored */ }
|
buf.writeInt(pkt.type.getValue());
|
||||||
this.entityInfo.ignoreBattle = buf.readBoolean();
|
if(pkt.entityInfo.classType != null) {
|
||||||
this.entityInfo.attackPower = buf.readInt();
|
buf.writeUtf(pkt.entityInfo.classType.getName());
|
||||||
this.entityInfo.attackProbability = buf.readInt();
|
} else {
|
||||||
this.entityInfo.attackVariance = buf.readInt();
|
buf.writeUtf("unknown");
|
||||||
this.entityInfo.attackEffect = EntityInfo.Effect.fromString(buf.readUtf());
|
}
|
||||||
this.entityInfo.attackEffectProbability = buf.readInt();
|
buf.writeBoolean(pkt.entityInfo.ignoreBattle);
|
||||||
this.entityInfo.defenseDamage = buf.readInt();
|
buf.writeInt(pkt.entityInfo.attackPower);
|
||||||
this.entityInfo.defenseDamageProbability = buf.readInt();
|
buf.writeInt(pkt.entityInfo.attackProbability);
|
||||||
this.entityInfo.evasion = buf.readInt();
|
buf.writeInt(pkt.entityInfo.attackVariance);
|
||||||
this.entityInfo.speed = buf.readInt();
|
buf.writeUtf(pkt.entityInfo.attackEffect.toString());
|
||||||
this.entityInfo.category = buf.readUtf();
|
buf.writeInt(pkt.entityInfo.attackEffectProbability);
|
||||||
this.entityInfo.decisionAttack = buf.readInt();
|
buf.writeInt(pkt.entityInfo.defenseDamage);
|
||||||
this.entityInfo.decisionDefend = buf.readInt();
|
buf.writeInt(pkt.entityInfo.defenseDamageProbability);
|
||||||
this.entityInfo.decisionFlee = buf.readInt();
|
buf.writeInt(pkt.entityInfo.evasion);
|
||||||
this.entityInfo.customName = buf.readUtf();
|
buf.writeInt(pkt.entityInfo.speed);
|
||||||
|
buf.writeInt(pkt.entityInfo.hasteSpeed);
|
||||||
|
buf.writeInt(pkt.entityInfo.slowSpeed);
|
||||||
|
buf.writeUtf(pkt.entityInfo.category);
|
||||||
|
buf.writeInt(pkt.entityInfo.decisionAttack);
|
||||||
|
buf.writeInt(pkt.entityInfo.decisionDefend);
|
||||||
|
buf.writeInt(pkt.entityInfo.decisionFlee);
|
||||||
|
buf.writeUtf(pkt.entityInfo.customName);
|
||||||
|
buf.writeUtf(pkt.entityInfo.playerName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PayloadHandler implements IPayloadHandler<PacketEditingMessage> {
|
public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketEditingMessage> {
|
||||||
|
public Decoder() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(final @NotNull PacketEditingMessage pkt, final IPayloadContext ctx) {
|
public PacketEditingMessage apply(RegistryFriendlyByteBuf buf) {
|
||||||
|
Type type = Type.valueOf(buf.readInt());
|
||||||
|
EntityInfo einfo = new EntityInfo();
|
||||||
|
try {
|
||||||
|
einfo.classType = einfo.getClass().getClassLoader().loadClass(buf.readUtf());
|
||||||
|
} catch (ClassNotFoundException e) { /* ignored */ }
|
||||||
|
einfo.ignoreBattle = buf.readBoolean();
|
||||||
|
einfo.attackPower = buf.readInt();
|
||||||
|
einfo.attackProbability = buf.readInt();
|
||||||
|
einfo.attackVariance = buf.readInt();
|
||||||
|
einfo.attackEffect = EntityInfo.Effect.fromString(buf.readUtf());
|
||||||
|
einfo.attackEffectProbability = buf.readInt();
|
||||||
|
einfo.defenseDamage = buf.readInt();
|
||||||
|
einfo.defenseDamageProbability = buf.readInt();
|
||||||
|
einfo.evasion = buf.readInt();
|
||||||
|
einfo.speed = buf.readInt();
|
||||||
|
einfo.hasteSpeed = buf.readInt();
|
||||||
|
einfo.slowSpeed = buf.readInt();
|
||||||
|
einfo.category = buf.readUtf();
|
||||||
|
einfo.decisionAttack = buf.readInt();
|
||||||
|
einfo.decisionDefend = buf.readInt();
|
||||||
|
einfo.decisionFlee = buf.readInt();
|
||||||
|
einfo.customName = buf.readUtf();
|
||||||
|
einfo.playerName = buf.readUtf();
|
||||||
|
return new PacketEditingMessage(type, einfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Consumer implements BiConsumer<PacketEditingMessage, CustomPayloadEvent.Context> {
|
||||||
|
public Consumer() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accept(PacketEditingMessage pkt, CustomPayloadEvent.Context ctx) {
|
||||||
ctx.enqueueWork(() -> {
|
ctx.enqueueWork(() -> {
|
||||||
if (FMLEnvironment.dist.isClient()) {
|
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
|
||||||
TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx);
|
|
||||||
}
|
|
||||||
}).exceptionally(e -> {
|
|
||||||
ctx.disconnect(Component.literal("Exception handling PacketEditingMessage! " + e.getMessage()));
|
|
||||||
return null;
|
|
||||||
});
|
});
|
||||||
|
ctx.setPacketHandled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,52 +1,59 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||||
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||||
import io.netty.buffer.ByteBuf;
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraft.network.codec.ByteBufCodecs;
|
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.neoforged.fml.loading.FMLEnvironment;
|
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadHandler;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public record PacketGeneralMessage(String message) implements CustomPacketPayload
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class PacketGeneralMessage
|
||||||
{
|
{
|
||||||
public static final CustomPacketPayload.Type<PacketGeneralMessage> TYPE = new CustomPacketPayload.Type<>(ResourceLocation.fromNamespaceAndPath(TurnBasedMinecraftMod.MODID, "network_packetgeneralmessage"));
|
String message;
|
||||||
|
|
||||||
public static final StreamCodec<ByteBuf, PacketGeneralMessage> STREAM_CODEC = StreamCodec.composite(
|
|
||||||
ByteBufCodecs.STRING_UTF8,
|
|
||||||
PacketGeneralMessage::message,
|
|
||||||
PacketGeneralMessage::new
|
|
||||||
);
|
|
||||||
|
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PacketGeneralMessage()
|
||||||
|
{
|
||||||
|
message = new String();
|
||||||
|
}
|
||||||
|
|
||||||
public PacketGeneralMessage(String message)
|
public PacketGeneralMessage(String message)
|
||||||
{
|
{
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class Encoder implements BiConsumer<PacketGeneralMessage, RegistryFriendlyByteBuf> {
|
||||||
|
public Encoder() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type<? extends CustomPacketPayload> type() {
|
public void accept(PacketGeneralMessage pkt, RegistryFriendlyByteBuf buf) {
|
||||||
return TYPE;
|
buf.writeUtf(pkt.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PayloadHandler implements IPayloadHandler<PacketGeneralMessage> {
|
public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketGeneralMessage> {
|
||||||
|
public Decoder() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(final @NotNull PacketGeneralMessage pkt, final IPayloadContext ctx) {
|
public PacketGeneralMessage apply(RegistryFriendlyByteBuf buf) {
|
||||||
|
return new PacketGeneralMessage(buf.readUtf());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Consumer implements BiConsumer<PacketGeneralMessage, CustomPayloadEvent.Context> {
|
||||||
|
public Consumer() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accept(PacketGeneralMessage pkt, CustomPayloadEvent.Context ctx) {
|
||||||
ctx.enqueueWork(() -> {
|
ctx.enqueueWork(() -> {
|
||||||
if (FMLEnvironment.dist.isClient()) {
|
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
|
||||||
TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx);
|
|
||||||
}
|
|
||||||
}).exceptionally(e -> {
|
|
||||||
ctx.disconnect(Component.literal("Exception handling PacketGeneralMessage! " + e.getMessage()));
|
|
||||||
return null;
|
|
||||||
});
|
});
|
||||||
|
ctx.setPacketHandled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
57
src/main/resources/META-INF/mods.toml
Normal file
57
src/main/resources/META-INF/mods.toml
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
# This is an example mods.toml file. It contains the data relating to the loading mods.
|
||||||
|
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
|
||||||
|
# The overall format is standard TOML format, v0.5.0.
|
||||||
|
# Note that there are a couple of TOML lists in this file.
|
||||||
|
# Find more information on toml format here: https://github.com/toml-lang/toml
|
||||||
|
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
||||||
|
modLoader="javafml" #mandatory
|
||||||
|
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
|
||||||
|
loaderVersion="${loader_version_range}" #mandatory (34 is current forge version)
|
||||||
|
# A URL to refer people to when problems occur with this mod
|
||||||
|
issueTrackerURL="https://github.com/Stephen-Seo/TurnBasedMinecraftMod/issues" #optional
|
||||||
|
license="MIT"
|
||||||
|
# A list of mods - how many allowed here is determined by the individual mod loader
|
||||||
|
[[mods]] #mandatory
|
||||||
|
# The modid of the mod
|
||||||
|
modId="${mod_id}" #mandatory
|
||||||
|
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
|
||||||
|
version="${mod_version}" #mandatory
|
||||||
|
# A display name for the mod
|
||||||
|
displayName="${mod_name}" #mandatory
|
||||||
|
# A URL to query for updates for this mod. See the JSON update specification <here>
|
||||||
|
#updateJSONURL="" #optional
|
||||||
|
updateJSONURL="https://github.com/Stephen-Seo/TurnBasedMinecraftMod/raw/refs/heads/forge/update.json"
|
||||||
|
# A URL for the "homepage" for this mod, displayed in the mod UI
|
||||||
|
displayURL="https://github.com/Stephen-Seo/TurnBasedMinecraftMod" #optional
|
||||||
|
# A file name (in the root of the mod JAR) containing a logo for display
|
||||||
|
#logoFile="" #optional
|
||||||
|
# A text field displayed in the mod UI
|
||||||
|
credits="Thanks for this mod goes to Java" #optional
|
||||||
|
# A text field displayed in the mod UI
|
||||||
|
authors="${mod_authors}" #optional
|
||||||
|
# The description text for the mod (multi line!) (#mandatory)
|
||||||
|
description='''
|
||||||
|
Implements turn-based-battle in Minecraft.
|
||||||
|
'''
|
||||||
|
|
||||||
|
logoFile="assets/com_burnedkirby_turnbasedminecraft/tbmm_icon.png"
|
||||||
|
|
||||||
|
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
||||||
|
[[dependencies.com_burnedkirby_turnbasedminecraft]] #optional
|
||||||
|
# the modid of the dependency
|
||||||
|
modId="forge" #mandatory
|
||||||
|
# Does this dependency have to exist - if not, ordering below must be specified
|
||||||
|
mandatory=true #mandatory
|
||||||
|
# The version range of the dependency
|
||||||
|
versionRange="${forge_version_range}" #mandatory
|
||||||
|
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
||||||
|
ordering="NONE"
|
||||||
|
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
||||||
|
side="BOTH"
|
||||||
|
# Here's another dependency
|
||||||
|
[[dependencies.com_burnedkirby_turnbasedminecraft]]
|
||||||
|
modId="minecraft"
|
||||||
|
mandatory=true
|
||||||
|
versionRange="${minecraft_version_range}"
|
||||||
|
ordering="NONE"
|
||||||
|
side="BOTH"
|
|
@ -1,94 +0,0 @@
|
||||||
# This is an example neoforge.mods.toml file. It contains the data relating to the loading mods.
|
|
||||||
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
|
|
||||||
# The overall format is standard TOML format, v0.5.0.
|
|
||||||
# Note that there are a couple of TOML lists in this file.
|
|
||||||
# Find more information on toml format here: https://github.com/toml-lang/toml
|
|
||||||
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
|
||||||
modLoader="javafml" #mandatory
|
|
||||||
|
|
||||||
# A version range to match for said mod loader - for regular FML @Mod it will be the FML version. This is currently 2.
|
|
||||||
loaderVersion="${loader_version_range}" #mandatory
|
|
||||||
|
|
||||||
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
|
|
||||||
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
|
|
||||||
license="${mod_license}"
|
|
||||||
|
|
||||||
# A URL to refer people to when problems occur with this mod
|
|
||||||
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
|
|
||||||
|
|
||||||
# A list of mods - how many allowed here is determined by the individual mod loader
|
|
||||||
[[mods]] #mandatory
|
|
||||||
|
|
||||||
# The modid of the mod
|
|
||||||
modId="${mod_id}" #mandatory
|
|
||||||
|
|
||||||
# The version number of the mod
|
|
||||||
version="${mod_version}" #mandatory
|
|
||||||
|
|
||||||
# A display name for the mod
|
|
||||||
displayName="${mod_name}" #mandatory
|
|
||||||
|
|
||||||
# A URL to query for updates for this mod. See the JSON update specification https://docs.neoforged.net/docs/misc/updatechecker/
|
|
||||||
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
|
|
||||||
updateJSONURL="https://github.com/Stephen-Seo/TurnBasedMinecraftMod/raw/refs/heads/neoforge/update.json"
|
|
||||||
|
|
||||||
# A URL for the "homepage" for this mod, displayed in the mod UI
|
|
||||||
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional
|
|
||||||
|
|
||||||
# A file name (in the root of the mod JAR) containing a logo for display
|
|
||||||
#logoFile="examplemod.png" #optional
|
|
||||||
logoFile="assets/com_burnedkirby_turnbasedminecraft/tbmm_icon.png"
|
|
||||||
|
|
||||||
# A text field displayed in the mod UI
|
|
||||||
#credits="" #optional
|
|
||||||
|
|
||||||
# A text field displayed in the mod UI
|
|
||||||
authors="${mod_authors}" #optional
|
|
||||||
|
|
||||||
# The description text for the mod (multi line!) (#mandatory)
|
|
||||||
description='''${mod_description}'''
|
|
||||||
|
|
||||||
# The [[mixins]] block allows you to declare your mixin config to FML so that it gets loaded.
|
|
||||||
#[[mixins]]
|
|
||||||
#config="${mod_id}.mixins.json"
|
|
||||||
|
|
||||||
# The [[accessTransformers]] block allows you to declare where your AT file is.
|
|
||||||
# If this block is omitted, a fallback attempt will be made to load an AT from META-INF/accesstransformer.cfg
|
|
||||||
#[[accessTransformers]]
|
|
||||||
#file="META-INF/accesstransformer.cfg"
|
|
||||||
|
|
||||||
# The coremods config file path is not configurable and is always loaded from META-INF/coremods.json
|
|
||||||
|
|
||||||
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
|
||||||
[[dependencies.${mod_id}]] #optional
|
|
||||||
# the modid of the dependency
|
|
||||||
modId="neoforge" #mandatory
|
|
||||||
# The type of the dependency. Can be one of "required", "optional", "incompatible" or "discouraged" (case insensitive).
|
|
||||||
# 'required' requires the mod to exist, 'optional' does not
|
|
||||||
# 'incompatible' will prevent the game from loading when the mod exists, and 'discouraged' will show a warning
|
|
||||||
type="required" #mandatory
|
|
||||||
# Optional field describing why the dependency is required or why it is incompatible
|
|
||||||
# reason="..."
|
|
||||||
# The version range of the dependency
|
|
||||||
versionRange="${neo_version_range}" #mandatory
|
|
||||||
# An ordering relationship for the dependency.
|
|
||||||
# BEFORE - This mod is loaded BEFORE the dependency
|
|
||||||
# AFTER - This mod is loaded AFTER the dependency
|
|
||||||
ordering="NONE"
|
|
||||||
# Side this dependency is applied on - BOTH, CLIENT, or SERVER
|
|
||||||
side="BOTH"
|
|
||||||
|
|
||||||
# Here's another dependency
|
|
||||||
[[dependencies.${mod_id}]]
|
|
||||||
modId="minecraft"
|
|
||||||
type="required"
|
|
||||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
|
||||||
versionRange="${minecraft_version_range}"
|
|
||||||
ordering="NONE"
|
|
||||||
side="BOTH"
|
|
||||||
|
|
||||||
# Features are specific properties of the game environment, that you may want to declare you require. This example declares
|
|
||||||
# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't
|
|
||||||
# stop your mod loading on the server for example.
|
|
||||||
#[features.${mod_id}]
|
|
||||||
#openGLVersion="[3.2,)"
|
|
22
update.json
22
update.json
|
@ -1,22 +1,14 @@
|
||||||
{
|
{
|
||||||
"homepage": "https://github.com/Stephen-Seo/TurnBasedMinecraftMod",
|
"homepage": "https://github.com/Stephen-Seo/TurnBasedMinecraftMod",
|
||||||
"1.21.3": {
|
|
||||||
"1.26.5": "Config improvements, NeoForge 21.3.11-beta.\n https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/neoforge/Changelog.md",
|
|
||||||
"1.26.4": "Add player-specific config, NeoForge 21.3.6-beta.\n https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/neoforge/Changelog.md",
|
|
||||||
"1.26.3": "Ported to NeoForge 21.3.2-beta (MC 1.21.3), minor tweak to packet.\n https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/neoforge/Changelog.md"
|
|
||||||
},
|
|
||||||
"1.21.1": {
|
"1.21.1": {
|
||||||
"1.26.5-MC-1.21.1": "Config improvements, NeoForge 21.1.74.\n https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/neoforge/Changelog.md",
|
"1.26.4": "Add player-specific config, Forge 52.0.24.\n https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/forge/Changelog.md",
|
||||||
"1.26.4-MC-1.21.1": "Add player-specific config, NeoForge 21.1.73.\n https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/neoforge/Changelog.md",
|
"1.26.3": "Minor networking change.\n https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/forge/Changelog.md",
|
||||||
"1.26.3-MC-1.21.1": "Minor tweak to packet.\n https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/neoforge/Changelog.md",
|
"1.26.2": "Display Entities on attack menu in BattleGUI.\n https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/forge/Changelog.md",
|
||||||
"1.26.2": "Display Entities on attack menu in BattleGUI.\n https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/neoforge/Changelog.md",
|
"1.26.1": "Ported to Forge 52.0.22, leave BattleGUI with Escape Key, MC music paused in battle properly.\n https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/forge/Changelog.md",
|
||||||
"1.26.1": "Ported to NeoForge 21.1.72, leave BattleGUI with Escape key, MC music paused in battle properly.\n https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/neoforge/Changelog.md",
|
"1.26.0": "Ported to Forge 52.0.21, client config.\n https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/forge/Changelog.md"
|
||||||
"1.26.0": "Ported to NeoForge 21.1.69, client config.\n https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/neoforge/Changelog.md"
|
|
||||||
},
|
},
|
||||||
"promos": {
|
"promos": {
|
||||||
"1.21.3-latest": "1.26.5",
|
"1.21.1-latest": "1.26.4",
|
||||||
"1.21.3-recommended": "1.26.5",
|
"1.21.1-recommended": "1.26.4"
|
||||||
"1.21.1-latest": "1.26.5-MC-1.21.1",
|
|
||||||
"1.21.1-recommended": "1.26.5-MC-1.21.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue