Compare commits
62 commits
forge-1.25
...
neoforge
Author | SHA1 | Date | |
---|---|---|---|
Stephen Seo | bba99d4e6a | ||
Stephen Seo | 356502f722 | ||
Stephen Seo | 75976c8d9a | ||
Stephen Seo | 62774b0b0c | ||
Stephen Seo | 846840c3a7 | ||
Stephen Seo | 43bb0c7059 | ||
Stephen Seo | 288ed1cfd6 | ||
Stephen Seo | b8a32a490e | ||
Stephen Seo | ae3cbfe4f6 | ||
Stephen Seo | 9a481f95d0 | ||
Stephen Seo | 24a29eaba6 | ||
Stephen Seo | 9fab572800 | ||
Stephen Seo | 6f0c223c9d | ||
Stephen Seo | 17c39a5329 | ||
Stephen Seo | 4879aaefd1 | ||
Stephen Seo | 46f8e22c8b | ||
Stephen Seo | 54afb08263 | ||
Stephen Seo | 2616e73407 | ||
Stephen Seo | edc3246bd1 | ||
Stephen Seo | b1b8451331 | ||
Stephen Seo | f635badfe1 | ||
Stephen Seo | fb2c4cd13c | ||
Stephen Seo | 830f4255bb | ||
Stephen Seo | 490518a58a | ||
Stephen Seo | e3ba1abdae | ||
Stephen Seo | d564756c42 | ||
Stephen Seo | 64a7fb263f | ||
Stephen Seo | 52b1b5ee05 | ||
Stephen Seo | 2e71ea97ad | ||
Stephen Seo | f9178777ee | ||
Stephen Seo | 9d4cd5c4e7 | ||
Stephen Seo | 85c4588470 | ||
Stephen Seo | 7770698947 | ||
Stephen Seo | a3d4ae74ef | ||
Stephen Seo | f56891e1d0 | ||
Stephen Seo | d58ef1585a | ||
Stephen Seo | 2cbad47b33 | ||
Stephen Seo | d57f18d6c2 | ||
Stephen Seo | c0bbf92efc | ||
Stephen Seo | 5708e46118 | ||
Stephen Seo | edf2d3926d | ||
Stephen Seo | 3caf1d31bf | ||
Stephen Seo | 01bf977fd6 | ||
Stephen Seo | 75b710c3d4 | ||
Stephen Seo | 0c5e823839 | ||
Stephen Seo | c8e405f685 | ||
Stephen Seo | 29d45ea0f9 | ||
Stephen Seo | 63fb52e75f | ||
Stephen Seo | 4881f056f5 | ||
Stephen Seo | 3cc138dd47 | ||
Stephen Seo | 8d15bbb593 | ||
Stephen Seo | 36b25b7d07 | ||
Stephen Seo | 4801558716 | ||
Stephen Seo | 69b72cadd8 | ||
Stephen Seo | f245947686 | ||
Stephen Seo | 08b8c7d412 | ||
Stephen Seo | 8e3b028f6c | ||
Stephen Seo | 7c4d4b6eb8 | ||
Stephen Seo | 02684bfbad | ||
Stephen Seo | b00f500e36 | ||
Stephen Seo | a1de902d69 | ||
Stephen Seo | c9bf87271d |
50
.forgejo/workflows/build-jar.yaml
Normal file
50
.forgejo/workflows/build-jar.yaml
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
name: Build TurnBasedMC and create Release
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check-release-exists:
|
||||||
|
runs-on: any_archLinux
|
||||||
|
outputs:
|
||||||
|
status: ${{ steps.release_exists_check.outputs.http_code }}
|
||||||
|
steps:
|
||||||
|
- name: Check if release already exists
|
||||||
|
id: release_exists_check
|
||||||
|
run: |
|
||||||
|
curl -X GET "https://git.seodisparate.com/api/v1/repos/stephenseo/TurnBasedMinecraftMod/releases/tags/${GITHUB_REF_NAME}" \
|
||||||
|
-H 'accept: application/json' -o release_check_resp.json 2>/dev/null \
|
||||||
|
-w '%{http_code}\n' | sed 's/^\([0-9]\+\)/http_code=\1/' >> "$GITHUB_OUTPUT"
|
||||||
|
build-and-create-release:
|
||||||
|
needs: check-release-exists
|
||||||
|
if: ${{ needs.check-release-exists.outputs.status == '404' }}
|
||||||
|
runs-on: any_archLinux
|
||||||
|
steps:
|
||||||
|
- 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 && sed -i '/org.gradle.jvmargs/s/Xmx[0-9]\+m/Xmx1024m/' gradle.properties && echo 'neogradle.subsystems.decompiler.maxThreads=1' >> gradle.properties
|
||||||
|
- 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
|
||||||
|
- name: Create release and attach jar
|
||||||
|
run: |
|
||||||
|
curl --fail-with-body -X 'POST' \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/TurnBasedMinecraftMod/releases" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d "{
|
||||||
|
\"name\": \"TurnBasedMinecraftMod version ${GITHUB_REF_NAME}\",
|
||||||
|
\"body\": \"See the [Changelog](https://git.seodisparate.com/stephenseo/TurnBasedMinecraftMod/src/branch/neoforge/Changelog.md)
|
||||||
|
|
||||||
|
$(java --version | sed -n '1p;2,$s/^/ /p')
|
||||||
|
$(javac --version)
|
||||||
|
$(find TurnBasedMinecraftMod/build/libs -regex '.*all.jar$' -exec sha256sum '{}' ';')\",
|
||||||
|
\"tag_name\": \"${GITHUB_REF_NAME}\"
|
||||||
|
}" > response.json \
|
||||||
|
&& curl --fail-with-body -X 'POST' \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/TurnBasedMinecraftMod/releases/$(jq .id < response.json)/assets" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
|
-H 'Content-Type: multipart/form-data' \
|
||||||
|
-F "attachment=@$(find TurnBasedMinecraftMod/build/libs -regex '.*all.jar$');type=application/java-archive" > response2.json
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -22,3 +22,4 @@ eclipse
|
||||||
run
|
run
|
||||||
|
|
||||||
logs/
|
logs/
|
||||||
|
runs/
|
||||||
|
|
62
Changelog.md
62
Changelog.md
|
@ -1,5 +1,67 @@
|
||||||
# Upcoming changes
|
# Upcoming changes
|
||||||
|
|
||||||
|
# Version NeoForge-1.25.2
|
||||||
|
|
||||||
|
Fix invalid use of throwable potions. (Previously, the Player would "drink"
|
||||||
|
splash/lingering potions when used.) Now, if a splash/lingering potion is
|
||||||
|
"Use"d in battle, it will be thrown.
|
||||||
|
|
||||||
|
Add experimental support for "right-click" of arbitrary items on hotbar when
|
||||||
|
"Use" is used in battle.
|
||||||
|
|
||||||
|
# Version Forge-1.25.2
|
||||||
|
|
||||||
|
Fix invalid use of throwable potions. (Previously, the Player would "drink"
|
||||||
|
splash/lingering potions when used.) Now, if a splash/lingering potion is
|
||||||
|
"Use"d in battle, it will be thrown.
|
||||||
|
|
||||||
|
Add experimental support for "right-click" of arbitrary items on hotbar when
|
||||||
|
"Use" is used in battle.
|
||||||
|
|
||||||
|
# Version Forge-1.25.1
|
||||||
|
|
||||||
|
Add icon for mod in Mod list description.
|
||||||
|
|
||||||
|
Update for Forge 49.0.19.
|
||||||
|
Works on Forge Minecraft 1.20.4.
|
||||||
|
|
||||||
|
# Version NeoForge-1.25.1
|
||||||
|
|
||||||
|
Add icon for mod in Mod list description.
|
||||||
|
|
||||||
|
Update for NeoForge 20.4.108-beta.
|
||||||
|
Works on NeoForge Minecraft 1.20.4.
|
||||||
|
|
||||||
|
# Version NeoForge-1.25.0
|
||||||
|
|
||||||
|
Add new dependency `j-ogg-vorbis`.
|
||||||
|
|
||||||
|
Implement playing Vorbis encoded .ogg files for battle/silly music.
|
||||||
|
|
||||||
|
# Version Forge-1.25.0
|
||||||
|
|
||||||
|
Remove usage of "shadow jar" in build.gradle, and use jarJar instead.
|
||||||
|
|
||||||
|
Add new dependency `j-ogg-vorbis`.
|
||||||
|
|
||||||
|
Implement playing Vorbis encoded .ogg files for battle/silly music.
|
||||||
|
|
||||||
|
# Version NeoForge-1.24.0
|
||||||
|
|
||||||
|
Update to NeoForge 1.20.2-20.2.88.
|
||||||
|
|
||||||
|
Allow use of Crossbows in battle (it should behave identically to Bows).
|
||||||
|
|
||||||
|
# Version Forge-1.24.0
|
||||||
|
|
||||||
|
Update to Forge 1.20.2-48.1.0.
|
||||||
|
|
||||||
|
The `master` branch of this repository will track the build for Minecraft Forge.
|
||||||
|
|
||||||
|
The `neoforge` branch of this repo. will track the build for NeoForge.
|
||||||
|
|
||||||
|
Allow use of Crossbows in battle (it should behave identically to Bows).
|
||||||
|
|
||||||
# Version 1.23.1
|
# Version 1.23.1
|
||||||
|
|
||||||
More robust handling of disallowed Damage Sources in battle (via config).
|
More robust handling of disallowed Damage Sources in battle (via config).
|
||||||
|
|
77
FAQ.md
Normal file
77
FAQ.md
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
## How do I use this mod to have turn-based-battle with any mob (including mobs from other mods)?
|
||||||
|
|
||||||
|
To have turn-based-battle with a mob, it must have a config entry in the server
|
||||||
|
config. This can either be done manually or be [done in-game via a
|
||||||
|
command](https://www.youtube.com/watch?v=MK648OVHddE).
|
||||||
|
|
||||||
|
## Is it possible to have a mob's config applied to any mob with a specific name?
|
||||||
|
|
||||||
|
Yes, [this video explains this feature](https://www.youtube.com/watch?v=9lBETQFMd3A).
|
||||||
|
|
||||||
|
## Can the mod play music while a battle is happening?
|
||||||
|
|
||||||
|
Yes, you have to put the music (`.wav`, `.ogg`, or `.mp3`) in
|
||||||
|
`.minecraft/config/TurnBasedMinecraft/Music/battle` and
|
||||||
|
`.minecraft/config/TurnBasedMinecraft/Music/silly` . Note that `.wav`, `.ogg`,
|
||||||
|
and `.mp3` music files are supported, but `.mid` files are disabled due to lack
|
||||||
|
of volume control with the default Java library api. The config file can be
|
||||||
|
edited to change what categories of entities trigger what type of music, but
|
||||||
|
generally "passive" mobs trigger the "silly" music and everything else triggers
|
||||||
|
"battle" music. Note that the default server config has turn-based-battle
|
||||||
|
disabled for "passive" mobs.
|
||||||
|
|
||||||
|
**Note that while .ogg Vorbis files are supported, .ogg Opus files are NOT
|
||||||
|
supported.**
|
||||||
|
|
||||||
|
One can use FFmpeg to convert music files into .ogg Vorbis:
|
||||||
|
|
||||||
|
ffmpeg -i <music_file_to_convert> -map a:0 -c:a libvorbis output.ogg
|
||||||
|
|
||||||
|
## Why can't the mod play my mp3 files?
|
||||||
|
|
||||||
|
The third-party-library used to load mp3 files seems to have issues with
|
||||||
|
loading any mp3 file that isn't "barebones". Try removing the metadata of the
|
||||||
|
mp3 file. I've found that using mp3s without album art embedded in it seems to
|
||||||
|
work.
|
||||||
|
|
||||||
|
**It is recommended to use .ogg Vorbis files instead of .mp3 files.**
|
||||||
|
|
||||||
|
## Why do passive mobs don't start turn-based battle?
|
||||||
|
|
||||||
|
By default, the `passive` category is set to "ignore turn-based-battle" in the
|
||||||
|
server config. Use `/tbm-server-edit` to change this. (Click on
|
||||||
|
`ignore_battle_types` which should be dark-green. A list of "categories" will
|
||||||
|
appear at the bottom of the text. Click on `passive` to remove the "passive"
|
||||||
|
category.)
|
||||||
|
![Screenshot one of two showing how to unset passive category from ignore battle types list](https://seodisparate.com/static/uploads/TBMM_ignore_battle_types_screenshot0.png)
|
||||||
|
![Screenshot two of two showing how to unset passive category from ignore battle types list](https://seodisparate.com/static/uploads/TBMM_ignore_battle_types_screenshot1.png)
|
||||||
|
|
||||||
|
Alternatively, edit the [server config](https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/ad78063a16c768f660dd086cba857a3be43a84b2/src/main/resources/assets/com_burnedkirby_turnbasedminecraft/TBM_Config.toml#L46)
|
||||||
|
and remove "passive" from the ignore\_battle\_types list.
|
||||||
|
|
||||||
|
## Why is the mod's config file missing?
|
||||||
|
|
||||||
|
The mod needs to be run once to generate the default config file and
|
||||||
|
directories for battle music. After running it once, you can now close
|
||||||
|
Minecraft and edit the config found at
|
||||||
|
`.minecraft/config/TurnBasedMinecraft/TBM_Config.toml` Note that some options
|
||||||
|
only apply to the server and some only to the client, as specified in the
|
||||||
|
config. This means that server config must be changed on the server side for it
|
||||||
|
to take effect (local singleplayer will use all of the local config, but
|
||||||
|
multiplayer setups will require the server config to be changed on the server
|
||||||
|
side). [You can edit the server-side config in game via the "/tbm-server-edit"
|
||||||
|
command](https://youtu.be/9xkbHNWkcIY).
|
||||||
|
|
||||||
|
## I updated the mod, but now my config changes are back to default, what happened?
|
||||||
|
|
||||||
|
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
|
||||||
|
config's version number with the existing config's version number. If the
|
||||||
|
existing config is determined to be outdated, then it is renamed to a different
|
||||||
|
name (which usually includes the date/time of when it was renamed), and the new
|
||||||
|
default config is placed in its place. There is a config option to prevent this
|
||||||
|
from happening, but it is strongly recommended to not disable this since this
|
||||||
|
will cause updates to the config to never be placed in the mod's config
|
||||||
|
directory. If you have changes you want to keep, but the mod renamed the
|
||||||
|
original config, you will have to edit the `TBM_Config.toml` to have the
|
||||||
|
changes you want from the renamed older config file.
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2018-2023 Stephen Seo
|
Copyright (c) 2018-2024 Stephen Seo
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
49
README.md
49
README.md
|
@ -7,10 +7,15 @@ This mod puts turn-based-combat of RPGs into Minecraft!
|
||||||
Precompiled jars are available here:
|
Precompiled jars are available here:
|
||||||
https://seodisparate.com/static/tbm_releases/
|
https://seodisparate.com/static/tbm_releases/
|
||||||
https://burnedkirby.com/tbmm_downloads/
|
https://burnedkirby.com/tbmm_downloads/
|
||||||
https://www.curseforge.com/minecraft/mc-mods/turnbasedminecraft/files
|
https://www.curseforge.com/minecraft/mc-mods/turnbasedminecraft/files
|
||||||
|
https://modrinth.com/mod/turnbasedmc
|
||||||
|
https://git.seodisparate.com/stephenseo/TurnBasedMinecraftMod/releases
|
||||||
|
|
||||||
(Once modrinth.com has approved this mod, the modrinth page of this mod will be
|
# Forge or NeoForge
|
||||||
linked here.)
|
|
||||||
|
The `forge` branch tracks the version of the mod for Minecraft Forge.
|
||||||
|
|
||||||
|
The `neoforge` branch tracks the version of the mod for Minecraft NeoForge.
|
||||||
|
|
||||||
# What changed in what version
|
# What changed in what version
|
||||||
|
|
||||||
|
@ -41,14 +46,19 @@ When playing multiplayer, some configuration of the config on the server may be
|
||||||
between them
|
between them
|
||||||
- Supports use of the vanilla Minecraft bow and arrows (have bow selected when
|
- Supports use of the vanilla Minecraft bow and arrows (have bow selected when
|
||||||
in battle)
|
in battle)
|
||||||
- Supports custom battle music to be played when fighting enemies. (They must be
|
- Supports custom battle music to be played when fighting enemies. (They must
|
||||||
placed in `.minecraft/config/TurnBasedMinecraft/Music/battle` or
|
be placed in `.minecraft/config/TurnBasedMinecraft/Music/battle` or
|
||||||
`.minecraft/config/TurnBasedMinecraft/Music/silly`. Client-side config determines
|
`.minecraft/config/TurnBasedMinecraft/Music/silly`. Client-side config
|
||||||
which song plays in battle for the client. only `.wav`, ~~`.mid`~~, and `.mp3` files
|
determines which song plays in battle for the client. only `.wav`,
|
||||||
supported. ~~Only `.mid` files are not affected by volume options (master and
|
~~`.mid`~~, `.mp3`, and `.ogg` files supported. ~~Only `.mid` files are not
|
||||||
music sliders))~~ Midi file playback has been disabled for now due to lack of volume
|
affected by volume options (master and music sliders))~~ Midi file playback
|
||||||
control issues. MP3 file playback sometimes fails, but seems to work better when the
|
has been disabled for now due to lack of volume control issues. MP3 file
|
||||||
file is as "barebones" as possible (no album art metadata in the file).
|
playback sometimes fails, but seems to work better when the file is as
|
||||||
|
"barebones" as possible (no album art metadata in the file).
|
||||||
|
- It is recommended to use `.ogg` files for music.
|
||||||
|
- Note that ogg Vorbis is supported, and NOT ogg Opus.
|
||||||
|
- One can convert to ogg Vorbis with ffmpeg like this: `ffmpeg -i
|
||||||
|
<my_music_file_to_convert> -map a:0 -c:a libvorbis output.ogg`.
|
||||||
- Config allows limiting number of combatants in turn-based battle.
|
- Config allows limiting number of combatants in turn-based battle.
|
||||||
- Config can be modified (server-side) to add entries of mobs from other mods.
|
- Config can be modified (server-side) to add entries of mobs from other mods.
|
||||||
(by default an unknown mob cannot enter turn-based battle, so the config must be
|
(by default an unknown mob cannot enter turn-based battle, so the config must be
|
||||||
|
@ -61,16 +71,27 @@ configured for them.)
|
||||||
# Building
|
# Building
|
||||||
|
|
||||||
Simply invoke `./gradlew build` in the mod directory and after some time the
|
Simply invoke `./gradlew build` in the mod directory and after some time the
|
||||||
finished jar will be saved at "build/libs/TurnBasedMinecraft-1.23.1.jar"
|
finished jar will be saved at
|
||||||
|
`build/libs/TurnBasedMinecraft-NeoForge-1.25.2-all.jar`
|
||||||
|
|
||||||
|
# Reproducibility
|
||||||
|
|
||||||
|
This mod should support reproducible builds. See `Reproducibility.md` to see
|
||||||
|
more details.
|
||||||
|
|
||||||
# Other notes
|
# Other notes
|
||||||
|
|
||||||
This mod uses [shadow](https://github.com/johnrengelman/shadow) which is
|
This mod uses [j-ogg-vorbis](https://github.com/stephengold/j-ogg-all)
|
||||||
licenced under the [Apache License 2.0](https://github.com/johnrengelman/shadow/blob/master/LICENSE).
|
available from [http://www.j-ogg.de](http://www.j-ogg.de) and copyrighted by
|
||||||
|
Tor-Einar 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
|
||||||
|
|
||||||
|
[See the FAQ page.](https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/master/FAQ.md)
|
||||||
|
|
||||||
# Related Videos
|
# Related Videos
|
||||||
|
|
||||||
[See related videos here](https://burnedkirby.com/posts/tbmm/)
|
[See related videos here](https://burnedkirby.com/posts/tbmm/)
|
||||||
|
|
109
Reproducibility.md
Normal file
109
Reproducibility.md
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
# Reproducibility
|
||||||
|
|
||||||
|
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
|
||||||
|
should result in an identical jar due to reproducible builds.
|
||||||
|
|
||||||
|
## NeoForge 1.25.2
|
||||||
|
|
||||||
|
$ java --version
|
||||||
|
openjdk 17.0.10 2024-01-16
|
||||||
|
OpenJDK Runtime Environment (build 17.0.10+7)
|
||||||
|
OpenJDK 64-Bit Server VM (build 17.0.10+7, mixed mode)
|
||||||
|
|
||||||
|
$ javac --version
|
||||||
|
javac 17.0.10
|
||||||
|
|
||||||
|
$ sha256sum build/libs/TurnBasedMinecraft-NeoForge-1.25.2-all.jar
|
||||||
|
c59533059eb322a616f38ab40ccbc7d4d6c1667a651328a4c6eb187fe16d7a6f build/libs/TurnBasedMinecraft-NeoForge-1.25.2-all.jar
|
||||||
|
|
||||||
|
## Forge 1.25.2
|
||||||
|
|
||||||
|
$ java --version
|
||||||
|
openjdk 17.0.10 2024-01-16
|
||||||
|
OpenJDK Runtime Environment (build 17.0.10+7)
|
||||||
|
OpenJDK 64-Bit Server VM (build 17.0.10+7, mixed mode)
|
||||||
|
|
||||||
|
$ javac --version
|
||||||
|
javac 17.0.10
|
||||||
|
|
||||||
|
$ sha256sum build/libs/TurnBasedMinecraft-Forge-1.25.2-all.jar
|
||||||
|
00bc7958431e161b0a512ce32b41c1a97516b00e109195294ee18d4abf58dc26 build/libs/TurnBasedMinecraft-Forge-1.25.2-all.jar
|
||||||
|
|
||||||
|
## Forge 1.25.1
|
||||||
|
|
||||||
|
$ java --version
|
||||||
|
openjdk 17.0.9 2023-10-17
|
||||||
|
OpenJDK Runtime Environment (build 17.0.9+8)
|
||||||
|
OpenJDK 64-Bit Server VM (build 17.0.9+8, mixed mode)
|
||||||
|
|
||||||
|
$ javac --version
|
||||||
|
javac 17.0.9
|
||||||
|
|
||||||
|
$ sha256sum build/libs/TurnBasedMinecraft-Forge-1.25.1-all.jar
|
||||||
|
33711947eed8b24fa7fd65d36ecdb6ed78e144af8d7fff6e1bfa304cfe4a1d3d build/libs/TurnBasedMinecraft-Forge-1.25.1-all.jar
|
||||||
|
|
||||||
|
## NeoForge 1.25.1
|
||||||
|
|
||||||
|
$ java --version
|
||||||
|
openjdk 17.0.9 2023-10-17
|
||||||
|
OpenJDK Runtime Environment (build 17.0.9+8)
|
||||||
|
OpenJDK 64-Bit Server VM (build 17.0.9+8, mixed mode)
|
||||||
|
|
||||||
|
$ javac --version
|
||||||
|
javac 17.0.9
|
||||||
|
|
||||||
|
$ sha256sum build/libs/TurnBasedMinecraft-NeoForge-1.25.1-all.jar
|
||||||
|
b0ec086c356c4d3662dcea4bdd9aeb2b0786e4ef40e061599e81b529746e01ea build/libs/TurnBasedMinecraft-NeoForge-1.25.1-all.jar
|
||||||
|
|
||||||
|
## NeoForge 1.25.0
|
||||||
|
|
||||||
|
$ java --version
|
||||||
|
openjdk 17.0.9 2023-10-17
|
||||||
|
OpenJDK Runtime Environment (build 17.0.9+8)
|
||||||
|
OpenJDK 64-Bit Server VM (build 17.0.9+8, mixed mode)
|
||||||
|
|
||||||
|
$ javac --version
|
||||||
|
javac 17.0.9
|
||||||
|
|
||||||
|
$ sha256sum build/libs/TurnBasedMinecraft-NeoForge-1.25.0-all.jar
|
||||||
|
0e5eacc8aefd3b1a1c8e6c9657108172934fae2e727547ca7c12f9ff79ce4e8e build/libs/TurnBasedMinecraft-NeoForge-1.25.0-all.jar
|
||||||
|
|
||||||
|
## Forge 1.25.0
|
||||||
|
|
||||||
|
$ java --version
|
||||||
|
openjdk 17.0.9 2023-10-17
|
||||||
|
OpenJDK Runtime Environment (build 17.0.9+8)
|
||||||
|
OpenJDK 64-Bit Server VM (build 17.0.9+8, mixed mode)
|
||||||
|
|
||||||
|
$ javac --version
|
||||||
|
javac 17.0.9
|
||||||
|
|
||||||
|
$ sha256sum build/libs/TurnBasedMinecraft-Forge-1.25.0-all.jar
|
||||||
|
51ef854552b180df68969f4cec6fdc8716ef519b947948b9e5f4ce9953d00162 build/libs/TurnBasedMinecraft-Forge-1.25.0-all.jar
|
||||||
|
|
||||||
|
## NeoForge 1.24.0
|
||||||
|
|
||||||
|
$ java --version
|
||||||
|
openjdk 17.0.9 2023-10-17
|
||||||
|
OpenJDK Runtime Environment (build 17.0.9+8)
|
||||||
|
OpenJDK 64-Bit Server VM (build 17.0.9+8, mixed mode)
|
||||||
|
|
||||||
|
$ javac --version
|
||||||
|
javac 17.0.9
|
||||||
|
|
||||||
|
$ sha256sum build/libs/TurnBasedMinecraft-NeoForge-1.24.0-all.jar
|
||||||
|
584935b6e928ad141a55e4d1a21944cebff5152396782085d145bbe34c29286c build/libs/TurnBasedMinecraft-NeoForge-1.24.0-all.jar
|
||||||
|
|
||||||
|
## Forge 1.24.0
|
||||||
|
|
||||||
|
$ java --version
|
||||||
|
openjdk 17.0.9 2023-10-17
|
||||||
|
OpenJDK Runtime Environment (build 17.0.9+8)
|
||||||
|
OpenJDK 64-Bit Server VM (build 17.0.9+8, mixed mode)
|
||||||
|
|
||||||
|
$ javac --version
|
||||||
|
javac 17.0.9
|
||||||
|
|
||||||
|
$ sha256sum build/libs/TurnBasedMinecraft-Forge-1.24.0.jar
|
||||||
|
e17c370cdf347b053c7f55091afed77564dcd8f419615bd6ca87babe10329c07 build/libs/TurnBasedMinecraft-Forge-1.24.0.jar
|
249
build.gradle
249
build.gradle
|
@ -2,185 +2,111 @@ plugins {
|
||||||
id 'eclipse'
|
id 'eclipse'
|
||||||
id 'idea'
|
id 'idea'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
|
id 'net.neoforged.gradle.userdev' version '7.0.80'
|
||||||
id 'com.github.johnrengelman.shadow' version '8.1.1'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
version = "1.23.1"
|
version = mod_version
|
||||||
group = "com.burnedkirby.TurnBasedMinecraft"
|
group = mod_group_id
|
||||||
archivesBaseName = "TurnBasedMinecraft"
|
archivesBaseName = "TurnBasedMinecraft-NeoForge"
|
||||||
|
|
||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||||
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
|
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
|
||||||
|
|
||||||
minecraft {
|
jarJar.enable()
|
||||||
// The mappings can be changed at any time, and must be in the following format.
|
|
||||||
// snapshot_YYYYMMDD Snapshot are built nightly.
|
|
||||||
// stable_# Stables are built at the discretion of the MCP team.
|
|
||||||
// Use non-default mappings at your own risk. they may not always work.
|
|
||||||
// Simply re-run your setup task after changing the mappings to update your workspace.
|
|
||||||
mappings channel: mapping_channel, version: mapping_version
|
|
||||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
|
||||||
|
|
||||||
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
// Default run configurations.
|
||||||
|
// These can be tweaked, removed, or duplicated as needed.
|
||||||
|
runs {
|
||||||
|
// applies to all the run configs below
|
||||||
|
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'
|
||||||
|
|
||||||
// This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
|
// Recommended logging level for the console
|
||||||
// It is REQUIRED to be set to true for this template to function.
|
// You can set various levels here.
|
||||||
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
|
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
|
||||||
copyIdeResources = true
|
systemProperty 'forge.logging.console.level', 'debug'
|
||||||
|
|
||||||
// Default run configurations.
|
modSource project.sourceSets.main
|
||||||
// These can be tweaked, removed, or duplicated as needed.
|
}
|
||||||
runs {
|
|
||||||
client {
|
|
||||||
workingDirectory project.file('run')
|
|
||||||
|
|
||||||
// Recommended logging data for a userdev environment
|
client {
|
||||||
property 'forge.logging.markers', 'REGISTRIES'
|
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
||||||
|
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
|
||||||
|
}
|
||||||
|
|
||||||
// Recommended logging level for the console
|
server {
|
||||||
property 'forge.logging.console.level', 'debug'
|
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
|
||||||
|
programArgument '--nogui'
|
||||||
|
}
|
||||||
|
|
||||||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
// This run config launches GameTestServer and runs all registered gametests, then exits.
|
||||||
property 'forge.enabledGameTestNamespaces', 'TurnBasedMinecraftMod'
|
// By default, the server will crash when no gametests are provided.
|
||||||
|
// The gametest system is also enabled by default for other run configs under the /test command.
|
||||||
|
gameTestServer {
|
||||||
|
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
|
||||||
|
}
|
||||||
|
|
||||||
mods {
|
data {
|
||||||
TurnBasedMinecraftMod {
|
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
|
||||||
source sourceSets.main
|
// workingDirectory project.file('run-data')
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
server {
|
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
|
||||||
workingDirectory project.file('run')
|
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
|
||||||
|
|
||||||
// Recommended logging data for a userdev environment
|
|
||||||
property 'forge.logging.markers', 'REGISTRIES'
|
|
||||||
|
|
||||||
// Recommended logging level for the console
|
|
||||||
property 'forge.logging.console.level', 'debug'
|
|
||||||
|
|
||||||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
|
||||||
property 'forge.enabledGameTestNamespaces', 'TurnBasedMinecraftMod'
|
|
||||||
|
|
||||||
mods {
|
|
||||||
TurnBasedMinecraftMod {
|
|
||||||
source sourceSets.main
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This run config launches GameTestServer and runs all registered gametests, then exits.
|
|
||||||
// By default, the server will crash when no gametests are provided.
|
|
||||||
// The gametest system is also enabled by default for other run configs under the /test command.
|
|
||||||
gameTestServer {
|
|
||||||
workingDirectory project.file('run')
|
|
||||||
|
|
||||||
// Recommended logging data for a userdev environment
|
|
||||||
// The markers can be added/remove as needed separated by commas.
|
|
||||||
// "SCAN": For mods scan.
|
|
||||||
// "REGISTRIES": For firing of registry events.
|
|
||||||
// "REGISTRYDUMP": For getting the contents of all registries.
|
|
||||||
property 'forge.logging.markers', 'REGISTRIES'
|
|
||||||
|
|
||||||
// Recommended logging level for the console
|
|
||||||
// You can set various levels here.
|
|
||||||
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
|
|
||||||
property 'forge.logging.console.level', 'debug'
|
|
||||||
|
|
||||||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
|
||||||
property 'forge.enabledGameTestNamespaces', 'TurnBasedMinecraftMod'
|
|
||||||
|
|
||||||
mods {
|
|
||||||
TurnBasedMinecraftMod {
|
|
||||||
source sourceSets.main
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data {
|
|
||||||
workingDirectory project.file('run')
|
|
||||||
|
|
||||||
// Recommended logging data for a userdev environment
|
|
||||||
property 'forge.logging.markers', 'REGISTRIES'
|
|
||||||
|
|
||||||
// Recommended logging level for the console
|
|
||||||
property 'forge.logging.console.level', 'debug'
|
|
||||||
|
|
||||||
args '--mod', 'TurnBasedMinecraftMod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources')
|
|
||||||
|
|
||||||
mods {
|
|
||||||
TurnBasedMinecraftMod {
|
|
||||||
source sourceSets.main
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Include resources generated by data generators.
|
// Include resources generated by data generators.
|
||||||
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||||
|
|
||||||
//repositories {
|
repositories {
|
||||||
// // Put repositories for dependencies here
|
flatDir {
|
||||||
// // ForgeGradle automatically adds the Forge maven and Maven Central for you
|
dir 'libs'
|
||||||
//
|
}
|
||||||
// // If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
|
|
||||||
// // flatDir {
|
|
||||||
// // dir 'libs'
|
|
||||||
// // }
|
|
||||||
// mavenCentral()
|
|
||||||
// jcenter()
|
|
||||||
//
|
|
||||||
// dependencies {
|
|
||||||
// classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4'
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
apply plugin: 'com.github.johnrengelman.shadow'
|
|
||||||
|
|
||||||
configurations {
|
|
||||||
shade
|
|
||||||
impelmentation.extendsFrom shade
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
|
// Specify the version of Minecraft to use.
|
||||||
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
|
// Depending on the plugin applied there are several options. We will assume you applied the userdev plugin as shown above.
|
||||||
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
|
// The group for userdev is net.neoforged, the module name is neoforge, and the version is the same as the neoforge version.
|
||||||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
// You can however also use the vanilla plugin (net.neoforged.gradle.vanilla) to use a version of Minecraft without the neoforge loader.
|
||||||
|
// And its provides the option to then use net.minecraft as the group, and one of; client, server or joined as the module name, plus the game version as version.
|
||||||
|
// For all intends and purposes: You can treat this dependency as if it is a normal library you would use.
|
||||||
|
implementation "net.neoforged:neoforge:${neo_version}"
|
||||||
|
|
||||||
// Real mod deobf dependency examples - these get remapped to your current mappings
|
// implementation files('libs/javamp3-1.0.3.jar')
|
||||||
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
|
implementation 'fr.delthas:javamp3:1.0.3'
|
||||||
// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
|
|
||||||
// implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency
|
|
||||||
|
|
||||||
// Examples using mod jars from ./libs
|
implementation 'com.github.stephengold:j-ogg-vorbis:1.0.4'
|
||||||
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
|
|
||||||
|
|
||||||
// For more info...
|
jarJar(group: 'fr.delthas', name: 'javamp3', version: '[1.0.0,2.0.0)') {
|
||||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
jarJar.pin(it, '1.0.3')
|
||||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
}
|
||||||
implementation files('libs/javamp3-1.0.3.jar')
|
|
||||||
|
|
||||||
shade files('libs/javamp3-1.0.3.jar')
|
jarJar(group: 'com.github.stephengold', name: 'j-ogg-vorbis', version: '[1.0.4, 2.0.0)') {
|
||||||
|
jarJar.pin(it, '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.
|
||||||
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
|
// 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
|
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
|
||||||
tasks.named('processResources', ProcessResources).configure {
|
tasks.withType(ProcessResources).configureEach {
|
||||||
var replaceProperties = [
|
var replaceProperties = [
|
||||||
minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
|
minecraft_version : minecraft_version, 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_name: mod_name, mod_license: mod_license, mod_version: mod_version,
|
mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
|
||||||
mod_authors: mod_authors, mod_description: mod_description,
|
mod_authors : mod_authors, mod_description: mod_description,
|
||||||
]
|
]
|
||||||
inputs.properties replaceProperties
|
inputs.properties replaceProperties
|
||||||
|
|
||||||
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
|
filesMatching(['META-INF/mods.toml']) {
|
||||||
expand replaceProperties + [project: project]
|
expand replaceProperties + [project: project]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,54 +119,21 @@ jar {
|
||||||
"Specification-Title": "TurnBasedMinecraftMod",
|
"Specification-Title": "TurnBasedMinecraftMod",
|
||||||
"Specification-Vendor": "TurnBasedMinecraftMod_BK",
|
"Specification-Vendor": "TurnBasedMinecraftMod_BK",
|
||||||
"Specification-Version": "1", // We are version 1 of ourselves
|
"Specification-Version": "1", // We are version 1 of ourselves
|
||||||
"Implementation-Title": project.name,
|
"Implementation-Title": "TurnBasedMinecraftMod",
|
||||||
"Implementation-Version": "${version}",
|
"Implementation-Version": "${version}",
|
||||||
"Implementation-Vendor" :"TurnBasedMinecraftMod_BK",
|
"Implementation-Vendor" :"TurnBasedMinecraftMod_BK",
|
||||||
// Do not place timestamp for the sake of reproducible builds
|
// Do not place timestamp for the sake of reproducible builds
|
||||||
// "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
// "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
||||||
// "ContainedDeps": "javamp3-1.0.3.jar"
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
|
||||||
archiveClassifier = ''
|
|
||||||
//project.configurations.shadow.setTransitive(true);
|
|
||||||
configurations = [project.configurations.shade]
|
|
||||||
relocate 'fr.delthas', 'com.burnedkirby.tbm_repack.fr.delthas'
|
|
||||||
finalizedBy 'reobfShadowJar'
|
|
||||||
}
|
|
||||||
|
|
||||||
assemble.dependsOn shadowJar
|
|
||||||
|
|
||||||
reobf {
|
|
||||||
shadowJar {} // reobfuscate the shadowed jar
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reproducible Builds
|
// Reproducible Builds
|
||||||
tasks.withType(AbstractArchiveTask).configureEach {
|
tasks.withType(AbstractArchiveTask).configureEach {
|
||||||
preserveFileTimestamps = false
|
preserveFileTimestamps = false
|
||||||
reproducibleFileOrder = true
|
reproducibleFileOrder = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example configuration to allow publishing using the maven-publish task
|
tasks.withType(JavaCompile).configureEach {
|
||||||
// we define a custom artifact that is sourced from the reobfJar output task
|
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
||||||
// and then declare that to be published
|
}
|
||||||
// Note you'll need to add a repository here
|
|
||||||
//def reobfFile = file("$buildDir/reobfJar/output.jar")
|
|
||||||
//def reobfArtifact = artifacts.add('default', reobfFile) {
|
|
||||||
// type 'jar'
|
|
||||||
// builtBy 'reobfJar'
|
|
||||||
//}
|
|
||||||
//publishing {
|
|
||||||
// publications {
|
|
||||||
// mavenJava(MavenPublication) {
|
|
||||||
// artifact reobfArtifact
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// repositories {
|
|
||||||
// maven {
|
|
||||||
// url "file:///${project.projectDir}/mcmodsrepo"
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
|
@ -1,38 +1,25 @@
|
||||||
org.gradle.jvmargs=-Xmx4096m
|
org.gradle.jvmargs=-Xmx4096m
|
||||||
org.gradle.daemon=false
|
org.gradle.daemon=false
|
||||||
|
org.gradle.debug=false
|
||||||
|
|
||||||
## Environment Properties
|
#read more on this at https://github.com/neoforged/NeoGradle/blob/NG_7.0/README.md#apply-parchment-mappings
|
||||||
|
# you can also find the latest versions at: https://parchmentmc.org/docs/getting-started
|
||||||
# The Minecraft version must agree with the Forge version to get a valid artifact
|
neogradle.subsystems.parchment.minecraftVersion=1.20.3
|
||||||
minecraft_version=1.20.1
|
neogradle.subsystems.parchment.mappingsVersion=2023.12.31
|
||||||
|
# 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.20.4
|
||||||
# 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.20.1,1.21)
|
minecraft_version_range=[1.20.4,1.21)
|
||||||
# The Forge version must agree with the Minecraft version to get a valid artifact
|
# The Neo version must agree with the Minecraft version to get a valid artifact
|
||||||
forge_version=47.1.0
|
neo_version=20.4.109-beta
|
||||||
# The Forge version range can use any version of Forge as bounds or match the loader version range
|
# The Neo version range can use any version of Neo as bounds
|
||||||
forge_version_range=[47,)
|
neo_version_range=[20.4,)
|
||||||
# The loader version range can only use the major version of Forge/FML as bounds
|
# The loader version range can only use the major version of FML as bounds
|
||||||
loader_version_range=[47,)
|
loader_version_range=[2,)
|
||||||
# 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.20.1
|
|
||||||
|
|
||||||
## Mod Properties
|
## Mod Properties
|
||||||
|
|
||||||
|
@ -44,11 +31,11 @@ mod_name=TurnBasedMinecraftMod
|
||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=MIT
|
mod_license=MIT
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
mod_version=1.23.1
|
mod_version=1.25.2
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||||
# This should match the base package used for the mod sources.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
#mod_group_id=com.example.examplemod
|
mod_group_id=com.burnedkirby.TurnBasedMinecraft
|
||||||
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
|
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
|
||||||
mod_authors=BurnedKirby a.k.a. Stephen Seo
|
mod_authors=BurnedKirby a.k.a. Stephen Seo
|
||||||
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
|
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
|
||||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
11
gradlew
vendored
11
gradlew
vendored
|
@ -85,6 +85,9 @@ done
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
|
|
||||||
|
@ -141,7 +144,7 @@ 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=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
|
||||||
|
@ -149,7 +152,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=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
|
||||||
|
@ -194,10 +197,6 @@ if "$cygwin" || "$msys" ; then
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# 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"'
|
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
# Collect all arguments for the java command;
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
# shell script including quotes and variable substitutions, so put them in
|
||||||
|
|
184
gradlew.bat
vendored
184
gradlew.bat
vendored
|
@ -1,92 +1,92 @@
|
||||||
@rem
|
@rem
|
||||||
@rem Copyright 2015 the original author or authors.
|
@rem Copyright 2015 the original author or authors.
|
||||||
@rem
|
@rem
|
||||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@rem you may not use this file except in compliance with the License.
|
@rem you may not use this file except in compliance with the License.
|
||||||
@rem You may obtain a copy of the License at
|
@rem You may obtain a copy of the License at
|
||||||
@rem
|
@rem
|
||||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
@rem
|
@rem
|
||||||
@rem Unless required by applicable law or agreed to in writing, software
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@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
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@rem
|
@rem
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
|
|
||||||
@rem Set local scope for the variables with windows NT shell
|
@rem Set local scope for the variables with windows NT shell
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%"=="" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
@rem This is normally unused
|
@rem This is normally unused
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
@rem Find java.exe
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if %ERRORLEVEL% equ 0 goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
echo.
|
echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation.
|
echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:findJavaFromJavaHome
|
:findJavaFromJavaHome
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
echo.
|
echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation.
|
echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
set EXIT_CODE=%ERRORLEVEL%
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
exit /b %EXIT_CODE%
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
:omega
|
:omega
|
||||||
|
|
|
@ -2,8 +2,7 @@ pluginManagement {
|
||||||
repositories {
|
repositories {
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
maven {
|
maven {
|
||||||
name = 'MinecraftForge'
|
url = 'https://maven.neoforged.net/releases'
|
||||||
url = 'https://maven.minecraftforge.net/'
|
|
||||||
}
|
}
|
||||||
jcenter()
|
jcenter()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
|
@ -5,13 +5,13 @@ import com.burnedkirby.TurnBasedMinecraft.common.Combatant;
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.Config;
|
import com.burnedkirby.TurnBasedMinecraft.common.Config;
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleDecision;
|
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleDecision;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.components.AbstractButton;
|
import net.minecraft.client.gui.components.AbstractButton;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
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.neoforge.network.PacketDistributor;
|
||||||
|
|
||||||
import java.util.ConcurrentModificationException;
|
import java.util.ConcurrentModificationException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -150,11 +150,11 @@ public class BattleGui extends Screen {
|
||||||
.getSideAEntrySet()) {
|
.getSideAEntrySet()) {
|
||||||
if (e.getValue().entity != null) {
|
if (e.getValue().entity != null) {
|
||||||
addRenderableWidget(new EntitySelectionButton(width / 4 - 60, y, 120, 20, e.getValue().entity.getDisplayName(), e.getKey(), true, (button) -> {
|
addRenderableWidget(new EntitySelectionButton(width / 4 - 60, y, 120, 20, e.getValue().entity.getDisplayName(), e.getKey(), true, (button) -> {
|
||||||
buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
|
entityButtonActionEvent(button, ButtonAction.ATTACK_TARGET);
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
addRenderableWidget(new EntitySelectionButton(width / 4 - 60, y, 120, 20, "Unknown", e.getKey(), true, (button) -> {
|
addRenderableWidget(new EntitySelectionButton(width / 4 - 60, y, 120, 20, "Unknown", e.getKey(), true, (button) -> {
|
||||||
buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
|
entityButtonActionEvent(button, ButtonAction.ATTACK_TARGET);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
y += 20;
|
y += 20;
|
||||||
|
@ -168,11 +168,11 @@ public class BattleGui extends Screen {
|
||||||
.getSideBEntrySet()) {
|
.getSideBEntrySet()) {
|
||||||
if (e.getValue().entity != null) {
|
if (e.getValue().entity != null) {
|
||||||
addRenderableWidget(new EntitySelectionButton(width * 3 / 4 - 60, y, 120, 20, e.getValue().entity.getDisplayName(), e.getKey(), false, (button) -> {
|
addRenderableWidget(new EntitySelectionButton(width * 3 / 4 - 60, y, 120, 20, e.getValue().entity.getDisplayName(), e.getKey(), false, (button) -> {
|
||||||
buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
|
entityButtonActionEvent(button, ButtonAction.ATTACK_TARGET);
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
addRenderableWidget(new EntitySelectionButton(width * 3 / 4 - 60, y, 120, 20, "Unknown", e.getKey(), false, (button) -> {
|
addRenderableWidget(new EntitySelectionButton(width * 3 / 4 - 60, y, 120, 20, "Unknown", e.getKey(), false, (button) -> {
|
||||||
buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
|
entityButtonActionEvent(button, ButtonAction.ATTACK_TARGET);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
y += 20;
|
y += 20;
|
||||||
|
@ -202,8 +202,8 @@ public class BattleGui extends Screen {
|
||||||
case SWITCH_ITEM:
|
case SWITCH_ITEM:
|
||||||
info = "To which item will you switch to?";
|
info = "To which item will you switch to?";
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
addRenderableWidget(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, "", i, (button) -> {
|
addRenderableWidget(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, i, (button) -> {
|
||||||
buttonActionEvent(button, ButtonAction.DO_ITEM_SWITCH);
|
itemButtonActionEvent(button, ButtonAction.DO_ITEM_SWITCH);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
addRenderableWidget(Button.builder(Component.literal("Cancel"), (button) -> {
|
addRenderableWidget(Button.builder(Component.literal("Cancel"), (button) -> {
|
||||||
|
@ -213,8 +213,8 @@ public class BattleGui extends Screen {
|
||||||
case USE_ITEM:
|
case USE_ITEM:
|
||||||
info = "Which item will you use?";
|
info = "Which item will you use?";
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
addRenderableWidget(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, "", i, (button) -> {
|
addRenderableWidget(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, i, (button) -> {
|
||||||
buttonActionEvent(button, ButtonAction.DO_USE_ITEM);
|
itemButtonActionEvent(button, ButtonAction.DO_USE_ITEM);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
addRenderableWidget(Button.builder(Component.literal("Cancel"), (button) -> {
|
addRenderableWidget(Button.builder(Component.literal("Cancel"), (button) -> {
|
||||||
|
@ -275,27 +275,21 @@ public class BattleGui extends Screen {
|
||||||
setState(MenuState.ATTACK_TARGET);
|
setState(MenuState.ATTACK_TARGET);
|
||||||
break;
|
break;
|
||||||
case DEFEND:
|
case DEFEND:
|
||||||
TurnBasedMinecraftMod.getHandler().sendToServer(new PacketBattleDecision(
|
PacketDistributor.SERVER.noArg().send(new PacketBattleDecision(
|
||||||
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.DEFEND, 0));
|
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.DEFEND, 0));
|
||||||
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:
|
||||||
TurnBasedMinecraftMod.getHandler().sendToServer(new PacketBattleDecision(
|
PacketDistributor.SERVER.noArg().send(new PacketBattleDecision(
|
||||||
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.FLEE, 0));
|
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.FLEE, 0));
|
||||||
setState(MenuState.WAITING);
|
setState(MenuState.WAITING);
|
||||||
break;
|
break;
|
||||||
case ATTACK_TARGET:
|
case ATTACK_TARGET:
|
||||||
if (button instanceof EntitySelectionButton) {
|
// Invalid, but set menu to main menu anyways.
|
||||||
TurnBasedMinecraftMod.getHandler()
|
setState(MenuState.MAIN_MENU);
|
||||||
.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(),
|
|
||||||
Battle.Decision.ATTACK, ((EntitySelectionButton) button).getID()));
|
|
||||||
setState(MenuState.WAITING);
|
|
||||||
} else {
|
|
||||||
setState(MenuState.MAIN_MENU);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case SWITCH_HELD_ITEM:
|
case SWITCH_HELD_ITEM:
|
||||||
setState(MenuState.SWITCH_ITEM);
|
setState(MenuState.SWITCH_ITEM);
|
||||||
|
@ -307,31 +301,50 @@ public class BattleGui extends Screen {
|
||||||
setState(MenuState.MAIN_MENU);
|
setState(MenuState.MAIN_MENU);
|
||||||
break;
|
break;
|
||||||
case DO_ITEM_SWITCH:
|
case DO_ITEM_SWITCH:
|
||||||
if (button instanceof ItemSelectionButton) {
|
// Invalid, but set menu to main menu anyways.
|
||||||
TurnBasedMinecraftMod.getHandler()
|
setState(MenuState.MAIN_MENU);
|
||||||
.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(),
|
|
||||||
Battle.Decision.SWITCH_ITEM, ((ItemSelectionButton) button).getID()));
|
|
||||||
if (((ItemSelectionButton) button).getID() >= 0 && ((ItemSelectionButton) button).getID() < 9) {
|
|
||||||
Minecraft.getInstance().player.getInventory().selected = ((ItemSelectionButton) button).getID();
|
|
||||||
}
|
|
||||||
setState(MenuState.WAITING);
|
|
||||||
} else {
|
|
||||||
setState(MenuState.MAIN_MENU);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case DO_USE_ITEM:
|
case DO_USE_ITEM:
|
||||||
if (button instanceof ItemSelectionButton) {
|
// Invalid, but set menu to main menu anyways.
|
||||||
TurnBasedMinecraftMod.getHandler()
|
setState(MenuState.MAIN_MENU);
|
||||||
.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(),
|
|
||||||
Battle.Decision.USE_ITEM, ((ItemSelectionButton) button).getID()));
|
|
||||||
setState(MenuState.WAITING);
|
|
||||||
} else {
|
|
||||||
setState(MenuState.MAIN_MENU);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void entityButtonActionEvent(EntitySelectionButton button, ButtonAction action) {
|
||||||
|
if (action.equals(ButtonAction.ATTACK_TARGET)) {
|
||||||
|
PacketDistributor.SERVER.noArg().send(
|
||||||
|
new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(),
|
||||||
|
Battle.Decision.ATTACK, ((EntitySelectionButton) button).getID()));
|
||||||
|
setState(MenuState.WAITING);
|
||||||
|
} else {
|
||||||
|
setState(MenuState.MAIN_MENU);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void itemButtonActionEvent(ItemSelectionButton button, ButtonAction action) {
|
||||||
|
switch (action) {
|
||||||
|
case DO_ITEM_SWITCH:
|
||||||
|
PacketDistributor.SERVER.noArg().send(
|
||||||
|
new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(),
|
||||||
|
Battle.Decision.SWITCH_ITEM, button.getID()));
|
||||||
|
if (button.getID() >= 0 && button.getID() < 9) {
|
||||||
|
Minecraft.getInstance().player.getInventory().selected = button.getID();
|
||||||
|
}
|
||||||
|
setState(MenuState.WAITING);
|
||||||
|
break;
|
||||||
|
case DO_USE_ITEM:
|
||||||
|
PacketDistributor.SERVER.noArg().send(
|
||||||
|
new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(),
|
||||||
|
Battle.Decision.USE_ITEM, button.getID()));
|
||||||
|
setState(MenuState.WAITING);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
setState(MenuState.MAIN_MENU);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPauseScreen() {
|
public boolean isPauseScreen() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -368,4 +381,9 @@ 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.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +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 de.jarnbjo.vorbis.VorbisAudioFileReader;
|
||||||
import fr.delthas.javamp3.Sound;
|
import fr.delthas.javamp3.Sound;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
@ -28,7 +29,9 @@ public class BattleMusic
|
||||||
private boolean playingIsSilly;
|
private boolean playingIsSilly;
|
||||||
private boolean isPlaying;
|
private boolean isPlaying;
|
||||||
private Thread mp3StreamThread;
|
private Thread mp3StreamThread;
|
||||||
|
private Thread oggVorbisStreamThread;
|
||||||
private MP3Streamer mp3StreamRunnable;
|
private MP3Streamer mp3StreamRunnable;
|
||||||
|
private OGGVorbisStreamer oggVorbisStreamRunnable;
|
||||||
|
|
||||||
public BattleMusic(Logger logger)
|
public BattleMusic(Logger logger)
|
||||||
{
|
{
|
||||||
|
@ -81,7 +84,7 @@ public class BattleMusic
|
||||||
}
|
}
|
||||||
String ext = name.substring(extIndex + 1).toLowerCase();
|
String ext = name.substring(extIndex + 1).toLowerCase();
|
||||||
// return ext.equals("mid") || ext.equals("wav") || ext.equals("mp3");
|
// return ext.equals("mid") || ext.equals("wav") || ext.equals("mp3");
|
||||||
return ext.equals("wav") || ext.equals("mp3"); // midi disabled
|
return ext.equals("wav") || ext.equals("mp3") || ext.equals("ogg"); // midi disabled
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
for(File f : battleFiles)
|
for(File f : battleFiles)
|
||||||
|
@ -101,7 +104,7 @@ public class BattleMusic
|
||||||
}
|
}
|
||||||
String ext = name.substring(extIndex + 1).toLowerCase();
|
String ext = name.substring(extIndex + 1).toLowerCase();
|
||||||
// return ext.equals("mid") || ext.equals("wav") || ext.equals("mp3");
|
// return ext.equals("mid") || ext.equals("wav") || ext.equals("mp3");
|
||||||
return ext.equals("wav") || ext.equals("mp3"); // midi disabled
|
return ext.equals("wav") || ext.equals("mp3") || ext.equals("ogg"); // midi disabled
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
for(File f : sillyFiles)
|
for(File f : sillyFiles)
|
||||||
|
@ -303,6 +306,39 @@ public class BattleMusic
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (suffix.equals("ogg")) {
|
||||||
|
if(sequencer != null && sequencer.isRunning())
|
||||||
|
{
|
||||||
|
sequencer.stop();
|
||||||
|
}
|
||||||
|
if(clip != null && clip.isActive())
|
||||||
|
{
|
||||||
|
clip.stop();
|
||||||
|
clip.close();
|
||||||
|
}
|
||||||
|
if(mp3StreamThread != null && mp3StreamThread.isAlive())
|
||||||
|
{
|
||||||
|
mp3StreamRunnable.setKeepPlaying(false);
|
||||||
|
try { mp3StreamThread.join(); } catch (Throwable t) { /* ignored */ }
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (oggVorbisStreamRunnable == null) {
|
||||||
|
oggVorbisStreamRunnable = new OGGVorbisStreamer(next, logger, volume);
|
||||||
|
} else {
|
||||||
|
oggVorbisStreamRunnable.setOggVorbisFile(next);
|
||||||
|
oggVorbisStreamRunnable.setVolume(volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
oggVorbisStreamThread = new Thread(oggVorbisStreamRunnable);
|
||||||
|
oggVorbisStreamThread.start();
|
||||||
|
logger.info("Started playing OggVorbis " + next.getName());
|
||||||
|
} catch (Throwable t) {
|
||||||
|
logger.error("Failed to play battle music (ogg)");
|
||||||
|
t.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,6 +356,10 @@ public class BattleMusic
|
||||||
mp3StreamRunnable.setKeepPlaying(false);
|
mp3StreamRunnable.setKeepPlaying(false);
|
||||||
try { mp3StreamThread.join(); } catch (Throwable t) { /* ignored */ }
|
try { mp3StreamThread.join(); } catch (Throwable t) { /* ignored */ }
|
||||||
}
|
}
|
||||||
|
if (oggVorbisStreamThread != null && oggVorbisStreamThread.isAlive()) {
|
||||||
|
oggVorbisStreamRunnable.setKeepPlaying(false);
|
||||||
|
try { oggVorbisStreamThread.join(); } catch (Throwable t) { /* ignored */ }
|
||||||
|
}
|
||||||
if(resumeMCSounds)
|
if(resumeMCSounds)
|
||||||
{
|
{
|
||||||
Minecraft.getInstance().getSoundManager().resume();
|
Minecraft.getInstance().getSoundManager().resume();
|
||||||
|
@ -454,4 +494,93 @@ public class BattleMusic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class OGGVorbisStreamer implements Runnable {
|
||||||
|
private AtomicBoolean keepPlaying;
|
||||||
|
private File oggVorbisFile;
|
||||||
|
private Logger logger;
|
||||||
|
private float volume;
|
||||||
|
|
||||||
|
public OGGVorbisStreamer(File oggVorbisFile, Logger logger, float volume) {
|
||||||
|
keepPlaying = new AtomicBoolean(true);
|
||||||
|
this.oggVorbisFile = oggVorbisFile;
|
||||||
|
this.logger = logger;
|
||||||
|
this.volume = volume;
|
||||||
|
if (this.volume > 1.0F) {
|
||||||
|
this.volume = 1.0F;
|
||||||
|
} else if (this.volume < 0.0F) {
|
||||||
|
this.volume = 0.0F;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKeepPlaying(boolean playing) {
|
||||||
|
keepPlaying.set(playing);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOggVorbisFile(File oggVorbisFile) {
|
||||||
|
this.oggVorbisFile = oggVorbisFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVolume(float volume) {
|
||||||
|
this.volume = volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
keepPlaying.set(true);
|
||||||
|
SourceDataLine sdl = null;
|
||||||
|
try {
|
||||||
|
VorbisAudioFileReader reader = new VorbisAudioFileReader();
|
||||||
|
AudioFormat audioFormat = reader.getAudioFileFormat(oggVorbisFile).getFormat();
|
||||||
|
sdl = AudioSystem.getSourceDataLine(audioFormat);
|
||||||
|
sdl.open(audioFormat);
|
||||||
|
{
|
||||||
|
FloatControl volumeControl = (FloatControl) sdl.getControl(FloatControl.Type.MASTER_GAIN);
|
||||||
|
volumeControl.setValue(volume * 20.0f - 20.0f); // in decibels
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioInputStream ais = reader.getAudioInputStream(oggVorbisFile);
|
||||||
|
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
byte[] cached = null;
|
||||||
|
int cachedOffset = 0;
|
||||||
|
int cachedSize = 0;
|
||||||
|
byte[] buf = new byte[4096];
|
||||||
|
sdl.start();
|
||||||
|
int read = ais.read(buf);
|
||||||
|
while (keepPlaying.get()) {
|
||||||
|
if (baos != null) {
|
||||||
|
if (read != -1) {
|
||||||
|
sdl.write(buf, 0, read);
|
||||||
|
baos.write(buf, 0, read);
|
||||||
|
read = ais.read(buf);
|
||||||
|
} else {
|
||||||
|
ais.close();
|
||||||
|
ais = null;
|
||||||
|
cached = baos.toByteArray();
|
||||||
|
baos = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cachedSize = cached.length - cachedOffset;
|
||||||
|
if (cachedSize > 4096) {
|
||||||
|
cachedSize = 4096;
|
||||||
|
}
|
||||||
|
sdl.write(cached, cachedOffset, cachedSize);
|
||||||
|
cachedOffset += cachedSize;
|
||||||
|
if (cachedOffset >= cached.length) {
|
||||||
|
cachedOffset = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Throwable t) {
|
||||||
|
logger.error("Stream play oggVorbis", t);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sdl != null) {
|
||||||
|
sdl.stop();
|
||||||
|
sdl.flush();
|
||||||
|
sdl.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +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.minecraftforge.network.NetworkEvent;
|
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public class ClientProxy extends CommonProxy {
|
public class ClientProxy extends CommonProxy {
|
||||||
private BattleGui battleGui = null;
|
private BattleGui battleGui = null;
|
||||||
|
@ -224,7 +222,7 @@ public class ClientProxy extends CommonProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <MSG> void handlePacket(MSG msg, Supplier<NetworkEvent.Context> ctx) {
|
public <MSG> void handlePacket(final MSG msg, final PlayPayloadContext 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());
|
||||||
|
@ -435,6 +433,11 @@ public class ClientProxy extends CommonProxy {
|
||||||
parentComponent.getSiblings().add(message);
|
parentComponent.getSiblings().add(message);
|
||||||
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
|
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
|
||||||
}
|
}
|
||||||
|
case CROSSBOW_NO_AMMO: {
|
||||||
|
parentComponent.getSiblings().add(from);
|
||||||
|
parentComponent.getSiblings().add(Component.literal(" tried to use their crossbow but ran out of ammo!"));
|
||||||
|
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (msg.getClass() == PacketGeneralMessage.class) {
|
} else if (msg.getClass() == PacketGeneralMessage.class) {
|
||||||
|
|
|
@ -1,34 +1,49 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.client;
|
package com.burnedkirby.TurnBasedMinecraft.client;
|
||||||
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.CommonProxy;
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.components.AbstractButton;
|
import net.minecraft.client.gui.components.Button;
|
||||||
|
import net.minecraft.client.gui.components.Renderable;
|
||||||
|
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||||
|
import net.minecraft.client.gui.narration.NarratableEntry;
|
||||||
import net.minecraft.client.gui.narration.NarratedElementType;
|
import net.minecraft.client.gui.narration.NarratedElementType;
|
||||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
|
||||||
public class EntitySelectionButton extends AbstractButton {
|
public class EntitySelectionButton implements Renderable, GuiEventListener, NarratableEntry {
|
||||||
TBMButtonPress onPress;
|
private int x;
|
||||||
|
private int y;
|
||||||
|
private int width;
|
||||||
|
private int height;
|
||||||
|
private boolean focused;
|
||||||
|
private Button nestedButton;
|
||||||
|
TBMEntityButtonPress onPress;
|
||||||
private int entityID;
|
private int entityID;
|
||||||
private boolean isSideA;
|
private boolean isSideA;
|
||||||
|
|
||||||
public EntitySelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int entityID, boolean isSideA, TBMButtonPress onPress) {
|
public EntitySelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int entityID, boolean isSideA, TBMEntityButtonPress onPress) {
|
||||||
super(x, y, widthIn, heightIn, Component.literal(buttonText));
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.width = widthIn;
|
||||||
|
this.height = heightIn;
|
||||||
this.onPress = onPress;
|
this.onPress = onPress;
|
||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
this.isSideA = isSideA;
|
this.isSideA = isSideA;
|
||||||
|
this.nestedButton = Button.builder(Component.literal(buttonText), (unused) -> {}).pos(x, y).size(widthIn, heightIn).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntitySelectionButton(int x, int y, int widthIn, int heightIn, Component buttonTextComponent, int entityID, boolean isSideA, TBMButtonPress onPress) {
|
public EntitySelectionButton(int x, int y, int widthIn, int heightIn, Component buttonTextComponent, int entityID, boolean isSideA, TBMEntityButtonPress onPress) {
|
||||||
super(x, y, widthIn, heightIn, buttonTextComponent);
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.width = widthIn;
|
||||||
|
this.height = heightIn;
|
||||||
this.onPress = onPress;
|
this.onPress = onPress;
|
||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
this.isSideA = isSideA;
|
this.isSideA = isSideA;
|
||||||
|
this.nestedButton = Button.builder(buttonTextComponent, (unused) -> {}).pos(x, y).size(widthIn, heightIn).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getID() {
|
public int getID() {
|
||||||
|
@ -41,63 +56,86 @@ public class EntitySelectionButton extends AbstractButton {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
|
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
|
||||||
super.render(guiGraphics, mouseX, mouseY, partialTicks);
|
this.nestedButton.render(guiGraphics, mouseX, mouseY, partialTicks);
|
||||||
Entity e = Minecraft.getInstance().level.getEntity(entityID);
|
Entity e = Minecraft.getInstance().level.getEntity(entityID);
|
||||||
if (e != null && e instanceof LivingEntity && ((LivingEntity) e).isAlive()) {
|
if (e != null && e instanceof LivingEntity && ((LivingEntity) e).isAlive()) {
|
||||||
int health = (int) (((LivingEntity) e).getHealth() + 0.5f);
|
int health = (int) (((LivingEntity) e).getHealth() + 0.5f);
|
||||||
int xpos = getX();
|
int xpos = this.x;
|
||||||
int xoffset;
|
int xoffset;
|
||||||
if (isSideA) {
|
if (isSideA) {
|
||||||
xpos += getWidth() + 4;
|
xpos += this.width + 4;
|
||||||
xoffset = 4;
|
xoffset = 4;
|
||||||
} else {
|
} else {
|
||||||
xpos -= 6;
|
xpos -= 6;
|
||||||
xoffset = -4;
|
xoffset = -4;
|
||||||
}
|
}
|
||||||
if (health > 200) {
|
if (health > 200) {
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
|
guiGraphics.fill(xpos, this.y + this.height * 4 / 5, xpos + 2, this.y + this.height, 0xFFFF0000);
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
|
guiGraphics.fill(xpos, this.y + this.height * 3 / 5, xpos + 2, this.y + this.height * 4 / 5, 0xFFFFFF00);
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
|
guiGraphics.fill(xpos, this.y + this.height * 2 / 5, xpos + 2, this.y + this.height * 3 / 5, 0xFF00FF00);
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() / 5, xpos + 2, getY() + getHeight() * 2 / 5, 0xFF00FFFF);
|
guiGraphics.fill(xpos, this.y + this.height / 5, xpos + 2, this.y + this.height * 2 / 5, 0xFF00FFFF);
|
||||||
guiGraphics.fill(xpos, getY(), xpos + 2, getY() + getHeight() / 5, 0xFF0000FF);
|
guiGraphics.fill(xpos, this.y, xpos + 2, this.y + this.height / 5, 0xFF0000FF);
|
||||||
int healthHeight = ((health - 200) * getHeight() / 100);
|
int healthHeight = ((health - 200) * this.height / 100);
|
||||||
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFFFFFF);
|
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFFFFFFFF);
|
||||||
} else if (health > 100) {
|
} else if (health > 100) {
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
|
guiGraphics.fill(xpos, this.y + this.height * 4 / 5, xpos + 2, this.y + this.height, 0xFFFF0000);
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
|
guiGraphics.fill(xpos, this.y + this.height * 3 / 5, xpos + 2, this.y + this.height * 4 / 5, 0xFFFFFF00);
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
|
guiGraphics.fill(xpos, this.y + this.height * 2 / 5, xpos + 2, this.y + this.height * 3 / 5, 0xFF00FF00);
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() / 5, xpos + 2, getY() + getHeight() * 2 / 5, 0xFF00FFFF);
|
guiGraphics.fill(xpos, this.y + this.height / 5, xpos + 2, this.y + this.height * 2 / 5, 0xFF00FFFF);
|
||||||
int healthHeight = ((health - 100) * getHeight() / 100);
|
int healthHeight = ((health - 100) * this.height / 100);
|
||||||
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF0000FF);
|
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFF0000FF);
|
||||||
} else if (health > 50) {
|
} else if (health > 50) {
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
|
guiGraphics.fill(xpos, this.y + this.height * 4 / 5, xpos + 2, this.y + this.height, 0xFFFF0000);
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
|
guiGraphics.fill(xpos, this.y + this.height * 3 / 5, xpos + 2, this.y + this.height * 4 / 5, 0xFFFFFF00);
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
|
guiGraphics.fill(xpos, this.y + this.height * 2 / 5, xpos + 2, this.y + this.height * 3 / 5, 0xFF00FF00);
|
||||||
int healthHeight = ((health - 50) * getHeight() / 50);
|
int healthHeight = ((health - 50) * this.height / 50);
|
||||||
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF00FFFF);
|
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFF00FFFF);
|
||||||
} else if (health > 20) {
|
} else if (health > 20) {
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
|
guiGraphics.fill(xpos, this.y + this.height * 4 / 5, xpos + 2, this.y + this.height, 0xFFFF0000);
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
|
guiGraphics.fill(xpos, this.y + this.height * 3 / 5, xpos + 2, this.y + this.height * 4 / 5, 0xFFFFFF00);
|
||||||
int healthHeight = ((health - 20) * getHeight() / 30);
|
int healthHeight = ((health - 20) * this.height / 30);
|
||||||
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF00FF00);
|
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFF00FF00);
|
||||||
} else if (health > 10) {
|
} else if (health > 10) {
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
|
guiGraphics.fill(xpos, this.y + this.height * 4 / 5, xpos + 2, this.y + this.height, 0xFFFF0000);
|
||||||
int healthHeight = ((health - 10) * getHeight() / 10);
|
int healthHeight = ((health - 10) * this.height / 10);
|
||||||
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFFFF00);
|
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFFFFFF00);
|
||||||
} else {
|
} else {
|
||||||
int healthHeight = (health * getHeight() / 10);
|
int healthHeight = (health * this.height / 10);
|
||||||
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFF0000);
|
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFFFF0000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void updateWidgetNarration(NarrationElementOutput p_259858_) {
|
|
||||||
p_259858_.add(NarratedElementType.HINT, TurnBasedMinecraftMod.proxy.getEntity(entityID, Minecraft.getInstance().level.dimension()).getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPress() {
|
public void onPress() {
|
||||||
onPress.onPress(this);
|
onPress.onPress(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFocused(boolean b) {
|
||||||
|
this.focused = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFocused() {
|
||||||
|
return focused;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NarrationPriority narrationPriority() {
|
||||||
|
return NarrationPriority.FOCUSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateNarration(NarrationElementOutput narrationElementOutput) {
|
||||||
|
narrationElementOutput.add(NarratedElementType.HINT, TurnBasedMinecraftMod.proxy.getEntity(entityID, Minecraft.getInstance().level.dimension()).getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mouseClicked(double x, double y, int unknown) {
|
||||||
|
if (unknown == 0 && x >= this.x && y >= this.y && x <= (double)(this.x + this.width) && y <= (double)(this.y + this.height)) {
|
||||||
|
onPress();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,26 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.client;
|
package com.burnedkirby.TurnBasedMinecraft.client;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.components.AbstractButton;
|
import net.minecraft.client.gui.components.Renderable;
|
||||||
|
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||||
|
import net.minecraft.client.gui.narration.NarratableEntry;
|
||||||
import net.minecraft.client.gui.narration.NarratedElementType;
|
import net.minecraft.client.gui.narration.NarratedElementType;
|
||||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
|
|
||||||
public class ItemSelectionButton extends AbstractButton {
|
public class ItemSelectionButton implements Renderable, GuiEventListener, NarratableEntry {
|
||||||
|
private int x;
|
||||||
TBMButtonPress onPress;
|
private int y;
|
||||||
|
private int width;
|
||||||
|
private int height;
|
||||||
|
TBMItemButtonPress onPress;
|
||||||
private int itemStackID;
|
private int itemStackID;
|
||||||
|
private boolean focused;
|
||||||
|
|
||||||
public ItemSelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int itemStackID, TBMButtonPress onPress) {
|
public ItemSelectionButton(int x, int y, int widthIn, int heightIn, int itemStackID, TBMItemButtonPress onPress) {
|
||||||
super(x, y, widthIn, heightIn, Component.literal(buttonText));
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.width = widthIn;
|
||||||
|
this.height = heightIn;
|
||||||
this.onPress = onPress;
|
this.onPress = onPress;
|
||||||
this.itemStackID = itemStackID;
|
this.itemStackID = itemStackID;
|
||||||
}
|
}
|
||||||
|
@ -24,23 +31,44 @@ public class ItemSelectionButton extends AbstractButton {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float unk) {
|
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float unk) {
|
||||||
if (visible) {
|
boolean hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
||||||
boolean hovered = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + getWidth() && mouseY < getY() + getHeight();
|
if (hovered) {
|
||||||
if (hovered) {
|
guiGraphics.fill(this.x, this.y, this.x + this.width, this.y + this.height, 0x80FFFFFF);
|
||||||
guiGraphics.fill(getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x80FFFFFF);
|
} else {
|
||||||
} else {
|
guiGraphics.fill(this.x, this.y, this.x + this.width, this.y + this.height, 0x20707070);
|
||||||
guiGraphics.fill(getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x20707070);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void updateWidgetNarration(NarrationElementOutput p_259858_) {
|
|
||||||
p_259858_.add(NarratedElementType.HINT, "Item " + this.itemStackID);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPress() {
|
public void onPress() {
|
||||||
onPress.onPress(this);
|
onPress.onPress(this);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
public void setFocused(boolean b) {
|
||||||
|
focused = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFocused() {
|
||||||
|
return focused;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NarrationPriority narrationPriority() {
|
||||||
|
return NarrationPriority.FOCUSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateNarration(NarrationElementOutput narrationElementOutput) {
|
||||||
|
narrationElementOutput.add(NarratedElementType.HINT, "Item " + this.itemStackID);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mouseClicked(double x, double y, int unknown) {
|
||||||
|
if (unknown == 0 && x >= this.x && y >= this.y && x <= (double)(this.x + this.width) && y <= (double)(this.y + this.height)) {
|
||||||
|
onPress();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package com.burnedkirby.TurnBasedMinecraft.client;
|
||||||
|
|
||||||
|
public interface TBMEntityButtonPress {
|
||||||
|
void onPress(EntitySelectionButton button);
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package com.burnedkirby.TurnBasedMinecraft.client;
|
||||||
|
|
||||||
|
public interface TBMItemButtonPress {
|
||||||
|
void onPress(ItemSelectionButton button);
|
||||||
|
}
|
|
@ -9,10 +9,10 @@ import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketGeneralMessage
|
||||||
import net.minecraft.world.damagesource.DamageTypes;
|
import net.minecraft.world.damagesource.DamageTypes;
|
||||||
import net.minecraft.world.entity.monster.Creeper;
|
import net.minecraft.world.entity.monster.Creeper;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
import net.neoforged.neoforge.event.entity.living.LivingAttackEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingChangeTargetEvent;
|
import net.neoforged.neoforge.event.entity.living.LivingChangeTargetEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.neoforged.neoforge.network.PacketDistributor;
|
||||||
import net.minecraftforge.network.PacketDistributor;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
|
|
||||||
public class AttackEventHandler
|
public class AttackEventHandler
|
||||||
{
|
{
|
||||||
|
@ -82,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");
|
||||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)editingInfo.editor), new PacketGeneralMessage("Cannot edit custom name from entity without custom name"));
|
PacketDistributor.PLAYER.with((ServerPlayer)editingInfo.editor).send(new PacketGeneralMessage("Cannot edit custom name from entity without custom name"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
editingInfo.entityInfo = config.getCustomEntityInfo(event.getEntity().getCustomName().getString());
|
editingInfo.entityInfo = config.getCustomEntityInfo(event.getEntity().getCustomName().getString());
|
||||||
|
@ -91,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();
|
||||||
}
|
}
|
||||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)editingInfo.editor), new PacketGeneralMessage("Editing custom name \"" + event.getEntity().getCustomName().getString() + "\""));
|
PacketDistributor.PLAYER.with((ServerPlayer)editingInfo.editor).send(new PacketGeneralMessage("Editing custom name \"" + event.getEntity().getCustomName().getString() + "\""));
|
||||||
TurnBasedMinecraftMod.logger.info("Begin editing custom \"" + event.getEntity().getCustomName().getString() + "\"");
|
TurnBasedMinecraftMod.logger.info("Begin editing custom \"" + event.getEntity().getCustomName().getString() + "\"");
|
||||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)editingInfo.editor), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with((ServerPlayer)editingInfo.editor).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -107,9 +107,9 @@ public class AttackEventHandler
|
||||||
{
|
{
|
||||||
editingInfo.entityInfo = editingInfo.entityInfo.clone();
|
editingInfo.entityInfo = editingInfo.entityInfo.clone();
|
||||||
}
|
}
|
||||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)editingInfo.editor), new PacketGeneralMessage("Editing entity \"" + editingInfo.entityInfo.classType.getName() + "\""));
|
PacketDistributor.PLAYER.with((ServerPlayer)editingInfo.editor).send(new PacketGeneralMessage("Editing entity \"" + editingInfo.entityInfo.classType.getName() + "\""));
|
||||||
TurnBasedMinecraftMod.logger.info("Begin editing \"" + editingInfo.entityInfo.classType.getName() + "\"");
|
TurnBasedMinecraftMod.logger.info("Begin editing \"" + editingInfo.entityInfo.classType.getName() + "\"");
|
||||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)editingInfo.editor), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with((ServerPlayer)editingInfo.editor).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleInfo;
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleMessage;
|
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleMessage;
|
||||||
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.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;
|
||||||
|
@ -13,8 +14,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.minecraftforge.common.CreativeModeTabRegistry;
|
import net.neoforged.neoforge.common.CreativeModeTabRegistry;
|
||||||
import net.minecraftforge.network.PacketDistributor;
|
import net.neoforged.neoforge.network.PacketDistributor;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
@ -448,7 +449,7 @@ public class Battle {
|
||||||
}
|
}
|
||||||
PacketBattleInfo infoPacket = new PacketBattleInfo(getSideAIDs(), getSideBIDs(), timer, TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos(), !TurnBasedMinecraftMod.proxy.getConfig().isBattleDecisionDurationForever());
|
PacketBattleInfo infoPacket = new PacketBattleInfo(getSideAIDs(), getSideBIDs(), timer, TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos(), !TurnBasedMinecraftMod.proxy.getConfig().isBattleDecisionDurationForever());
|
||||||
for (Combatant p : players.values()) {
|
for (Combatant p : players.values()) {
|
||||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) p.entity), infoPacket);
|
PacketDistributor.PLAYER.with((ServerPlayer)p.entity).send(infoPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,7 +464,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()) {
|
||||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) p.entity), packet);
|
PacketDistributor.PLAYER.with((ServerPlayer)p.entity).send(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -573,7 +574,7 @@ public class Battle {
|
||||||
|
|
||||||
private void removeCombatantPostRemove(Combatant c) {
|
private void removeCombatantPostRemove(Combatant c) {
|
||||||
if (c.entity instanceof Player) {
|
if (c.entity instanceof Player) {
|
||||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) c.entity), new PacketBattleMessage(PacketBattleMessage.MessageType.ENDED, 0, 0, dimension, 0));
|
PacketDistributor.PLAYER.with((ServerPlayer)c.entity).send(new PacketBattleMessage(PacketBattleMessage.MessageType.ENDED, 0, 0, dimension, 0));
|
||||||
}
|
}
|
||||||
battleManager.addRecentlyLeftBattle(c);
|
battleManager.addRecentlyLeftBattle(c);
|
||||||
}
|
}
|
||||||
|
@ -793,6 +794,28 @@ public class Battle {
|
||||||
sendMessageToAllPlayers(PacketBattleMessage.MessageType.BOW_NO_AMMO, next.entity.getId(), 0, 0);
|
sendMessageToAllPlayers(PacketBattleMessage.MessageType.BOW_NO_AMMO, next.entity.getId(), 0, 0);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
} else if (heldItemStack.getItem() instanceof CrossbowItem) {
|
||||||
|
debugLog += " with crossbow";
|
||||||
|
if (Utility.doesPlayerHaveArrows((Player) next.entity)) {
|
||||||
|
final Entity nextEntity = next.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 pitchDirection = Utility.pitchDirection(next.entity.getX(), next.entity.getY(), next.entity.getZ(), target.entity.getX(), target.entity.getY(), target.entity.getZ());
|
||||||
|
if (TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled()) {
|
||||||
|
next.yaw = yawDirection;
|
||||||
|
next.pitch = pitchDirection;
|
||||||
|
}
|
||||||
|
// have player look at attack target
|
||||||
|
((ServerPlayer) nextEntity).connection.teleport(nextEntity.getX(), nextEntity.getY(), nextEntity.getZ(), yawDirection, pitchDirection);
|
||||||
|
CrossbowItem itemCrossbow = (CrossbowItem) heldItemStack.getItem();
|
||||||
|
TurnBasedMinecraftMod.proxy.getAttackerViaBowSet().add(new AttackerViaBow(nextEntity, getId()));
|
||||||
|
itemCrossbow.releaseUsing(heldItemStack, nextEntity.level(), (LivingEntity)nextEntity, -100);
|
||||||
|
itemCrossbow.use(nextEntity.level(), (Player)nextEntity, InteractionHand.MAIN_HAND);
|
||||||
|
sendMessageToAllPlayers(PacketBattleMessage.MessageType.FIRED_ARROW, nextEntity.getId(), targetEntity.getId(), 0);
|
||||||
|
} else {
|
||||||
|
sendMessageToAllPlayers(PacketBattleMessage.MessageType.CROSSBOW_NO_AMMO, next.entity.getId(), 0, 0);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
debugLog += " without bow";
|
debugLog += " without bow";
|
||||||
int hitChance = TurnBasedMinecraftMod.proxy.getConfig().getPlayerAttackProbability();
|
int hitChance = TurnBasedMinecraftMod.proxy.getConfig().getPlayerAttackProbability();
|
||||||
|
@ -1079,7 +1102,7 @@ public class Battle {
|
||||||
final Entity nextEntity = next.entity;
|
final Entity nextEntity = next.entity;
|
||||||
final int nextItemToUse = next.itemToUse;
|
final int nextItemToUse = next.itemToUse;
|
||||||
((Player) nextEntity).getInventory().setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level(), (LivingEntity) nextEntity));
|
((Player) nextEntity).getInventory().setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level(), (LivingEntity) nextEntity));
|
||||||
} else if (targetItem instanceof PotionItem) {
|
} else if (targetItem instanceof PotionItem && !(targetItem instanceof ThrowablePotionItem)) {
|
||||||
debugLog += " potion";
|
debugLog += " potion";
|
||||||
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_POTION.getValue(), targetItemStack.getDisplayName().getString());
|
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_POTION.getValue(), targetItemStack.getDisplayName().getString());
|
||||||
final Entity nextEntity = next.entity;
|
final Entity nextEntity = next.entity;
|
||||||
|
@ -1090,7 +1113,10 @@ public class Battle {
|
||||||
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_INVALID.getValue(), targetItemStack.getDisplayName().getString());
|
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_INVALID.getValue(), targetItemStack.getDisplayName().getString());
|
||||||
final Entity nextEntity = next.entity;
|
final Entity nextEntity = next.entity;
|
||||||
final int nextItemToUse = next.itemToUse;
|
final int nextItemToUse = next.itemToUse;
|
||||||
((Player)nextEntity).getInventory().setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level(), (LivingEntity) nextEntity));
|
final int prevItem = ((Player)nextEntity).getInventory().selected;
|
||||||
|
((Player)nextEntity).getInventory().selected = nextItemToUse;
|
||||||
|
((Player)nextEntity).getInventory().setItem(nextItemToUse, targetItem.use(nextEntity.level(), (Player)nextEntity, InteractionHand.MAIN_HAND).getObject());
|
||||||
|
((Player)nextEntity).getInventory().selected = prevItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -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.minecraftforge.common.MinecraftForge;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
import net.neoforged.neoforge.event.entity.living.LivingAttackEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingChangeTargetEvent;
|
import net.neoforged.neoforge.event.entity.living.LivingChangeTargetEvent;
|
||||||
import net.minecraftforge.network.PacketDistributor;
|
import net.neoforged.neoforge.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>();
|
||||||
MinecraftForge.EVENT_BUS.register(battleUpdater);
|
NeoForge.EVENT_BUS.register(battleUpdater);
|
||||||
tempIDPair = new EntityIDDimPair();
|
tempIDPair = new EntityIDDimPair();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ public class BattleManager
|
||||||
public void cleanup()
|
public void cleanup()
|
||||||
{
|
{
|
||||||
battleUpdater.setRunning(false);
|
battleUpdater.setRunning(false);
|
||||||
MinecraftForge.EVENT_BUS.unregister(battleUpdater);
|
NeoForge.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) {
|
||||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(()->(ServerPlayer) c.entity), new PacketGeneralMessage("You just left battle! " + config.getLeaveBattleCooldownSeconds() + " seconds until you can attack/be-attacked again!"));
|
PacketDistributor.PLAYER.with((ServerPlayer)c.entity).send(new PacketGeneralMessage("You just left battle! " + config.getLeaveBattleCooldownSeconds() + " seconds until you can attack/be-attacked again!"));
|
||||||
}
|
}
|
||||||
recentlyLeftBattle.put(c.entity.getId(), c);
|
recentlyLeftBattle.put(c.entity.getId(), c);
|
||||||
entityToBattleMap.remove(new EntityIDDimPair(c.entity));
|
entityToBattleMap.remove(new EntityIDDimPair(c.entity));
|
||||||
|
@ -337,7 +337,7 @@ public class BattleManager
|
||||||
iter.remove();
|
iter.remove();
|
||||||
if(entry.getValue().entity instanceof ServerPlayer)
|
if(entry.getValue().entity instanceof ServerPlayer)
|
||||||
{
|
{
|
||||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(()->(ServerPlayer)entry.getValue().entity), new PacketGeneralMessage("Timer ended, you can now attack/be-attacked again."));
|
PacketDistributor.PLAYER.with((ServerPlayer)entry.getValue().entity).send(new PacketGeneralMessage("Timer ended, you can now attack/be-attacked again."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.common;
|
package com.burnedkirby.TurnBasedMinecraft.common;
|
||||||
|
|
||||||
|
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.neoforged.neoforge.event.TickEvent;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
|
|
@ -5,15 +5,14 @@ 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.minecraftforge.network.NetworkEvent;
|
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
||||||
import net.minecraftforge.server.ServerLifecycleHooks;
|
import net.neoforged.neoforge.server.ServerLifecycleHooks;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public class CommonProxy
|
public class CommonProxy
|
||||||
{
|
{
|
||||||
|
@ -173,5 +172,5 @@ public class CommonProxy
|
||||||
return ServerLifecycleHooks.getCurrentServer().getLevel(dim).getEntity(id);
|
return ServerLifecycleHooks.getCurrentServer().getLevel(dim).getEntity(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <MSG> void handlePacket(MSG msg, Supplier<NetworkEvent.Context> ctx) {}
|
public <MSG> void handlePacket(final MSG msg, final PlayPayloadContext ctx) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1521,7 +1521,7 @@ public class Config
|
||||||
possibleIgnoreHurtDamageSources.clear();
|
possibleIgnoreHurtDamageSources.clear();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
VanillaRegistries.createLookup().lookupOrThrow(Registries.DAMAGE_TYPE).listElements().forEach(dt -> possibleIgnoreHurtDamageSources.add(dt.get().msgId()));
|
VanillaRegistries.createLookup().lookupOrThrow(Registries.DAMAGE_TYPE).listElements().forEach(dt -> possibleIgnoreHurtDamageSources.add(dt.value().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.minecraftforge.event.entity.EntityTravelToDimensionEvent;
|
import net.neoforged.neoforge.event.entity.EntityTravelToDimensionEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.network.PacketDistributor;
|
import net.neoforged.neoforge.network.PacketDistributor;
|
||||||
|
|
||||||
public class DimensionChangedHandler {
|
public class DimensionChangedHandler {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
@ -14,9 +14,7 @@ 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) {
|
||||||
TurnBasedMinecraftMod.getHandler().send(
|
PacketDistributor.PLAYER.with((ServerPlayer)event.getEntity()).send(new PacketGeneralMessage("Left battle due to moving to a different dimension"));
|
||||||
PacketDistributor.PLAYER.with(() -> (ServerPlayer)event.getEntity()),
|
|
||||||
new PacketGeneralMessage("Left battle due to moving to a different dimension"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.common;
|
package com.burnedkirby.TurnBasedMinecraft.common;
|
||||||
|
|
||||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.neoforged.neoforge.event.entity.living.LivingHurtEvent;
|
||||||
|
|
||||||
public class HurtEventHandler {
|
public class HurtEventHandler {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
|
@ -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.minecraftforge.event.entity.EntityJoinLevelEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent;
|
||||||
|
|
||||||
public class PlayerJoinEventHandler
|
public class PlayerJoinEventHandler
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.common;
|
package com.burnedkirby.TurnBasedMinecraft.common;
|
||||||
|
|
||||||
|
import ca.weblite.objc.Client;
|
||||||
import com.burnedkirby.TurnBasedMinecraft.client.ClientProxy;
|
import com.burnedkirby.TurnBasedMinecraft.client.ClientProxy;
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.networking.*;
|
import com.burnedkirby.TurnBasedMinecraft.common.networking.*;
|
||||||
import com.mojang.brigadier.LiteralMessage;
|
import com.mojang.brigadier.LiteralMessage;
|
||||||
|
@ -18,20 +19,20 @@ 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.minecraftforge.common.MinecraftForge;
|
import net.neoforged.bus.api.IEventBus;
|
||||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.event.server.ServerStartingEvent;
|
import net.neoforged.fml.loading.FMLEnvironment;
|
||||||
import net.minecraftforge.event.server.ServerStoppingEvent;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.neoforged.neoforge.event.server.ServerStartingEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.neoforged.neoforge.event.server.ServerStoppingEvent;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
import net.neoforged.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent;
|
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.neoforged.fml.event.lifecycle.FMLDedicatedServerSetupEvent;
|
||||||
import net.minecraftforge.network.NetworkRegistry;
|
import net.neoforged.neoforge.network.event.RegisterPayloadHandlerEvent;
|
||||||
import net.minecraftforge.network.PacketDistributor;
|
import net.neoforged.neoforge.network.registration.IPayloadRegistrar;
|
||||||
import net.minecraftforge.network.simple.SimpleChannel;
|
import net.neoforged.neoforge.network.PacketDistributor;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ import org.apache.logging.log4j.Logger;
|
||||||
public class TurnBasedMinecraftMod {
|
public class TurnBasedMinecraftMod {
|
||||||
public static final String MODID = "com_burnedkirby_turnbasedminecraft";
|
public static final String MODID = "com_burnedkirby_turnbasedminecraft";
|
||||||
public static final String NAME = "Turn Based Minecraft Mod";
|
public static final String NAME = "Turn Based Minecraft Mod";
|
||||||
public static final String VERSION = "1.23.1";
|
public static final String VERSION = "1.25.2";
|
||||||
public static final String CONFIG_FILENAME = "TBM_Config.toml";
|
public static final String CONFIG_FILENAME = "TBM_Config.toml";
|
||||||
public static final String DEFAULT_CONFIG_FILENAME = "TBM_Config_DEFAULT.toml";
|
public static final String DEFAULT_CONFIG_FILENAME = "TBM_Config_DEFAULT.toml";
|
||||||
public static final String CONFIG_DIRECTORY = "config/TurnBasedMinecraft/";
|
public static final String CONFIG_DIRECTORY = "config/TurnBasedMinecraft/";
|
||||||
|
@ -50,83 +51,62 @@ 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(2);
|
private static final String PROTOCOL_VERSION = Integer.toString(3);
|
||||||
private static final ResourceLocation HANDLER_ID = new ResourceLocation(MODID, "main_channel");
|
private static final ResourceLocation HANDLER_ID = new ResourceLocation(MODID, "main_channel");
|
||||||
private static final SimpleChannel HANDLER = NetworkRegistry.ChannelBuilder
|
|
||||||
.named(HANDLER_ID)
|
|
||||||
.clientAcceptedVersions(PROTOCOL_VERSION::equals)
|
|
||||||
.serverAcceptedVersions(PROTOCOL_VERSION::equals)
|
|
||||||
.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 SimpleChannel getHandler() {
|
|
||||||
return HANDLER;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CommonProxy proxy;
|
public static CommonProxy proxy;
|
||||||
|
|
||||||
public TurnBasedMinecraftMod() {
|
public TurnBasedMinecraftMod(IEventBus eventBus) {
|
||||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::firstInit);
|
eventBus.addListener(this::firstInit);
|
||||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::secondInitClient);
|
eventBus.addListener(this::secondInitClient);
|
||||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::secondInitServer);
|
eventBus.addListener(this::secondInitServer);
|
||||||
|
eventBus.addListener(this::registerNetwork);
|
||||||
|
NeoForge.EVENT_BUS.register(this);
|
||||||
|
}
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
private void registerNetwork(final RegisterPayloadHandlerEvent event) {
|
||||||
|
final IPayloadRegistrar registrar = event.registrar(MODID);
|
||||||
|
|
||||||
|
registrar.play(PacketBattleDecision.ID, PacketBattleDecision::new, handler -> handler
|
||||||
|
.server(PacketBattleDecision.PayloadHandler.getInstance()::handleData));
|
||||||
|
|
||||||
|
registrar.play(PacketBattleInfo.ID, PacketBattleInfo::new, handler -> handler
|
||||||
|
.client(PacketBattleInfo.PayloadHandler.getInstance()::handleData));
|
||||||
|
|
||||||
|
registrar.play(PacketBattleMessage.ID, PacketBattleMessage::new, handler -> handler
|
||||||
|
.client(PacketBattleMessage.PayloadHandler.getInstance()::handleData));
|
||||||
|
|
||||||
|
registrar.play(PacketBattleRequestInfo.ID, PacketBattleRequestInfo::new, handler -> handler
|
||||||
|
.server(PacketBattleRequestInfo.PayloadHandler.getInstance()::handleData));
|
||||||
|
|
||||||
|
registrar.play(PacketEditingMessage.ID, PacketEditingMessage::new, handler -> handler
|
||||||
|
.client(PacketEditingMessage.PayloadHandler.getInstance()::handleData));
|
||||||
|
|
||||||
|
registrar.play(PacketGeneralMessage.ID, PacketGeneralMessage::new, handler -> handler
|
||||||
|
.client(PacketGeneralMessage.PayloadHandler.getInstance()::handleData));
|
||||||
|
|
||||||
|
logger.debug("Register packets com_burnedkirby_turnbasedminecraft");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void firstInit(final FMLCommonSetupEvent event) {
|
private void firstInit(final FMLCommonSetupEvent event) {
|
||||||
proxy = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> CommonProxy::new);
|
if (FMLEnvironment.dist.isClient()) {
|
||||||
|
proxy = new ClientProxy();
|
||||||
|
} else {
|
||||||
|
proxy = new CommonProxy();
|
||||||
|
}
|
||||||
proxy.setLogger(logger);
|
proxy.setLogger(logger);
|
||||||
proxy.initialize();
|
proxy.initialize();
|
||||||
|
|
||||||
// register packets
|
|
||||||
int packetHandlerID = 0;
|
|
||||||
HANDLER.registerMessage(
|
|
||||||
packetHandlerID++,
|
|
||||||
PacketBattleInfo.class,
|
|
||||||
PacketBattleInfo::encode,
|
|
||||||
PacketBattleInfo::decode,
|
|
||||||
PacketBattleInfo::handle);
|
|
||||||
HANDLER.registerMessage(
|
|
||||||
packetHandlerID++,
|
|
||||||
PacketBattleRequestInfo.class,
|
|
||||||
PacketBattleRequestInfo::encode,
|
|
||||||
PacketBattleRequestInfo::decode,
|
|
||||||
PacketBattleRequestInfo::handle);
|
|
||||||
HANDLER.registerMessage(
|
|
||||||
packetHandlerID++,
|
|
||||||
PacketBattleDecision.class,
|
|
||||||
PacketBattleDecision::encode,
|
|
||||||
PacketBattleDecision::decode,
|
|
||||||
PacketBattleDecision::handle);
|
|
||||||
HANDLER.registerMessage(
|
|
||||||
packetHandlerID++,
|
|
||||||
PacketBattleMessage.class,
|
|
||||||
PacketBattleMessage::encode,
|
|
||||||
PacketBattleMessage::decode,
|
|
||||||
PacketBattleMessage::handle);
|
|
||||||
HANDLER.registerMessage(
|
|
||||||
packetHandlerID++,
|
|
||||||
PacketGeneralMessage.class,
|
|
||||||
PacketGeneralMessage::encode,
|
|
||||||
PacketGeneralMessage::decode,
|
|
||||||
PacketGeneralMessage::handle);
|
|
||||||
HANDLER.registerMessage(
|
|
||||||
packetHandlerID++,
|
|
||||||
PacketEditingMessage.class,
|
|
||||||
PacketEditingMessage::encode,
|
|
||||||
PacketEditingMessage::decode,
|
|
||||||
PacketEditingMessage::handle);
|
|
||||||
|
|
||||||
// register event handler(s)
|
// register event handler(s)
|
||||||
MinecraftForge.EVENT_BUS.register(new AttackEventHandler());
|
NeoForge.EVENT_BUS.register(new AttackEventHandler());
|
||||||
MinecraftForge.EVENT_BUS.register(new PlayerJoinEventHandler());
|
NeoForge.EVENT_BUS.register(new PlayerJoinEventHandler());
|
||||||
MinecraftForge.EVENT_BUS.register(new DimensionChangedHandler());
|
NeoForge.EVENT_BUS.register(new DimensionChangedHandler());
|
||||||
MinecraftForge.EVENT_BUS.register(new HurtEventHandler());
|
NeoForge.EVENT_BUS.register(new HurtEventHandler());
|
||||||
|
|
||||||
logger.debug("Init com_burnedkirby_turnbasedminecraft");
|
logger.debug("Init com_burnedkirby_turnbasedminecraft");
|
||||||
}
|
}
|
||||||
|
@ -172,7 +152,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());
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP disabled turn-based-combat for everyone"));
|
PacketDistributor.PLAYER.with(player).send(new PacketGeneralMessage("OP disabled turn-based-combat for everyone"));
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}));
|
}));
|
||||||
|
@ -193,7 +173,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()) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP enabled turn-based-combat for everyone"));
|
PacketDistributor.PLAYER.with(player).send(new PacketGeneralMessage("OP enabled turn-based-combat for everyone"));
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}));
|
}));
|
||||||
|
@ -204,7 +184,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());
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP enabled turn-based-combat for you"));
|
PacketDistributor.PLAYER.with(player).send(new PacketGeneralMessage("OP enabled turn-based-combat for you"));
|
||||||
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;
|
||||||
|
@ -216,7 +196,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());
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP disabled turn-based-combat for you"));
|
PacketDistributor.PLAYER.with(player).send(new PacketGeneralMessage("OP disabled turn-based-combat for you"));
|
||||||
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;
|
||||||
|
@ -229,12 +209,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) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
proxy.setEditingPlayer(player);
|
proxy.setEditingPlayer(player);
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
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;
|
||||||
|
@ -245,14 +225,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)) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("An error occurred while attempting to save an entry to the config"));
|
PacketDistributor.PLAYER.with(player).send(new PacketGeneralMessage("An error occurred while attempting to save an entry to the config"));
|
||||||
proxy.removeEditingInfo(player.getId());
|
proxy.removeEditingInfo(player.getId());
|
||||||
} else {
|
} else {
|
||||||
proxy.removeEditingInfo(player.getId());
|
proxy.removeEditingInfo(player.getId());
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("Entity info saved in config and loaded."));
|
PacketDistributor.PLAYER.with(player).send(new PacketGeneralMessage("Entity info saved in config and loaded."));
|
||||||
}
|
}
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -265,7 +245,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());
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("Cancelled editing entry."));
|
PacketDistributor.PLAYER.with(player).send(new PacketGeneralMessage("Cancelled editing entry."));
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}))
|
}))
|
||||||
|
@ -277,11 +257,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) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
proxy.setEditingPlayer(player);
|
proxy.setEditingPlayer(player);
|
||||||
proxy.getEditingInfo(player.getId()).isEditingCustomName = true;
|
proxy.getEditingInfo(player.getId()).isEditingCustomName = true;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
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;
|
||||||
|
@ -291,9 +271,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) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -305,9 +285,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) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_IGNORE_BATTLE));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_IGNORE_BATTLE));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -321,9 +301,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;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -336,9 +316,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) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_POWER));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_POWER));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -355,9 +335,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.attackPower = attackPower;
|
editingInfo.entityInfo.attackPower = attackPower;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -370,9 +350,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) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_PROBABILITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_PROBABILITY));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -391,9 +371,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.attackProbability = attackProbability;
|
editingInfo.entityInfo.attackProbability = attackProbability;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -406,9 +386,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) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_VARIANCE));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_VARIANCE));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -425,9 +405,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.attackVariance = attackVariance;
|
editingInfo.entityInfo.attackVariance = attackVariance;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -440,9 +420,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) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -456,9 +436,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;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -471,9 +451,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) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT_PROBABILITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT_PROBABILITY));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -492,9 +472,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.attackEffectProbability = attackEffectProbability;
|
editingInfo.entityInfo.attackEffectProbability = attackEffectProbability;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -507,9 +487,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) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -526,9 +506,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.defenseDamage = defenseDamage;
|
editingInfo.entityInfo.defenseDamage = defenseDamage;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -541,9 +521,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) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE_PROBABILITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE_PROBABILITY));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -562,9 +542,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.defenseDamageProbability = defenseDamageProbability;
|
editingInfo.entityInfo.defenseDamageProbability = defenseDamageProbability;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -577,9 +557,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) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_EVASION));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_EVASION));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -598,9 +578,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.evasion = evasion;
|
editingInfo.entityInfo.evasion = evasion;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -613,9 +593,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) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SPEED));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SPEED));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -632,9 +612,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.speed = speed;
|
editingInfo.entityInfo.speed = speed;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -647,9 +627,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) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_CATEGORY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_CATEGORY));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -663,9 +643,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;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -678,9 +658,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) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_ATTACK));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_ATTACK));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -699,9 +679,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.decisionAttack = decisionAttack;
|
editingInfo.entityInfo.decisionAttack = decisionAttack;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -714,9 +694,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) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_DEFEND));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_DEFEND));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -735,9 +715,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.decisionDefend = decisionDefend;
|
editingInfo.entityInfo.decisionDefend = decisionDefend;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -750,9 +730,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) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_FLEE));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_FLEE));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -766,9 +746,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;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -784,7 +764,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();
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.SERVER_EDIT));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.SERVER_EDIT));
|
||||||
return 1;
|
return 1;
|
||||||
})
|
})
|
||||||
.then(Commands.literal("leave_battle_cooldown").executes(c -> {
|
.then(Commands.literal("leave_battle_cooldown").executes(c -> {
|
||||||
|
|
|
@ -1,17 +1,20 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
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 com.burnedkirby.TurnBasedMinecraft.common.Battle.Decision;
|
import com.burnedkirby.TurnBasedMinecraft.common.Battle.Decision;
|
||||||
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
||||||
|
|
||||||
public class PacketBattleDecision
|
public class PacketBattleDecision implements CustomPacketPayload
|
||||||
{
|
{
|
||||||
|
public static final ResourceLocation ID = new ResourceLocation(TurnBasedMinecraftMod.MODID, "network_packetbattledecision");
|
||||||
|
|
||||||
private int battleID;
|
private int battleID;
|
||||||
private Battle.Decision decision;
|
private Battle.Decision decision;
|
||||||
private int targetIDOrItemID;
|
private int targetIDOrItemID;
|
||||||
|
@ -24,26 +27,44 @@ public class PacketBattleDecision
|
||||||
this.decision = decision;
|
this.decision = decision;
|
||||||
this.targetIDOrItemID = targetIDOrItemID;
|
this.targetIDOrItemID = targetIDOrItemID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void encode(PacketBattleDecision pkt, FriendlyByteBuf buf) {
|
public PacketBattleDecision(final FriendlyByteBuf buf) {
|
||||||
buf.writeInt(pkt.battleID);
|
this.battleID = buf.readInt();
|
||||||
buf.writeInt(pkt.decision.getValue());
|
this.decision = Decision.valueOf(buf.readInt());
|
||||||
buf.writeInt(pkt.targetIDOrItemID);
|
this.targetIDOrItemID = buf.readInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PacketBattleDecision decode(FriendlyByteBuf buf) {
|
@Override
|
||||||
return new PacketBattleDecision(buf.readInt(), Decision.valueOf(buf.readInt()), buf.readInt());
|
public void write(FriendlyByteBuf buf) {
|
||||||
|
buf.writeInt(battleID);
|
||||||
|
buf.writeInt(decision.getValue());
|
||||||
|
buf.writeInt(targetIDOrItemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handle(final PacketBattleDecision pkt, Supplier<NetworkEvent.Context> ctx) {
|
@Override
|
||||||
ctx.get().enqueueWork(() -> {
|
public ResourceLocation id() {
|
||||||
Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
|
return ID;
|
||||||
if(b != null)
|
}
|
||||||
{
|
|
||||||
ServerPlayer player = ctx.get().getSender();
|
public static class PayloadHandler {
|
||||||
b.setDecision(player.getId(), pkt.decision, pkt.targetIDOrItemID);
|
private static final PayloadHandler INSTANCE = new PayloadHandler();
|
||||||
}
|
|
||||||
});
|
public static PayloadHandler getInstance() {
|
||||||
ctx.get().setPacketHandled(true);
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleData(final PacketBattleDecision pkt, final PlayPayloadContext ctx) {
|
||||||
|
ctx.workHandler().submitAsync(() -> {
|
||||||
|
Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
|
||||||
|
if(b != null)
|
||||||
|
{
|
||||||
|
Player player = ctx.player().get();
|
||||||
|
b.setDecision(player.getId(), pkt.decision, pkt.targetIDOrItemID);
|
||||||
|
}
|
||||||
|
}).exceptionally(e -> {
|
||||||
|
ctx.packetHandler().disconnect(Component.literal("Exception handling PacketBattleDecision! " + e.getMessage()));
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,20 @@ package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
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.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
||||||
|
|
||||||
public class PacketBattleInfo
|
public class PacketBattleInfo implements CustomPacketPayload
|
||||||
{
|
{
|
||||||
|
public static final ResourceLocation ID = new ResourceLocation(TurnBasedMinecraftMod.MODID, "network_packetbattleinfo");
|
||||||
private Collection<Integer> sideA;
|
private Collection<Integer> sideA;
|
||||||
private Collection<Integer> sideB;
|
private Collection<Integer> sideB;
|
||||||
private long decisionNanos;
|
private long decisionNanos;
|
||||||
|
@ -38,65 +41,80 @@ public class PacketBattleInfo
|
||||||
this.turnTimerEnabled = turnTimerEnabled;
|
this.turnTimerEnabled = turnTimerEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void encode(PacketBattleInfo msg, FriendlyByteBuf buf) {
|
public PacketBattleInfo(final FriendlyByteBuf buf) {
|
||||||
buf.writeInt(msg.sideA.size());
|
int sideACount = buf.readInt();
|
||||||
buf.writeInt(msg.sideB.size());
|
int sideBCount = buf.readInt();
|
||||||
for(Integer id : msg.sideA) {
|
this.sideA = new ArrayList<>(sideACount);
|
||||||
buf.writeInt(id);
|
this.sideB = new ArrayList<>(sideBCount);
|
||||||
}
|
for (int i = 0; i < sideACount; ++i) {
|
||||||
for(Integer id : msg.sideB) {
|
this.sideA.add(buf.readInt());
|
||||||
buf.writeInt(id);
|
}
|
||||||
}
|
for (int i = 0; i < sideBCount; ++i) {
|
||||||
buf.writeLong(msg.decisionNanos);
|
this.sideB.add(buf.readInt());
|
||||||
buf.writeLong(msg.maxDecisionNanos);
|
}
|
||||||
buf.writeBoolean(msg.turnTimerEnabled);
|
this.decisionNanos = buf.readLong();
|
||||||
|
this.maxDecisionNanos = buf.readLong();
|
||||||
|
this.turnTimerEnabled = buf.readBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PacketBattleInfo decode(FriendlyByteBuf buf) {
|
@Override
|
||||||
int sideACount = buf.readInt();
|
public void write(FriendlyByteBuf buf) {
|
||||||
int sideBCount = buf.readInt();
|
buf.writeInt(sideA.size());
|
||||||
Collection<Integer> sideA = new ArrayList<Integer>(sideACount);
|
buf.writeInt(sideB.size());
|
||||||
Collection<Integer> sideB = new ArrayList<Integer>(sideBCount);
|
for(Integer id : sideA) {
|
||||||
for(int i = 0; i < sideACount; ++i) {
|
buf.writeInt(id);
|
||||||
sideA.add(buf.readInt());
|
}
|
||||||
}
|
for(Integer id : sideB) {
|
||||||
for(int i = 0; i < sideBCount; ++i) {
|
buf.writeInt(id);
|
||||||
sideB.add(buf.readInt());
|
}
|
||||||
}
|
buf.writeLong(decisionNanos);
|
||||||
long decisionNanos = buf.readLong();
|
buf.writeLong(maxDecisionNanos);
|
||||||
long maxDecisionNanos = buf.readLong();
|
buf.writeBoolean(turnTimerEnabled);
|
||||||
boolean turnTimerEnabled = buf.readBoolean();
|
|
||||||
return new PacketBattleInfo(sideA, sideB, decisionNanos, maxDecisionNanos, turnTimerEnabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handle(final PacketBattleInfo pkt, Supplier<NetworkEvent.Context> ctx) {
|
@Override
|
||||||
ctx.get().enqueueWork(() -> {
|
public ResourceLocation id() {
|
||||||
if(TurnBasedMinecraftMod.proxy.getLocalBattle() == null)
|
return ID;
|
||||||
{
|
}
|
||||||
return;
|
|
||||||
}
|
public static class PayloadHandler {
|
||||||
TurnBasedMinecraftMod.proxy.getLocalBattle().clearCombatants();
|
private static final PayloadHandler INSTANCE = new PayloadHandler();
|
||||||
for(Integer id : pkt.sideA)
|
|
||||||
{
|
public static PayloadHandler getInstance() {
|
||||||
Entity e = Minecraft.getInstance().level.getEntity(id);
|
return INSTANCE;
|
||||||
if(e != null)
|
}
|
||||||
|
|
||||||
|
public void handleData(final PacketBattleInfo pkt, final PlayPayloadContext ctx) {
|
||||||
|
ctx.workHandler().submitAsync(() -> {
|
||||||
|
if(TurnBasedMinecraftMod.proxy.getLocalBattle() == null)
|
||||||
{
|
{
|
||||||
TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideA(e);
|
return;
|
||||||
}
|
}
|
||||||
}
|
TurnBasedMinecraftMod.proxy.getLocalBattle().clearCombatants();
|
||||||
for(Integer id : pkt.sideB)
|
for(Integer id : pkt.sideA)
|
||||||
{
|
|
||||||
Entity e = Minecraft.getInstance().level.getEntity(id);
|
|
||||||
if(e != null)
|
|
||||||
{
|
{
|
||||||
TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideB(e);
|
Entity e = Minecraft.getInstance().level.getEntity(id);
|
||||||
|
if(e != null)
|
||||||
|
{
|
||||||
|
TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideA(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
for(Integer id : pkt.sideB)
|
||||||
TurnBasedMinecraftMod.proxy.setBattleGuiTime((int)(pkt.decisionNanos / 1000000000L));
|
{
|
||||||
TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
|
Entity e = Minecraft.getInstance().level.getEntity(id);
|
||||||
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerEnabled(pkt.turnTimerEnabled);
|
if(e != null)
|
||||||
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerMax((int)(pkt.maxDecisionNanos / 1000000000L));
|
{
|
||||||
});
|
TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideB(e);
|
||||||
ctx.get().setPacketHandled(true);
|
}
|
||||||
|
}
|
||||||
|
TurnBasedMinecraftMod.proxy.setBattleGuiTime((int)(pkt.decisionNanos / 1000000000L));
|
||||||
|
TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
|
||||||
|
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerEnabled(pkt.turnTimerEnabled);
|
||||||
|
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerMax((int)(pkt.maxDecisionNanos / 1000000000L));
|
||||||
|
}).exceptionally(e -> {
|
||||||
|
ctx.packetHandler().disconnect(Component.literal("Exception handling PacketBattleInfo! " + e.getMessage()));
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,20 +2,38 @@ package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||||
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.Utility;
|
import com.burnedkirby.TurnBasedMinecraft.common.Utility;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
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.minecraftforge.api.distmarker.Dist;
|
import net.neoforged.fml.loading.FMLEnvironment;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
|
||||||
|
|
||||||
public class PacketBattleMessage
|
public class PacketBattleMessage implements CustomPacketPayload
|
||||||
{
|
{
|
||||||
|
public static final ResourceLocation ID = new ResourceLocation(TurnBasedMinecraftMod.MODID, "network_packetbattlemessage");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(FriendlyByteBuf buf) {
|
||||||
|
buf.writeInt(messageType.getValue());
|
||||||
|
buf.writeInt(entityIDFrom);
|
||||||
|
buf.writeInt(entityIDTo);
|
||||||
|
buf.writeUtf(Utility.serializeDimension(dimension));
|
||||||
|
buf.writeInt(amount);
|
||||||
|
buf.writeUtf(custom);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResourceLocation id() {
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
public enum MessageType
|
public enum MessageType
|
||||||
{
|
{
|
||||||
ENTERED(0),
|
ENTERED(0),
|
||||||
|
@ -39,7 +57,8 @@ public class PacketBattleMessage
|
||||||
BOW_NO_AMMO(18),
|
BOW_NO_AMMO(18),
|
||||||
CREEPER_WAIT(19),
|
CREEPER_WAIT(19),
|
||||||
CREEPER_WAIT_FINAL(20),
|
CREEPER_WAIT_FINAL(20),
|
||||||
CREEPER_EXPLODE(21);
|
CREEPER_EXPLODE(21),
|
||||||
|
CROSSBOW_NO_AMMO(22);
|
||||||
|
|
||||||
private int value;
|
private int value;
|
||||||
private static Map<Integer, MessageType> map = new HashMap<Integer, MessageType>();
|
private static Map<Integer, MessageType> map = new HashMap<Integer, MessageType>();
|
||||||
|
@ -153,31 +172,32 @@ public class PacketBattleMessage
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
this.custom = custom;
|
this.custom = custom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void encode(PacketBattleMessage pkt, FriendlyByteBuf buf) {
|
public PacketBattleMessage(final FriendlyByteBuf buf) {
|
||||||
buf.writeInt(pkt.messageType.getValue());
|
this.messageType = MessageType.valueOf(buf.readInt());
|
||||||
buf.writeInt(pkt.entityIDFrom);
|
this.entityIDFrom = buf.readInt();
|
||||||
buf.writeInt(pkt.entityIDTo);
|
this.entityIDTo = buf.readInt();
|
||||||
buf.writeUtf(Utility.serializeDimension(pkt.dimension));
|
this.dimension = Utility.deserializeDimension(buf.readUtf());
|
||||||
buf.writeInt(pkt.amount);
|
this.amount = buf.readInt();
|
||||||
buf.writeUtf(pkt.custom);
|
this.custom = buf.readUtf();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PacketBattleMessage decode(FriendlyByteBuf buf) {
|
public static class PayloadHandler {
|
||||||
return new PacketBattleMessage(
|
private static final PayloadHandler INSTANCE = new PayloadHandler();
|
||||||
MessageType.valueOf(
|
|
||||||
buf.readInt()),
|
public static PayloadHandler getInstance() {
|
||||||
buf.readInt(),
|
return INSTANCE;
|
||||||
buf.readInt(),
|
}
|
||||||
Utility.deserializeDimension(buf.readUtf()),
|
|
||||||
buf.readInt(),
|
public void handleData(final PacketBattleMessage pkt, final PlayPayloadContext ctx) {
|
||||||
buf.readUtf());
|
ctx.workHandler().submitAsync(() -> {
|
||||||
}
|
if (FMLEnvironment.dist.isClient()) {
|
||||||
|
TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx);
|
||||||
public static void handle(final PacketBattleMessage pkt, Supplier<NetworkEvent.Context> ctx) {
|
}
|
||||||
ctx.get().enqueueWork(() -> {
|
}).exceptionally(e -> {
|
||||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
|
ctx.packetHandler().disconnect(Component.literal("Exception handling PacketBattleMessage! " + e.getMessage()));
|
||||||
});
|
return null;
|
||||||
ctx.get().setPacketHandled(true);
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
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 net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
||||||
|
|
||||||
public class PacketBattleRequestInfo
|
public class PacketBattleRequestInfo implements CustomPacketPayload
|
||||||
{
|
{
|
||||||
|
public static final ResourceLocation ID = new ResourceLocation(TurnBasedMinecraftMod.MODID, "network_packetbattlerequestinfo");
|
||||||
|
|
||||||
private int battleID;
|
private int battleID;
|
||||||
|
|
||||||
public PacketBattleRequestInfo() {}
|
public PacketBattleRequestInfo() {}
|
||||||
|
@ -18,23 +21,44 @@ public class PacketBattleRequestInfo
|
||||||
{
|
{
|
||||||
this.battleID = battleID;
|
this.battleID = battleID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void encode(PacketBattleRequestInfo pkt, FriendlyByteBuf buf) {
|
public PacketBattleRequestInfo(final FriendlyByteBuf buf) {
|
||||||
buf.writeInt(pkt.battleID);
|
battleID = buf.readInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PacketBattleRequestInfo decode(FriendlyByteBuf buf) {
|
@Override
|
||||||
return new PacketBattleRequestInfo(buf.readInt());
|
public void write(FriendlyByteBuf buf) {
|
||||||
|
buf.writeInt(battleID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handle(final PacketBattleRequestInfo pkt, Supplier<NetworkEvent.Context> ctx) {
|
@Override
|
||||||
ctx.get().enqueueWork(() -> {
|
public ResourceLocation id() {
|
||||||
Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
|
return ID;
|
||||||
if(b == null) {
|
}
|
||||||
return;
|
|
||||||
}
|
public static class PayloadHandler {
|
||||||
TurnBasedMinecraftMod.getHandler().reply(new PacketBattleInfo(b.getSideAIDs(), b.getSideBIDs(), b.getTimerNanos(), TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos(), !TurnBasedMinecraftMod.proxy.getConfig().isBattleDecisionDurationForever()), ctx.get());
|
private static final PayloadHandler INSTANCE = new PayloadHandler();
|
||||||
});
|
|
||||||
ctx.get().setPacketHandled(true);
|
public static PayloadHandler getInstance() {
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleData(final PacketBattleRequestInfo pkt, final PlayPayloadContext ctx) {
|
||||||
|
ctx.workHandler().submitAsync(() -> {
|
||||||
|
Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
|
||||||
|
if(b == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ctx.replyHandler().send(new PacketBattleInfo(
|
||||||
|
b.getSideAIDs(),
|
||||||
|
b.getSideBIDs(),
|
||||||
|
b.getTimerNanos(),
|
||||||
|
TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos(),
|
||||||
|
!TurnBasedMinecraftMod.proxy.getConfig().isBattleDecisionDurationForever()));
|
||||||
|
}).exceptionally(e -> {
|
||||||
|
ctx.packetHandler().disconnect(Component.literal("Exception handling PacketBattleRequestInfo! " + e.getMessage()));
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,16 +3,49 @@ package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.EntityInfo;
|
import com.burnedkirby.TurnBasedMinecraft.common.EntityInfo;
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.neoforged.fml.loading.FMLEnvironment;
|
||||||
|
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public class PacketEditingMessage
|
public class PacketEditingMessage implements CustomPacketPayload
|
||||||
{
|
{
|
||||||
|
public static final ResourceLocation ID = new ResourceLocation(TurnBasedMinecraftMod.MODID, "network_packeteditingmessage");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(FriendlyByteBuf buf) {
|
||||||
|
buf.writeInt(type.getValue());
|
||||||
|
if(entityInfo.classType != null) {
|
||||||
|
buf.writeUtf(entityInfo.classType.getName());
|
||||||
|
} else {
|
||||||
|
buf.writeUtf("unknown");
|
||||||
|
}
|
||||||
|
buf.writeBoolean(entityInfo.ignoreBattle);
|
||||||
|
buf.writeInt(entityInfo.attackPower);
|
||||||
|
buf.writeInt(entityInfo.attackProbability);
|
||||||
|
buf.writeInt(entityInfo.attackVariance);
|
||||||
|
buf.writeUtf(entityInfo.attackEffect.toString());
|
||||||
|
buf.writeInt(entityInfo.attackEffectProbability);
|
||||||
|
buf.writeInt(entityInfo.defenseDamage);
|
||||||
|
buf.writeInt(entityInfo.defenseDamageProbability);
|
||||||
|
buf.writeInt(entityInfo.evasion);
|
||||||
|
buf.writeInt(entityInfo.speed);
|
||||||
|
buf.writeUtf(entityInfo.category);
|
||||||
|
buf.writeInt(entityInfo.decisionAttack);
|
||||||
|
buf.writeInt(entityInfo.decisionDefend);
|
||||||
|
buf.writeInt(entityInfo.decisionFlee);
|
||||||
|
buf.writeUtf(entityInfo.customName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResourceLocation id() {
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
public enum Type
|
public enum Type
|
||||||
{
|
{
|
||||||
ATTACK_ENTITY(0),
|
ATTACK_ENTITY(0),
|
||||||
|
@ -87,59 +120,46 @@ public class PacketEditingMessage
|
||||||
this.entityInfo = entityInfo;
|
this.entityInfo = entityInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void encode(PacketEditingMessage pkt, FriendlyByteBuf buf) {
|
public PacketEditingMessage(final FriendlyByteBuf buf) {
|
||||||
buf.writeInt(pkt.type.getValue());
|
this.type = Type.valueOf(buf.readInt());
|
||||||
if(pkt.entityInfo.classType != null) {
|
this.entityInfo = new EntityInfo();
|
||||||
buf.writeUtf(pkt.entityInfo.classType.getName());
|
try {
|
||||||
} else {
|
this.entityInfo.classType = this.entityInfo.getClass().getClassLoader().loadClass(buf.readUtf());
|
||||||
buf.writeUtf("unknown");
|
} catch (ClassNotFoundException e) { /* ignored */ }
|
||||||
}
|
this.entityInfo.ignoreBattle = buf.readBoolean();
|
||||||
buf.writeBoolean(pkt.entityInfo.ignoreBattle);
|
this.entityInfo.attackPower = buf.readInt();
|
||||||
buf.writeInt(pkt.entityInfo.attackPower);
|
this.entityInfo.attackProbability = buf.readInt();
|
||||||
buf.writeInt(pkt.entityInfo.attackProbability);
|
this.entityInfo.attackVariance = buf.readInt();
|
||||||
buf.writeInt(pkt.entityInfo.attackVariance);
|
this.entityInfo.attackEffect = EntityInfo.Effect.fromString(buf.readUtf());
|
||||||
buf.writeUtf(pkt.entityInfo.attackEffect.toString());
|
this.entityInfo.attackEffectProbability = buf.readInt();
|
||||||
buf.writeInt(pkt.entityInfo.attackEffectProbability);
|
this.entityInfo.defenseDamage = buf.readInt();
|
||||||
buf.writeInt(pkt.entityInfo.defenseDamage);
|
this.entityInfo.defenseDamageProbability = buf.readInt();
|
||||||
buf.writeInt(pkt.entityInfo.defenseDamageProbability);
|
this.entityInfo.evasion = buf.readInt();
|
||||||
buf.writeInt(pkt.entityInfo.evasion);
|
this.entityInfo.speed = buf.readInt();
|
||||||
buf.writeInt(pkt.entityInfo.speed);
|
this.entityInfo.category = buf.readUtf();
|
||||||
buf.writeUtf(pkt.entityInfo.category);
|
this.entityInfo.decisionAttack = buf.readInt();
|
||||||
buf.writeInt(pkt.entityInfo.decisionAttack);
|
this.entityInfo.decisionDefend = buf.readInt();
|
||||||
buf.writeInt(pkt.entityInfo.decisionDefend);
|
this.entityInfo.decisionFlee = buf.readInt();
|
||||||
buf.writeInt(pkt.entityInfo.decisionFlee);
|
this.entityInfo.customName = buf.readUtf();
|
||||||
buf.writeUtf(pkt.entityInfo.customName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PacketEditingMessage decode(FriendlyByteBuf 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.category = buf.readUtf();
|
|
||||||
einfo.decisionAttack = buf.readInt();
|
|
||||||
einfo.decisionDefend = buf.readInt();
|
|
||||||
einfo.decisionFlee = buf.readInt();
|
|
||||||
einfo.customName = buf.readUtf();
|
|
||||||
return new PacketEditingMessage(type, einfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handle(final PacketEditingMessage pkt, Supplier<NetworkEvent.Context> ctx) {
|
public static class PayloadHandler {
|
||||||
ctx.get().enqueueWork(() -> {
|
private static final PayloadHandler INSTANCE = new PayloadHandler();
|
||||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
|
|
||||||
});
|
public static PayloadHandler getInstance() {
|
||||||
ctx.get().setPacketHandled(true);
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleData(final PacketEditingMessage pkt, final PlayPayloadContext ctx) {
|
||||||
|
ctx.workHandler().submitAsync(() -> {
|
||||||
|
if (FMLEnvironment.dist.isClient()) {
|
||||||
|
TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx);
|
||||||
|
}
|
||||||
|
}).exceptionally(e -> {
|
||||||
|
ctx.packetHandler().disconnect(Component.literal("Exception handling PacketEditingMessage! " + e.getMessage()));
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,16 +1,18 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||||
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.neoforged.fml.loading.FMLEnvironment;
|
||||||
|
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
||||||
|
|
||||||
public class PacketGeneralMessage
|
public class PacketGeneralMessage implements CustomPacketPayload
|
||||||
{
|
{
|
||||||
|
public static final ResourceLocation ID = new ResourceLocation(TurnBasedMinecraftMod.MODID, "network_packetgeneralmessage");
|
||||||
|
|
||||||
String message;
|
String message;
|
||||||
|
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
|
@ -26,19 +28,37 @@ public class PacketGeneralMessage
|
||||||
{
|
{
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void encode(PacketGeneralMessage pkt, FriendlyByteBuf buf) {
|
public PacketGeneralMessage(final FriendlyByteBuf buf) {
|
||||||
buf.writeUtf(pkt.message);
|
this.message = buf.readUtf();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PacketGeneralMessage decode(FriendlyByteBuf buf) {
|
@Override
|
||||||
return new PacketGeneralMessage(buf.readUtf());
|
public void write(FriendlyByteBuf buf) {
|
||||||
|
buf.writeUtf(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handle(final PacketGeneralMessage pkt, Supplier<NetworkEvent.Context> ctx) {
|
@Override
|
||||||
ctx.get().enqueueWork(() -> {
|
public ResourceLocation id() {
|
||||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
|
return ID;
|
||||||
});
|
}
|
||||||
ctx.get().setPacketHandled(true);
|
|
||||||
|
public static class PayloadHandler {
|
||||||
|
private static final PayloadHandler INSTANCE = new PayloadHandler();
|
||||||
|
|
||||||
|
public static PayloadHandler getInstance() {
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleData(final PacketGeneralMessage pkt, final PlayPayloadContext ctx) {
|
||||||
|
ctx.workHandler().submitAsync(() -> {
|
||||||
|
if (FMLEnvironment.dist.isClient()) {
|
||||||
|
TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx);
|
||||||
|
}
|
||||||
|
}).exceptionally(e -> {
|
||||||
|
ctx.packetHandler().disconnect(Component.literal("Exception handling PacketGeneralMessage! " + e.getMessage()));
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ modLoader="javafml" #mandatory
|
||||||
loaderVersion="${loader_version_range}" #mandatory (34 is current forge version)
|
loaderVersion="${loader_version_range}" #mandatory (34 is current forge version)
|
||||||
# A URL to refer people to when problems occur with this mod
|
# A URL to refer people to when problems occur with this mod
|
||||||
issueTrackerURL="https://github.com/Stephen-Seo/TurnBasedMinecraftMod/issues" #optional
|
issueTrackerURL="https://github.com/Stephen-Seo/TurnBasedMinecraftMod/issues" #optional
|
||||||
license="MIT"
|
license="${mod_license}"
|
||||||
# A list of mods - how many allowed here is determined by the individual mod loader
|
# A list of mods - how many allowed here is determined by the individual mod loader
|
||||||
[[mods]] #mandatory
|
[[mods]] #mandatory
|
||||||
# The modid of the mod
|
# The modid of the mod
|
||||||
|
@ -29,17 +29,18 @@ credits="Thanks for this mod goes to Java" #optional
|
||||||
# A text field displayed in the mod UI
|
# A text field displayed in the mod UI
|
||||||
authors="${mod_authors}" #optional
|
authors="${mod_authors}" #optional
|
||||||
# The description text for the mod (multi line!) (#mandatory)
|
# The description text for the mod (multi line!) (#mandatory)
|
||||||
description='''
|
description='''${mod_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.
|
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
||||||
[[dependencies.com_burnedkirby_turnbasedminecraft]] #optional
|
[[dependencies.com_burnedkirby_turnbasedminecraft]] #optional
|
||||||
# the modid of the dependency
|
# the modid of the dependency
|
||||||
modId="forge" #mandatory
|
modId="neoforge" #mandatory
|
||||||
# Does this dependency have to exist - if not, ordering below must be specified
|
# Does this dependency have to exist - if not, ordering below must be specified
|
||||||
mandatory=true #mandatory
|
type="required" #mandatory
|
||||||
# The version range of the dependency
|
# The version range of the dependency
|
||||||
versionRange="${forge_version_range}" #mandatory
|
versionRange="${neo_version_range}" #mandatory
|
||||||
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
||||||
|
@ -47,7 +48,7 @@ Implements turn-based-battle in Minecraft.
|
||||||
# Here's another dependency
|
# Here's another dependency
|
||||||
[[dependencies.com_burnedkirby_turnbasedminecraft]]
|
[[dependencies.com_burnedkirby_turnbasedminecraft]]
|
||||||
modId="minecraft"
|
modId="minecraft"
|
||||||
mandatory=true
|
type="required"
|
||||||
versionRange="${minecraft_version_range}"
|
versionRange="${minecraft_version_range}"
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
side="BOTH"
|
side="BOTH"
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
|
@ -1,18 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"modid": "com_burnedkirby_turnbasedminecraft",
|
|
||||||
"name": "Turn Based Minecraft",
|
|
||||||
"description": "Changes battles to be turn-based.",
|
|
||||||
"version": "1.23.1",
|
|
||||||
"mcversion": "1.20.1",
|
|
||||||
"url": "",
|
|
||||||
"updateUrl": "",
|
|
||||||
"authorList": ["Stephen Seo"],
|
|
||||||
"credits": "The Forge and FML guys, for making this possible.
|
|
||||||
Dependencies:
|
|
||||||
JavaMP3 by delthas, josephx86, GlaDOSik, and kevinstadler (MIT License)",
|
|
||||||
"logoFile": "",
|
|
||||||
"screenshots": [],
|
|
||||||
"dependencies": []
|
|
||||||
}
|
|
||||||
]
|
|
Loading…
Reference in a new issue