Compare commits
112 commits
neoforge
...
forge-1.26
Author | SHA1 | Date | |
---|---|---|---|
a9df1e3c4d | |||
be78ddc1b6 | |||
42c69e8983 | |||
2572190b07 | |||
2d52e898f4 | |||
b13695d096 | |||
95333b799a | |||
ce72e80cb8 | |||
00f13aba72 | |||
3749aa9308 | |||
48983caf2c | |||
f50f412fd4 | |||
fde09d116d | |||
4c0872b7ad | |||
c1109245e4 | |||
780f2e89ad | |||
150c869dfb | |||
4ff1bafd91 | |||
f5af4c9bdf | |||
36b6673d69 | |||
991406b45b | |||
06ff3fb5ae | |||
ff6b4747ac | |||
4c969a4654 | |||
ecf981fb0c | |||
cf8df83b49 | |||
1b585b4377 | |||
b676a00c1c | |||
252b3a5272 | |||
8e469f1a8a | |||
02f7b179a5 | |||
c65f9bde1c | |||
504329fa88 | |||
8e646cb814 | |||
e6501e4fe3 | |||
4652ecf20e | |||
d5308986e9 | |||
7347437567 | |||
046e6c92bf | |||
f5cc024f2e | |||
7d8c63ea4d | |||
cebc42ff37 | |||
d006474932 | |||
1d12e8c3a7 | |||
e9019245dc | |||
6fb10c6ce1 | |||
dd30766732 | |||
a3a413f5d6 | |||
cbfd354919 | |||
524df98c22 | |||
20fe64ed61 | |||
5372e7a25a | |||
c07828f411 | |||
eef8433df4 | |||
b763720989 | |||
5c59c73332 | |||
f18cd91560 | |||
d57a75d3b2 | |||
fb7d4e39de | |||
71e3796694 | |||
c066e10762 | |||
971c56c69b | |||
b20f8314d0 | |||
e1e462cb6d | |||
84006554e8 | |||
a20d0e0ccb | |||
6815276eef | |||
8476b9b19c | |||
458aeaaf07 | |||
530fdadc07 | |||
be99607226 | |||
00c6ec12a4 | |||
5dda78f3a5 | |||
ae18f2686e | |||
6c3aa48923 | |||
05ab18b572 | |||
768844b05f | |||
c0879e120c | |||
039f27cbc1 | |||
ad78063a16 | |||
4c2bc47007 | |||
be19ce8748 | |||
3a6d800745 | |||
56a9db15ad | |||
18076715e0 | |||
8551aae80b | |||
cc7ef71384 | |||
6d8384ce04 | |||
0d0c0ca08c | |||
74291dde8f | |||
f687dfdaf3 | |||
6e8d3a8d5a | |||
47a2eb9c74 | |||
9680fdb24b | |||
398e8a9218 | |||
c4a8664297 | |||
9daf5c139f | |||
5168f8b346 | |||
304c739a25 | |||
0d8699c420 | |||
8ee3c99846 | |||
e5beef7c98 | |||
56353462f7 | |||
da17601477 | |||
5d905ac55e | |||
d7e35cbf5a | |||
132d16b2bd | |||
24247eab7b | |||
dc7d621d5c | |||
fc34310cbe | |||
601d5bc15d | |||
62576a06c6 |
44 changed files with 2825 additions and 996 deletions
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: highmem_self
|
||||
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]\+[mMgG]/Xmx1024m/' gradle.properties
|
||||
- run: cd TurnBasedMinecraftMod && ./gradlew --console=plain build
|
||||
- run: cd TurnBasedMinecraftMod/build/libs && find . -regex '.*all.jar$' -exec sha256sum '{}' ';' -exec bash -c 'sha256sum {} >> sha256sums.txt' ';' && java --version >> javaVersion.txt && javac --version >> javaVersion.txt
|
||||
- name: Create release and attach jar
|
||||
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/forge/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
|
||||
|
||||
logs/
|
||||
runs/
|
||||
|
|
167
Changelog.md
167
Changelog.md
|
@ -1,5 +1,172 @@
|
|||
# Upcoming changes
|
||||
|
||||
# Version Forge-1.26.4
|
||||
|
||||
Add support for "per-player-stats" in Turn-Based-Battle.
|
||||
|
||||
Update to Forge 52.0.24 (MC 1.21.1).
|
||||
|
||||
# Version NeoForge-1.26.4-MC-1.21.1
|
||||
|
||||
Add support for "per-player-stats" in Turn-Based-Battle.
|
||||
|
||||
Update to Neoforge 21.1.73 (Minecraft 1.21.1).
|
||||
|
||||
# Version NeoForge-1.26.4
|
||||
|
||||
Add support for "per-player-stats" in Turn-Based-Battle.
|
||||
|
||||
Update to NeoForge 21.3.6-beta (MC 1.21.3).
|
||||
|
||||
# Version Forge-1.26.3
|
||||
|
||||
Tweak to "Ping" packet to not create client-local Battle instance if it does
|
||||
not exist.
|
||||
|
||||
# Version NeoForge-1.26.3
|
||||
|
||||
Port to NeoForge 21.3.2-beta (MC 1.21.3).
|
||||
|
||||
Note that MC 1.21.1 (NeoForge 21.1.72) will still be supported in a separate
|
||||
branch (neoforge\_mc1.21.1) until MC version 1.22 is released.
|
||||
|
||||
Tweak to "Ping" packet to not create client-local Battle instance if it does
|
||||
not exist.
|
||||
|
||||
# Version NeoForge-1.26.3-MC-1.21.1
|
||||
|
||||
Tweak to "Ping" packet to not create client-local Battle instance if it does
|
||||
not exist.
|
||||
|
||||
# Version Forge-1.26.2
|
||||
|
||||
Show battling Entities next to their attack button in the BattleGUI.
|
||||
|
||||
# Version NeoForge-1.26.2
|
||||
|
||||
Show battling Entities next to their attack button in the BattleGUI.
|
||||
|
||||
# Version Forge-1.26.1
|
||||
|
||||
Minor fixes/refactorings that should make the mod more robust.
|
||||
|
||||
Port to Forge 52.0.22 (Minecraft 1.21.1).
|
||||
|
||||
Allow leaving battle GUI with Escape key (temporarily), and some refactorings
|
||||
to (hopefully) fix that pesky transient client-freeze-bug.
|
||||
|
||||
Minecraft's music should be paused during battle, even if it starts mid-battle.
|
||||
(Minecraft's music may play up to 4 seconds before it is paused by TBMM.)
|
||||
|
||||
# Version NeoForge-1.26.1
|
||||
|
||||
Minor fixes/refactorings that should make the mod more robust.
|
||||
|
||||
Port to NeoForge-21.1.72 (Minecraft 1.21.1).
|
||||
|
||||
Allow leaving battle GUI with Escape key (temporarily), and some refactorings
|
||||
to (hopefully) fix that pesky transient client-freeze-bug.
|
||||
|
||||
Minecraft's music should be paused during battle, even if it starts mid-battle.
|
||||
(Minecraft's music may play up to 4 seconds before it is paused by TBMM.)
|
||||
|
||||
# Version Forge-1.26.0
|
||||
|
||||
Port to Forge 52.0.21 (Minecraft 1.21.1).
|
||||
|
||||
Client-config available via `/tbm-client-edit` (same as NeoForge), but there is
|
||||
no way to access it via the mod-list (unlike NeoForge). Removed from file
|
||||
holding server-side config (same as NeoForge).
|
||||
|
||||
Add option in client-config to set battle/silly music volume, and an option for
|
||||
whether or not battle/silly music volume is affected by global music volume
|
||||
setting and whether or not it is affected by master volume setting.
|
||||
|
||||
Proper volume handling (like in the NeoForge branch).
|
||||
|
||||
Added Armadillo, Bogged, and Breeze to mob list in config.
|
||||
|
||||
# Version NeoForge-1.26.0
|
||||
|
||||
Make it possible to open the client-config from the Mod-list GUI.
|
||||
|
||||
Port to NeoForge 21.1.69 (Minecraft 1.21.1).
|
||||
|
||||
Fix volume handling of battle/silly music. (Previous implementation did not
|
||||
properly reduce volume based on Minecraft's "music volume" setting.)
|
||||
|
||||
Move client-config to NeoForge's configuration.
|
||||
|
||||
Add GUI to edit client-config that can be opened with /tbm-client-edit command.
|
||||
|
||||
Add option in client-config to set battle/silly music volume, and an option for
|
||||
whether or not battle/silly music volume is affected by global music volume
|
||||
setting and whether or not it is affected by master volume setting.
|
||||
|
||||
Added Armadillo, Bogged, and Breeze to mob list in config.
|
||||
|
||||
# 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
|
||||
|
||||
More robust handling of disallowed Damage Sources in battle (via config).
|
||||
|
|
93
FAQ.md
Normal file
93
FAQ.md
Normal file
|
@ -0,0 +1,93 @@
|
|||
## 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.**
|
||||
|
||||
**It is recommended to use .ogg Vorbis files instead of .mp3 files.**
|
||||
|
||||
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.**
|
||||
|
||||
## How do I configure battle music?
|
||||
|
||||
There is a way to edit client-config that deals with music settings, like what
|
||||
mob groups trigger battle/silly music and volume. This menu can be opened in one
|
||||
way.
|
||||
|
||||
- Run the command `/tbm-client-edit` to open the menu.
|
||||
|
||||
Note that "Accept" must be clicked on to save the client-config.
|
||||
|
||||
Note that the NeoForge version of this mod can access this menu through the mod
|
||||
list GUI. Minecraft Forge currently does not have this capability, so it can be
|
||||
only accessed via the command.
|
||||
|
||||
## Why do passive mobs don't start turn-based battle?
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
58
README.md
58
README.md
|
@ -7,14 +7,23 @@ This mod puts turn-based-combat of RPGs into Minecraft!
|
|||
Precompiled jars are available here:
|
||||
https://seodisparate.com/static/tbm_releases/
|
||||
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
|
||||
linked here.)
|
||||
# Documentation Page
|
||||
|
||||
https://stephen-seo.github.io/TurnBasedMinecraftMod/
|
||||
|
||||
# Forge or NeoForge
|
||||
|
||||
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
|
||||
|
||||
See the [Changelog](https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/master/Changelog.md)
|
||||
See the [Changelog](https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/forge/Changelog.md)
|
||||
|
||||
# Things you may need to know about this mod
|
||||
|
||||
|
@ -32,7 +41,8 @@ usually because a new entry has been added, the existing config is renamed to a
|
|||
a timestamp in the filename of when it was replaced. One can set a config option in the
|
||||
config to prevent it being overwritten if necessary.
|
||||
|
||||
Some options in the config file only affect the Server, and some only affect the Client.
|
||||
Some options in the config file only affect the Server, and ~~some only affect the Client.~~
|
||||
[Client-config can only be opened with `/tbm-client-edit`.](https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/forge/FAQ.md#how-do-i-configure-battle-music)
|
||||
When playing multiplayer, some configuration of the config on the server may be needed.
|
||||
|
||||
# Features
|
||||
|
@ -41,14 +51,19 @@ When playing multiplayer, some configuration of the config on the server may be
|
|||
between them
|
||||
- Supports use of the vanilla Minecraft bow and arrows (have bow selected when
|
||||
in battle)
|
||||
- Supports custom battle music to be played when fighting enemies. (They must be
|
||||
placed in `.minecraft/config/TurnBasedMinecraft/Music/battle` or
|
||||
`.minecraft/config/TurnBasedMinecraft/Music/silly`. Client-side config determines
|
||||
which song plays in battle for the client. only `.wav`, ~~`.mid`~~, and `.mp3` files
|
||||
supported. ~~Only `.mid` files are not affected by volume options (master and
|
||||
music sliders))~~ Midi file playback has been disabled for now due to lack of volume
|
||||
control issues. MP3 file playback sometimes fails, but seems to work better when the
|
||||
file is as "barebones" as possible (no album art metadata in the file).
|
||||
- Supports custom battle music to be played when fighting enemies. (They must
|
||||
be placed in `.minecraft/config/TurnBasedMinecraft/Music/battle` or
|
||||
`.minecraft/config/TurnBasedMinecraft/Music/silly`. Client-side config
|
||||
determines which song plays in battle for the client. only `.wav`,
|
||||
~~`.mid`~~, `.mp3`, and `.ogg` files supported. ~~Only `.mid` files are not
|
||||
affected by volume options (master and music sliders))~~ Midi file playback
|
||||
has been disabled for now due to lack of volume control issues. MP3 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 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
|
||||
|
@ -61,16 +76,27 @@ configured for them.)
|
|||
# Building
|
||||
|
||||
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-Forge-1.26.4-all.jar`
|
||||
|
||||
# Reproducibility
|
||||
|
||||
This mod should support reproducible builds. See `Reproducibility.md` to see
|
||||
more details.
|
||||
|
||||
# Other notes
|
||||
|
||||
This mod uses [shadow](https://github.com/johnrengelman/shadow) which is
|
||||
licenced under the [Apache License 2.0](https://github.com/johnrengelman/shadow/blob/master/LICENSE).
|
||||
This mod uses [j-ogg-vorbis](https://github.com/stephengold/j-ogg-all) 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)
|
||||
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/forge/FAQ.md)
|
||||
|
||||
# Related Videos
|
||||
|
||||
[See related videos here](https://burnedkirby.com/posts/tbmm/)
|
||||
|
|
226
Reproducibility.md
Normal file
226
Reproducibility.md
Normal file
|
@ -0,0 +1,226 @@
|
|||
# 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.26.3
|
||||
|
||||
$ java --version
|
||||
openjdk 21.0.5 2024-10-15
|
||||
OpenJDK Runtime Environment (build 21.0.5+11)
|
||||
OpenJDK 64-Bit Server VM (build 21.0.5+11, mixed mode, sharing)
|
||||
|
||||
$ javac --version
|
||||
javac 21.0.5
|
||||
|
||||
$ sha256sum build/libs/TurnBasedMinecraft-NeoForge-1.26.3-all.jar
|
||||
2c8f17499a475f22493244e16f499bed46ea6a32a20f6bd2be5b3151464b2225 build/libs/TurnBasedMinecraft-NeoForge-1.26.3-all.jar
|
||||
|
||||
## NeoForge 1.26.3-MC-1.21.1
|
||||
|
||||
$ java --version
|
||||
openjdk 21.0.5 2024-10-15
|
||||
OpenJDK Runtime Environment (build 21.0.5+11)
|
||||
OpenJDK 64-Bit Server VM (build 21.0.5+11, mixed mode, sharing)
|
||||
|
||||
$ javac --version
|
||||
javac 21.0.5
|
||||
|
||||
$ sha256sum build/libs/TurnBasedMinecraft-NeoForge-1.26.3-MC-1.21.1-all.jar
|
||||
311018353109da4d9a49379d9ebc29dbac7e2aef3331ec177bd0edc300d15b89 /home/public/TurnBasedMC/TurnBasedMinecraft-NeoForge-1.26.3-MC-1.21.1-all.jar
|
||||
|
||||
## Forge 1.26.3
|
||||
|
||||
$ java --version
|
||||
openjdk 21.0.5 2024-10-15
|
||||
OpenJDK Runtime Environment (build 21.0.5+11)
|
||||
OpenJDK 64-Bit Server VM (build 21.0.5+11, mixed mode, sharing)
|
||||
|
||||
$ javac --version
|
||||
javac 21.0.5
|
||||
|
||||
$ sha256sum build/libs/TurnBasedMinecraft-Forge-1.26.3-all.jar
|
||||
5fdaffd14f75c2340a410c37811a5f7644ade3c6852db4b982bf3161bab1aae7 build/libs/TurnBasedMinecraft-Forge-1.26.3-all.jar
|
||||
|
||||
## NeoForge 1.26.2
|
||||
|
||||
$ java --version
|
||||
openjdk 21.0.5 2024-10-15
|
||||
OpenJDK Runtime Environment (build 21.0.5+11)
|
||||
OpenJDK 64-Bit Server VM (build 21.0.5+11, mixed mode, sharing)
|
||||
|
||||
$ javac --version
|
||||
javac 21.0.5
|
||||
|
||||
$ sha256sum build/libs/TurnBasedMinecraft-NeoForge-1.26.2-all.jar
|
||||
d55f516a2166d266c0d60e881b170cb734372ac01c8a25cf12e2f593f7b87004 build/libs/TurnBasedMinecraft-NeoForge-1.26.2-all.jar
|
||||
|
||||
## Forge 1.26.2
|
||||
|
||||
$ java --version
|
||||
openjdk 21.0.5 2024-10-15
|
||||
OpenJDK Runtime Environment (build 21.0.5+11)
|
||||
OpenJDK 64-Bit Server VM (build 21.0.5+11, mixed mode, sharing)
|
||||
|
||||
$ javac --version
|
||||
javac 21.0.5
|
||||
|
||||
$ sha256sum build/libs/TurnBasedMinecraft-Forge-1.26.2-all.jar
|
||||
d06f3cc8e050aa4086dce187ffce2cc5049c67c401a0cd4608138880b0868e89 build/libs/TurnBasedMinecraft-Forge-1.26.2-all.jar
|
||||
|
||||
## Forge 1.26.1
|
||||
|
||||
$ java --version
|
||||
openjdk 21.0.5 2024-10-15
|
||||
OpenJDK Runtime Environment (build 21.0.5+11)
|
||||
OpenJDK 64-Bit Server VM (build 21.0.5+11, mixed mode, sharing)
|
||||
|
||||
$ javac --version
|
||||
javac 21.0.5
|
||||
|
||||
$ sha256sum build/libs/TurnBasedMinecraft-Forge-1.26.1-all.jar
|
||||
0fc0f1ea49c726b06b7a353fee4e59eaadd608a4074245477d1ccd957467305c build/libs/TurnBasedMinecraft-Forge-1.26.1-all.jar
|
||||
|
||||
## NeoForge 1.26.1
|
||||
|
||||
$ java --version
|
||||
openjdk 21.0.5 2024-10-15
|
||||
OpenJDK Runtime Environment (build 21.0.5+11)
|
||||
OpenJDK 64-Bit Server VM (build 21.0.5+11, mixed mode, sharing)
|
||||
|
||||
$ javac --version
|
||||
javac 21.0.5
|
||||
|
||||
$ sha256sum build/libs/TurnBasedMinecraft-NeoForge-1.26.1-all.jar
|
||||
ac3005191d9c23ad823e4ae33b750a0ac17518460fedc91242d031a8f1365101 build/libs/TurnBasedMinecraft-NeoForge-1.26.1-all.jar
|
||||
|
||||
## Forge 1.26.0
|
||||
|
||||
$ java --version
|
||||
openjdk 21.0.4 2024-07-16
|
||||
OpenJDK Runtime Environment (build 21.0.4+7)
|
||||
OpenJDK 64-Bit Server VM (build 21.0.4+7, mixed mode, sharing)
|
||||
|
||||
$ javac --version
|
||||
javac 21.0.4
|
||||
|
||||
$ sha256sum build/libs/TurnBasedMinecraft-Forge-1.26.0-all.jar
|
||||
9a3bb24fef9348e620ab5bcc120d83e11c5289a046561fb4ef91d0ccade9b271 build/libs/TurnBasedMinecraft-Forge-1.26.0-all.jar
|
||||
|
||||
## NeoForge 1.26.0
|
||||
|
||||
$ java --version
|
||||
openjdk 21.0.4 2024-07-16
|
||||
OpenJDK Runtime Environment (build 21.0.4+7)
|
||||
OpenJDK 64-Bit Server VM (build 21.0.4+7, mixed mode, sharing)
|
||||
|
||||
$ javac --version
|
||||
javac 21.0.4
|
||||
|
||||
$ sha256sum build/libs/TurnBasedMinecraft-NeoForge-1.26.0-all.jar
|
||||
a13e93df640eb3ce5577521421e760aa5d808d34d5cef9c5415ae7a699173ea9 build/libs/TurnBasedMinecraft-NeoForge-1.26.0-all.jar
|
||||
|
||||
## 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
|
278
build.gradle
278
build.gradle
|
@ -2,78 +2,69 @@ plugins {
|
|||
id 'eclipse'
|
||||
id 'idea'
|
||||
id 'maven-publish'
|
||||
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
|
||||
id 'com.github.johnrengelman.shadow' version '8.1.1'
|
||||
id 'net.minecraftforge.gradle' version '[6.0.24,6.2)'
|
||||
}
|
||||
|
||||
version = "1.23.1"
|
||||
group = "com.burnedkirby.TurnBasedMinecraft"
|
||||
archivesBaseName = "TurnBasedMinecraft"
|
||||
version = mod_version
|
||||
group = mod_group_id
|
||||
|
||||
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'))
|
||||
base {
|
||||
archivesName = "TurnBasedMinecraft-Forge"
|
||||
}
|
||||
|
||||
// Mojang ships Java 21 to end users in 1.20.5+, so your mod should target Java 21.
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
|
||||
println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
|
||||
|
||||
jarJar.enable()
|
||||
|
||||
minecraft {
|
||||
// The mappings can be changed at any time, and must be in the following format.
|
||||
// snapshot_YYYYMMDD Snapshot are built nightly.
|
||||
// stable_# Stables are built at the discretion of the MCP team.
|
||||
// Use non-default mappings at your own risk. they may not always work.
|
||||
// The mappings can be changed at any time and must be in the following format.
|
||||
// Channel: Version:
|
||||
// official MCVersion Official field/method names from Mojang mapping files
|
||||
// parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official
|
||||
//
|
||||
// You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
|
||||
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
|
||||
//
|
||||
// Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
|
||||
// Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started
|
||||
//
|
||||
// Use non-default mappings at your own risk. They may not always work.
|
||||
// Simply re-run your setup task after changing the mappings to update your workspace.
|
||||
mappings channel: mapping_channel, version: mapping_version
|
||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
||||
|
||||
// Tell FG to not automtically create the reobf tasks, as we now use Official mappings at runtime, If you don't use them at dev time then you'll have to fix your reobf yourself.
|
||||
reobf = false
|
||||
|
||||
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
// When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game.
|
||||
// In most cases, it is not necessary to enable.
|
||||
// enableEclipsePrepareRuns = true
|
||||
// enableIdeaPrepareRuns = true
|
||||
|
||||
// This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
|
||||
// It is REQUIRED to be set to true for this template to function.
|
||||
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
|
||||
copyIdeResources = true
|
||||
|
||||
// When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
|
||||
// The folder name can be set on a run configuration using the "folderName" property.
|
||||
// By default, the folder name of a run configuration is the name of the Gradle project containing it.
|
||||
// generateRunFolders = true
|
||||
|
||||
// This property enables access transformers for use in development.
|
||||
// They will be applied to the Minecraft artifact.
|
||||
// The access transformer file can be anywhere in the project.
|
||||
// However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge.
|
||||
// This default location is a best practice to automatically put the file in the right place in the final jar.
|
||||
// See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information.
|
||||
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
|
||||
// Default run configurations.
|
||||
// These can be tweaked, removed, or duplicated as needed.
|
||||
runs {
|
||||
client {
|
||||
workingDirectory project.file('run')
|
||||
|
||||
// Recommended logging data for a userdev environment
|
||||
property 'forge.logging.markers', 'REGISTRIES'
|
||||
|
||||
// Recommended logging level for the console
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
||||
property 'forge.enabledGameTestNamespaces', 'TurnBasedMinecraftMod'
|
||||
|
||||
mods {
|
||||
TurnBasedMinecraftMod {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
workingDirectory project.file('run')
|
||||
|
||||
// Recommended logging data for a userdev environment
|
||||
property 'forge.logging.markers', 'REGISTRIES'
|
||||
|
||||
// Recommended logging level for the console
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
||||
property 'forge.enabledGameTestNamespaces', 'TurnBasedMinecraftMod'
|
||||
|
||||
mods {
|
||||
TurnBasedMinecraftMod {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This run config launches GameTestServer and runs all registered gametests, then exits.
|
||||
// By default, the server will crash when no gametests are provided.
|
||||
// The gametest system is also enabled by default for other run configs under the /test command.
|
||||
gameTestServer {
|
||||
// applies to all the run configs below
|
||||
configureEach {
|
||||
workingDirectory project.file('run')
|
||||
|
||||
// Recommended logging data for a userdev environment
|
||||
|
@ -87,33 +78,31 @@ minecraft {
|
|||
// You can set various levels here.
|
||||
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
}
|
||||
|
||||
client {
|
||||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
||||
property 'forge.enabledGameTestNamespaces', 'TurnBasedMinecraftMod'
|
||||
property 'forge.enabledGameTestNamespaces', mod_id
|
||||
}
|
||||
|
||||
mods {
|
||||
TurnBasedMinecraftMod {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
server {
|
||||
property 'forge.enabledGameTestNamespaces', mod_id
|
||||
args '--nogui'
|
||||
}
|
||||
|
||||
// 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 {
|
||||
property 'forge.enabledGameTestNamespaces', mod_id
|
||||
}
|
||||
|
||||
data {
|
||||
workingDirectory project.file('run')
|
||||
// example of overriding the workingDirectory set in configureEach above
|
||||
workingDirectory project.file('run-data')
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
|
||||
args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -121,49 +110,52 @@ minecraft {
|
|||
// Include resources generated by data generators.
|
||||
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||
|
||||
//repositories {
|
||||
// // Put repositories for dependencies here
|
||||
// // ForgeGradle automatically adds the Forge maven and Maven Central for you
|
||||
//
|
||||
// // If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
|
||||
// // flatDir {
|
||||
// // dir 'libs'
|
||||
// // }
|
||||
// mavenCentral()
|
||||
// jcenter()
|
||||
//
|
||||
// dependencies {
|
||||
// classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4'
|
||||
// }
|
||||
//}
|
||||
repositories {
|
||||
// Put repositories for dependencies here
|
||||
// ForgeGradle automatically adds the Forge maven and Maven Central for you
|
||||
|
||||
apply plugin: 'com.github.johnrengelman.shadow'
|
||||
|
||||
configurations {
|
||||
shade
|
||||
impelmentation.extendsFrom shade
|
||||
flatDir {
|
||||
dir 'libs'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
|
||||
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
|
||||
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
|
||||
// Specify the version of Minecraft to use.
|
||||
// Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact.
|
||||
// The "userdev" classifier will be requested and setup by ForgeGradle.
|
||||
// If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
|
||||
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
|
||||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||
|
||||
// Real mod deobf dependency examples - these get remapped to your current mappings
|
||||
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
|
||||
// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
|
||||
// implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency
|
||||
// Example mod dependency with JEI
|
||||
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
|
||||
// compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
|
||||
// compileOnly "mezz.jei:jei-${mc_version}-forge-api:${jei_version}"
|
||||
// runtimeOnly "mezz.jei:jei-${mc_version}-forge:${jei_version}"
|
||||
|
||||
// Examples using mod jars from ./libs
|
||||
// Example mod dependency using a mod jar from ./libs with a flat dir repository
|
||||
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
|
||||
// The group id is ignored when searching -- in this case, it is "blank"
|
||||
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
|
||||
|
||||
// For more info...
|
||||
// For more info:
|
||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
||||
implementation files('libs/javamp3-1.0.3.jar')
|
||||
|
||||
// Hack fix for now, force jopt-simple to be exactly 5.0.4 because Mojang ships that version, but some transitive dependencies request 6.0+
|
||||
implementation('net.sf.jopt-simple:jopt-simple:5.0.4') { version { strictly '5.0.4' } }
|
||||
|
||||
shade files('libs/javamp3-1.0.3.jar')
|
||||
implementation 'fr.delthas:javamp3:1.0.3'
|
||||
|
||||
implementation 'com.github.stephengold:j-ogg-vorbis:1.0.4'
|
||||
|
||||
jarJar(group: 'fr.delthas', name: 'javamp3', version: '[1.0.0,2.0.0)') {
|
||||
jarJar.pin(it, '1.0.3')
|
||||
}
|
||||
|
||||
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.
|
||||
|
@ -185,36 +177,21 @@ tasks.named('processResources', ProcessResources).configure {
|
|||
}
|
||||
}
|
||||
|
||||
// Example for how to get properties into the manifest for reading by the runtime..
|
||||
jar {
|
||||
archiveClassifier = 'slim'
|
||||
// Example for how to get properties into the manifest for reading at runtime.
|
||||
tasks.named('jar', Jar).configure {
|
||||
manifest {
|
||||
attributes([
|
||||
"Specification-Title": "TurnBasedMinecraftMod",
|
||||
"Specification-Vendor": "TurnBasedMinecraftMod_BK",
|
||||
"Specification-Version": "1", // We are version 1 of ourselves
|
||||
"Implementation-Title": project.name,
|
||||
"Implementation-Version": "${version}",
|
||||
"Implementation-Vendor" :"TurnBasedMinecraftMod_BK",
|
||||
// Do not place timestamp for the sake of reproducible builds
|
||||
// "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
||||
// "ContainedDeps": "javamp3-1.0.3.jar"
|
||||
'Specification-Title' : mod_id,
|
||||
'Specification-Vendor' : mod_authors,
|
||||
'Specification-Version' : '1', // We are version 1 of ourselves
|
||||
'Implementation-Title' : "TurnBasedMinecraftMod",
|
||||
'Implementation-Version' : project.jar.archiveVersion,
|
||||
'Implementation-Vendor' : mod_authors
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
// This is the preferred method to reobfuscate your jar file
|
||||
//finalizedBy 'reobfJar'
|
||||
}
|
||||
|
||||
// Reproducible Builds
|
||||
|
@ -223,24 +200,21 @@ tasks.withType(AbstractArchiveTask).configureEach {
|
|||
reproducibleFileOrder = true
|
||||
}
|
||||
|
||||
// Example configuration to allow publishing using the maven-publish task
|
||||
// we define a custom artifact that is sourced from the reobfJar output task
|
||||
// and then declare that to be published
|
||||
// Note you'll need to add a repository here
|
||||
//def reobfFile = file("$buildDir/reobfJar/output.jar")
|
||||
//def reobfArtifact = artifacts.add('default', reobfFile) {
|
||||
// type 'jar'
|
||||
// builtBy 'reobfJar'
|
||||
//}
|
||||
//publishing {
|
||||
// publications {
|
||||
// mavenJava(MavenPublication) {
|
||||
// artifact reobfArtifact
|
||||
// }
|
||||
// }
|
||||
// repositories {
|
||||
// maven {
|
||||
// url "file:///${project.projectDir}/mcmodsrepo"
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
||||
}
|
||||
|
||||
// Merge the resources and classes into the same directory.
|
||||
// This is done because java expects modules to be in a single directory.
|
||||
// And if we have it in multiple we have to do performance intensive hacks like having the UnionFileSystem
|
||||
// This will eventually be migrated to ForgeGradle so modders don't need to manually do it. But that is later.
|
||||
sourceSets.each {
|
||||
def dir = layout.buildDirectory.dir("sourcesSets/$it.name")
|
||||
it.output.resourcesDir = dir
|
||||
it.java.destinationDirectory = dir
|
||||
}
|
||||
|
||||
// Ensure "jarJar" is run after "build"
|
||||
tasks.named("build").configure {
|
||||
finalizedBy "jarJar"
|
||||
}
|
||||
|
|
|
@ -1,20 +1,23 @@
|
|||
org.gradle.jvmargs=-Xmx4096m
|
||||
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
|
||||
# This is required to provide enough memory for the Minecraft decompilation process.
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
org.gradle.daemon=false
|
||||
|
||||
|
||||
## Environment Properties
|
||||
|
||||
# The Minecraft version must agree with the Forge version to get a valid artifact
|
||||
minecraft_version=1.20.1
|
||||
minecraft_version=1.21.1
|
||||
# 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
|
||||
# as they do not follow standard versioning conventions.
|
||||
minecraft_version_range=[1.20.1,1.21)
|
||||
minecraft_version_range=[1.21.1,1.22)
|
||||
# The Forge version must agree with the Minecraft version to get a valid artifact
|
||||
forge_version=47.1.0
|
||||
forge_version=52.0.24
|
||||
# The Forge version range can use any version of Forge as bounds or match the loader version range
|
||||
forge_version_range=[47,)
|
||||
forge_version_range=[0,)
|
||||
# The loader version range can only use the major version of Forge/FML as bounds
|
||||
loader_version_range=[47,)
|
||||
loader_version_range=[0,)
|
||||
# The mapping channel to use for mappings.
|
||||
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
|
||||
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
|
||||
|
@ -32,7 +35,8 @@ loader_version_range=[47,)
|
|||
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
|
||||
mapping_version=1.21.1
|
||||
|
||||
|
||||
## Mod Properties
|
||||
|
||||
|
@ -44,11 +48,11 @@ mod_name=TurnBasedMinecraftMod
|
|||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||
mod_license=MIT
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=1.23.1
|
||||
mod_version=1.26.4
|
||||
# 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.
|
||||
# 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.
|
||||
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.
|
||||
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
|
@ -11,5 +11,5 @@ pluginManagement {
|
|||
}
|
||||
|
||||
plugins {
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
|
||||
}
|
||||
|
|
|
@ -5,13 +5,15 @@ import com.burnedkirby.TurnBasedMinecraft.common.Combatant;
|
|||
import com.burnedkirby.TurnBasedMinecraft.common.Config;
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleDecision;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
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.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.inventory.InventoryScreen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.HashMap;
|
||||
|
@ -28,6 +30,8 @@ public class BattleGui extends Screen {
|
|||
private MenuState state;
|
||||
private boolean stateChanged;
|
||||
private String info;
|
||||
private Long waitMissingBattleTicks;
|
||||
private boolean showingEntities;
|
||||
|
||||
private enum MenuState {
|
||||
MAIN_MENU(0), ATTACK_TARGET(1), ITEM_ACTION(2), WAITING(3), SWITCH_ITEM(4), USE_ITEM(5);
|
||||
|
@ -91,6 +95,8 @@ public class BattleGui extends Screen {
|
|||
elapsedTime = 0;
|
||||
state = MenuState.MAIN_MENU;
|
||||
stateChanged = true;
|
||||
waitMissingBattleTicks = null;
|
||||
showingEntities = false;
|
||||
}
|
||||
|
||||
private void setState(MenuState state) {
|
||||
|
@ -125,6 +131,7 @@ public class BattleGui extends Screen {
|
|||
}
|
||||
|
||||
stateChanged = false;
|
||||
showingEntities = false;
|
||||
clearWidgets();
|
||||
switch (state) {
|
||||
case MAIN_MENU:
|
||||
|
@ -145,16 +152,17 @@ public class BattleGui extends Screen {
|
|||
case ATTACK_TARGET:
|
||||
info = "Who will you attack?";
|
||||
int y = 30;
|
||||
showingEntities = true;
|
||||
try {
|
||||
for (Map.Entry<Integer, Combatant> e : TurnBasedMinecraftMod.proxy.getLocalBattle()
|
||||
.getSideAEntrySet()) {
|
||||
if (e.getValue().entity != null) {
|
||||
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 {
|
||||
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;
|
||||
|
@ -168,11 +176,11 @@ public class BattleGui extends Screen {
|
|||
.getSideBEntrySet()) {
|
||||
if (e.getValue().entity != null) {
|
||||
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 {
|
||||
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;
|
||||
|
@ -202,8 +210,8 @@ public class BattleGui extends Screen {
|
|||
case SWITCH_ITEM:
|
||||
info = "To which item will you switch to?";
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
addRenderableWidget(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, "", i, (button) -> {
|
||||
buttonActionEvent(button, ButtonAction.DO_ITEM_SWITCH);
|
||||
addRenderableWidget(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, i, (button) -> {
|
||||
itemButtonActionEvent(button, ButtonAction.DO_ITEM_SWITCH);
|
||||
}));
|
||||
}
|
||||
addRenderableWidget(Button.builder(Component.literal("Cancel"), (button) -> {
|
||||
|
@ -213,8 +221,8 @@ public class BattleGui extends Screen {
|
|||
case USE_ITEM:
|
||||
info = "Which item will you use?";
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
addRenderableWidget(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, "", i, (button) -> {
|
||||
buttonActionEvent(button, ButtonAction.DO_USE_ITEM);
|
||||
addRenderableWidget(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, i, (button) -> {
|
||||
itemButtonActionEvent(button, ButtonAction.DO_USE_ITEM);
|
||||
}));
|
||||
}
|
||||
addRenderableWidget(Button.builder(Component.literal("Cancel"), (button) -> {
|
||||
|
@ -224,12 +232,29 @@ public class BattleGui extends Screen {
|
|||
}
|
||||
}
|
||||
|
||||
private int colorFromTicks(final Long ticks) {
|
||||
if (ticks < 20 * 10) {
|
||||
double value = (20 * 10 - ticks.intValue()) / (20.0 * 10.0);
|
||||
return 0xFF0000FF | (((int)(value * 255.0)) << 8) | (((int)(value * 255.0)) << 16);
|
||||
} else {
|
||||
return 0xFF0000FF;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
|
||||
if (TurnBasedMinecraftMod.proxy.getLocalBattle() == null) {
|
||||
if (waitMissingBattleTicks == null) {
|
||||
waitMissingBattleTicks = 0L;
|
||||
} else {
|
||||
waitMissingBattleTicks += 1L;
|
||||
}
|
||||
// drawHoveringText("Waiting...", width / 2 - 50, height / 2);
|
||||
drawString(guiGraphics, "Waiting...", width / 2 - 50, height / 2, 0xFFFFFFFF);
|
||||
drawString(guiGraphics, "Waiting...", width / 2 - 50, height / 2, colorFromTicks(waitMissingBattleTicks));
|
||||
super.render(guiGraphics, mouseX, mouseY, partialTicks);
|
||||
return;
|
||||
} else {
|
||||
waitMissingBattleTicks = null;
|
||||
}
|
||||
if (TurnBasedMinecraftMod.proxy.getLocalBattle().getState() == Battle.State.DECISION
|
||||
&& timeRemaining.get() > 0) {
|
||||
|
@ -243,6 +268,26 @@ public class BattleGui extends Screen {
|
|||
}
|
||||
|
||||
updateState();
|
||||
if (showingEntities) {
|
||||
int y = 30;
|
||||
try {
|
||||
for (Map.Entry<Integer, Combatant> e : TurnBasedMinecraftMod.proxy.getLocalBattle().getSideAEntrySet()) {
|
||||
if (e.getValue().entity instanceof LivingEntity lEntity) {
|
||||
InventoryScreen.renderEntityInInventoryFollowsMouse(guiGraphics, width / 4 - 60 - 20, y, width / 4 - 60, y + 20, 7, 0.0F, mouseX, mouseY, lEntity);
|
||||
}
|
||||
y += 20;
|
||||
}
|
||||
} catch(ConcurrentModificationException e) {}
|
||||
y = 30;
|
||||
try {
|
||||
for (Map.Entry<Integer, Combatant> e : TurnBasedMinecraftMod.proxy.getLocalBattle().getSideBEntrySet()) {
|
||||
if (e.getValue().entity instanceof LivingEntity lEntity) {
|
||||
InventoryScreen.renderEntityInInventoryFollowsMouse(guiGraphics, width * 3 / 4 - 60 + 120, y, width * 3 / 4 - 60 + 140, y + 20, 7, 0.0F, mouseX, mouseY, lEntity);
|
||||
}
|
||||
y += 20;
|
||||
}
|
||||
} catch(ConcurrentModificationException e) {}
|
||||
}
|
||||
|
||||
super.render(guiGraphics, mouseX, mouseY, partialTicks);
|
||||
|
||||
|
@ -275,27 +320,23 @@ public class BattleGui extends Screen {
|
|||
setState(MenuState.ATTACK_TARGET);
|
||||
break;
|
||||
case DEFEND:
|
||||
TurnBasedMinecraftMod.getHandler().sendToServer(new PacketBattleDecision(
|
||||
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.DEFEND, 0));
|
||||
TurnBasedMinecraftMod.getHandler().send(new PacketBattleDecision(
|
||||
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.DEFEND, 0),
|
||||
PacketDistributor.SERVER.noArg());
|
||||
setState(MenuState.WAITING);
|
||||
break;
|
||||
case ITEM:
|
||||
setState(MenuState.ITEM_ACTION);
|
||||
break;
|
||||
case FLEE:
|
||||
TurnBasedMinecraftMod.getHandler().sendToServer(new PacketBattleDecision(
|
||||
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.FLEE, 0));
|
||||
TurnBasedMinecraftMod.getHandler().send(new PacketBattleDecision(
|
||||
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.FLEE, 0),
|
||||
PacketDistributor.SERVER.noArg());
|
||||
setState(MenuState.WAITING);
|
||||
break;
|
||||
case ATTACK_TARGET:
|
||||
if (button instanceof EntitySelectionButton) {
|
||||
TurnBasedMinecraftMod.getHandler()
|
||||
.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(),
|
||||
Battle.Decision.ATTACK, ((EntitySelectionButton) button).getID()));
|
||||
setState(MenuState.WAITING);
|
||||
} else {
|
||||
setState(MenuState.MAIN_MENU);
|
||||
}
|
||||
// Invalid but set to main menu anyways.
|
||||
setState(MenuState.MAIN_MENU);
|
||||
break;
|
||||
case SWITCH_HELD_ITEM:
|
||||
setState(MenuState.SWITCH_ITEM);
|
||||
|
@ -307,44 +348,72 @@ public class BattleGui extends Screen {
|
|||
setState(MenuState.MAIN_MENU);
|
||||
break;
|
||||
case DO_ITEM_SWITCH:
|
||||
if (button instanceof ItemSelectionButton) {
|
||||
TurnBasedMinecraftMod.getHandler()
|
||||
.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);
|
||||
}
|
||||
// Invalid but set to main menu anyways.
|
||||
setState(MenuState.MAIN_MENU);
|
||||
break;
|
||||
case DO_USE_ITEM:
|
||||
if (button instanceof ItemSelectionButton) {
|
||||
TurnBasedMinecraftMod.getHandler()
|
||||
.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(),
|
||||
Battle.Decision.USE_ITEM, ((ItemSelectionButton) button).getID()));
|
||||
setState(MenuState.WAITING);
|
||||
} else {
|
||||
setState(MenuState.MAIN_MENU);
|
||||
}
|
||||
// Invalid, but set menu to main menu anyways.
|
||||
setState(MenuState.MAIN_MENU);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void entityButtonActionEvent(EntitySelectionButton button, ButtonAction action) {
|
||||
if (action.equals(ButtonAction.ATTACK_TARGET)) {
|
||||
TurnBasedMinecraftMod.getHandler().send(new PacketBattleDecision(
|
||||
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.ATTACK, button.getID()),
|
||||
PacketDistributor.SERVER.noArg());
|
||||
setState(MenuState.WAITING);
|
||||
} else {
|
||||
setState(MenuState.MAIN_MENU);
|
||||
}
|
||||
}
|
||||
|
||||
protected void itemButtonActionEvent(ItemSelectionButton button, ButtonAction action) {
|
||||
switch (action) {
|
||||
case DO_ITEM_SWITCH:
|
||||
TurnBasedMinecraftMod.getHandler().send(
|
||||
new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.SWITCH_ITEM, button.getID()),
|
||||
PacketDistributor.SERVER.noArg());
|
||||
if (button.getID() >= 0 && button.getID() < 9) {
|
||||
Minecraft.getInstance().player.getInventory().selected = button.getID();
|
||||
}
|
||||
setState(MenuState.WAITING);
|
||||
break;
|
||||
case DO_USE_ITEM:
|
||||
TurnBasedMinecraftMod.getHandler().send(
|
||||
new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.USE_ITEM, button.getID()),
|
||||
PacketDistributor.SERVER.noArg());
|
||||
setState(MenuState.WAITING);
|
||||
break;
|
||||
default:
|
||||
setState(MenuState.MAIN_MENU);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPauseScreen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int a, int b, int c) {
|
||||
public boolean keyPressed(int keyCode, int b, int c) {
|
||||
if (getMinecraft().player.isCreative()) {
|
||||
return super.keyPressed(a, b, c);
|
||||
return super.keyPressed(keyCode, b, c);
|
||||
} else if (keyCode == 256) {
|
||||
TurnBasedMinecraftMod.proxy.displayString("Leaving GUI, but the battle continues!");
|
||||
getMinecraft().setScreen(null);
|
||||
return true;
|
||||
}
|
||||
return false; // TODO verify return value
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderBackground(GuiGraphics p_283688_, int p_299421_, int p_298679_, float p_297268_) {
|
||||
// Left blank to not render background.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyReleased(int a, int b, int c) {
|
||||
if (getMinecraft().player.isCreative()) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.client;
|
||||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
import de.jarnbjo.vorbis.VorbisAudioFileReader;
|
||||
import fr.delthas.javamp3.Sound;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
@ -28,7 +29,9 @@ public class BattleMusic
|
|||
private boolean playingIsSilly;
|
||||
private boolean isPlaying;
|
||||
private Thread mp3StreamThread;
|
||||
private Thread oggVorbisStreamThread;
|
||||
private MP3Streamer mp3StreamRunnable;
|
||||
private OGGVorbisStreamer oggVorbisStreamRunnable;
|
||||
|
||||
public BattleMusic(Logger logger)
|
||||
{
|
||||
|
@ -81,7 +84,7 @@ public class BattleMusic
|
|||
}
|
||||
String ext = name.substring(extIndex + 1).toLowerCase();
|
||||
// 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)
|
||||
|
@ -101,7 +104,7 @@ public class BattleMusic
|
|||
}
|
||||
String ext = name.substring(extIndex + 1).toLowerCase();
|
||||
// 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)
|
||||
|
@ -177,7 +180,7 @@ public class BattleMusic
|
|||
if(initialized && next != null)
|
||||
{
|
||||
logger.debug("play called with file " + next.getName() + " and vol " + volume);
|
||||
Minecraft.getInstance().getSoundManager().pause();
|
||||
TurnBasedMinecraftMod.proxy.pauseMCMusic();
|
||||
String suffix = next.getName().substring(next.getName().length() - 3).toLowerCase();
|
||||
if(suffix.equals("mid") && sequencer != null)
|
||||
{
|
||||
|
@ -256,7 +259,7 @@ public class BattleMusic
|
|||
|
||||
// set volume
|
||||
FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
|
||||
gainControl.setValue(volume * 20.0f - 20.0f); // in decibels
|
||||
gainControl.setValue(BattleMusic.percentageToDecibels(volume)); // in decibels
|
||||
|
||||
clip.loop(Clip.LOOP_CONTINUOUSLY);
|
||||
clip.start();
|
||||
|
@ -303,6 +306,39 @@ public class BattleMusic
|
|||
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,9 +356,13 @@ public class BattleMusic
|
|||
mp3StreamRunnable.setKeepPlaying(false);
|
||||
try { mp3StreamThread.join(); } catch (Throwable t) { /* ignored */ }
|
||||
}
|
||||
if (oggVorbisStreamThread != null && oggVorbisStreamThread.isAlive()) {
|
||||
oggVorbisStreamRunnable.setKeepPlaying(false);
|
||||
try { oggVorbisStreamThread.join(); } catch (Throwable t) { /* ignored */ }
|
||||
}
|
||||
if(resumeMCSounds)
|
||||
{
|
||||
Minecraft.getInstance().getSoundManager().resume();
|
||||
TurnBasedMinecraftMod.proxy.resumeMCMusic();
|
||||
}
|
||||
isPlaying = false;
|
||||
}
|
||||
|
@ -347,6 +387,16 @@ public class BattleMusic
|
|||
return !sillyMusic.isEmpty();
|
||||
}
|
||||
|
||||
public static float percentageToDecibels(float percentage) {
|
||||
if (percentage > 1.0F) {
|
||||
return 0.0F;
|
||||
} else if (percentage <= 0.0F) {
|
||||
return Float.NEGATIVE_INFINITY;
|
||||
} else {
|
||||
return (float) (Math.log10(percentage) * 20.0);
|
||||
}
|
||||
}
|
||||
|
||||
private class MP3Streamer implements Runnable
|
||||
{
|
||||
private AtomicBoolean keepPlaying;
|
||||
|
@ -398,7 +448,7 @@ public class BattleMusic
|
|||
sdl.open(audioFormat);
|
||||
{
|
||||
FloatControl volumeControl = (FloatControl) sdl.getControl(FloatControl.Type.MASTER_GAIN);
|
||||
volumeControl.setValue(volume * 20.0f - 20.0f); // in decibels
|
||||
volumeControl.setValue(BattleMusic.percentageToDecibels(volume)); // in decibels
|
||||
}
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
@ -454,4 +504,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(BattleMusic.percentageToDecibels(volume)); // 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.client;
|
||||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ClientConfig {
|
||||
public static final ClientConfig CLIENT;
|
||||
public static final ForgeConfigSpec CLIENT_SPEC;
|
||||
|
||||
static {
|
||||
Pair<ClientConfig, ForgeConfigSpec> pair =
|
||||
new ForgeConfigSpec.Builder().configure(ClientConfig::new);
|
||||
CLIENT = pair.getKey();
|
||||
CLIENT_SPEC = pair.getValue();
|
||||
}
|
||||
|
||||
public final ForgeConfigSpec.ConfigValue<List<? extends String>> battleMusicList;
|
||||
public final ForgeConfigSpec.ConfigValue<List<? extends String>> sillyMusicList;
|
||||
public final ForgeConfigSpec.DoubleValue sillyMusicThreshold;
|
||||
public final ForgeConfigSpec.BooleanValue volumeAffectedByMasterVolume;
|
||||
public final ForgeConfigSpec.BooleanValue volumeAffectedByMusicVolume;
|
||||
public final ForgeConfigSpec.DoubleValue musicVolume;
|
||||
|
||||
ClientConfig(ForgeConfigSpec.Builder builder) {
|
||||
//builder.push("music");
|
||||
|
||||
List<String> battleMusicList = new ArrayList<String>(8);
|
||||
battleMusicList.add("monster");
|
||||
battleMusicList.add("animal");
|
||||
battleMusicList.add("boss");
|
||||
battleMusicList.add("player");
|
||||
this.battleMusicList = builder.comment("What categories of mobs that play \"battle\" music")
|
||||
.translation(TurnBasedMinecraftMod.MODID + ".clientconfig.battle_music_list")
|
||||
.defineList("battleMusicList", battleMusicList, (v) -> v instanceof String);
|
||||
|
||||
List<String> sillyMusicList = new ArrayList<String>(4);
|
||||
sillyMusicList.add("passive");
|
||||
this.sillyMusicList = builder.comment("What categories of mobs that play \"silly\" music")
|
||||
.translation(TurnBasedMinecraftMod.MODID + ".clientconfig.silly_music_list")
|
||||
.defineList("sillyMusicList", sillyMusicList, (v) -> true);
|
||||
|
||||
this.sillyMusicThreshold =
|
||||
builder.comment("Minimum percentage of silly entities in battle to use silly music")
|
||||
.translation(TurnBasedMinecraftMod.MODID + ".clientconfig.silly_percentage")
|
||||
.defineInRange("sillyMusicThreshold", 0.4, 0.0, 1.0);
|
||||
|
||||
this.volumeAffectedByMasterVolume = builder.comment(
|
||||
"If \"true\", music volume will be affected by global Master volume setting")
|
||||
.translation(TurnBasedMinecraftMod.MODID + ".clientconfig.volume_affected_by_master")
|
||||
.define("volumeAffectedByMasterVolume", true);
|
||||
|
||||
this.volumeAffectedByMusicVolume = builder.comment(
|
||||
"If \"true\", music volume will be affected by global Music volume setting")
|
||||
.translation(TurnBasedMinecraftMod.MODID + ".clientconfig.volume_affected_by_volume")
|
||||
.define("volumeAffectedByMusicVolume", true);
|
||||
|
||||
this.musicVolume =
|
||||
builder.comment("Volume of battle/silly music as a percentage between 0.0 and 1.0")
|
||||
.translation(TurnBasedMinecraftMod.MODID + ".clientconfig.music_volume")
|
||||
.defineInRange("musicVolume", 0.7, 0.0, 1.0);
|
||||
|
||||
//builder.pop();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,263 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.*;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ClientConfigGui extends net.minecraft.client.gui.screens.Screen {
|
||||
private final int widget_height = 20;
|
||||
private boolean dirtyFlag;
|
||||
private boolean accepted;
|
||||
private EditBox battleListEditBox = null;
|
||||
private EditBox sillyListEditBox = null;
|
||||
private SliderPercentage sillyMusicThresholdSlider = null;
|
||||
private Checkbox affectedByMasterVolCheckbox = null;
|
||||
private Checkbox affectedByMusicVolCheckbox = null;
|
||||
private SliderPercentage volumeSlider = null;
|
||||
|
||||
public ClientConfigGui() {
|
||||
super(Component.literal("TurnBasedMC Client Config"));
|
||||
|
||||
dirtyFlag = true;
|
||||
|
||||
accepted = false;
|
||||
}
|
||||
|
||||
public void onDirty() {
|
||||
clearWidgets();
|
||||
|
||||
// Initialize GUI elements.
|
||||
int widget_x_offset = 5;
|
||||
int widget_width = this.width / 2 - widget_x_offset * 2;
|
||||
int top_offset = 5;
|
||||
|
||||
addRenderableWidget(
|
||||
new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
|
||||
widget_width, widget_height, Component.literal("Battle Music Categories"),
|
||||
font));
|
||||
if (battleListEditBox == null) {
|
||||
battleListEditBox =
|
||||
new EditBox(font, this.width / 2 + widget_x_offset, top_offset, widget_width,
|
||||
widget_height, Component.literal("Battle Music Categories Edit Box"));
|
||||
} else {
|
||||
battleListEditBox.setPosition(this.width / 2 + widget_x_offset, top_offset);
|
||||
battleListEditBox.setSize(widget_width, widget_height);
|
||||
}
|
||||
String tempString = "";
|
||||
for (String category : ClientConfig.CLIENT.battleMusicList.get()) {
|
||||
if (tempString.isEmpty()) {
|
||||
tempString = category;
|
||||
} else {
|
||||
tempString += "," + category;
|
||||
}
|
||||
}
|
||||
battleListEditBox.setMaxLength(128);
|
||||
battleListEditBox.setValue(tempString);
|
||||
addRenderableWidget(battleListEditBox);
|
||||
|
||||
top_offset += widget_height;
|
||||
|
||||
addRenderableWidget(
|
||||
new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
|
||||
widget_width, widget_height, Component.literal("Silly Music Categories"),
|
||||
font));
|
||||
if (sillyListEditBox == null) {
|
||||
sillyListEditBox =
|
||||
new EditBox(font, this.width / 2 + widget_x_offset, top_offset, widget_width,
|
||||
widget_height, Component.literal("Silly Music Categories Edit Box"));
|
||||
} else {
|
||||
sillyListEditBox.setPosition(this.width / 2 + widget_x_offset, top_offset);
|
||||
sillyListEditBox.setSize(widget_width, widget_height);
|
||||
}
|
||||
tempString = "";
|
||||
for (String category : ClientConfig.CLIENT.sillyMusicList.get()) {
|
||||
if (tempString.isEmpty()) {
|
||||
tempString = category;
|
||||
} else {
|
||||
tempString += "," + category;
|
||||
}
|
||||
}
|
||||
sillyListEditBox.setMaxLength(128);
|
||||
sillyListEditBox.setValue(tempString);
|
||||
addRenderableWidget(sillyListEditBox);
|
||||
|
||||
top_offset += widget_height;
|
||||
|
||||
StringWidget stringWidget =
|
||||
new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
|
||||
widget_width, widget_height, Component.literal("Silly Music Threshold"), font);
|
||||
stringWidget.setTooltip(Tooltip.create(
|
||||
Component.literal("Ratio of minimum of silly mobs in battle to play silly music")));
|
||||
addRenderableWidget(stringWidget);
|
||||
if (sillyMusicThresholdSlider == null) {
|
||||
sillyMusicThresholdSlider =
|
||||
new SliderPercentage(this.width / 2 + widget_x_offset, top_offset, widget_width,
|
||||
widget_height, Component.literal("Silly Music Threshold: " +
|
||||
String.format("%.1f%%", ClientConfig.CLIENT.sillyMusicThreshold.get() * 100.0)),
|
||||
ClientConfig.CLIENT.sillyMusicThreshold.get(), "Silly Music Threshold: ");
|
||||
} else {
|
||||
sillyMusicThresholdSlider.setPosition(this.width / 2 + widget_x_offset, top_offset);
|
||||
sillyMusicThresholdSlider.setSize(widget_width, widget_height);
|
||||
}
|
||||
addRenderableWidget(sillyMusicThresholdSlider);
|
||||
|
||||
top_offset += widget_height;
|
||||
|
||||
stringWidget =
|
||||
new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
|
||||
widget_width, widget_height, Component.literal("Affected by Master Vol."),
|
||||
font);
|
||||
stringWidget.setTooltip(Tooltip.create(
|
||||
Component.literal("If enabled, volume is affected by global master volume.")));
|
||||
addRenderableWidget(stringWidget);
|
||||
if (affectedByMasterVolCheckbox == null) {
|
||||
affectedByMasterVolCheckbox = Checkbox.builder(Component.literal(""), font)
|
||||
.pos(this.width / 2 + widget_x_offset, top_offset).build();
|
||||
} else {
|
||||
affectedByMasterVolCheckbox.setPosition(this.width / 2 + widget_x_offset,
|
||||
top_offset);
|
||||
}
|
||||
if ((ClientConfig.CLIENT.volumeAffectedByMasterVolume.get() &&
|
||||
!affectedByMasterVolCheckbox.selected()) ||
|
||||
(!ClientConfig.CLIENT.volumeAffectedByMasterVolume.get() &&
|
||||
affectedByMasterVolCheckbox.selected())) {
|
||||
affectedByMasterVolCheckbox.onPress();
|
||||
}
|
||||
addRenderableWidget(affectedByMasterVolCheckbox);
|
||||
|
||||
top_offset += widget_height;
|
||||
|
||||
stringWidget =
|
||||
new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
|
||||
widget_width, widget_height, Component.literal("Affected by Music Vol."), font);
|
||||
stringWidget.setTooltip(Tooltip.create(
|
||||
Component.literal("If enabled, volume is affected by global music volume.")));
|
||||
addRenderableWidget(stringWidget);
|
||||
if (affectedByMusicVolCheckbox == null) {
|
||||
affectedByMusicVolCheckbox = Checkbox.builder(Component.literal(""), font)
|
||||
.pos(this.width / 2 + widget_x_offset, top_offset).build();
|
||||
} else {
|
||||
affectedByMusicVolCheckbox.setPosition(this.width / 2 + widget_x_offset,
|
||||
top_offset);
|
||||
}
|
||||
if ((ClientConfig.CLIENT.volumeAffectedByMusicVolume.get() &&
|
||||
!affectedByMusicVolCheckbox.selected()) ||
|
||||
(!ClientConfig.CLIENT.volumeAffectedByMusicVolume.get() &&
|
||||
affectedByMusicVolCheckbox.selected())) {
|
||||
affectedByMusicVolCheckbox.onPress();
|
||||
}
|
||||
addRenderableWidget(affectedByMusicVolCheckbox);
|
||||
|
||||
top_offset += widget_height;
|
||||
|
||||
stringWidget =
|
||||
new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
|
||||
widget_width, widget_height, Component.literal("Music Volume"), font);
|
||||
stringWidget.setTooltip(
|
||||
Tooltip.create(Component.literal("Volume of battle/silly music")));
|
||||
addRenderableWidget(stringWidget);
|
||||
if (volumeSlider == null) {
|
||||
volumeSlider =
|
||||
new SliderPercentage(this.width / 2 + widget_x_offset, top_offset, widget_width,
|
||||
widget_height, Component.literal(
|
||||
"Volume: " + String.format("%.1f%%", ClientConfig.CLIENT.musicVolume.get() * 100.0)),
|
||||
ClientConfig.CLIENT.musicVolume.get(), "Volume: ");
|
||||
} else {
|
||||
volumeSlider.setPosition(this.width / 2 + widget_x_offset, top_offset);
|
||||
volumeSlider.setSize(widget_width, widget_height);
|
||||
}
|
||||
addRenderableWidget(volumeSlider);
|
||||
|
||||
addRenderableWidget(Button.builder(Component.literal("Cancel"),
|
||||
(b) -> Minecraft.getInstance().setScreen(null))
|
||||
.bounds(this.width / 2 - widget_width + widget_x_offset,
|
||||
this.height - widget_height, widget_width, widget_height).build());
|
||||
addRenderableWidget(Button.builder(Component.literal("Accept"), (b) -> {
|
||||
accepted = true;
|
||||
}).bounds(this.width / 2 + widget_x_offset, this.height - widget_height, widget_width,
|
||||
widget_height).build());
|
||||
|
||||
dirtyFlag = false;
|
||||
}
|
||||
|
||||
private void doAccepted() {
|
||||
String temp = battleListEditBox.getValue();
|
||||
{
|
||||
List<String> battleList = new ArrayList<String>();
|
||||
for (String category : temp.split(",")) {
|
||||
battleList.add(category.strip());
|
||||
}
|
||||
ClientConfig.CLIENT.battleMusicList.set(battleList);
|
||||
}
|
||||
|
||||
temp = sillyListEditBox.getValue();
|
||||
{
|
||||
List<String> sillyList = new ArrayList<String>();
|
||||
for (String category : temp.split(",")) {
|
||||
sillyList.add(category.strip());
|
||||
}
|
||||
ClientConfig.CLIENT.sillyMusicList.set(sillyList);
|
||||
}
|
||||
|
||||
ClientConfig.CLIENT.sillyMusicThreshold.set(sillyMusicThresholdSlider.percentage);
|
||||
|
||||
ClientConfig.CLIENT.volumeAffectedByMasterVolume.set(affectedByMasterVolCheckbox.selected());
|
||||
|
||||
ClientConfig.CLIENT.volumeAffectedByMusicVolume.set(affectedByMusicVolCheckbox.selected());
|
||||
|
||||
ClientConfig.CLIENT.musicVolume.set(volumeSlider.percentage);
|
||||
|
||||
ClientConfig.CLIENT_SPEC.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPauseScreen() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) {
|
||||
if (accepted) {
|
||||
doAccepted();
|
||||
Minecraft.getInstance().setScreen(null);
|
||||
return;
|
||||
}
|
||||
if (dirtyFlag) {
|
||||
onDirty();
|
||||
}
|
||||
super.render(pGuiGraphics, pMouseX, pMouseY, pPartialTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(Minecraft pMinecraft, int pWidth, int pHeight) {
|
||||
dirtyFlag = true;
|
||||
super.resize(pMinecraft, pWidth, pHeight);
|
||||
}
|
||||
|
||||
private static class SliderPercentage extends AbstractSliderButton {
|
||||
private final String messagePrefix;
|
||||
private double percentage;
|
||||
|
||||
public SliderPercentage(int x, int y, int width, int height, Component message, double percentage, String messagePrefix) {
|
||||
super(x, y, width, height, message, percentage);
|
||||
this.percentage = percentage;
|
||||
this.messagePrefix = messagePrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateMessage() {
|
||||
setMessage(
|
||||
Component.literal(messagePrefix + String.format("%.1f%%", percentage * 100.0)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyValue() {
|
||||
percentage = value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,9 +15,7 @@ import net.minecraft.resources.ResourceKey;
|
|||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
private BattleGui battleGui = null;
|
||||
|
@ -96,13 +94,27 @@ public class ClientProxy extends CommonProxy {
|
|||
@Override
|
||||
public void playBattleMusic() {
|
||||
Options gs = Minecraft.getInstance().options;
|
||||
battleMusic.playBattle(gs.getSoundSourceVolume(SoundSource.MUSIC) * gs.getSoundSourceVolume(SoundSource.MASTER));
|
||||
float volume = ClientConfig.CLIENT.musicVolume.get().floatValue();
|
||||
if (ClientConfig.CLIENT.volumeAffectedByMasterVolume.get()) {
|
||||
volume *= gs.getSoundSourceVolume(SoundSource.MASTER);
|
||||
}
|
||||
if (ClientConfig.CLIENT.volumeAffectedByMusicVolume.get()) {
|
||||
volume *= gs.getSoundSourceVolume(SoundSource.MUSIC);
|
||||
}
|
||||
battleMusic.playBattle(volume);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSillyMusic() {
|
||||
Options gs = Minecraft.getInstance().options;
|
||||
battleMusic.playSilly(gs.getSoundSourceVolume(SoundSource.MUSIC) * gs.getSoundSourceVolume(SoundSource.MASTER));
|
||||
float volume = ClientConfig.CLIENT.musicVolume.get().floatValue();
|
||||
if (ClientConfig.CLIENT.volumeAffectedByMasterVolume.get()) {
|
||||
volume *= gs.getSoundSourceVolume(SoundSource.MASTER);
|
||||
}
|
||||
if (ClientConfig.CLIENT.volumeAffectedByMusicVolume.get()) {
|
||||
volume *= gs.getSoundSourceVolume(SoundSource.MUSIC);
|
||||
}
|
||||
battleMusic.playSilly(volume);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,9 +130,9 @@ public class ClientProxy extends CommonProxy {
|
|||
if (localBattle == null) {
|
||||
return;
|
||||
}
|
||||
if (type == null || type.isEmpty() || getConfig().isBattleMusicType(type)) {
|
||||
if (type == null || type.isEmpty() || ClientConfig.CLIENT.battleMusicList.get().contains(type)) {
|
||||
++battleMusicCount;
|
||||
} else if (getConfig().isSillyMusicType(type)) {
|
||||
} else if (ClientConfig.CLIENT.sillyMusicList.get().contains(type)) {
|
||||
++sillyMusicCount;
|
||||
} else {
|
||||
++battleMusicCount;
|
||||
|
@ -134,9 +146,9 @@ public class ClientProxy extends CommonProxy {
|
|||
battleMusicCount = 0;
|
||||
sillyMusicCount = 0;
|
||||
return;
|
||||
} else if (type == null || type.isEmpty() || getConfig().isBattleMusicType(type)) {
|
||||
} else if (type == null || type.isEmpty() || ClientConfig.CLIENT.battleMusicList.get().contains(type)) {
|
||||
--battleMusicCount;
|
||||
} else if (getConfig().isSillyMusicType(type)) {
|
||||
} else if (ClientConfig.CLIENT.sillyMusicList.get().contains(type)) {
|
||||
--sillyMusicCount;
|
||||
} else {
|
||||
--battleMusicCount;
|
||||
|
@ -187,7 +199,7 @@ public class ClientProxy extends CommonProxy {
|
|||
percentage = 100.0f * (float) sillyMusicCount / (float) (sillyMusicCount + battleMusicCount);
|
||||
}
|
||||
|
||||
if (percentage >= (float) getConfig().getSillyMusicThreshold()) {
|
||||
if (percentage >= ClientConfig.CLIENT.sillyMusicThreshold.get().floatValue()) {
|
||||
if (battleMusic.isPlaying()) {
|
||||
if (!battleMusic.isPlayingSilly() && battleMusic.hasSillyMusic()) {
|
||||
stopMusic(false);
|
||||
|
@ -224,7 +236,7 @@ public class ClientProxy extends CommonProxy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <MSG> void handlePacket(MSG msg, Supplier<NetworkEvent.Context> ctx) {
|
||||
public <MSG> void handlePacket(MSG msg, CustomPayloadEvent.Context ctx) {
|
||||
if (msg.getClass() == PacketBattleMessage.class) {
|
||||
PacketBattleMessage pkt = (PacketBattleMessage) msg;
|
||||
Entity fromEntity = getEntity(pkt.getEntityIDFrom(), pkt.getDimension());
|
||||
|
@ -358,6 +370,10 @@ public class ClientProxy extends CommonProxy {
|
|||
break;
|
||||
case TURN_BEGIN:
|
||||
TurnBasedMinecraftMod.proxy.displayString("The turn begins!");
|
||||
if (TurnBasedMinecraftMod.proxy.getLocalBattle() == null || TurnBasedMinecraftMod.proxy.getLocalBattle().getId() != pkt.getAmount()) {
|
||||
TurnBasedMinecraftMod.proxy.createLocalBattle(pkt.getAmount());
|
||||
}
|
||||
TurnBasedMinecraftMod.proxy.battleStarted();
|
||||
TurnBasedMinecraftMod.proxy.battleGuiTurnBegin();
|
||||
break;
|
||||
case TURN_END:
|
||||
|
@ -436,6 +452,12 @@ public class ClientProxy extends CommonProxy {
|
|||
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
|
||||
}
|
||||
break;
|
||||
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;
|
||||
}
|
||||
} else if (msg.getClass() == PacketGeneralMessage.class) {
|
||||
PacketGeneralMessage pkt = (PacketGeneralMessage) msg;
|
||||
|
@ -460,22 +482,27 @@ public class ClientProxy extends CommonProxy {
|
|||
MutableComponent text = Component.literal("Edit what value? ");
|
||||
text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
|
||||
|
||||
MutableComponent option = Component.literal("IgB");
|
||||
// HoverEvent.Action.SHOW_TEXT is probably SHOW_TEXT
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle"))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("IgnoreBattle"))));
|
||||
MutableComponent value = Component.literal("(" + pkt.getEntityInfo().ignoreBattle + ") ");
|
||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
MutableComponent option;
|
||||
MutableComponent value;
|
||||
|
||||
option = Component.literal("AP");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackPower"))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("AttackPower"))));
|
||||
value = Component.literal("(" + pkt.getEntityInfo().attackPower + ") ");
|
||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
if (pkt.getEntityInfo().playerName.isEmpty()) {
|
||||
option = Component.literal("IgB");
|
||||
// HoverEvent.Action.SHOW_TEXT is probably SHOW_TEXT
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle"))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("IgnoreBattle"))));
|
||||
value = Component.literal("(" + pkt.getEntityInfo().ignoreBattle + ") ");
|
||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
|
||||
option = Component.literal("AP");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackPower"))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("AttackPower"))));
|
||||
value = Component.literal("(" + pkt.getEntityInfo().attackPower + ") ");
|
||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
}
|
||||
|
||||
option = Component.literal("APr");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackProbability"))
|
||||
|
@ -485,13 +512,15 @@ public class ClientProxy extends CommonProxy {
|
|||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
|
||||
option = Component.literal("AV");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackVariance"))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("AttackVariance"))));
|
||||
value = Component.literal("(" + pkt.getEntityInfo().attackVariance + ") ");
|
||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
if (pkt.getEntityInfo().playerName.isEmpty()) {
|
||||
option = Component.literal("AV");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackVariance"))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("AttackVariance"))));
|
||||
value = Component.literal("(" + pkt.getEntityInfo().attackVariance + ") ");
|
||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
}
|
||||
|
||||
option = Component.literal("AE");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffect"))
|
||||
|
@ -509,21 +538,23 @@ public class ClientProxy extends CommonProxy {
|
|||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
|
||||
option = Component.literal("DD");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamage"))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DefenseDamage"))));
|
||||
value = Component.literal("(" + pkt.getEntityInfo().defenseDamage + ") ");
|
||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
if (pkt.getEntityInfo().playerName.isEmpty()) {
|
||||
option = Component.literal("DD");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamage"))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DefenseDamage"))));
|
||||
value = Component.literal("(" + pkt.getEntityInfo().defenseDamage + ") ");
|
||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
|
||||
option = Component.literal("DDPr");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamageProbability"))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DefenseDamageProbability"))));
|
||||
value = Component.literal("(" + pkt.getEntityInfo().defenseDamageProbability + "%) ");
|
||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
option = Component.literal("DDPr");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamageProbability"))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DefenseDamageProbability"))));
|
||||
value = Component.literal("(" + pkt.getEntityInfo().defenseDamageProbability + "%) ");
|
||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
}
|
||||
|
||||
option = Component.literal("E");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit evasion"))
|
||||
|
@ -541,37 +572,55 @@ public class ClientProxy extends CommonProxy {
|
|||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
|
||||
option = Component.literal("C");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category"))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("Category"))));
|
||||
value = Component.literal("(" + pkt.getEntityInfo().category + ") ");
|
||||
option = Component.literal("HS");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit hasteSpeed"))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("HasteSpeed"))));
|
||||
value = Component.literal("(" + pkt.getEntityInfo().hasteSpeed + ") ");
|
||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
|
||||
option = Component.literal("DecA");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionAttack"))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DecisionAttack"))));
|
||||
value = Component.literal("(" + pkt.getEntityInfo().decisionAttack + "%) ");
|
||||
option = Component.literal("SS");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit slowSpeed"))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("SlowSpeed"))));
|
||||
value = Component.literal("(" + pkt.getEntityInfo().slowSpeed + ") ");
|
||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
|
||||
option = Component.literal("DecD");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionDefend"))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DecisionDefend"))));
|
||||
value = Component.literal("(" + pkt.getEntityInfo().decisionDefend + "%) ");
|
||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
if (pkt.getEntityInfo().playerName.isEmpty()) {
|
||||
option = Component.literal("C");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category"))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("Category"))));
|
||||
value = Component.literal("(" + pkt.getEntityInfo().category + ") ");
|
||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
|
||||
option = Component.literal("DecF");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionFlee"))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DecisionFlee"))));
|
||||
value = Component.literal("(" + pkt.getEntityInfo().decisionFlee + "%) ");
|
||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
option = Component.literal("DecA");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionAttack"))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DecisionAttack"))));
|
||||
value = Component.literal("(" + pkt.getEntityInfo().decisionAttack + "%) ");
|
||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
|
||||
option = Component.literal("DecD");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionDefend"))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DecisionDefend"))));
|
||||
value = Component.literal("(" + pkt.getEntityInfo().decisionDefend + "%) ");
|
||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
|
||||
option = Component.literal("DecF");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionFlee"))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DecisionFlee"))));
|
||||
value = Component.literal("(" + pkt.getEntityInfo().decisionFlee + "%) ");
|
||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
}
|
||||
|
||||
option = Component.literal("Finished Editing");
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit finish")));
|
||||
|
@ -1281,6 +1330,44 @@ public class ClientProxy extends CommonProxy {
|
|||
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
|
||||
break;
|
||||
}
|
||||
case EDIT_HASTE_SPEED: {
|
||||
MutableComponent text = Component.literal("haste speed: ");
|
||||
text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
|
||||
|
||||
for (int i = 0; i <= 100; i += 10) {
|
||||
MutableComponent option = Component.literal(Integer.toString(i));
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit hasteSpeed " + Integer.toString(i))));
|
||||
text.getSiblings().add(option);
|
||||
if (i < 100) {
|
||||
text.getSiblings().add(Component.literal(", "));
|
||||
}
|
||||
}
|
||||
|
||||
text.getSiblings().add(Component.literal(" (or use command \"/tbm-edit edit hasteSpeed <integer>\")"));
|
||||
|
||||
parentComponent.getSiblings().add(text);
|
||||
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
|
||||
break;
|
||||
}
|
||||
case EDIT_SLOW_SPEED: {
|
||||
MutableComponent text = Component.literal("slow speed: ");
|
||||
text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
|
||||
|
||||
for (int i = 0; i <= 100; i += 10) {
|
||||
MutableComponent option = Component.literal(Integer.toString(i));
|
||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit slowSpeed " + Integer.toString(i))));
|
||||
text.getSiblings().add(option);
|
||||
if (i < 100) {
|
||||
text.getSiblings().add(Component.literal(", "));
|
||||
}
|
||||
}
|
||||
|
||||
text.getSiblings().add(Component.literal(" (or use command \"/tbm-edit edit slowSpeed <integer>\")"));
|
||||
|
||||
parentComponent.getSiblings().add(text);
|
||||
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
|
||||
break;
|
||||
}
|
||||
case EDIT_CATEGORY: {
|
||||
MutableComponent text = Component.literal("category: ");
|
||||
text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
|
||||
|
@ -1451,9 +1538,28 @@ public class ClientProxy extends CommonProxy {
|
|||
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
|
||||
break;
|
||||
}
|
||||
case PICK_PLAYER: {
|
||||
TurnBasedMinecraftMod.proxy.displayString("Use \"/tbm-edit player <player_name>\"");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showClientConfigGui() {
|
||||
Minecraft.getInstance().setScreen(new ClientConfigGui());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pauseMCMusic() {
|
||||
Minecraft.getInstance().getSoundManager().pause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resumeMCMusic() {
|
||||
Minecraft.getInstance().getSoundManager().resume();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,34 +1,49 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.client;
|
||||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.CommonProxy;
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
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.NarrationElementOutput;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
|
||||
public class EntitySelectionButton extends AbstractButton {
|
||||
TBMButtonPress onPress;
|
||||
public class EntitySelectionButton implements Renderable, GuiEventListener, NarratableEntry {
|
||||
private int x;
|
||||
private int y;
|
||||
private int width;
|
||||
private int height;
|
||||
private boolean focused;
|
||||
private Button nestedButton;
|
||||
TBMEntityButtonPress onPress;
|
||||
private int entityID;
|
||||
private boolean isSideA;
|
||||
|
||||
public EntitySelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int entityID, boolean isSideA, TBMButtonPress onPress) {
|
||||
super(x, y, widthIn, heightIn, Component.literal(buttonText));
|
||||
public EntitySelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int entityID, boolean isSideA, TBMEntityButtonPress onPress) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = widthIn;
|
||||
this.height = heightIn;
|
||||
this.onPress = onPress;
|
||||
this.entityID = entityID;
|
||||
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) {
|
||||
super(x, y, widthIn, heightIn, buttonTextComponent);
|
||||
public EntitySelectionButton(int x, int y, int widthIn, int heightIn, Component buttonTextComponent, int entityID, boolean isSideA, TBMEntityButtonPress onPress) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = widthIn;
|
||||
this.height = heightIn;
|
||||
this.onPress = onPress;
|
||||
this.entityID = entityID;
|
||||
this.isSideA = isSideA;
|
||||
this.nestedButton = Button.builder(buttonTextComponent, (unused) -> {}).pos(x, y).size(widthIn, heightIn).build();
|
||||
}
|
||||
|
||||
public int getID() {
|
||||
|
@ -41,63 +56,86 @@ public class EntitySelectionButton extends AbstractButton {
|
|||
|
||||
@Override
|
||||
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);
|
||||
if (e != null && e instanceof LivingEntity && ((LivingEntity) e).isAlive()) {
|
||||
int health = (int) (((LivingEntity) e).getHealth() + 0.5f);
|
||||
int xpos = getX();
|
||||
int xpos = this.x;
|
||||
int xoffset;
|
||||
if (isSideA) {
|
||||
xpos += getWidth() + 4;
|
||||
xpos += this.width + 4;
|
||||
xoffset = 4;
|
||||
} else {
|
||||
xpos -= 6;
|
||||
xoffset = -4;
|
||||
}
|
||||
if (health > 200) {
|
||||
guiGraphics.fill(xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
|
||||
guiGraphics.fill(xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
|
||||
guiGraphics.fill(xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
|
||||
guiGraphics.fill(xpos, getY() + getHeight() / 5, xpos + 2, getY() + getHeight() * 2 / 5, 0xFF00FFFF);
|
||||
guiGraphics.fill(xpos, getY(), xpos + 2, getY() + getHeight() / 5, 0xFF0000FF);
|
||||
int healthHeight = ((health - 200) * getHeight() / 100);
|
||||
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFFFFFF);
|
||||
guiGraphics.fill(xpos, this.y + this.height * 4 / 5, xpos + 2, this.y + this.height, 0xFFFF0000);
|
||||
guiGraphics.fill(xpos, this.y + this.height * 3 / 5, xpos + 2, this.y + this.height * 4 / 5, 0xFFFFFF00);
|
||||
guiGraphics.fill(xpos, this.y + this.height * 2 / 5, xpos + 2, this.y + this.height * 3 / 5, 0xFF00FF00);
|
||||
guiGraphics.fill(xpos, this.y + this.height / 5, xpos + 2, this.y + this.height * 2 / 5, 0xFF00FFFF);
|
||||
guiGraphics.fill(xpos, this.y, xpos + 2, this.y + this.height / 5, 0xFF0000FF);
|
||||
int healthHeight = ((health - 200) * this.height / 100);
|
||||
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFFFFFFFF);
|
||||
} else if (health > 100) {
|
||||
guiGraphics.fill(xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
|
||||
guiGraphics.fill(xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
|
||||
guiGraphics.fill(xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
|
||||
guiGraphics.fill(xpos, getY() + getHeight() / 5, xpos + 2, getY() + getHeight() * 2 / 5, 0xFF00FFFF);
|
||||
int healthHeight = ((health - 100) * getHeight() / 100);
|
||||
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF0000FF);
|
||||
guiGraphics.fill(xpos, this.y + this.height * 4 / 5, xpos + 2, this.y + this.height, 0xFFFF0000);
|
||||
guiGraphics.fill(xpos, this.y + this.height * 3 / 5, xpos + 2, this.y + this.height * 4 / 5, 0xFFFFFF00);
|
||||
guiGraphics.fill(xpos, this.y + this.height * 2 / 5, xpos + 2, this.y + this.height * 3 / 5, 0xFF00FF00);
|
||||
guiGraphics.fill(xpos, this.y + this.height / 5, xpos + 2, this.y + this.height * 2 / 5, 0xFF00FFFF);
|
||||
int healthHeight = ((health - 100) * this.height / 100);
|
||||
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFF0000FF);
|
||||
} else if (health > 50) {
|
||||
guiGraphics.fill(xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
|
||||
guiGraphics.fill(xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
|
||||
guiGraphics.fill(xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
|
||||
int healthHeight = ((health - 50) * getHeight() / 50);
|
||||
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF00FFFF);
|
||||
guiGraphics.fill(xpos, this.y + this.height * 4 / 5, xpos + 2, this.y + this.height, 0xFFFF0000);
|
||||
guiGraphics.fill(xpos, this.y + this.height * 3 / 5, xpos + 2, this.y + this.height * 4 / 5, 0xFFFFFF00);
|
||||
guiGraphics.fill(xpos, this.y + this.height * 2 / 5, xpos + 2, this.y + this.height * 3 / 5, 0xFF00FF00);
|
||||
int healthHeight = ((health - 50) * this.height / 50);
|
||||
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFF00FFFF);
|
||||
} else if (health > 20) {
|
||||
guiGraphics.fill(xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
|
||||
guiGraphics.fill(xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
|
||||
int healthHeight = ((health - 20) * getHeight() / 30);
|
||||
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF00FF00);
|
||||
guiGraphics.fill(xpos, this.y + this.height * 4 / 5, xpos + 2, this.y + this.height, 0xFFFF0000);
|
||||
guiGraphics.fill(xpos, this.y + this.height * 3 / 5, xpos + 2, this.y + this.height * 4 / 5, 0xFFFFFF00);
|
||||
int healthHeight = ((health - 20) * this.height / 30);
|
||||
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFF00FF00);
|
||||
} else if (health > 10) {
|
||||
guiGraphics.fill(xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
|
||||
int healthHeight = ((health - 10) * getHeight() / 10);
|
||||
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFFFF00);
|
||||
guiGraphics.fill(xpos, this.y + this.height * 4 / 5, xpos + 2, this.y + this.height, 0xFFFF0000);
|
||||
int healthHeight = ((health - 10) * this.height / 10);
|
||||
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFFFFFF00);
|
||||
} else {
|
||||
int healthHeight = (health * getHeight() / 10);
|
||||
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFF0000);
|
||||
int healthHeight = (health * this.height / 10);
|
||||
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() {
|
||||
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;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
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.NarrationElementOutput;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class ItemSelectionButton extends AbstractButton {
|
||||
|
||||
TBMButtonPress onPress;
|
||||
public class ItemSelectionButton implements Renderable, GuiEventListener, NarratableEntry {
|
||||
private int x;
|
||||
private int y;
|
||||
private int width;
|
||||
private int height;
|
||||
TBMItemButtonPress onPress;
|
||||
private int itemStackID;
|
||||
private boolean focused;
|
||||
|
||||
public ItemSelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int itemStackID, TBMButtonPress onPress) {
|
||||
super(x, y, widthIn, heightIn, Component.literal(buttonText));
|
||||
public ItemSelectionButton(int x, int y, int widthIn, int heightIn, int itemStackID, TBMItemButtonPress onPress) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = widthIn;
|
||||
this.height = heightIn;
|
||||
this.onPress = onPress;
|
||||
this.itemStackID = itemStackID;
|
||||
}
|
||||
|
@ -24,23 +31,44 @@ public class ItemSelectionButton extends AbstractButton {
|
|||
|
||||
@Override
|
||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float unk) {
|
||||
if (visible) {
|
||||
boolean hovered = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + getWidth() && mouseY < getY() + getHeight();
|
||||
if (hovered) {
|
||||
guiGraphics.fill(getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x80FFFFFF);
|
||||
} else {
|
||||
guiGraphics.fill(getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x20707070);
|
||||
}
|
||||
boolean hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
||||
if (hovered) {
|
||||
guiGraphics.fill(this.x, this.y, this.x + this.width, this.y + this.height, 0x80FFFFFF);
|
||||
} else {
|
||||
guiGraphics.fill(this.x, this.y, this.x + this.width, this.y + this.height, 0x20707070);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateWidgetNarration(NarrationElementOutput p_259858_) {
|
||||
p_259858_.add(NarratedElementType.HINT, "Item " + this.itemStackID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPress() {
|
||||
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);
|
||||
}
|
|
@ -82,7 +82,7 @@ public class AttackEventHandler
|
|||
if(!event.getEntity().hasCustomName())
|
||||
{
|
||||
TurnBasedMinecraftMod.logger.error("Cannot edit custom name from entity without custom name");
|
||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)editingInfo.editor), new PacketGeneralMessage("Cannot edit custom name from entity without custom name"));
|
||||
TurnBasedMinecraftMod.getHandler().send(new PacketGeneralMessage("Cannot edit custom name from entity without custom name"), PacketDistributor.PLAYER.with((ServerPlayer)editingInfo.editor));
|
||||
return;
|
||||
}
|
||||
editingInfo.entityInfo = config.getCustomEntityInfo(event.getEntity().getCustomName().getString());
|
||||
|
@ -91,9 +91,9 @@ public class AttackEventHandler
|
|||
editingInfo.entityInfo = new EntityInfo();
|
||||
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() + "\""));
|
||||
TurnBasedMinecraftMod.getHandler().send(new PacketGeneralMessage("Editing custom name \"" + event.getEntity().getCustomName().getString() + "\""), PacketDistributor.PLAYER.with((ServerPlayer)editingInfo.editor));
|
||||
TurnBasedMinecraftMod.logger.info("Begin editing custom \"" + event.getEntity().getCustomName().getString() + "\"");
|
||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)editingInfo.editor), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||
TurnBasedMinecraftMod.getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with((ServerPlayer)editingInfo.editor));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -107,9 +107,9 @@ public class AttackEventHandler
|
|||
{
|
||||
editingInfo.entityInfo = editingInfo.entityInfo.clone();
|
||||
}
|
||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)editingInfo.editor), new PacketGeneralMessage("Editing entity \"" + editingInfo.entityInfo.classType.getName() + "\""));
|
||||
TurnBasedMinecraftMod.getHandler().send(new PacketGeneralMessage("Editing entity \"" + editingInfo.entityInfo.classType.getName() + "\""), PacketDistributor.PLAYER.with((ServerPlayer)editingInfo.editor));
|
||||
TurnBasedMinecraftMod.logger.info("Begin editing \"" + editingInfo.entityInfo.classType.getName() + "\"");
|
||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)editingInfo.editor), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||
TurnBasedMinecraftMod.getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with((ServerPlayer)editingInfo.editor));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -2,8 +2,10 @@ package com.burnedkirby.TurnBasedMinecraft.common;
|
|||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleInfo;
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleMessage;
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattlePing;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
@ -48,6 +50,8 @@ public class Battle {
|
|||
|
||||
private ResourceKey<Level> dimension;
|
||||
|
||||
private long pingTimerNanos;
|
||||
|
||||
public enum State {
|
||||
DECISION(0),
|
||||
ACTION(1),
|
||||
|
@ -121,6 +125,7 @@ public class Battle {
|
|||
undecidedCount = new AtomicInteger(0);
|
||||
random = new Random();
|
||||
this.dimension = dimension;
|
||||
pingTimerNanos = 0;
|
||||
if (sideA != null) {
|
||||
for (Entity e : sideA) {
|
||||
EntityInfo entityInfo;
|
||||
|
@ -129,6 +134,9 @@ public class Battle {
|
|||
} catch (NullPointerException exception) {
|
||||
entityInfo = null;
|
||||
}
|
||||
if (entityInfo == null) {
|
||||
entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getPlayerInfo(e.getName().getString());
|
||||
}
|
||||
if (entityInfo == null) {
|
||||
entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(e);
|
||||
}
|
||||
|
@ -161,6 +169,9 @@ public class Battle {
|
|||
} catch (NullPointerException exception) {
|
||||
entityInfo = null;
|
||||
}
|
||||
if (entityInfo == null) {
|
||||
entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getPlayerInfo(e.getName().getString());
|
||||
}
|
||||
if (entityInfo == null) {
|
||||
entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(e);
|
||||
}
|
||||
|
@ -263,6 +274,9 @@ public class Battle {
|
|||
} catch (NullPointerException exception) {
|
||||
entityInfo = null;
|
||||
}
|
||||
if (entityInfo == null) {
|
||||
entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getPlayerInfo(e.getName().getString());
|
||||
}
|
||||
if (entityInfo == null) {
|
||||
entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(e);
|
||||
}
|
||||
|
@ -311,6 +325,9 @@ public class Battle {
|
|||
} catch (NullPointerException exception) {
|
||||
entityInfo = null;
|
||||
}
|
||||
if (entityInfo == null) {
|
||||
entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getPlayerInfo(e.getName().getString());
|
||||
}
|
||||
if (entityInfo == null) {
|
||||
entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(e);
|
||||
}
|
||||
|
@ -446,9 +463,19 @@ public class Battle {
|
|||
if (!isServer) {
|
||||
return;
|
||||
}
|
||||
PacketBattleInfo infoPacket = new PacketBattleInfo(getSideAIDs(), getSideBIDs(), timer, TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos(), !TurnBasedMinecraftMod.proxy.getConfig().isBattleDecisionDurationForever());
|
||||
PacketBattleInfo infoPacket = new PacketBattleInfo(getId(), getSideAIDs(), getSideBIDs(), timer, TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos(), !TurnBasedMinecraftMod.proxy.getConfig().isBattleDecisionDurationForever());
|
||||
for (Combatant p : players.values()) {
|
||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) p.entity), infoPacket);
|
||||
TurnBasedMinecraftMod.getHandler().send(infoPacket, PacketDistributor.PLAYER.with((ServerPlayer)p.entity));
|
||||
}
|
||||
}
|
||||
|
||||
protected void notifyPlayersBattlePing() {
|
||||
if (!isServer) {
|
||||
return;
|
||||
}
|
||||
PacketBattlePing pingPacket = new PacketBattlePing(getId(), (int)(timer / 1000000000L));
|
||||
for (Combatant p : players.values()) {
|
||||
TurnBasedMinecraftMod.getHandler().send(pingPacket, PacketDistributor.PLAYER.with((ServerPlayer)p.entity));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -463,7 +490,7 @@ public class Battle {
|
|||
PacketBattleMessage packet = new PacketBattleMessage(type, from, to, dimension, amount, custom);
|
||||
for (Combatant p : players.values()) {
|
||||
if (p.entity.isAlive()) {
|
||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) p.entity), packet);
|
||||
TurnBasedMinecraftMod.getHandler().send(packet, PacketDistributor.PLAYER.with((ServerPlayer)p.entity));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -573,7 +600,7 @@ public class Battle {
|
|||
|
||||
private void removeCombatantPostRemove(Combatant c) {
|
||||
if (c.entity instanceof Player) {
|
||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) c.entity), new PacketBattleMessage(PacketBattleMessage.MessageType.ENDED, 0, 0, dimension, 0));
|
||||
TurnBasedMinecraftMod.getHandler().send(new PacketBattleMessage(PacketBattleMessage.MessageType.ENDED, 0, 0, dimension, 0), PacketDistributor.PLAYER.with((ServerPlayer)c.entity));
|
||||
}
|
||||
battleManager.addRecentlyLeftBattle(c);
|
||||
}
|
||||
|
@ -650,6 +677,11 @@ public class Battle {
|
|||
}
|
||||
|
||||
private boolean update(final long dt) {
|
||||
pingTimerNanos += dt;
|
||||
if (pingTimerNanos >= 4000000000L) {
|
||||
pingTimerNanos = 0;
|
||||
notifyPlayersBattlePing();
|
||||
}
|
||||
if (battleEnded) {
|
||||
Collection<Combatant> combatants = new ArrayList<Combatant>();
|
||||
combatants.addAll(sideA.values());
|
||||
|
@ -761,7 +793,7 @@ public class Battle {
|
|||
case ATTACK:
|
||||
debugLog += " attack";
|
||||
Combatant target = null;
|
||||
if (next.entity instanceof Player) {
|
||||
if (next.entity instanceof Player player) {
|
||||
debugLog += " as player";
|
||||
target = sideA.get(next.targetEntityID);
|
||||
if (target == null) {
|
||||
|
@ -770,15 +802,15 @@ public class Battle {
|
|||
if (target == null || !target.entity.isAlive() || target == next) {
|
||||
continue;
|
||||
}
|
||||
ItemStack heldItemStack = ((Player) next.entity).getMainHandItem();
|
||||
ItemStack heldItemStack = player.getMainHandItem();
|
||||
if (heldItemStack.getItem() instanceof BowItem) {
|
||||
debugLog += " with bow";
|
||||
if (Utility.doesPlayerHaveArrows((Player) next.entity)) {
|
||||
if (Utility.doesPlayerHaveArrows(player)) {
|
||||
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());
|
||||
final int randomTimeLeft = random.nextInt(heldItemStack.getItem().getUseDuration(heldItemStack) / 3);
|
||||
final int randomTimeLeft = random.nextInt(heldItemStack.getUseDuration((LivingEntity)next.entity) / 3);
|
||||
if (TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled()) {
|
||||
next.yaw = yawDirection;
|
||||
next.pitch = pitchDirection;
|
||||
|
@ -793,11 +825,43 @@ public class Battle {
|
|||
sendMessageToAllPlayers(PacketBattleMessage.MessageType.BOW_NO_AMMO, next.entity.getId(), 0, 0);
|
||||
}
|
||||
continue;
|
||||
} else if (heldItemStack.getItem() instanceof CrossbowItem) {
|
||||
debugLog += " with crossbow";
|
||||
// Similar to attack with bow.
|
||||
if (Utility.doesPlayerHaveArrows(player)) {
|
||||
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(player.getMainHandItem(), 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";
|
||||
int hitChance = TurnBasedMinecraftMod.proxy.getConfig().getPlayerAttackProbability();
|
||||
int hitChance;
|
||||
if (next.entityInfo != null && !next.entityInfo.playerName.isEmpty()) {
|
||||
hitChance = next.entityInfo.attackProbability;
|
||||
} else {
|
||||
hitChance = TurnBasedMinecraftMod.proxy.getConfig().getPlayerAttackProbability();
|
||||
}
|
||||
if (target.entity instanceof Player) {
|
||||
hitChance = hitChance * (100 - TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion()) / 100;
|
||||
if (target.entityInfo != null && !target.entityInfo.playerName.isEmpty()) {
|
||||
hitChance = hitChance * (100 - target.entityInfo.evasion) / 100;
|
||||
} else {
|
||||
hitChance = hitChance * (100 - TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion()) / 100;
|
||||
}
|
||||
} else {
|
||||
hitChance = hitChance * (100 - target.entityInfo.evasion) / 100;
|
||||
}
|
||||
|
@ -834,6 +898,13 @@ public class Battle {
|
|||
((Player) nextEntity).attack(targetEntity);
|
||||
TurnBasedMinecraftMod.proxy.setAttackingEntity(null);
|
||||
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ATTACK, nextEntity.getId(), targetEntity.getId(), TurnBasedMinecraftMod.proxy.getAttackingDamage());
|
||||
// Attack effect
|
||||
if (next.entityInfo != null && next.entityInfo.attackEffect != EntityInfo.Effect.UNKNOWN && next.entityInfo.attackEffectProbability > 0) {
|
||||
if (random.nextInt(100) < next.entityInfo.attackEffectProbability) {
|
||||
next.entityInfo.attackEffect.applyEffectToEntity((LivingEntity)targetEntity);
|
||||
sendMessageToAllPlayers(PacketBattleMessage.MessageType.WAS_AFFECTED, nextEntity.getId(), targetEntity.getId(), 0, next.entityInfo.attackEffect.getAffectedString());
|
||||
}
|
||||
}
|
||||
if (defenseDamageTriggered) {
|
||||
// defense damage
|
||||
DamageSource defenseDamageSource = targetEntity.damageSources().mobAttack((LivingEntity) targetEntity);
|
||||
|
@ -978,48 +1049,111 @@ public class Battle {
|
|||
int fastestEnemySpeed = 0;
|
||||
if (next.isSideA) {
|
||||
for (Combatant c : sideB.values()) {
|
||||
if (c.entity instanceof Player) {
|
||||
int playerSpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed();
|
||||
if (((Player) c.entity).hasEffect(MobEffects.MOVEMENT_SPEED)) {
|
||||
playerSpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerHasteSpeed();
|
||||
} else if (((Player) c.entity).hasEffect(MobEffects.MOVEMENT_SLOWDOWN)) {
|
||||
playerSpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerSlowSpeed();
|
||||
if (c.entity instanceof Player player) {
|
||||
int playerSpeed;
|
||||
if (c.entityInfo != null && !c.entityInfo.playerName.isEmpty()) {
|
||||
playerSpeed = c.entityInfo.speed;
|
||||
} else {
|
||||
playerSpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed();
|
||||
}
|
||||
if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) {
|
||||
if (c.entityInfo != null && !c.entityInfo.playerName.isEmpty()) {
|
||||
playerSpeed = c.entityInfo.hasteSpeed;
|
||||
} else {
|
||||
playerSpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerHasteSpeed();
|
||||
}
|
||||
} else if (player.hasEffect(MobEffects.MOVEMENT_SLOWDOWN)) {
|
||||
if (c.entityInfo != null && !c.entityInfo.playerName.isEmpty()) {
|
||||
playerSpeed = c.entityInfo.slowSpeed;
|
||||
} else {
|
||||
playerSpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerSlowSpeed();
|
||||
}
|
||||
}
|
||||
if (playerSpeed > fastestEnemySpeed) {
|
||||
fastestEnemySpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed();
|
||||
}
|
||||
} else {
|
||||
if (c.entityInfo.speed > fastestEnemySpeed) {
|
||||
if (c.entity instanceof LivingEntity livingEntity) {
|
||||
if (livingEntity.hasEffect(MobEffects.MOVEMENT_SPEED)) {
|
||||
if (c.entityInfo.hasteSpeed > fastestEnemySpeed) {
|
||||
fastestEnemySpeed = c.entityInfo.hasteSpeed;
|
||||
}
|
||||
} else if (livingEntity.hasEffect(MobEffects.MOVEMENT_SLOWDOWN)) {
|
||||
if (c.entityInfo.slowSpeed > fastestEnemySpeed) {
|
||||
fastestEnemySpeed = c.entityInfo.slowSpeed;
|
||||
}
|
||||
} else if (c.entityInfo.speed > fastestEnemySpeed) {
|
||||
fastestEnemySpeed = c.entityInfo.speed;
|
||||
}
|
||||
} else if (c.entityInfo.speed > fastestEnemySpeed) {
|
||||
fastestEnemySpeed = c.entityInfo.speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (Combatant c : sideA.values()) {
|
||||
if (c.entity instanceof Player) {
|
||||
int playerSpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed();
|
||||
if (((Player) c.entity).hasEffect(MobEffects.MOVEMENT_SPEED)) {
|
||||
playerSpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerHasteSpeed();
|
||||
} else if (((Player) c.entity).hasEffect(MobEffects.MOVEMENT_SLOWDOWN)) {
|
||||
playerSpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerSlowSpeed();
|
||||
if (c.entity instanceof Player player) {
|
||||
int playerSpeed;
|
||||
if (c.entityInfo != null && !c.entityInfo.playerName.isEmpty()) {
|
||||
playerSpeed = c.entityInfo.speed;
|
||||
} else {
|
||||
playerSpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed();
|
||||
}
|
||||
if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) {
|
||||
if (c.entityInfo != null && !c.entityInfo.playerName.isEmpty()) {
|
||||
playerSpeed = c.entityInfo.hasteSpeed;
|
||||
} else {
|
||||
playerSpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerHasteSpeed();
|
||||
}
|
||||
} else if (player.hasEffect(MobEffects.MOVEMENT_SLOWDOWN)) {
|
||||
if (c.entityInfo != null && !c.entityInfo.playerName.isEmpty()) {
|
||||
playerSpeed = c.entityInfo.slowSpeed;
|
||||
} else {
|
||||
playerSpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerSlowSpeed();
|
||||
}
|
||||
}
|
||||
if (playerSpeed > fastestEnemySpeed) {
|
||||
fastestEnemySpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed();
|
||||
}
|
||||
} else {
|
||||
if (c.entityInfo.speed > fastestEnemySpeed) {
|
||||
if (c.entity instanceof LivingEntity livingEntity) {
|
||||
if (livingEntity.hasEffect(MobEffects.MOVEMENT_SPEED)) {
|
||||
if (c.entityInfo.hasteSpeed > fastestEnemySpeed) {
|
||||
fastestEnemySpeed = c.entityInfo.hasteSpeed;
|
||||
}
|
||||
} else if (livingEntity.hasEffect(MobEffects.MOVEMENT_SLOWDOWN)) {
|
||||
if (c.entityInfo.slowSpeed > fastestEnemySpeed) {
|
||||
fastestEnemySpeed = c.entityInfo.slowSpeed;
|
||||
}
|
||||
} else if (c.entityInfo.speed > fastestEnemySpeed) {
|
||||
fastestEnemySpeed = c.entityInfo.speed;
|
||||
}
|
||||
} else if (c.entityInfo.speed > fastestEnemySpeed) {
|
||||
fastestEnemySpeed = c.entityInfo.speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int fleeProbability = 0;
|
||||
if (next.entity instanceof Player) {
|
||||
int playerSpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed();
|
||||
if (((Player) next.entity).hasEffect(MobEffects.MOVEMENT_SPEED)) {
|
||||
playerSpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerHasteSpeed();
|
||||
} else if (((Player) next.entity).hasEffect(MobEffects.MOVEMENT_SLOWDOWN)) {
|
||||
playerSpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerSlowSpeed();
|
||||
if (next.entity instanceof Player player) {
|
||||
int playerSpeed;
|
||||
if (next.entityInfo != null && !next.entityInfo.playerName.isEmpty()) {
|
||||
playerSpeed = next.entityInfo.speed;
|
||||
} else {
|
||||
playerSpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed();
|
||||
}
|
||||
if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) {
|
||||
if (next.entityInfo != null && !next.entityInfo.playerName.isEmpty()) {
|
||||
playerSpeed = next.entityInfo.hasteSpeed;
|
||||
} else {
|
||||
playerSpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerHasteSpeed();
|
||||
}
|
||||
} else if (player.hasEffect(MobEffects.MOVEMENT_SLOWDOWN)) {
|
||||
if (next.entityInfo != null && !next.entityInfo.playerName.isEmpty()) {
|
||||
playerSpeed = next.entityInfo.slowSpeed;
|
||||
} else {
|
||||
playerSpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerSlowSpeed();
|
||||
}
|
||||
}
|
||||
if (fastestEnemySpeed >= playerSpeed) {
|
||||
fleeProbability = TurnBasedMinecraftMod.proxy.getConfig().getFleeBadProbability();
|
||||
|
@ -1064,7 +1198,7 @@ public class Battle {
|
|||
debugLog += " null";
|
||||
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_NOTHING.getValue());
|
||||
break;
|
||||
} else if (targetItem.isEdible()) {
|
||||
} else if (Utility.isItemEdible(targetItemStack)) {
|
||||
debugLog += " food";
|
||||
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_FOOD.getValue(), targetItemStack.getDisplayName().getString());
|
||||
final Entity nextEntity = next.entity;
|
||||
|
@ -1073,13 +1207,13 @@ public class Battle {
|
|||
} else {
|
||||
// then check vanilla foods
|
||||
final CreativeModeTab foodAndDrinksTab = CreativeModeTabRegistry.getTab(CreativeModeTabs.FOOD_AND_DRINKS.location());
|
||||
if (foodAndDrinksTab.contains(targetItemStack) && targetItem.isEdible()) {
|
||||
if (foodAndDrinksTab.contains(targetItemStack) && Utility.isItemEdible(targetItemStack)) {
|
||||
debugLog += " food";
|
||||
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_FOOD.getValue(), targetItemStack.getDisplayName().getString());
|
||||
final Entity nextEntity = next.entity;
|
||||
final int nextItemToUse = next.itemToUse;
|
||||
((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";
|
||||
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_POTION.getValue(), targetItemStack.getDisplayName().getString());
|
||||
final Entity nextEntity = next.entity;
|
||||
|
@ -1090,7 +1224,10 @@ public class Battle {
|
|||
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_INVALID.getValue(), targetItemStack.getDisplayName().getString());
|
||||
final Entity nextEntity = next.entity;
|
||||
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;
|
||||
|
|
|
@ -317,7 +317,7 @@ public class BattleManager
|
|||
c.time = System.nanoTime();
|
||||
Config config = TurnBasedMinecraftMod.proxy.getConfig();
|
||||
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!"));
|
||||
TurnBasedMinecraftMod.getHandler().send(new PacketGeneralMessage("You just left battle! " + config.getLeaveBattleCooldownSeconds() + " seconds until you can attack/be-attacked again!"), PacketDistributor.PLAYER.with((ServerPlayer)c.entity));
|
||||
}
|
||||
recentlyLeftBattle.put(c.entity.getId(), c);
|
||||
entityToBattleMap.remove(new EntityIDDimPair(c.entity));
|
||||
|
@ -337,7 +337,7 @@ public class BattleManager
|
|||
iter.remove();
|
||||
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."));
|
||||
TurnBasedMinecraftMod.getHandler().send(new PacketGeneralMessage("Timer ended, you can now attack/be-attacked again."), PacketDistributor.PLAYER.with((ServerPlayer)entry.getValue().entity));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,10 +26,10 @@ public class BattleUpdater
|
|||
|
||||
@SubscribeEvent
|
||||
public void update(TickEvent.ServerTickEvent tickEvent) {
|
||||
if(tickEvent.phase != TickEvent.Phase.START && isRunning.get() && ++tick > tickLimit) {
|
||||
if(tickEvent.phase != TickEvent.Phase.START && isRunning.get() && ++tick > tickLimit && tickEvent.haveTime()) {
|
||||
tick = 0;
|
||||
manager.battleMap.entrySet().removeIf(entry -> entry.getValue().update());
|
||||
manager.updateRecentlyLeftBattle();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import net.minecraft.resources.ResourceKey;
|
|||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||
import net.minecraftforge.server.ServerLifecycleHooks;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
@ -13,7 +13,6 @@ import java.util.HashSet;
|
|||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class CommonProxy
|
||||
{
|
||||
|
@ -173,5 +172,10 @@ public class CommonProxy
|
|||
return ServerLifecycleHooks.getCurrentServer().getLevel(dim).getEntity(id);
|
||||
}
|
||||
|
||||
public <MSG> void handlePacket(MSG msg, Supplier<NetworkEvent.Context> ctx) {}
|
||||
public <MSG> void handlePacket(MSG msg,CustomPayloadEvent.Context ctx) {}
|
||||
|
||||
public void showClientConfigGui() {}
|
||||
|
||||
public void pauseMCMusic() {}
|
||||
public void resumeMCMusic() {}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ public class Config
|
|||
private boolean battleDecisionDurationForever = false;
|
||||
private Map<String, EntityInfo> entityInfoMap;
|
||||
private Map<String, EntityInfo> customEntityInfoMap;
|
||||
private Map<String, EntityInfo> customPlayerInfoMap;
|
||||
private Set<String> ignoreBattleTypes;
|
||||
private Logger logger;
|
||||
private int playerSpeed = 50;
|
||||
|
@ -37,10 +38,7 @@ public class Config
|
|||
private int fleeBadProbability = 35;
|
||||
private int minimumHitPercentage = 4;
|
||||
private int maxInBattle = 8;
|
||||
private Set<String> musicBattleTypes;
|
||||
private Set<String> musicSillyTypes;
|
||||
private boolean freezeCombatantsInBattle = false;
|
||||
private int sillyMusicThreshold = 40;
|
||||
private int configVersion = 0;
|
||||
private Set<Integer> battleIgnoringPlayers = null;
|
||||
private boolean onlyOPsSelfDisableTB = true;
|
||||
|
@ -61,10 +59,9 @@ public class Config
|
|||
{
|
||||
entityInfoMap = new HashMap<String, EntityInfo>();
|
||||
customEntityInfoMap = new HashMap<String, EntityInfo>();
|
||||
customPlayerInfoMap = new HashMap<String, EntityInfo>();
|
||||
ignoreBattleTypes = new HashSet<String>();
|
||||
this.logger = logger;
|
||||
musicBattleTypes = new HashSet<String>();
|
||||
musicSillyTypes = new HashSet<String>();
|
||||
battleIgnoringPlayers = new HashSet<Integer>();
|
||||
possibleIgnoreHurtDamageSources = new HashSet<String>();
|
||||
ignoreHurtDamageSources = new HashSet<String>();
|
||||
|
@ -156,56 +153,6 @@ public class Config
|
|||
{
|
||||
CommentedFileConfig conf = getConfigObj(configFile);
|
||||
|
||||
// client config
|
||||
try {
|
||||
Collection<String> battle_music_categories = conf.get("client_config.battle_music");
|
||||
if (battle_music_categories != null) {
|
||||
for (String category : battle_music_categories) {
|
||||
musicBattleTypes.add(category);
|
||||
}
|
||||
} else {
|
||||
musicBattleTypes.add("monster");
|
||||
musicBattleTypes.add("animal");
|
||||
musicBattleTypes.add("boss");
|
||||
musicBattleTypes.add("player");
|
||||
logNotFound("client_config.battle_music");
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
musicBattleTypes.add("monster");
|
||||
musicBattleTypes.add("animal");
|
||||
musicBattleTypes.add("boss");
|
||||
musicBattleTypes.add("player");
|
||||
logTOMLInvalidValue("client_config.battle_music");
|
||||
}
|
||||
|
||||
try {
|
||||
Collection<String> silly_music_categories = conf.get("client_config.silly_music");
|
||||
if (silly_music_categories != null) {
|
||||
for (String category : silly_music_categories) {
|
||||
musicSillyTypes.add(category);
|
||||
}
|
||||
} else {
|
||||
musicSillyTypes.add("passive");
|
||||
logNotFound("client_config.silly_music");
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
musicSillyTypes.add("passive");
|
||||
logTOMLInvalidValue("client_config.silly_music");
|
||||
}
|
||||
|
||||
try {
|
||||
OptionalInt silly_music_threshold = conf.getOptionalInt("client_config.silly_music_threshold");
|
||||
if(silly_music_threshold.isPresent()) {
|
||||
this.sillyMusicThreshold = silly_music_threshold.getAsInt();
|
||||
} else {
|
||||
this.sillyMusicThreshold = 40;
|
||||
logNotFound("client_config.silly_music_threshold", "40");
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
this.sillyMusicThreshold = 40;
|
||||
logTOMLInvalidValue("client_config.silly_music_threshold", "40");
|
||||
}
|
||||
|
||||
// server_config
|
||||
try {
|
||||
OptionalInt leave_battle_cooldown = conf.getOptionalInt("server_config.leave_battle_cooldown");
|
||||
|
@ -573,23 +520,33 @@ public class Config
|
|||
logger.error("Entity with invalid custom_name (must be a string), skipping...");
|
||||
continue;
|
||||
}
|
||||
} else if (nestedConf.contains("player_name")) {
|
||||
try {
|
||||
eInfo.playerName = nestedConf.get("player_name");
|
||||
name = eInfo.playerName;
|
||||
} catch (ClassCastException e) {
|
||||
logger.error("Entity with invalid player_name (must be a string), skipping...");
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
logger.error("Entity must have \"name\" or \"custom_name\" entry");
|
||||
logger.error("Entity must have \"name\" or \"custom_name\" or \"player_name\" entry");
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
eInfo.attackPower = nestedConf.getInt("attack_power");
|
||||
if(eInfo.attackPower < 0) {
|
||||
logClampedValueEntity("attack_power", name, Integer.toString(eInfo.attackPower), "0");
|
||||
eInfo.attackPower = 0;
|
||||
if (eInfo.playerName.isEmpty()) {
|
||||
try {
|
||||
eInfo.attackPower = nestedConf.getInt("attack_power");
|
||||
if (eInfo.attackPower < 0) {
|
||||
logClampedValueEntity("attack_power", name, Integer.toString(eInfo.attackPower), "0");
|
||||
eInfo.attackPower = 0;
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
logEntityInvalidValue("attack_power", name, "3");
|
||||
eInfo.attackPower = 3;
|
||||
} catch (NullPointerException e) {
|
||||
logEntityMissingRequiredValue("attack_power", name, "3");
|
||||
eInfo.attackPower = 3;
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
logEntityInvalidValue("attack_power", name, "3");
|
||||
eInfo.attackPower = 3;
|
||||
} catch (NullPointerException e) {
|
||||
logEntityMissingRequiredValue("attack_power", name, "3");
|
||||
eInfo.attackPower = 3;
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -637,49 +594,51 @@ public class Config
|
|||
logEntityMissingOptionalValue("attack_effect", name, "unknown");
|
||||
}
|
||||
|
||||
try {
|
||||
eInfo.attackVariance = nestedConf.getInt("attack_variance");
|
||||
if(eInfo.attackVariance < 0) {
|
||||
logClampedValueEntity("attack_variance", name, Integer.toString(eInfo.attackVariance), "0");
|
||||
eInfo.attackVariance = 0;
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
eInfo.attackVariance = 0;
|
||||
logEntityInvalidValue("attack_variance", name, "0");
|
||||
} catch (NullPointerException e) {
|
||||
eInfo.attackVariance = 0;
|
||||
logEntityMissingOptionalValue("attack_variance", name, "0");
|
||||
}
|
||||
|
||||
try {
|
||||
eInfo.defenseDamage = nestedConf.getInt("defense_damage");
|
||||
if(eInfo.defenseDamage < 0) {
|
||||
logClampedValueEntity("defense_damage", name, Integer.toString(eInfo.defenseDamage), "0");
|
||||
eInfo.defenseDamage = 0;
|
||||
} else if(eInfo.defenseDamage != 0) {
|
||||
try {
|
||||
eInfo.defenseDamageProbability = nestedConf.getInt("defense_damage_probability");
|
||||
if(eInfo.defenseDamageProbability < 1) {
|
||||
logClampedValueEntity("defense_damage_probability", name, Integer.toString(eInfo.defenseDamageProbability), "1");
|
||||
eInfo.defenseDamageProbability = 1;
|
||||
} else if(eInfo.defenseDamageProbability > 100) {
|
||||
logClampedValueEntity("defense_damage_probability", name, Integer.toString(eInfo.defenseDamageProbability), "100");
|
||||
eInfo.defenseDamageProbability = 100;
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
eInfo.defenseDamage = 0;
|
||||
logger.warn("Entity \"" + name + "\" has specified defense_damage but defense_damage_probability is invalid, disabling defense_damage");
|
||||
} catch (NullPointerException e) {
|
||||
eInfo.defenseDamage = 0;
|
||||
logger.warn("Entity \"" + name + "\" has specified defense_damage but defense_damage_probability is missing, disabling defense_damage");
|
||||
if (eInfo.playerName.isEmpty()) {
|
||||
try {
|
||||
eInfo.attackVariance = nestedConf.getInt("attack_variance");
|
||||
if (eInfo.attackVariance < 0) {
|
||||
logClampedValueEntity("attack_variance", name, Integer.toString(eInfo.attackVariance), "0");
|
||||
eInfo.attackVariance = 0;
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
eInfo.attackVariance = 0;
|
||||
logEntityInvalidValue("attack_variance", name, "0");
|
||||
} catch (NullPointerException e) {
|
||||
eInfo.attackVariance = 0;
|
||||
logEntityMissingOptionalValue("attack_variance", name, "0");
|
||||
}
|
||||
|
||||
try {
|
||||
eInfo.defenseDamage = nestedConf.getInt("defense_damage");
|
||||
if (eInfo.defenseDamage < 0) {
|
||||
logClampedValueEntity("defense_damage", name, Integer.toString(eInfo.defenseDamage), "0");
|
||||
eInfo.defenseDamage = 0;
|
||||
} else if (eInfo.defenseDamage != 0) {
|
||||
try {
|
||||
eInfo.defenseDamageProbability = nestedConf.getInt("defense_damage_probability");
|
||||
if (eInfo.defenseDamageProbability < 1) {
|
||||
logClampedValueEntity("defense_damage_probability", name, Integer.toString(eInfo.defenseDamageProbability), "1");
|
||||
eInfo.defenseDamageProbability = 1;
|
||||
} else if (eInfo.defenseDamageProbability > 100) {
|
||||
logClampedValueEntity("defense_damage_probability", name, Integer.toString(eInfo.defenseDamageProbability), "100");
|
||||
eInfo.defenseDamageProbability = 100;
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
eInfo.defenseDamage = 0;
|
||||
logger.warn("Entity \"" + name + "\" has specified defense_damage but defense_damage_probability is invalid, disabling defense_damage");
|
||||
} catch (NullPointerException e) {
|
||||
eInfo.defenseDamage = 0;
|
||||
logger.warn("Entity \"" + name + "\" has specified defense_damage but defense_damage_probability is missing, disabling defense_damage");
|
||||
}
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
eInfo.defenseDamage = 0;
|
||||
logEntityInvalidValue("defense_damage", name, "0");
|
||||
} catch (NullPointerException e) {
|
||||
eInfo.defenseDamage = 0;
|
||||
logEntityMissingOptionalValue("defense_damage", name, "0");
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
eInfo.defenseDamage = 0;
|
||||
logEntityInvalidValue("defense_damage", name, "0");
|
||||
} catch (NullPointerException e) {
|
||||
eInfo.defenseDamage = 0;
|
||||
logEntityMissingOptionalValue("defense_damage", name, "0");
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -710,82 +669,106 @@ public class Config
|
|||
}
|
||||
|
||||
try {
|
||||
eInfo.ignoreBattle = nestedConf.get("ignore_battle");
|
||||
eInfo.hasteSpeed = nestedConf.getInt("haste_speed");
|
||||
} catch (ClassCastException e) {
|
||||
logEntityInvalidValue("ignore_battle", name, "false");
|
||||
eInfo.ignoreBattle = false;
|
||||
logEntityInvalidValue("haste_speed", name, "80");
|
||||
eInfo.hasteSpeed = 80;
|
||||
} catch (NullPointerException e) {
|
||||
logEntityMissingRequiredValue("ignore_battle", name, "false");
|
||||
eInfo.ignoreBattle = false;
|
||||
logEntityMissingOptionalValue("haste_speed", name, "80");
|
||||
eInfo.hasteSpeed = 80;
|
||||
}
|
||||
|
||||
try {
|
||||
eInfo.category = nestedConf.get("category");
|
||||
eInfo.slowSpeed = nestedConf.getInt("slow_speed");
|
||||
} catch (ClassCastException e) {
|
||||
logEntityInvalidValue("category", name, "unknown");
|
||||
eInfo.category = "unknown";
|
||||
logEntityInvalidValue("slow_speed", name, "20");
|
||||
eInfo.slowSpeed = 20;
|
||||
} catch (NullPointerException e) {
|
||||
logEntityMissingRequiredValue("category", name, "unknown");
|
||||
eInfo.category = "unknown";
|
||||
logEntityMissingOptionalValue("slow_speed", name, "20");
|
||||
eInfo.slowSpeed = 20;
|
||||
}
|
||||
|
||||
try {
|
||||
eInfo.decisionAttack = nestedConf.getInt("decision_attack_probability");
|
||||
if(eInfo.decisionAttack < 0) {
|
||||
logClampedValueEntity("decision_attack_probability", name, Integer.toString(eInfo.decisionAttack), "0");
|
||||
eInfo.decisionAttack = 0;
|
||||
} else if(eInfo.decisionAttack > 100) {
|
||||
logClampedValueEntity("decision_attack_probability", name, Integer.toString(eInfo.decisionAttack), "100");
|
||||
eInfo.decisionAttack = 100;
|
||||
if (eInfo.playerName.isEmpty()) {
|
||||
try {
|
||||
eInfo.ignoreBattle = nestedConf.get("ignore_battle");
|
||||
} catch (ClassCastException e) {
|
||||
logEntityInvalidValue("ignore_battle", name, "false");
|
||||
eInfo.ignoreBattle = false;
|
||||
} catch (NullPointerException e) {
|
||||
logEntityMissingRequiredValue("ignore_battle", name, "false");
|
||||
eInfo.ignoreBattle = false;
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
logEntityInvalidValue("decision_attack_probability", name, "70");
|
||||
eInfo.decisionAttack = 70;
|
||||
} catch (NullPointerException e) {
|
||||
logEntityMissingRequiredValue("decision_attack_probability", name, "70");
|
||||
eInfo.decisionAttack = 70;
|
||||
}
|
||||
|
||||
try {
|
||||
eInfo.decisionDefend = nestedConf.getInt("decision_defend_probability");
|
||||
if(eInfo.decisionDefend < 0) {
|
||||
logClampedValueEntity("decision_defend_probability", name, Integer.toString(eInfo.decisionDefend), "0");
|
||||
eInfo.decisionDefend = 0;
|
||||
} else if(eInfo.decisionDefend > 100) {
|
||||
logClampedValueEntity("decision_defend_probability", name, Integer.toString(eInfo.decisionDefend), "100");
|
||||
eInfo.decisionDefend = 100;
|
||||
try {
|
||||
eInfo.category = nestedConf.get("category");
|
||||
} catch (ClassCastException e) {
|
||||
logEntityInvalidValue("category", name, "unknown");
|
||||
eInfo.category = "unknown";
|
||||
} catch (NullPointerException e) {
|
||||
logEntityMissingRequiredValue("category", name, "unknown");
|
||||
eInfo.category = "unknown";
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
logEntityInvalidValue("decision_defend_probability", name, "20");
|
||||
eInfo.decisionDefend = 20;
|
||||
} catch (NullPointerException e) {
|
||||
logEntityMissingRequiredValue("decision_defend_probability", name, "20");
|
||||
eInfo.decisionDefend = 20;
|
||||
}
|
||||
|
||||
try {
|
||||
eInfo.decisionFlee = nestedConf.getInt("decision_flee_probability");
|
||||
if(eInfo.decisionFlee < 0) {
|
||||
logClampedValueEntity("decision_flee_probability", name, Integer.toString(eInfo.decisionFlee), "0");
|
||||
eInfo.decisionFlee = 0;
|
||||
} else if(eInfo.decisionFlee > 100) {
|
||||
logClampedValueEntity("decision_flee_probability", name, Integer.toString(eInfo.decisionFlee), "100");
|
||||
eInfo.decisionFlee = 100;
|
||||
try {
|
||||
eInfo.decisionAttack = nestedConf.getInt("decision_attack_probability");
|
||||
if (eInfo.decisionAttack < 0) {
|
||||
logClampedValueEntity("decision_attack_probability", name, Integer.toString(eInfo.decisionAttack), "0");
|
||||
eInfo.decisionAttack = 0;
|
||||
} else if (eInfo.decisionAttack > 100) {
|
||||
logClampedValueEntity("decision_attack_probability", name, Integer.toString(eInfo.decisionAttack), "100");
|
||||
eInfo.decisionAttack = 100;
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
logEntityInvalidValue("decision_attack_probability", name, "70");
|
||||
eInfo.decisionAttack = 70;
|
||||
} catch (NullPointerException e) {
|
||||
logEntityMissingRequiredValue("decision_attack_probability", name, "70");
|
||||
eInfo.decisionAttack = 70;
|
||||
}
|
||||
|
||||
try {
|
||||
eInfo.decisionDefend = nestedConf.getInt("decision_defend_probability");
|
||||
if (eInfo.decisionDefend < 0) {
|
||||
logClampedValueEntity("decision_defend_probability", name, Integer.toString(eInfo.decisionDefend), "0");
|
||||
eInfo.decisionDefend = 0;
|
||||
} else if (eInfo.decisionDefend > 100) {
|
||||
logClampedValueEntity("decision_defend_probability", name, Integer.toString(eInfo.decisionDefend), "100");
|
||||
eInfo.decisionDefend = 100;
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
logEntityInvalidValue("decision_defend_probability", name, "20");
|
||||
eInfo.decisionDefend = 20;
|
||||
} catch (NullPointerException e) {
|
||||
logEntityMissingRequiredValue("decision_defend_probability", name, "20");
|
||||
eInfo.decisionDefend = 20;
|
||||
}
|
||||
|
||||
try {
|
||||
eInfo.decisionFlee = nestedConf.getInt("decision_flee_probability");
|
||||
if (eInfo.decisionFlee < 0) {
|
||||
logClampedValueEntity("decision_flee_probability", name, Integer.toString(eInfo.decisionFlee), "0");
|
||||
eInfo.decisionFlee = 0;
|
||||
} else if (eInfo.decisionFlee > 100) {
|
||||
logClampedValueEntity("decision_flee_probability", name, Integer.toString(eInfo.decisionFlee), "100");
|
||||
eInfo.decisionFlee = 100;
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
logEntityInvalidValue("decision_flee_probability", name, "10");
|
||||
eInfo.decisionFlee = 10;
|
||||
} catch (NullPointerException e) {
|
||||
logEntityMissingRequiredValue("decision_flee_probability", name, "10");
|
||||
eInfo.decisionFlee = 10;
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
logEntityInvalidValue("decision_flee_probability", name, "10");
|
||||
eInfo.decisionFlee = 10;
|
||||
} catch (NullPointerException e) {
|
||||
logEntityMissingRequiredValue("decision_flee_probability", name, "10");
|
||||
eInfo.decisionFlee = 10;
|
||||
}
|
||||
|
||||
if(eInfo.classType != null) {
|
||||
entityInfoMap.put(eInfo.classType.getName(), eInfo);
|
||||
} else if(!eInfo.customName.isEmpty()) {
|
||||
customEntityInfoMap.put(eInfo.customName, eInfo);
|
||||
} else if (!eInfo.playerName.isEmpty()) {
|
||||
customPlayerInfoMap.put(eInfo.playerName, eInfo);
|
||||
} else {
|
||||
logger.error("Cannot add entity to internal config, no \"name\" or \"custom_name\"");
|
||||
logger.error("Cannot add entity to internal config, no \"name\" or \"custom_name\" or \"player_name\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -851,6 +834,8 @@ public class Config
|
|||
newConf.set("defense_damage_probability", eInfo.defenseDamageProbability);
|
||||
newConf.set("evasion", eInfo.evasion);
|
||||
newConf.set("speed", eInfo.speed);
|
||||
newConf.set("haste_speed", eInfo.hasteSpeed);
|
||||
newConf.set("slow_speed", eInfo.slowSpeed);
|
||||
newConf.set("ignore_battle", eInfo.ignoreBattle);
|
||||
newConf.set("category", eInfo.category);
|
||||
newConf.set("decision_attack_probability", eInfo.decisionAttack);
|
||||
|
@ -880,9 +865,11 @@ public class Config
|
|||
|
||||
boolean saved = false;
|
||||
try {
|
||||
if (eInfo.classType != null || !eInfo.customName.isEmpty()) {
|
||||
if (eInfo.classType != null || !eInfo.customName.isEmpty() || !eInfo.playerName.isEmpty()) {
|
||||
for (com.electronwill.nightconfig.core.Config entity : entities) {
|
||||
String entityName = entity.get("name");
|
||||
String customName = entity.get("custom_name");
|
||||
String playerName = entity.get("player_name");
|
||||
if ((eInfo.classType != null && entityName != null && entityName.equals(eInfo.classType.getName()))) {
|
||||
entity.set("attack_power", eInfo.attackPower);
|
||||
entity.set("attack_probability", eInfo.attackProbability);
|
||||
|
@ -893,6 +880,8 @@ public class Config
|
|||
entity.set("defense_damage_probability", eInfo.defenseDamageProbability);
|
||||
entity.set("evasion", eInfo.evasion);
|
||||
entity.set("speed", eInfo.speed);
|
||||
entity.set("haste_speed", eInfo.hasteSpeed);
|
||||
entity.set("slow_speed", eInfo.slowSpeed);
|
||||
entity.set("ignore_battle", eInfo.ignoreBattle);
|
||||
entity.set("category", eInfo.category);
|
||||
entity.set("decision_attack_probability", eInfo.decisionAttack);
|
||||
|
@ -900,26 +889,35 @@ public class Config
|
|||
entity.set("decision_flee_probability", eInfo.decisionFlee);
|
||||
saved = true;
|
||||
break;
|
||||
} else {
|
||||
String customName = entity.get("custom_name");
|
||||
if(!eInfo.customName.isEmpty() && customName != null && customName.equals(eInfo.customName)) {
|
||||
entity.set("attack_power", eInfo.attackPower);
|
||||
entity.set("attack_probability", eInfo.attackProbability);
|
||||
entity.set("attack_variance", eInfo.attackVariance);
|
||||
entity.set("attack_effect", eInfo.attackEffect.toString());
|
||||
entity.set("attack_effect_probability", eInfo.attackEffectProbability);
|
||||
entity.set("defense_damage", eInfo.defenseDamage);
|
||||
entity.set("defense_damage_probability", eInfo.defenseDamageProbability);
|
||||
entity.set("evasion", eInfo.evasion);
|
||||
entity.set("speed", eInfo.speed);
|
||||
entity.set("ignore_battle", eInfo.ignoreBattle);
|
||||
entity.set("category", eInfo.category);
|
||||
entity.set("decision_attack_probability", eInfo.decisionAttack);
|
||||
entity.set("decision_defend_probability", eInfo.decisionDefend);
|
||||
entity.set("decision_flee_probability", eInfo.decisionFlee);
|
||||
saved = true;
|
||||
break;
|
||||
}
|
||||
} else if (!eInfo.customName.isEmpty() && customName != null && customName.equals(eInfo.customName)) {
|
||||
entity.set("attack_power", eInfo.attackPower);
|
||||
entity.set("attack_probability", eInfo.attackProbability);
|
||||
entity.set("attack_variance", eInfo.attackVariance);
|
||||
entity.set("attack_effect", eInfo.attackEffect.toString());
|
||||
entity.set("attack_effect_probability", eInfo.attackEffectProbability);
|
||||
entity.set("defense_damage", eInfo.defenseDamage);
|
||||
entity.set("defense_damage_probability", eInfo.defenseDamageProbability);
|
||||
entity.set("evasion", eInfo.evasion);
|
||||
entity.set("speed", eInfo.speed);
|
||||
entity.set("haste_speed", eInfo.hasteSpeed);
|
||||
entity.set("slow_speed", eInfo.slowSpeed);
|
||||
entity.set("ignore_battle", eInfo.ignoreBattle);
|
||||
entity.set("category", eInfo.category);
|
||||
entity.set("decision_attack_probability", eInfo.decisionAttack);
|
||||
entity.set("decision_defend_probability", eInfo.decisionDefend);
|
||||
entity.set("decision_flee_probability", eInfo.decisionFlee);
|
||||
saved = true;
|
||||
break;
|
||||
} else if (!eInfo.playerName.isEmpty() && playerName != null && playerName.equals(eInfo.playerName)) {
|
||||
entity.set("attack_probability", eInfo.attackProbability);
|
||||
entity.set("attack_effect", eInfo.attackEffect.toString());
|
||||
entity.set("attack_effect_probability", eInfo.attackEffectProbability);
|
||||
entity.set("evasion", eInfo.evasion);
|
||||
entity.set("speed", eInfo.speed);
|
||||
entity.set("haste_speed", eInfo.hasteSpeed);
|
||||
entity.set("slow_speed", eInfo.slowSpeed);
|
||||
saved = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!saved) {
|
||||
|
@ -928,25 +926,38 @@ public class Config
|
|||
newEntry.set("name", eInfo.classType.getName());
|
||||
} else if(!eInfo.customName.isEmpty()) {
|
||||
newEntry.set("custom_name", eInfo.customName);
|
||||
} else if (!eInfo.playerName.isEmpty()) {
|
||||
newEntry.set("player_name", eInfo.playerName);
|
||||
} else {
|
||||
logger.error("Failed to save new entity entry into config, no name or custom_name");
|
||||
conf.close();
|
||||
return false;
|
||||
}
|
||||
newEntry.set("attack_power", eInfo.attackPower);
|
||||
|
||||
if (eInfo.playerName.isEmpty()) {
|
||||
newEntry.set("attack_power", eInfo.attackPower);
|
||||
}
|
||||
newEntry.set("attack_probability", eInfo.attackProbability);
|
||||
newEntry.set("attack_variance", eInfo.attackVariance);
|
||||
if (eInfo.playerName.isEmpty()) {
|
||||
newEntry.set("attack_variance", eInfo.attackVariance);
|
||||
}
|
||||
newEntry.set("attack_effect", eInfo.attackEffect.toString());
|
||||
newEntry.set("attack_effect_probability", eInfo.attackEffectProbability);
|
||||
newEntry.set("defense_damage", eInfo.defenseDamage);
|
||||
newEntry.set("defense_damage_probability", eInfo.defenseDamageProbability);
|
||||
if (eInfo.playerName.isEmpty()) {
|
||||
newEntry.set("defense_damage", eInfo.defenseDamage);
|
||||
newEntry.set("defense_damage_probability", eInfo.defenseDamageProbability);
|
||||
}
|
||||
newEntry.set("evasion", eInfo.evasion);
|
||||
newEntry.set("speed", eInfo.speed);
|
||||
newEntry.set("ignore_battle", eInfo.ignoreBattle);
|
||||
newEntry.set("category", eInfo.category);
|
||||
newEntry.set("decision_attack_probability", eInfo.decisionAttack);
|
||||
newEntry.set("decision_defend_probability", eInfo.decisionDefend);
|
||||
newEntry.set("decision_flee_probability", eInfo.decisionFlee);
|
||||
newEntry.set("haste_speed", eInfo.hasteSpeed);
|
||||
newEntry.set("slow_speed", eInfo.slowSpeed);
|
||||
if (eInfo.playerName.isEmpty()) {
|
||||
newEntry.set("ignore_battle", eInfo.ignoreBattle);
|
||||
newEntry.set("category", eInfo.category);
|
||||
newEntry.set("decision_attack_probability", eInfo.decisionAttack);
|
||||
newEntry.set("decision_defend_probability", eInfo.decisionDefend);
|
||||
newEntry.set("decision_flee_probability", eInfo.decisionFlee);
|
||||
}
|
||||
entities.add(newEntry);
|
||||
saved = true;
|
||||
}
|
||||
|
@ -971,8 +982,10 @@ public class Config
|
|||
|
||||
if(eInfo.classType != null) {
|
||||
entityInfoMap.put(eInfo.classType.getName(), eInfo);
|
||||
} else if(!eInfo.customName.isEmpty()){
|
||||
} else if(!eInfo.customName.isEmpty()) {
|
||||
customEntityInfoMap.put(eInfo.customName, eInfo);
|
||||
} else if (!eInfo.playerName.isEmpty()) {
|
||||
customPlayerInfoMap.put(eInfo.playerName, eInfo);
|
||||
} else {
|
||||
logger.warn("Failed to update entity info in memory");
|
||||
}
|
||||
|
@ -1152,6 +1165,22 @@ public class Config
|
|||
return eInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of an EntityInfo (to prevent editing it).
|
||||
* @param playerName
|
||||
* @return a clone of the stored custom EntityInfo or null if invalid String
|
||||
*/
|
||||
public EntityInfo getPlayerInfo(String playerName) {
|
||||
if (playerName == null) {
|
||||
return null;
|
||||
}
|
||||
EntityInfo eInfo = customPlayerInfoMap.get(playerName);
|
||||
if (eInfo != null) {
|
||||
eInfo = eInfo.clone();
|
||||
}
|
||||
return eInfo;
|
||||
}
|
||||
|
||||
protected EntityInfo getCustomEntityInfoReference(String customName)
|
||||
{
|
||||
if(customName == null) {
|
||||
|
@ -1160,6 +1189,13 @@ public class Config
|
|||
return customEntityInfoMap.get(customName);
|
||||
}
|
||||
|
||||
protected EntityInfo getPlayerInfoReference(String playerName) {
|
||||
if (playerName == null) {
|
||||
return null;
|
||||
}
|
||||
return customPlayerInfoMap.get(playerName);
|
||||
}
|
||||
|
||||
private int getConfigFileVersion(File configFile)
|
||||
{
|
||||
int version = 0;
|
||||
|
@ -1328,16 +1364,6 @@ public class Config
|
|||
this.maxInBattle = maxInBattle;
|
||||
}
|
||||
|
||||
public boolean isBattleMusicType(String type)
|
||||
{
|
||||
return musicBattleTypes.contains(type.toLowerCase());
|
||||
}
|
||||
|
||||
public boolean isSillyMusicType(String type)
|
||||
{
|
||||
return musicSillyTypes.contains(type.toLowerCase());
|
||||
}
|
||||
|
||||
public boolean isFreezeCombatantsEnabled()
|
||||
{
|
||||
return freezeCombatantsInBattle;
|
||||
|
@ -1347,11 +1373,6 @@ public class Config
|
|||
freezeCombatantsInBattle = enabled;
|
||||
}
|
||||
|
||||
public int getSillyMusicThreshold()
|
||||
{
|
||||
return sillyMusicThreshold;
|
||||
}
|
||||
|
||||
public int getConfigVersion()
|
||||
{
|
||||
return configVersion;
|
||||
|
|
|
@ -15,8 +15,8 @@ public class DimensionChangedHandler {
|
|||
if(TurnBasedMinecraftMod.proxy.getBattleManager().forceLeaveBattle(new EntityIDDimPair(event.getEntity()))
|
||||
&& event.getEntity() instanceof ServerPlayer) {
|
||||
TurnBasedMinecraftMod.getHandler().send(
|
||||
PacketDistributor.PLAYER.with(() -> (ServerPlayer)event.getEntity()),
|
||||
new PacketGeneralMessage("Left battle due to moving to a different dimension"));
|
||||
new PacketGeneralMessage("Left battle due to moving to a different dimension"),
|
||||
PacketDistributor.PLAYER.with((ServerPlayer)event.getEntity()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ public class EditingInfo
|
|||
public EntityInfo entityInfo;
|
||||
public boolean isPendingEntitySelection;
|
||||
public boolean isEditingCustomName;
|
||||
public boolean isEditingPlayer;
|
||||
|
||||
public EditingInfo()
|
||||
{
|
||||
|
@ -15,6 +16,7 @@ public class EditingInfo
|
|||
entityInfo = null;
|
||||
isPendingEntitySelection = true;
|
||||
isEditingCustomName = false;
|
||||
isEditingPlayer = false;
|
||||
}
|
||||
|
||||
public EditingInfo(Player player)
|
||||
|
@ -23,5 +25,6 @@ public class EditingInfo
|
|||
entityInfo = null;
|
||||
isPendingEntitySelection = true;
|
||||
isEditingCustomName = false;
|
||||
isEditingPlayer = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,12 +17,15 @@ public class EntityInfo
|
|||
public int defenseDamageProbability;
|
||||
public int evasion;
|
||||
public int speed;
|
||||
public int hasteSpeed;
|
||||
public int slowSpeed;
|
||||
public String category;
|
||||
public int decisionAttack;
|
||||
public int decisionDefend;
|
||||
public int decisionFlee;
|
||||
public String customName;
|
||||
|
||||
public String playerName;
|
||||
|
||||
public enum Effect
|
||||
{
|
||||
SPEED,
|
||||
|
@ -276,7 +279,7 @@ public class EntityInfo
|
|||
{
|
||||
if(this == FIRE)
|
||||
{
|
||||
entity.setSecondsOnFire(duration / 20);
|
||||
entity.setRemainingFireTicks(duration / 2);
|
||||
return;
|
||||
}
|
||||
else if(this != UNKNOWN)
|
||||
|
@ -366,11 +369,39 @@ public class EntityInfo
|
|||
defenseDamageProbability = 0;
|
||||
evasion = 15;
|
||||
speed = 50;
|
||||
hasteSpeed = 80;
|
||||
slowSpeed = 20;
|
||||
category = "unknown";
|
||||
decisionAttack = 70;
|
||||
decisionDefend = 20;
|
||||
decisionFlee = 10;
|
||||
customName = new String();
|
||||
customName = "";
|
||||
playerName = "";
|
||||
}
|
||||
|
||||
public EntityInfo(Class classType, boolean ignoreBattle, int attackPower, int attackProbability, int attackVariance,
|
||||
Effect attackEffect, int attackEffectProbability, int defenseDamage, int defenseDamageProbability,
|
||||
int evasion, int speed, int hasteSpeed, int slowSpeed, String category, int decisionAttack, int decisionDefend, int decisionFlee,
|
||||
String customName, String playerName) {
|
||||
this.classType = classType;
|
||||
this.ignoreBattle = ignoreBattle;
|
||||
this.attackPower = attackPower;
|
||||
this.attackProbability = attackProbability;
|
||||
this.attackVariance = attackVariance;
|
||||
this.attackEffect = attackEffect;
|
||||
this.attackEffectProbability = attackEffectProbability;
|
||||
this.defenseDamage = defenseDamage;
|
||||
this.defenseDamageProbability = defenseDamageProbability;
|
||||
this.evasion = evasion;
|
||||
this.speed = speed;
|
||||
this.hasteSpeed = hasteSpeed;
|
||||
this.slowSpeed = slowSpeed;
|
||||
this.category = category;
|
||||
this.decisionAttack = decisionAttack;
|
||||
this.decisionDefend = decisionDefend;
|
||||
this.decisionFlee = decisionFlee;
|
||||
this.customName = customName;
|
||||
this.playerName = playerName;
|
||||
}
|
||||
|
||||
public EntityInfo clone()
|
||||
|
@ -387,11 +418,14 @@ public class EntityInfo
|
|||
newEntityInfo.defenseDamageProbability = defenseDamageProbability;
|
||||
newEntityInfo.evasion = evasion;
|
||||
newEntityInfo.speed = speed;
|
||||
newEntityInfo.hasteSpeed = hasteSpeed;
|
||||
newEntityInfo.slowSpeed = slowSpeed;
|
||||
newEntityInfo.category = category;
|
||||
newEntityInfo.decisionAttack = decisionAttack;
|
||||
newEntityInfo.decisionDefend = decisionDefend;
|
||||
newEntityInfo.decisionFlee = decisionFlee;
|
||||
newEntityInfo.customName = new String(customName);
|
||||
newEntityInfo.customName = customName;
|
||||
newEntityInfo.playerName = playerName;
|
||||
return newEntityInfo;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.common;
|
||||
|
||||
import com.burnedkirby.TurnBasedMinecraft.client.ClientConfig;
|
||||
import com.burnedkirby.TurnBasedMinecraft.client.ClientProxy;
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.networking.*;
|
||||
import com.mojang.brigadier.LiteralMessage;
|
||||
|
@ -25,13 +26,12 @@ import net.minecraftforge.event.server.ServerStoppingEvent;
|
|||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.network.NetworkRegistry;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
import net.minecraftforge.network.simple.SimpleChannel;
|
||||
import net.minecraftforge.network.*;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
@ -39,7 +39,7 @@ import org.apache.logging.log4j.Logger;
|
|||
public class TurnBasedMinecraftMod {
|
||||
public static final String MODID = "com_burnedkirby_turnbasedminecraft";
|
||||
public static final String NAME = "Turn Based Minecraft Mod";
|
||||
public static final String VERSION = "1.23.1";
|
||||
public static final String VERSION = "1.26.4";
|
||||
public static final String CONFIG_FILENAME = "TBM_Config.toml";
|
||||
public static final String DEFAULT_CONFIG_FILENAME = "TBM_Config_DEFAULT.toml";
|
||||
public static final String CONFIG_DIRECTORY = "config/TurnBasedMinecraft/";
|
||||
|
@ -50,13 +50,14 @@ public class TurnBasedMinecraftMod {
|
|||
public static final String MUSIC_SILLY = MUSIC_ROOT + "silly/";
|
||||
public static final String MUSIC_BATTLE = MUSIC_ROOT + "battle/";
|
||||
|
||||
private static final String PROTOCOL_VERSION = Integer.toString(2);
|
||||
private static final ResourceLocation HANDLER_ID = new ResourceLocation(MODID, "main_channel");
|
||||
private static final SimpleChannel HANDLER = NetworkRegistry.ChannelBuilder
|
||||
private static final Integer PROTOCOL_VERSION = 5;
|
||||
private static final ResourceLocation HANDLER_ID = ResourceLocation.fromNamespaceAndPath(MODID, "main_channel");
|
||||
|
||||
private static final SimpleChannel HANDLER = ChannelBuilder
|
||||
.named(HANDLER_ID)
|
||||
.clientAcceptedVersions(PROTOCOL_VERSION::equals)
|
||||
.serverAcceptedVersions(PROTOCOL_VERSION::equals)
|
||||
.networkProtocolVersion(() -> PROTOCOL_VERSION)
|
||||
.clientAcceptedVersions(Channel.VersionTest.exact(PROTOCOL_VERSION))
|
||||
.serverAcceptedVersions(Channel.VersionTest.exact(PROTOCOL_VERSION))
|
||||
.networkProtocolVersion(PROTOCOL_VERSION)
|
||||
.simpleChannel();
|
||||
protected static Logger logger = LogManager.getLogger();
|
||||
|
||||
|
@ -70,57 +71,62 @@ public class TurnBasedMinecraftMod {
|
|||
|
||||
public static CommonProxy proxy;
|
||||
|
||||
public TurnBasedMinecraftMod() {
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::firstInit);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::secondInitClient);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::secondInitServer);
|
||||
public TurnBasedMinecraftMod(FMLJavaModLoadingContext ctx) {
|
||||
ctx.getModEventBus().addListener(this::firstInit);
|
||||
ctx.getModEventBus().addListener(this::secondInitClient);
|
||||
ctx.getModEventBus().addListener(this::secondInitServer);
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
ctx.registerConfig(ModConfig.Type.CLIENT, ClientConfig.CLIENT_SPEC);
|
||||
}
|
||||
|
||||
private void firstInit(final FMLCommonSetupEvent event) {
|
||||
proxy = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> CommonProxy::new);
|
||||
proxy = DistExecutor.unsafeRunForDist(() -> () -> new ClientProxy(), () -> () -> new CommonProxy());
|
||||
proxy.setLogger(logger);
|
||||
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);
|
||||
HANDLER.messageBuilder(PacketBattleInfo.class, NetworkDirection.PLAY_TO_CLIENT)
|
||||
.encoder(new PacketBattleInfo.Encoder())
|
||||
.decoder(new PacketBattleInfo.Decoder())
|
||||
.consumerNetworkThread(new PacketBattleInfo.Consumer())
|
||||
.add();
|
||||
HANDLER.messageBuilder(PacketBattleRequestInfo.class, NetworkDirection.PLAY_TO_SERVER)
|
||||
.encoder(new PacketBattleRequestInfo.Encoder())
|
||||
.decoder(new PacketBattleRequestInfo.Decoder())
|
||||
.consumerNetworkThread(new PacketBattleRequestInfo.Consumer())
|
||||
.add();
|
||||
HANDLER.messageBuilder(PacketBattleDecision.class, NetworkDirection.PLAY_TO_SERVER)
|
||||
.encoder(new PacketBattleDecision.Encoder())
|
||||
.decoder(new PacketBattleDecision.Decoder())
|
||||
.consumerNetworkThread(new PacketBattleDecision.Consumer())
|
||||
.add();
|
||||
HANDLER.messageBuilder(PacketBattleMessage.class, NetworkDirection.PLAY_TO_CLIENT)
|
||||
.encoder(new PacketBattleMessage.Encoder())
|
||||
.decoder(new PacketBattleMessage.Decoder())
|
||||
.consumerNetworkThread(new PacketBattleMessage.Consumer())
|
||||
.add();
|
||||
HANDLER.messageBuilder(PacketGeneralMessage.class, NetworkDirection.PLAY_TO_CLIENT)
|
||||
.encoder(new PacketGeneralMessage.Encoder())
|
||||
.decoder(new PacketGeneralMessage.Decoder())
|
||||
.consumerNetworkThread(new PacketGeneralMessage.Consumer())
|
||||
.add();
|
||||
HANDLER.messageBuilder(PacketEditingMessage.class, NetworkDirection.PLAY_TO_CLIENT)
|
||||
.encoder(new PacketEditingMessage.Encoder())
|
||||
.decoder(new PacketEditingMessage.Decoder())
|
||||
.consumerNetworkThread(new PacketEditingMessage.Consumer())
|
||||
.add();
|
||||
HANDLER.messageBuilder(PacketClientGui.class, NetworkDirection.PLAY_TO_CLIENT)
|
||||
.encoder(new PacketClientGui.Encoder())
|
||||
.decoder(new PacketClientGui.Decoder())
|
||||
.consumerNetworkThread(new PacketClientGui.Consumer())
|
||||
.add();
|
||||
HANDLER.messageBuilder(PacketBattlePing.class, NetworkDirection.PLAY_TO_CLIENT)
|
||||
.encoder(new PacketBattlePing.Encoder())
|
||||
.decoder(new PacketBattlePing.Decoder())
|
||||
.consumerNetworkThread(new PacketBattlePing.Consumer())
|
||||
.add();
|
||||
|
||||
// register event handler(s)
|
||||
MinecraftForge.EVENT_BUS.register(new AttackEventHandler());
|
||||
|
@ -172,7 +178,7 @@ public class TurnBasedMinecraftMod {
|
|||
proxy.getConfig().setBattleDisabledForAll(true);
|
||||
for (ServerPlayer player : c.getSource().getServer().getPlayerList().getPlayers()) {
|
||||
proxy.getConfig().addBattleIgnoringPlayer(player.getId());
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP disabled turn-based-combat for everyone"));
|
||||
getHandler().send(new PacketGeneralMessage("OP disabled turn-based-combat for everyone"), PacketDistributor.PLAYER.with(player));
|
||||
}
|
||||
return 1;
|
||||
}));
|
||||
|
@ -193,7 +199,7 @@ public class TurnBasedMinecraftMod {
|
|||
proxy.getConfig().setBattleDisabledForAll(false);
|
||||
proxy.getConfig().clearBattleIgnoringPlayers();
|
||||
for (ServerPlayer player : c.getSource().getServer().getPlayerList().getPlayers()) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP enabled turn-based-combat for everyone"));
|
||||
getHandler().send(new PacketGeneralMessage("OP enabled turn-based-combat for everyone"), PacketDistributor.PLAYER.with(player));
|
||||
}
|
||||
return 1;
|
||||
}));
|
||||
|
@ -204,7 +210,7 @@ public class TurnBasedMinecraftMod {
|
|||
.then(Commands.argument("targets", EntityArgument.players()).executes(c -> {
|
||||
for (ServerPlayer player : EntityArgument.getPlayers(c, "targets")) {
|
||||
proxy.getConfig().addBattleIgnoringPlayer(player.getId());
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP enabled turn-based-combat for you"));
|
||||
getHandler().send(new PacketGeneralMessage("OP enabled turn-based-combat for you"), PacketDistributor.PLAYER.with(player));
|
||||
c.getSource().sendSuccess(() -> Component.literal("Enabled turn-based-combat for " + player.getDisplayName().getString()), true);
|
||||
}
|
||||
return 1;
|
||||
|
@ -216,7 +222,7 @@ public class TurnBasedMinecraftMod {
|
|||
.then(Commands.argument("targets", EntityArgument.players()).executes(c -> {
|
||||
for (ServerPlayer player : EntityArgument.getPlayers(c, "targets")) {
|
||||
proxy.getConfig().removeBattleIgnoringPlayer(player.getId());
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP disabled turn-based-combat for you"));
|
||||
getHandler().send(new PacketGeneralMessage("OP disabled turn-based-combat for you"), PacketDistributor.PLAYER.with(player));
|
||||
c.getSource().sendSuccess(() -> Component.literal("Disabled turn-based-combat for " + player.getDisplayName().getString()), true);
|
||||
}
|
||||
return 1;
|
||||
|
@ -229,12 +235,12 @@ public class TurnBasedMinecraftMod {
|
|||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
EditingInfo editingInfo = proxy.getEditingInfo(player.getId());
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
proxy.setEditingPlayer(player);
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
logger.info("Begin editing TBM Entity for player \"" + player.getDisplayName().getString() + "\" (\"" + c.getSource().getDisplayName() + "\")");
|
||||
}
|
||||
return 1;
|
||||
|
@ -245,14 +251,14 @@ public class TurnBasedMinecraftMod {
|
|||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
if (!proxy.getConfig().editEntityEntry(editingInfo.entityInfo)) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("An error occurred while attempting to save an entry to the config"));
|
||||
getHandler().send(new PacketGeneralMessage("An error occurred while attempting to save an entry to the config"), PacketDistributor.PLAYER.with(player));
|
||||
proxy.removeEditingInfo(player.getId());
|
||||
} else {
|
||||
proxy.removeEditingInfo(player.getId());
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("Entity info saved in config and loaded."));
|
||||
getHandler().send(new PacketGeneralMessage("Entity info saved in config and loaded."), PacketDistributor.PLAYER.with(player));
|
||||
}
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -265,7 +271,7 @@ public class TurnBasedMinecraftMod {
|
|||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
if (editingInfo != null) {
|
||||
proxy.removeEditingInfo(player.getId());
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("Cancelled editing entry."));
|
||||
getHandler().send(new PacketGeneralMessage("Cancelled editing entry."), PacketDistributor.PLAYER.with(player));
|
||||
}
|
||||
return 1;
|
||||
}))
|
||||
|
@ -277,23 +283,47 @@ public class TurnBasedMinecraftMod {
|
|||
Message exceptionMessage = new LiteralMessage("Invalid action for tbm-edit");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
proxy.setEditingPlayer(player);
|
||||
proxy.getEditingInfo(player.getId()).isEditingCustomName = true;
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
logger.info("Begin editing custom TBM Entity for player \"" + player.getDisplayName().getString() + "\" (\"" + c.getSource().getDisplayName() + "\")");
|
||||
}
|
||||
return 1;
|
||||
}))
|
||||
.then(Commands.literal("player")
|
||||
.executes(c -> {
|
||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_PLAYER), PacketDistributor.PLAYER.with(player));
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.argument("playerName", StringArgumentType.greedyString()).executes(c -> {
|
||||
String name = StringArgumentType.getString(c, "playerName");
|
||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
getHandler().send(new PacketGeneralMessage("Editing player \"" + name + "\""), PacketDistributor.PLAYER.with(player));
|
||||
TurnBasedMinecraftMod.logger.info("Begin editing player \"" + name + "\"");
|
||||
proxy.setEditingPlayer(player);
|
||||
EditingInfo editInfo = proxy.getEditingInfo(player.getId());
|
||||
editInfo.isEditingPlayer = true;
|
||||
editInfo.entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getPlayerInfo(name);
|
||||
if (editInfo.entityInfo == null) {
|
||||
editInfo.entityInfo = new EntityInfo();
|
||||
}
|
||||
editInfo.entityInfo.playerName = name;
|
||||
editInfo.isPendingEntitySelection = false;
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||
return 1;
|
||||
}))
|
||||
)
|
||||
.then(Commands.literal("edit")
|
||||
.executes(c -> {
|
||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -305,9 +335,9 @@ public class TurnBasedMinecraftMod {
|
|||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_IGNORE_BATTLE));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_IGNORE_BATTLE), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -321,9 +351,9 @@ public class TurnBasedMinecraftMod {
|
|||
boolean ignoreBattle = BoolArgumentType.getBool(c, "ignoreBattle");
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
editingInfo.entityInfo.ignoreBattle = ignoreBattle;
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -336,9 +366,9 @@ public class TurnBasedMinecraftMod {
|
|||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_POWER));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_POWER), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -355,9 +385,9 @@ public class TurnBasedMinecraftMod {
|
|||
}
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
editingInfo.entityInfo.attackPower = attackPower;
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -370,9 +400,9 @@ public class TurnBasedMinecraftMod {
|
|||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_PROBABILITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_PROBABILITY), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -391,9 +421,9 @@ public class TurnBasedMinecraftMod {
|
|||
}
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
editingInfo.entityInfo.attackProbability = attackProbability;
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -406,9 +436,9 @@ public class TurnBasedMinecraftMod {
|
|||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_VARIANCE));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_VARIANCE), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -425,9 +455,9 @@ public class TurnBasedMinecraftMod {
|
|||
}
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
editingInfo.entityInfo.attackVariance = attackVariance;
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -440,9 +470,9 @@ public class TurnBasedMinecraftMod {
|
|||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -456,9 +486,9 @@ public class TurnBasedMinecraftMod {
|
|||
EntityInfo.Effect effect = EntityInfo.Effect.fromString(StringArgumentType.getString(c, "attackEffect"));
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
editingInfo.entityInfo.attackEffect = effect;
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -471,9 +501,9 @@ public class TurnBasedMinecraftMod {
|
|||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT_PROBABILITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT_PROBABILITY), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -492,9 +522,9 @@ public class TurnBasedMinecraftMod {
|
|||
}
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
editingInfo.entityInfo.attackEffectProbability = attackEffectProbability;
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -507,9 +537,9 @@ public class TurnBasedMinecraftMod {
|
|||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -526,9 +556,9 @@ public class TurnBasedMinecraftMod {
|
|||
}
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
editingInfo.entityInfo.defenseDamage = defenseDamage;
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -541,9 +571,9 @@ public class TurnBasedMinecraftMod {
|
|||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE_PROBABILITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE_PROBABILITY), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -562,9 +592,9 @@ public class TurnBasedMinecraftMod {
|
|||
}
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
editingInfo.entityInfo.defenseDamageProbability = defenseDamageProbability;
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -577,9 +607,9 @@ public class TurnBasedMinecraftMod {
|
|||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_EVASION));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_EVASION), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -598,9 +628,9 @@ public class TurnBasedMinecraftMod {
|
|||
}
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
editingInfo.entityInfo.evasion = evasion;
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -609,32 +639,66 @@ public class TurnBasedMinecraftMod {
|
|||
}))
|
||||
)
|
||||
.then(Commands.literal("speed")
|
||||
.executes(c -> {
|
||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SPEED), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
}
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.argument("speed", IntegerArgumentType.integer())
|
||||
.executes(c -> {
|
||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
int speed = IntegerArgumentType.getInteger(c, "speed");
|
||||
if (speed < 0) {
|
||||
speed = 0;
|
||||
}
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
editingInfo.entityInfo.speed = speed;
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
}
|
||||
return 1;
|
||||
}))
|
||||
)
|
||||
.then(Commands.literal("hasteSpeed")
|
||||
.executes(c -> {
|
||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SPEED));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_HASTE_SPEED), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
}
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.argument("speed", IntegerArgumentType.integer())
|
||||
.then(Commands.argument("hasteSpeed", IntegerArgumentType.integer())
|
||||
.executes(c -> {
|
||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
int speed = IntegerArgumentType.getInteger(c, "speed");
|
||||
if (speed < 0) {
|
||||
speed = 0;
|
||||
int hasteSpeed = IntegerArgumentType.getInteger(c, "hasteSpeed");
|
||||
if (hasteSpeed < 0) {
|
||||
hasteSpeed = 0;
|
||||
}
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
editingInfo.entityInfo.speed = speed;
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||
editingInfo.entityInfo.hasteSpeed = hasteSpeed;
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -642,14 +706,48 @@ public class TurnBasedMinecraftMod {
|
|||
return 1;
|
||||
}))
|
||||
)
|
||||
.then(Commands.literal("slowSpeed")
|
||||
.executes(c -> {
|
||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SLOW_SPEED), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
}
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.argument("slowSpeed", IntegerArgumentType.integer())
|
||||
.executes(c -> {
|
||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
int slowSpeed = IntegerArgumentType.getInteger(c, "slowSpeed");
|
||||
if (slowSpeed < 0) {
|
||||
slowSpeed = 0;
|
||||
}
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
editingInfo.entityInfo.slowSpeed = slowSpeed;
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
}
|
||||
return 1;
|
||||
}))
|
||||
)
|
||||
.then(Commands.literal("category")
|
||||
.executes(c -> {
|
||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_CATEGORY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_CATEGORY), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -663,9 +761,9 @@ public class TurnBasedMinecraftMod {
|
|||
String category = StringArgumentType.getString(c, "category");
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
editingInfo.entityInfo.category = category;
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -678,9 +776,9 @@ public class TurnBasedMinecraftMod {
|
|||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_ATTACK));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_ATTACK), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -699,9 +797,9 @@ public class TurnBasedMinecraftMod {
|
|||
}
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
editingInfo.entityInfo.decisionAttack = decisionAttack;
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -714,9 +812,9 @@ public class TurnBasedMinecraftMod {
|
|||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_DEFEND));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_DEFEND), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -735,9 +833,9 @@ public class TurnBasedMinecraftMod {
|
|||
}
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
editingInfo.entityInfo.decisionDefend = decisionDefend;
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -750,9 +848,9 @@ public class TurnBasedMinecraftMod {
|
|||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_FLEE));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_FLEE), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -766,9 +864,9 @@ public class TurnBasedMinecraftMod {
|
|||
int decisionFlee = IntegerArgumentType.getInteger(c, "decisionFlee");
|
||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||
editingInfo.entityInfo.decisionFlee = decisionFlee;
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), PacketDistributor.PLAYER.with(player));
|
||||
} else if (editingInfo != null) {
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), PacketDistributor.PLAYER.with(player));
|
||||
} else {
|
||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||
|
@ -784,7 +882,7 @@ public class TurnBasedMinecraftMod {
|
|||
.requires(c -> c.hasPermission(2))
|
||||
.executes(c -> {
|
||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.SERVER_EDIT));
|
||||
getHandler().send(new PacketEditingMessage(PacketEditingMessage.Type.SERVER_EDIT), PacketDistributor.PLAYER.with(player));
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.literal("leave_battle_cooldown").executes(c -> {
|
||||
|
@ -1691,6 +1789,15 @@ public class TurnBasedMinecraftMod {
|
|||
return 1;
|
||||
})))
|
||||
);
|
||||
|
||||
// tbm-client-edit
|
||||
event.getDispatcher().register(
|
||||
Commands.literal("tbm-client-edit").executes(c -> {
|
||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
getHandler().send(new PacketClientGui(), PacketDistributor.PLAYER.with(player));
|
||||
return 1;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.common;
|
||||
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ArrowItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
public class Utility
|
||||
|
@ -59,7 +61,11 @@ public class Utility
|
|||
}
|
||||
|
||||
public static ResourceKey<Level> deserializeDimension(String dimString) {
|
||||
ResourceLocation dimRes = new ResourceLocation(dimString);
|
||||
ResourceLocation dimRes = ResourceLocation.parse(dimString);
|
||||
return ResourceKey.create(Registries.DIMENSION, dimRes);
|
||||
}
|
||||
|
||||
public static boolean isItemEdible(ItemStack itemStack) {
|
||||
return itemStack.get(DataComponents.FOOD) != null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.Battle;
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.Battle.Decision;
|
||||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class PacketBattleDecision
|
||||
{
|
||||
|
@ -24,26 +24,41 @@ public class PacketBattleDecision
|
|||
this.decision = decision;
|
||||
this.targetIDOrItemID = targetIDOrItemID;
|
||||
}
|
||||
|
||||
public static void encode(PacketBattleDecision pkt, FriendlyByteBuf buf) {
|
||||
buf.writeInt(pkt.battleID);
|
||||
buf.writeInt(pkt.decision.getValue());
|
||||
buf.writeInt(pkt.targetIDOrItemID);
|
||||
|
||||
public static class Encoder implements BiConsumer<PacketBattleDecision, RegistryFriendlyByteBuf> {
|
||||
public Encoder() {}
|
||||
|
||||
@Override
|
||||
public void accept(PacketBattleDecision pkt, RegistryFriendlyByteBuf buf) {
|
||||
buf.writeInt(pkt.battleID);
|
||||
buf.writeInt(pkt.decision.getValue());
|
||||
buf.writeInt(pkt.targetIDOrItemID);
|
||||
}
|
||||
}
|
||||
|
||||
public static PacketBattleDecision decode(FriendlyByteBuf buf) {
|
||||
return new PacketBattleDecision(buf.readInt(), Decision.valueOf(buf.readInt()), buf.readInt());
|
||||
|
||||
public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketBattleDecision> {
|
||||
public Decoder() {}
|
||||
|
||||
@Override
|
||||
public PacketBattleDecision apply(RegistryFriendlyByteBuf buf) {
|
||||
return new PacketBattleDecision(buf.readInt(), Decision.valueOf(buf.readInt()), buf.readInt());
|
||||
}
|
||||
}
|
||||
|
||||
public static void handle(final PacketBattleDecision pkt, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
|
||||
if(b != null)
|
||||
{
|
||||
ServerPlayer player = ctx.get().getSender();
|
||||
b.setDecision(player.getId(), pkt.decision, pkt.targetIDOrItemID);
|
||||
}
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
|
||||
public static class Consumer implements BiConsumer<PacketBattleDecision, CustomPayloadEvent.Context> {
|
||||
public Consumer() {}
|
||||
|
||||
@Override
|
||||
public void accept(PacketBattleDecision pkt, CustomPayloadEvent.Context ctx) {
|
||||
ctx.enqueueWork(() -> {
|
||||
Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
|
||||
if(b != null)
|
||||
{
|
||||
ServerPlayer player = ctx.getSender();
|
||||
b.setDecision(player.getId(), pkt.decision, pkt.targetIDOrItemID);
|
||||
}
|
||||
});
|
||||
ctx.setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class PacketBattleInfo
|
||||
{
|
||||
private int battleID;
|
||||
private Collection<Integer> sideA;
|
||||
private Collection<Integer> sideB;
|
||||
private long decisionNanos;
|
||||
|
@ -22,6 +23,7 @@ public class PacketBattleInfo
|
|||
|
||||
public PacketBattleInfo()
|
||||
{
|
||||
battleID = 0;
|
||||
sideA = new ArrayList<Integer>();
|
||||
sideB = new ArrayList<Integer>();
|
||||
decisionNanos = TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos();
|
||||
|
@ -29,8 +31,9 @@ public class PacketBattleInfo
|
|||
turnTimerEnabled = false;
|
||||
}
|
||||
|
||||
public PacketBattleInfo(Collection<Integer> sideA, Collection<Integer> sideB, long decisionNanos, long maxDecisionNanos, boolean turnTimerEnabled)
|
||||
public PacketBattleInfo(int battleID, Collection<Integer> sideA, Collection<Integer> sideB, long decisionNanos, long maxDecisionNanos, boolean turnTimerEnabled)
|
||||
{
|
||||
this.battleID = battleID;
|
||||
this.sideA = sideA;
|
||||
this.sideB = sideB;
|
||||
this.decisionNanos = decisionNanos;
|
||||
|
@ -38,65 +41,83 @@ public class PacketBattleInfo
|
|||
this.turnTimerEnabled = turnTimerEnabled;
|
||||
}
|
||||
|
||||
public static void encode(PacketBattleInfo msg, FriendlyByteBuf buf) {
|
||||
buf.writeInt(msg.sideA.size());
|
||||
buf.writeInt(msg.sideB.size());
|
||||
for(Integer id : msg.sideA) {
|
||||
buf.writeInt(id);
|
||||
}
|
||||
for(Integer id : msg.sideB) {
|
||||
buf.writeInt(id);
|
||||
}
|
||||
buf.writeLong(msg.decisionNanos);
|
||||
buf.writeLong(msg.maxDecisionNanos);
|
||||
buf.writeBoolean(msg.turnTimerEnabled);
|
||||
public static class Encoder implements BiConsumer<PacketBattleInfo, RegistryFriendlyByteBuf> {
|
||||
public Encoder() {}
|
||||
|
||||
@Override
|
||||
public void accept(PacketBattleInfo msg, RegistryFriendlyByteBuf buf) {
|
||||
buf.writeInt(msg.battleID);
|
||||
buf.writeInt(msg.sideA.size());
|
||||
buf.writeInt(msg.sideB.size());
|
||||
for(Integer id : msg.sideA) {
|
||||
buf.writeInt(id);
|
||||
}
|
||||
for(Integer id : msg.sideB) {
|
||||
buf.writeInt(id);
|
||||
}
|
||||
buf.writeLong(msg.decisionNanos);
|
||||
buf.writeLong(msg.maxDecisionNanos);
|
||||
buf.writeBoolean(msg.turnTimerEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
public static PacketBattleInfo decode(FriendlyByteBuf buf) {
|
||||
int sideACount = buf.readInt();
|
||||
int sideBCount = buf.readInt();
|
||||
Collection<Integer> sideA = new ArrayList<Integer>(sideACount);
|
||||
Collection<Integer> sideB = new ArrayList<Integer>(sideBCount);
|
||||
for(int i = 0; i < sideACount; ++i) {
|
||||
sideA.add(buf.readInt());
|
||||
}
|
||||
for(int i = 0; i < sideBCount; ++i) {
|
||||
sideB.add(buf.readInt());
|
||||
}
|
||||
long decisionNanos = buf.readLong();
|
||||
long maxDecisionNanos = buf.readLong();
|
||||
boolean turnTimerEnabled = buf.readBoolean();
|
||||
return new PacketBattleInfo(sideA, sideB, decisionNanos, maxDecisionNanos, turnTimerEnabled);
|
||||
public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketBattleInfo> {
|
||||
public Decoder() {}
|
||||
|
||||
@Override
|
||||
public PacketBattleInfo apply(RegistryFriendlyByteBuf buf) {
|
||||
int battleID = buf.readInt();
|
||||
int sideACount = buf.readInt();
|
||||
int sideBCount = buf.readInt();
|
||||
Collection<Integer> sideA = new ArrayList<Integer>(sideACount);
|
||||
Collection<Integer> sideB = new ArrayList<Integer>(sideBCount);
|
||||
for(int i = 0; i < sideACount; ++i) {
|
||||
sideA.add(buf.readInt());
|
||||
}
|
||||
for(int i = 0; i < sideBCount; ++i) {
|
||||
sideB.add(buf.readInt());
|
||||
}
|
||||
long decisionNanos = buf.readLong();
|
||||
long maxDecisionNanos = buf.readLong();
|
||||
boolean turnTimerEnabled = buf.readBoolean();
|
||||
return new PacketBattleInfo(battleID, sideA, sideB, decisionNanos, maxDecisionNanos, turnTimerEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
public static void handle(final PacketBattleInfo pkt, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
if(TurnBasedMinecraftMod.proxy.getLocalBattle() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
TurnBasedMinecraftMod.proxy.getLocalBattle().clearCombatants();
|
||||
for(Integer id : pkt.sideA)
|
||||
{
|
||||
Entity e = Minecraft.getInstance().level.getEntity(id);
|
||||
if(e != null)
|
||||
|
||||
public static class Consumer implements BiConsumer<PacketBattleInfo, CustomPayloadEvent.Context> {
|
||||
public Consumer() {}
|
||||
|
||||
@Override
|
||||
public void accept(PacketBattleInfo pkt, CustomPayloadEvent.Context ctx) {
|
||||
ctx.enqueueWork(() -> {
|
||||
if(TurnBasedMinecraftMod.proxy.getLocalBattle() == null)
|
||||
{
|
||||
TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideA(e);
|
||||
TurnBasedMinecraftMod.proxy.createLocalBattle(pkt.battleID);
|
||||
}
|
||||
}
|
||||
for(Integer id : pkt.sideB)
|
||||
{
|
||||
Entity e = Minecraft.getInstance().level.getEntity(id);
|
||||
if(e != null)
|
||||
TurnBasedMinecraftMod.proxy.getLocalBattle().clearCombatants();
|
||||
for(Integer id : pkt.sideA)
|
||||
{
|
||||
TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideB(e);
|
||||
Entity e = Minecraft.getInstance().level.getEntity(id);
|
||||
if(e != null)
|
||||
{
|
||||
TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideA(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
TurnBasedMinecraftMod.proxy.setBattleGuiTime((int)(pkt.decisionNanos / 1000000000L));
|
||||
TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
|
||||
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerEnabled(pkt.turnTimerEnabled);
|
||||
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerMax((int)(pkt.maxDecisionNanos / 1000000000L));
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
for(Integer id : pkt.sideB)
|
||||
{
|
||||
Entity e = Minecraft.getInstance().level.getEntity(id);
|
||||
if(e != null)
|
||||
{
|
||||
TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideB(e);
|
||||
}
|
||||
}
|
||||
TurnBasedMinecraftMod.proxy.setBattleGuiAsGui();
|
||||
TurnBasedMinecraftMod.proxy.setBattleGuiTime((int)(pkt.decisionNanos / 1000000000L));
|
||||
TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
|
||||
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerEnabled(pkt.turnTimerEnabled);
|
||||
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerMax((int)(pkt.maxDecisionNanos / 1000000000L));
|
||||
});
|
||||
ctx.setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.Utility;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class PacketBattleMessage
|
||||
{
|
||||
|
@ -39,7 +39,8 @@ public class PacketBattleMessage
|
|||
BOW_NO_AMMO(18),
|
||||
CREEPER_WAIT(19),
|
||||
CREEPER_WAIT_FINAL(20),
|
||||
CREEPER_EXPLODE(21);
|
||||
CREEPER_EXPLODE(21),
|
||||
CROSSBOW_NO_AMMO(22);
|
||||
|
||||
private int value;
|
||||
private static Map<Integer, MessageType> map = new HashMap<Integer, MessageType>();
|
||||
|
@ -153,31 +154,46 @@ public class PacketBattleMessage
|
|||
this.amount = amount;
|
||||
this.custom = custom;
|
||||
}
|
||||
|
||||
public static void encode(PacketBattleMessage pkt, FriendlyByteBuf buf) {
|
||||
buf.writeInt(pkt.messageType.getValue());
|
||||
buf.writeInt(pkt.entityIDFrom);
|
||||
buf.writeInt(pkt.entityIDTo);
|
||||
buf.writeUtf(Utility.serializeDimension(pkt.dimension));
|
||||
buf.writeInt(pkt.amount);
|
||||
buf.writeUtf(pkt.custom);
|
||||
|
||||
public static class Encoder implements BiConsumer<PacketBattleMessage, RegistryFriendlyByteBuf> {
|
||||
public Encoder() {}
|
||||
|
||||
@Override
|
||||
public void accept(PacketBattleMessage pkt, RegistryFriendlyByteBuf buf) {
|
||||
buf.writeInt(pkt.messageType.getValue());
|
||||
buf.writeInt(pkt.entityIDFrom);
|
||||
buf.writeInt(pkt.entityIDTo);
|
||||
buf.writeUtf(Utility.serializeDimension(pkt.dimension));
|
||||
buf.writeInt(pkt.amount);
|
||||
buf.writeUtf(pkt.custom);
|
||||
}
|
||||
}
|
||||
|
||||
public static PacketBattleMessage decode(FriendlyByteBuf buf) {
|
||||
return new PacketBattleMessage(
|
||||
MessageType.valueOf(
|
||||
buf.readInt()),
|
||||
buf.readInt(),
|
||||
buf.readInt(),
|
||||
Utility.deserializeDimension(buf.readUtf()),
|
||||
buf.readInt(),
|
||||
buf.readUtf());
|
||||
|
||||
public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketBattleMessage> {
|
||||
public Decoder() {}
|
||||
|
||||
@Override
|
||||
public PacketBattleMessage apply(RegistryFriendlyByteBuf buf) {
|
||||
return new PacketBattleMessage(
|
||||
MessageType.valueOf(
|
||||
buf.readInt()),
|
||||
buf.readInt(),
|
||||
buf.readInt(),
|
||||
Utility.deserializeDimension(buf.readUtf()),
|
||||
buf.readInt(),
|
||||
buf.readUtf());
|
||||
}
|
||||
}
|
||||
|
||||
public static void handle(final PacketBattleMessage pkt, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
|
||||
public static class Consumer implements BiConsumer<PacketBattleMessage, CustomPayloadEvent.Context> {
|
||||
public Consumer() {}
|
||||
|
||||
@Override
|
||||
public void accept(PacketBattleMessage pkt, CustomPayloadEvent.Context ctx) {
|
||||
ctx.enqueueWork(() -> {
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
|
||||
});
|
||||
ctx.setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class PacketBattlePing {
|
||||
private int battleID;
|
||||
private int decisionSeconds;
|
||||
|
||||
public PacketBattlePing() {
|
||||
battleID = 0;
|
||||
decisionSeconds = 1;
|
||||
}
|
||||
|
||||
public PacketBattlePing(int battleID, int decisionSeconds) {
|
||||
this.battleID = battleID;
|
||||
this.decisionSeconds = decisionSeconds;
|
||||
}
|
||||
|
||||
public static class Encoder implements BiConsumer<PacketBattlePing, RegistryFriendlyByteBuf> {
|
||||
public Encoder() {}
|
||||
|
||||
@Override
|
||||
public void accept(PacketBattlePing pkt, RegistryFriendlyByteBuf buf) {
|
||||
buf.writeInt(pkt.battleID);
|
||||
buf.writeInt(pkt.decisionSeconds);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketBattlePing> {
|
||||
public Decoder() {}
|
||||
|
||||
@Override
|
||||
public PacketBattlePing apply(RegistryFriendlyByteBuf buf) {
|
||||
return new PacketBattlePing(buf.readInt(), buf.readInt());
|
||||
}
|
||||
}
|
||||
|
||||
public static class Consumer implements BiConsumer<PacketBattlePing, CustomPayloadEvent.Context> {
|
||||
public Consumer() {}
|
||||
|
||||
@Override
|
||||
public void accept(PacketBattlePing pkt, CustomPayloadEvent.Context ctx) {
|
||||
ctx.enqueueWork(() -> {
|
||||
if (TurnBasedMinecraftMod.proxy.getLocalBattle() != null) {
|
||||
TurnBasedMinecraftMod.proxy.setBattleGuiAsGui();
|
||||
TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
|
||||
TurnBasedMinecraftMod.proxy.setBattleGuiTime(pkt.decisionSeconds);
|
||||
TurnBasedMinecraftMod.proxy.pauseMCMusic();
|
||||
}
|
||||
});
|
||||
ctx.setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.Battle;
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class PacketBattleRequestInfo
|
||||
{
|
||||
|
@ -18,23 +18,38 @@ public class PacketBattleRequestInfo
|
|||
{
|
||||
this.battleID = battleID;
|
||||
}
|
||||
|
||||
public static void encode(PacketBattleRequestInfo pkt, FriendlyByteBuf buf) {
|
||||
buf.writeInt(pkt.battleID);
|
||||
|
||||
public static class Encoder implements BiConsumer<PacketBattleRequestInfo, RegistryFriendlyByteBuf> {
|
||||
public Encoder() {}
|
||||
|
||||
@Override
|
||||
public void accept(PacketBattleRequestInfo pkt, RegistryFriendlyByteBuf buf) {
|
||||
buf.writeInt(pkt.battleID);
|
||||
}
|
||||
}
|
||||
|
||||
public static PacketBattleRequestInfo decode(FriendlyByteBuf buf) {
|
||||
return new PacketBattleRequestInfo(buf.readInt());
|
||||
|
||||
public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketBattleRequestInfo> {
|
||||
public Decoder() {}
|
||||
|
||||
@Override
|
||||
public PacketBattleRequestInfo apply(RegistryFriendlyByteBuf buf) {
|
||||
return new PacketBattleRequestInfo(buf.readInt());
|
||||
}
|
||||
}
|
||||
|
||||
public static void handle(final PacketBattleRequestInfo pkt, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
|
||||
if(b == null) {
|
||||
return;
|
||||
}
|
||||
TurnBasedMinecraftMod.getHandler().reply(new PacketBattleInfo(b.getSideAIDs(), b.getSideBIDs(), b.getTimerNanos(), TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos(), !TurnBasedMinecraftMod.proxy.getConfig().isBattleDecisionDurationForever()), ctx.get());
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
|
||||
public static class Consumer implements BiConsumer<PacketBattleRequestInfo, CustomPayloadEvent.Context> {
|
||||
public Consumer() {}
|
||||
|
||||
@Override
|
||||
public void accept(PacketBattleRequestInfo pkt, CustomPayloadEvent.Context ctx) {
|
||||
ctx.enqueueWork(() -> {
|
||||
Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
|
||||
if(b == null) {
|
||||
return;
|
||||
}
|
||||
TurnBasedMinecraftMod.getHandler().reply(new PacketBattleInfo(b.getId(), b.getSideAIDs(), b.getSideBIDs(), b.getTimerNanos(), TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos(), !TurnBasedMinecraftMod.proxy.getConfig().isBattleDecisionDurationForever()), ctx);
|
||||
});
|
||||
ctx.setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class PacketClientGui {
|
||||
int reserved;
|
||||
|
||||
public PacketClientGui() {
|
||||
reserved = 0;
|
||||
}
|
||||
|
||||
public PacketClientGui(int reserved) {
|
||||
this.reserved = reserved;
|
||||
}
|
||||
|
||||
public static class Encoder implements BiConsumer<PacketClientGui, RegistryFriendlyByteBuf> {
|
||||
public Encoder() {}
|
||||
|
||||
@Override
|
||||
public void accept(PacketClientGui pkt, RegistryFriendlyByteBuf buf) {
|
||||
buf.writeInt(pkt.reserved);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketClientGui> {
|
||||
public Decoder() {}
|
||||
|
||||
@Override
|
||||
public PacketClientGui apply(RegistryFriendlyByteBuf registryFriendlyByteBuf) {
|
||||
return new PacketClientGui(registryFriendlyByteBuf.readInt());
|
||||
}
|
||||
}
|
||||
|
||||
public static class Consumer implements BiConsumer<PacketClientGui, CustomPayloadEvent.Context> {
|
||||
public Consumer() {}
|
||||
|
||||
@Override
|
||||
public void accept(PacketClientGui pkt, CustomPayloadEvent.Context ctx) {
|
||||
ctx.enqueueWork(() -> {
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.showClientConfigGui());
|
||||
});
|
||||
ctx.setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,14 +2,15 @@ package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
|||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.EntityInfo;
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class PacketEditingMessage
|
||||
{
|
||||
|
@ -27,11 +28,14 @@ public class PacketEditingMessage
|
|||
EDIT_DEFENSE_DAMAGE_PROBABILITY(9),
|
||||
EDIT_EVASION(10),
|
||||
EDIT_SPEED(11),
|
||||
EDIT_HASTE_SPEED(18),
|
||||
EDIT_SLOW_SPEED(19),
|
||||
EDIT_CATEGORY(12),
|
||||
EDIT_DECISION_ATTACK(13),
|
||||
EDIT_DECISION_DEFEND(14),
|
||||
EDIT_DECISION_FLEE(15),
|
||||
SERVER_EDIT(16);
|
||||
SERVER_EDIT(16),
|
||||
PICK_PLAYER(17);
|
||||
|
||||
Type(int value)
|
||||
{
|
||||
|
@ -87,59 +91,80 @@ public class PacketEditingMessage
|
|||
this.entityInfo = entityInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public static void encode(PacketEditingMessage pkt, FriendlyByteBuf buf) {
|
||||
buf.writeInt(pkt.type.getValue());
|
||||
if(pkt.entityInfo.classType != null) {
|
||||
buf.writeUtf(pkt.entityInfo.classType.getName());
|
||||
} else {
|
||||
buf.writeUtf("unknown");
|
||||
}
|
||||
buf.writeBoolean(pkt.entityInfo.ignoreBattle);
|
||||
buf.writeInt(pkt.entityInfo.attackPower);
|
||||
buf.writeInt(pkt.entityInfo.attackProbability);
|
||||
buf.writeInt(pkt.entityInfo.attackVariance);
|
||||
buf.writeUtf(pkt.entityInfo.attackEffect.toString());
|
||||
buf.writeInt(pkt.entityInfo.attackEffectProbability);
|
||||
buf.writeInt(pkt.entityInfo.defenseDamage);
|
||||
buf.writeInt(pkt.entityInfo.defenseDamageProbability);
|
||||
buf.writeInt(pkt.entityInfo.evasion);
|
||||
buf.writeInt(pkt.entityInfo.speed);
|
||||
buf.writeUtf(pkt.entityInfo.category);
|
||||
buf.writeInt(pkt.entityInfo.decisionAttack);
|
||||
buf.writeInt(pkt.entityInfo.decisionDefend);
|
||||
buf.writeInt(pkt.entityInfo.decisionFlee);
|
||||
buf.writeUtf(pkt.entityInfo.customName);
|
||||
}
|
||||
|
||||
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 class Encoder implements BiConsumer<PacketEditingMessage, RegistryFriendlyByteBuf> {
|
||||
public Encoder() {}
|
||||
|
||||
@Override
|
||||
public void accept(PacketEditingMessage pkt, RegistryFriendlyByteBuf buf) {
|
||||
buf.writeInt(pkt.type.getValue());
|
||||
if(pkt.entityInfo.classType != null) {
|
||||
buf.writeUtf(pkt.entityInfo.classType.getName());
|
||||
} else {
|
||||
buf.writeUtf("unknown");
|
||||
}
|
||||
buf.writeBoolean(pkt.entityInfo.ignoreBattle);
|
||||
buf.writeInt(pkt.entityInfo.attackPower);
|
||||
buf.writeInt(pkt.entityInfo.attackProbability);
|
||||
buf.writeInt(pkt.entityInfo.attackVariance);
|
||||
buf.writeUtf(pkt.entityInfo.attackEffect.toString());
|
||||
buf.writeInt(pkt.entityInfo.attackEffectProbability);
|
||||
buf.writeInt(pkt.entityInfo.defenseDamage);
|
||||
buf.writeInt(pkt.entityInfo.defenseDamageProbability);
|
||||
buf.writeInt(pkt.entityInfo.evasion);
|
||||
buf.writeInt(pkt.entityInfo.speed);
|
||||
buf.writeInt(pkt.entityInfo.hasteSpeed);
|
||||
buf.writeInt(pkt.entityInfo.slowSpeed);
|
||||
buf.writeUtf(pkt.entityInfo.category);
|
||||
buf.writeInt(pkt.entityInfo.decisionAttack);
|
||||
buf.writeInt(pkt.entityInfo.decisionDefend);
|
||||
buf.writeInt(pkt.entityInfo.decisionFlee);
|
||||
buf.writeUtf(pkt.entityInfo.customName);
|
||||
buf.writeUtf(pkt.entityInfo.playerName);
|
||||
}
|
||||
}
|
||||
|
||||
public static void handle(final PacketEditingMessage pkt, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketEditingMessage> {
|
||||
public Decoder() {}
|
||||
|
||||
@Override
|
||||
public PacketEditingMessage apply(RegistryFriendlyByteBuf buf) {
|
||||
Type type = Type.valueOf(buf.readInt());
|
||||
EntityInfo einfo = new EntityInfo();
|
||||
try {
|
||||
einfo.classType = einfo.getClass().getClassLoader().loadClass(buf.readUtf());
|
||||
} catch (ClassNotFoundException e) { /* ignored */ }
|
||||
einfo.ignoreBattle = buf.readBoolean();
|
||||
einfo.attackPower = buf.readInt();
|
||||
einfo.attackProbability = buf.readInt();
|
||||
einfo.attackVariance = buf.readInt();
|
||||
einfo.attackEffect = EntityInfo.Effect.fromString(buf.readUtf());
|
||||
einfo.attackEffectProbability = buf.readInt();
|
||||
einfo.defenseDamage = buf.readInt();
|
||||
einfo.defenseDamageProbability = buf.readInt();
|
||||
einfo.evasion = buf.readInt();
|
||||
einfo.speed = buf.readInt();
|
||||
einfo.hasteSpeed = buf.readInt();
|
||||
einfo.slowSpeed = buf.readInt();
|
||||
einfo.category = buf.readUtf();
|
||||
einfo.decisionAttack = buf.readInt();
|
||||
einfo.decisionDefend = buf.readInt();
|
||||
einfo.decisionFlee = buf.readInt();
|
||||
einfo.customName = buf.readUtf();
|
||||
einfo.playerName = buf.readUtf();
|
||||
return new PacketEditingMessage(type, einfo);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Consumer implements BiConsumer<PacketEditingMessage, CustomPayloadEvent.Context> {
|
||||
public Consumer() {}
|
||||
|
||||
@Override
|
||||
public void accept(PacketEditingMessage pkt, CustomPayloadEvent.Context ctx) {
|
||||
ctx.enqueueWork(() -> {
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
|
||||
});
|
||||
ctx.setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class PacketGeneralMessage
|
||||
{
|
||||
|
@ -26,19 +26,34 @@ public class PacketGeneralMessage
|
|||
{
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public static void encode(PacketGeneralMessage pkt, FriendlyByteBuf buf) {
|
||||
buf.writeUtf(pkt.message);
|
||||
|
||||
public static class Encoder implements BiConsumer<PacketGeneralMessage, RegistryFriendlyByteBuf> {
|
||||
public Encoder() {}
|
||||
|
||||
@Override
|
||||
public void accept(PacketGeneralMessage pkt, RegistryFriendlyByteBuf buf) {
|
||||
buf.writeUtf(pkt.message);
|
||||
}
|
||||
}
|
||||
|
||||
public static PacketGeneralMessage decode(FriendlyByteBuf buf) {
|
||||
return new PacketGeneralMessage(buf.readUtf());
|
||||
|
||||
public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketGeneralMessage> {
|
||||
public Decoder() {}
|
||||
|
||||
@Override
|
||||
public PacketGeneralMessage apply(RegistryFriendlyByteBuf buf) {
|
||||
return new PacketGeneralMessage(buf.readUtf());
|
||||
}
|
||||
}
|
||||
|
||||
public static void handle(final PacketGeneralMessage pkt, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
|
||||
public static class Consumer implements BiConsumer<PacketGeneralMessage, CustomPayloadEvent.Context> {
|
||||
public Consumer() {}
|
||||
|
||||
@Override
|
||||
public void accept(PacketGeneralMessage pkt, CustomPayloadEvent.Context ctx) {
|
||||
ctx.enqueueWork(() -> {
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
|
||||
});
|
||||
ctx.setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ version="${mod_version}" #mandatory
|
|||
displayName="${mod_name}" #mandatory
|
||||
# A URL to query for updates for this mod. See the JSON update specification <here>
|
||||
#updateJSONURL="" #optional
|
||||
updateJSONURL="https://github.com/Stephen-Seo/TurnBasedMinecraftMod/raw/refs/heads/forge/update.json"
|
||||
# A URL for the "homepage" for this mod, displayed in the mod UI
|
||||
displayURL="https://github.com/Stephen-Seo/TurnBasedMinecraftMod" #optional
|
||||
# A file name (in the root of the mod JAR) containing a logo for display
|
||||
|
@ -32,6 +33,9 @@ authors="${mod_authors}" #optional
|
|||
description='''
|
||||
Implements turn-based-battle in Minecraft.
|
||||
'''
|
||||
|
||||
logoFile="assets/com_burnedkirby_turnbasedminecraft/tbmm_icon.png"
|
||||
|
||||
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
||||
[[dependencies.com_burnedkirby_turnbasedminecraft]] #optional
|
||||
# the modid of the dependency
|
||||
|
|
|
@ -1,21 +1,13 @@
|
|||
# Please do not change this option, the mod uses this to keep track of what new
|
||||
# changes to add to the config.
|
||||
version = 10
|
||||
version = 11
|
||||
# Change this to "true" if you want the config to never be replaced. This means
|
||||
# that you will not get new mob listings from future updates unless this remains
|
||||
# "false"!
|
||||
do_not_overwrite = false
|
||||
|
||||
[client_config]
|
||||
|
||||
# What categories play this type of music (battle_music). Unknown categories will default to this type.
|
||||
battle_music = ["monster", "animal", "boss", "player"]
|
||||
# What categories play this type of music (silly_music).
|
||||
silly_music = ["passive"]
|
||||
|
||||
# Minimum percentage of silly entities in battle to use silly music.
|
||||
silly_music_threshold = 40
|
||||
|
||||
# Note that client config is no longer stored here but rather in the settings.
|
||||
|
||||
[server_config]
|
||||
|
||||
|
@ -138,6 +130,37 @@ decision_defend_probability = 0
|
|||
decision_flee_probability = 0
|
||||
ignore_battle = false
|
||||
|
||||
[[server_config.entity]]
|
||||
name = "net.minecraft.world.entity.monster.Bogged"
|
||||
attack_power = 3
|
||||
attack_probability = 75
|
||||
attack_variance = 1
|
||||
attack_effect = "poison"
|
||||
attack_effect_probability = 50
|
||||
defense_damage = 0
|
||||
evasion = 10
|
||||
category = "monster"
|
||||
speed = 20
|
||||
decision_attack_probability = 100
|
||||
decision_defend_probability = 0
|
||||
decision_flee_probability = 0
|
||||
ignore_battle = false
|
||||
|
||||
[[server_config.entity]]
|
||||
name = "net.minecraft.world.entity.monster.breeze.Breeze"
|
||||
attack_power = 1
|
||||
attack_probability = 50
|
||||
attack_effect = "unknown"
|
||||
attack_variance = 0
|
||||
defense_damage = 0
|
||||
evasion = 45
|
||||
category = "monster"
|
||||
speed = 45
|
||||
decision_attack_probability = 100
|
||||
decision_defend_probability = 0
|
||||
decision_flee_probability = 0
|
||||
ignore_battle = false
|
||||
|
||||
[[server_config.entity]]
|
||||
name = "net.minecraft.world.entity.monster.CaveSpider"
|
||||
attack_power = 2
|
||||
|
@ -684,6 +707,21 @@ decision_defend_probability = 0
|
|||
decision_flee_probability = 100
|
||||
ignore_battle = false
|
||||
|
||||
[[server_config.entity]]
|
||||
name = "net.minecraft.world.entity.animal.armadillo.Armadillo"
|
||||
attack_power = 0
|
||||
attack_probability = 0
|
||||
attack_variance = 0
|
||||
attack_effect = "unknown"
|
||||
defense_damage = 0
|
||||
evasion = 10
|
||||
category = "passive"
|
||||
speed = 20
|
||||
decision_attack_probability = 0
|
||||
decision_defend_probability = 50
|
||||
decision_flee_probability = 50
|
||||
ignore_battle = false
|
||||
|
||||
[[server_config.entity]]
|
||||
name = "net.minecraft.world.entity.animal.axolotl.Axolotl"
|
||||
attack_power = 2
|
||||
|
|
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": []
|
||||
}
|
||||
]
|
13
update.json
Normal file
13
update.json
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"homepage": "https://github.com/Stephen-Seo/TurnBasedMinecraftMod",
|
||||
"1.21.1": {
|
||||
"1.26.3": "Minor networking change.\n https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/forge/Changelog.md",
|
||||
"1.26.2": "Display Entities on attack menu in BattleGUI.\n https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/forge/Changelog.md",
|
||||
"1.26.1": "Ported to Forge 52.0.22, leave BattleGUI with Escape Key, MC music paused in battle properly.\n https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/forge/Changelog.md",
|
||||
"1.26.0": "Ported to Forge 52.0.21, client config.\n https://github.com/Stephen-Seo/TurnBasedMinecraftMod/blob/forge/Changelog.md"
|
||||
},
|
||||
"promos": {
|
||||
"1.21.1-latest": "1.26.3",
|
||||
"1.21.1-recommended": "1.26.3"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue