Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f767de3beb
|
||
|
|
78dcd67723
|
||
|
|
f3249e6b9e | ||
|
|
0099e0e3d2 | ||
|
|
f2569fd50e | ||
|
|
e90aeef31b | ||
|
|
3d653a1856 | ||
|
|
b5e0b5ceca | ||
|
|
dcc3cec023 | ||
|
|
989c38f377 | ||
|
|
fea65c7891 | ||
|
|
d49555c5e1 | ||
|
|
dedb96e5cb | ||
|
|
1b0a8bf8de | ||
|
|
8bf18ac3c6 | ||
|
|
61a91ca4a9 | ||
|
|
5e281eb967 | ||
|
|
f0b29d0266 | ||
|
|
4ec6b01e6a | ||
|
|
58a1ada322 | ||
|
|
195ee0446a | ||
|
|
629080cfb3 | ||
|
|
2390e06ad3 | ||
|
|
b6a3e39cae | ||
|
|
548312ea34 | ||
|
|
1c1702b11d | ||
|
|
eb09f196e5 | ||
|
|
d122518bcf | ||
|
|
fd53b95457 | ||
|
|
76af835e2e | ||
|
|
90a196d3bc | ||
|
|
ae928dbee1 | ||
|
|
fa701e81cf | ||
|
|
c44e502dab | ||
|
|
8669b0f183 | ||
|
|
2b9e7b1166 | ||
|
|
5a00e5c79f | ||
|
|
887fa9ff4c | ||
|
|
ac962ce70d | ||
|
|
21866cc94f | ||
|
|
497c8dbd94 | ||
|
|
40cd6b43cb | ||
|
|
84b3392e9a | ||
|
|
b654ab1b54 | ||
|
|
1639b73a0d | ||
|
|
74163d2edf | ||
|
|
a35742fc64 | ||
|
|
2768b3445f | ||
|
|
7763337e37 | ||
|
|
c93fcd2c0f | ||
|
|
ae20589b1a | ||
|
|
6e2005c6c9 | ||
|
|
d7f3ff6e06 | ||
|
|
75b6d14aac | ||
|
|
f250854243 | ||
|
|
bfd1b40482 | ||
|
|
941bf7c30e | ||
|
|
28f14a7b42 | ||
|
|
a3dc1118f8 | ||
|
|
8b9ca0541a | ||
|
|
6680d33abb | ||
|
|
4e6ae10528 | ||
|
|
c728f2fd05 | ||
|
|
aa54f50116 | ||
|
|
f9775eb3ce | ||
|
|
d8adfb132a | ||
|
|
ebd8a66d05 | ||
|
|
024d4b93a3 | ||
|
|
a04e0eddc7 | ||
|
|
0c1e3ee82d | ||
|
|
e65004c12e | ||
|
|
e61a83e5ad | ||
|
|
10d126cbe7 | ||
|
|
39df65b111 | ||
|
|
d8c39f6463 | ||
|
|
b97c13b487 | ||
|
|
71c8f41bd4 | ||
|
|
eeea9d7fdc | ||
|
|
e46deea6c5 | ||
|
|
0e30d2f5ee | ||
|
|
c2634d2dc3 | ||
|
|
d1254391aa | ||
|
|
3dae51062d | ||
|
|
86e454077a | ||
|
|
7d032a3e4a | ||
|
|
b4b6ff015e | ||
|
|
db647ba73a | ||
|
|
5dd5de04a8 | ||
|
|
bfbeb8dafc | ||
|
|
577590b1eb | ||
|
|
c828e8b111 | ||
|
|
9109e247db | ||
|
|
fe29db24cf | ||
|
|
3c8079aee2 | ||
|
|
ee82a47abb | ||
|
|
7251ee1b18 | ||
|
|
1582bca318 | ||
|
|
0615c78075 | ||
|
|
fbb80124db | ||
|
|
3430b25b5e | ||
|
|
def0ce4840 | ||
|
|
ed89d0a5a8 | ||
|
|
7af96fec84 | ||
|
|
d8fd027415 | ||
|
|
4441e04472 | ||
|
|
c5bec028c0 | ||
|
|
bd6008d5a7 | ||
|
|
fc4157127a | ||
|
|
ea3c9d085e | ||
|
|
1b1a104cc4 | ||
|
|
6d43d90367 | ||
|
|
3323449eea | ||
|
|
c72ca2baa0 | ||
|
|
d4e6fff86e | ||
|
|
06c96900ec | ||
|
|
a0dd21bed5 | ||
|
|
b25c0f9850 | ||
|
|
f9ab88c9e4 | ||
|
|
3238a3eca4 | ||
|
|
8685846be3 | ||
|
|
2ebfa4185b | ||
|
|
c4b4c8d9e0 | ||
|
|
60dd509fcb | ||
|
|
b6c67c320e | ||
|
|
e4676a18fe | ||
|
|
a5b0758b67 | ||
|
|
27ba69fa43 | ||
|
|
14b162b098 | ||
|
|
f1e9a6f1e8 | ||
|
|
00c8164201 | ||
|
|
206d1e03bb | ||
|
|
c180263e3f | ||
|
|
8872c65ba2 | ||
|
|
abe79fb351 | ||
|
|
b76a014432 | ||
|
|
c7b9e15cef | ||
|
|
fade6da4e2 | ||
|
|
86c67bfe52 | ||
|
|
6cda366bc2 | ||
|
|
2771c6c5d1 | ||
|
|
7ba541843b | ||
|
|
47ac4d5894 | ||
|
|
6c424946fe | ||
|
|
b4e5b10299 | ||
|
|
efeb9019a6 | ||
|
|
5b994a58da | ||
|
|
0d030d0ca7 | ||
|
|
8b45ddd4ef | ||
|
|
cff73e9e67 | ||
|
|
a7fa150836 | ||
|
|
7225117fea | ||
|
|
3f44016db1 | ||
|
|
c0dc2c5908 | ||
|
|
8a0ebb77eb | ||
|
|
4ebb0acbfe | ||
|
|
b4831c4f09 | ||
|
|
17563f1856 | ||
|
|
486cf4c74d | ||
|
|
0528f0ebc6 | ||
|
|
ce43c2ba84 | ||
|
|
f37bb34cdf | ||
|
|
3fb60fa2c5 | ||
|
|
e59c1a5d3a | ||
|
|
3831a7d1f0 | ||
|
|
f7aee7c797 | ||
|
|
68b0a65288 | ||
|
|
7633319f2a | ||
|
|
ca8ca25a3f | ||
|
|
a96657d600 | ||
|
|
bf664a4314 | ||
|
|
8dd5bec27f | ||
|
|
e11ae8b2cf | ||
|
|
c8f070cf7d | ||
|
|
cc76a19fe3 | ||
|
|
d0b4ca57d1 | ||
|
|
18d103d202 | ||
|
|
56241cee40 | ||
|
|
061874fa46 | ||
|
|
c1d22c98ef | ||
|
|
06c7afd21a | ||
|
|
ecb360eabd | ||
|
|
56941722aa | ||
|
|
2452d753af | ||
|
|
2085a725b0 | ||
|
|
b67f99e8ea | ||
|
|
eee5dd7fa2 | ||
|
|
9c5e2bd4c9 | ||
|
|
87efd2dcf3 | ||
|
|
170e1a9cb5 | ||
|
|
7d4ef278cd | ||
|
|
05c6d3447a | ||
|
|
ef9f8d2000 | ||
|
|
9d192b61ea | ||
|
|
d4d7e96c15 | ||
|
|
918fa83388 | ||
|
|
34f26bb3bd | ||
|
|
ccbfa6cf00 | ||
|
|
bcb429ec7f | ||
|
|
5f38d74cfc | ||
|
|
5111c354c1 | ||
|
|
643b2e9975 | ||
|
|
d9bc12b05e | ||
|
|
f7e6de8594 | ||
|
|
8275088bda | ||
|
|
06dd7a5555 | ||
|
|
4fa6bccaa7 | ||
|
|
7df7e3700b | ||
|
|
adf1b2692a | ||
|
|
b57d3364a3 | ||
|
|
48e67537c1 | ||
|
|
fe7455e379 | ||
|
|
01e4f20c68 | ||
|
|
bf066d6156 | ||
|
|
20bf1fd89d | ||
|
|
f2a470f943 | ||
|
|
845077ff35 | ||
|
|
ff03e29b3f | ||
|
|
fad9a4873f | ||
|
|
ad21d93863 | ||
|
|
4d366d06cd | ||
|
|
197a3c956e | ||
|
|
f8371c461d | ||
|
|
02f0855d3d | ||
|
|
22a4085978 | ||
|
|
acae93e9cf | ||
|
|
803cf8f109 | ||
|
|
4af2de9fee | ||
|
|
d916789acb | ||
|
|
54d120c296 | ||
|
|
a84cbbd209 | ||
|
|
295b6f268e | ||
|
|
a1e674f61d | ||
|
|
bf1f896b39 | ||
|
|
eeb2b40138 | ||
|
|
60ff394785 | ||
|
|
149c017099 | ||
|
|
233d6c150c | ||
|
|
96aa95f9d7 | ||
|
|
7e1a8a704a | ||
|
|
cd769921b9 | ||
|
|
7d33952145 | ||
|
|
58f1134254 | ||
|
|
6d1f2830d1 | ||
|
|
d103dd74f9 | ||
|
|
cd0f238b97 | ||
|
|
d7a475adfd | ||
|
|
0cc99eadde | ||
|
|
cffc7750b9 | ||
|
|
838109ccd5 | ||
|
|
67f413cc59 | ||
|
|
c498332c36 |
No files matched your search
@@ -0,0 +1,6 @@
|
||||
[*.java]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
ij_continuation_indent_size = 8
|
||||
ij_java_names_count_to_use_import_on_demand = 9999
|
||||
ij_java_class_count_to_use_import_on_demand = 9999
|
||||
@@ -0,0 +1 @@
|
||||
.gitea/CODEOWNERS linguist-detectable=false
|
||||
@@ -0,0 +1,3 @@
|
||||
# Pull requests request review from the eligible staff team(s).
|
||||
# One approval from either an Admin or Developer satisfies branch protection.
|
||||
* @trueog/Admins @trueog/Developers
|
||||
@@ -10,13 +10,13 @@ jobs:
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: Validate gradle wrapper
|
||||
uses: gradle/actions/wrapper-validation@v4
|
||||
uses: gradle/actions/wrapper-validation@v5
|
||||
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'temurin'
|
||||
@@ -31,40 +31,40 @@ jobs:
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: api-build
|
||||
path: api/build/libs
|
||||
path: build/libs/packetevents-api-*.jar
|
||||
|
||||
- name: Upload build artifacts spigot
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: spigot-build
|
||||
path: spigot/build/libs
|
||||
path: build/libs/packetevents-spigot-*.jar
|
||||
|
||||
- name: Upload build artifacts netty-common
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: netty-common-build
|
||||
path: netty-common/build/libs
|
||||
path: build/libs/packetevents-netty-common-*.jar
|
||||
|
||||
- name: Upload build artifacts bungeecord
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: bungeecord-build
|
||||
path: bungeecord/build/libs
|
||||
path: build/libs/packetevents-bungeecord-*.jar
|
||||
|
||||
- name: Upload build artifacts velocity
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: velocity-build
|
||||
path: velocity/build/libs
|
||||
path: build/libs/packetevents-velocity-*.jar
|
||||
|
||||
- name: Upload build artifacts fabric
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: fabric-build
|
||||
path: fabric/build/libs
|
||||
path: build/libs/packetevents-fabric-*.jar
|
||||
|
||||
- name: Upload build artifacts sponge
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: sponge-build
|
||||
path: sponge/build/libs
|
||||
path: build/libs/packetevents-sponge-*.jar
|
||||
@@ -12,13 +12,13 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Validate gradle wrapper
|
||||
uses: gradle/actions/wrapper-validation@v4
|
||||
uses: gradle/actions/wrapper-validation@v5
|
||||
|
||||
- name: Setup java 21
|
||||
uses: actions/setup-java@v4
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: 21
|
||||
distribution: temurin
|
||||
|
||||
@@ -126,3 +126,5 @@ run/
|
||||
|
||||
# Build Source Kotlin
|
||||
/buildSrc/.kotlin/
|
||||
|
||||
.env
|
||||
+157
@@ -1,3 +1,160 @@
|
||||
!!!!! v2.11.2
|
||||
|
||||
# PacketEvents 2.11.2 is finally out! 🎉
|
||||
|
||||
This update fixes various bugs. It's encouraged that users update.
|
||||
Again, huge thanks to all users who have donated their hard-earned money to PacketEvents since the previous release. It's been received & it's very much appreciated.
|
||||
|
||||
Recent donors: PebbleHost, SSomar1607, ipavdev, Suleyman Abulkhasan, frap
|
||||
|
||||
Also, thanks to the contributors that made this update possible.
|
||||
|
||||
If you intend on donating and do not wish to be mentioned, please add such a note on your donation.
|
||||
|
||||
# Announcement 📢⚠️
|
||||
|
||||
Visit our website: https://packetevents.com\
|
||||
Documentation: https://docs.packetevents.com\
|
||||
JavaDocs: https://javadocs.packetevents.com\
|
||||
I've released a new YouTube [video](https://youtu.be/G7qYRHpZVIo).
|
||||
|
||||
## What's Changed (Summary)
|
||||
* Fixed SynchronizedRegistriesHandler issues
|
||||
* Fixed various equality/nullability issues with Registry values
|
||||
* Explicitly specify 'Locale#ROOT' for all String#toLowerCaser() calls
|
||||
* Removed 'end skylight' for 1.21.8 and below
|
||||
* Log warning message when failing to uninject from velocity initializer
|
||||
* Recommend release builds (and fallback to development builds) to users who run outdated software.
|
||||
* Add 'CHAIN' to the 'CHAINS' tag
|
||||
* Add new offset(Blockface face, int i) method to Vector3f/d/i classes
|
||||
* Fixed 'infiniburn' tag parsing for 1.18.1 and older
|
||||
* Fixed unexpected NPE if bukkit entity is null during unsafe lookup
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.11.1...v2.11.2
|
||||
|
||||
## If you want to support PacketEvents, consider donating to us on [PayPal](https://paypal.me/retrooperdev) or sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper).
|
||||
|
||||
## Maven/Gradle Dependency Setup Guide
|
||||
|
||||
**Check it out**: https://docs.packetevents.com/introduction/development-setup/
|
||||
|
||||
|
||||
!!!!! v2.11.1
|
||||
|
||||
# PacketEvents 2.11.1 is finally out! 🎉
|
||||
|
||||
This update fixes various bugs. It's encouraged that users update.
|
||||
Thanks to all users who donated after the previous release announcement. It's been received & it's appreciated.
|
||||
|
||||
Recent donors: TrekCraft, 3add, Vadim Soudé
|
||||
|
||||
If you intend on donating and do not wish to be mentioned, please add such a note on your donation.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### Visit our website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed (Summary)
|
||||
* Fixed 'Can't resolve 'minecraft:day' in 'minecraft:timeline' for V_1_21_11'
|
||||
* Fixed decoding & encoding for WrapperLoginServerPluginRequest & WrapperLoginClientPluginResponse
|
||||
* Improve StateTypes testing
|
||||
* Added system property packetevents.debug.nbt-codec-trace
|
||||
* Fixed Sound Codec
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.11.0...v2.11.1
|
||||
|
||||
## If you want to support PacketEvents, consider donating to us on [PayPal](https://paypal.me/retrooperdev) or sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.11.0
|
||||
|
||||
# PacketEvents 2.11.0 is finally out! 🎉
|
||||
|
||||
This update adds support for Minecraft 1.21.11.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### Visit our website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed (Summary)
|
||||
|
||||
* Added support for Minecraft 1.21.11
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.10.1...v2.11.0
|
||||
|
||||
## If you want to support PacketEvents, consider donating to us on [PayPal](https://paypal.me/retrooperdev) or sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.10.1
|
||||
|
||||
# PacketEvents 2.10.1 is finally out! 🎉
|
||||
|
||||
This update includes some bug fixes.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### Visit our website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed (Summary)
|
||||
|
||||
* Fixed for certain particle types on 1.21.9 & 1.21.10 Minecraft
|
||||
* Fixed the bee's component on 1.21.9 & 1.21.10 Minecraft
|
||||
* Correction of 'mul' calculation in LpVector3d
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.10.0...v2.10.1
|
||||
|
||||
## If you want to support PacketEvents, consider sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.10.0
|
||||
|
||||
# PacketEvents 2.10.0 is finally out! 🎉
|
||||
|
||||
This update includes critical bug fixes & minor additions to the API.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### We have our very own website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed (Summary)
|
||||
|
||||
* Added 1.21.9 & 1.21.10 support
|
||||
* Various bug fixes (such as TPS reading, PlayerModelType reading/writing, and more)
|
||||
* Update adventure API
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.9.5...v2.10.0
|
||||
|
||||
## If you want to support PacketEvents, consider sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.9.5
|
||||
|
||||
# PacketEvents 2.9.5 is out now! 🎉
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!--suppress HtmlDeprecatedAttribute -->
|
||||
<div align="center">
|
||||
<h2><i>PacketEvents</i></h2>
|
||||
<h3><i>A powerful networking library for Minecraft packet processing and manipulation.</i></h3>
|
||||
<h3>PacketEvents is a protocol library tailored to Minecraft Java Edition, designed to facilitate the processing and transmission of packets.</h3>
|
||||
<a href="https://github.com/retrooper/packetevents/actions"><img src="https://img.shields.io/github/actions/workflow/status/retrooper/packetevents/gradle-publish.yml?style=for-the-badge&logo=github"></a>
|
||||
<a href="https://discord.gg/DVHxPPxHZc"><img src="https://img.shields.io/discord/721686193061888071?color=5562e9&logo=discord&logoColor=white&style=for-the-badge"></a>
|
||||
<img src="https://img.shields.io/github/license/retrooper/packetevents?style=for-the-badge&logo=github">
|
||||
@@ -11,7 +11,7 @@
|
||||
<h3>Resources</h3>
|
||||
|
||||
- [Read documentation](https://docs.packetevents.com/)
|
||||
- [Getting Started](https://docs.packetevents.com/getting-started)
|
||||
- [Getting Started](https://docs.packetevents.com/development-setup)
|
||||
- [JavaDocs](https://javadocs.packetevents.com)
|
||||
- [Releases](https://github.com/retrooper/packetevents/releases/)
|
||||
- [Modrinth](https://modrinth.com/plugin/packetevents)
|
||||
|
||||
@@ -31,15 +31,6 @@ dependencies {
|
||||
}
|
||||
compileOnly(libs.gson)
|
||||
|
||||
testImplementation(libs.bundles.adventure)
|
||||
testImplementation(project(":patch:adventure-text-serializer-gson"))
|
||||
testImplementation(libs.adventure.text.serializer.legacy)
|
||||
testImplementation(project(":netty-common"))
|
||||
testImplementation(testlibs.mockbukkit)
|
||||
testImplementation(testlibs.slf4j)
|
||||
testImplementation(testlibs.bundles.junit)
|
||||
testImplementation(libs.netty)
|
||||
testImplementation(libs.classgraph)
|
||||
}
|
||||
|
||||
mappingCompression {
|
||||
@@ -83,10 +74,6 @@ tasks {
|
||||
packageName = "com.github.retrooper.packetevents.util"
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
exclude {
|
||||
val path = it.path
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.event.PacketEvent;
|
||||
import com.github.retrooper.packetevents.event.PacketListenerAbstract;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* The {@link PacketEvent} implements this interface.
|
||||
@@ -31,7 +30,9 @@ import com.github.retrooper.packetevents.event.PacketListenerAbstract;
|
||||
* @author retrooper
|
||||
* @since 1.8
|
||||
*/
|
||||
@NullMarked
|
||||
public interface CallableEvent {
|
||||
|
||||
default void call(PacketListenerCommon listener) {
|
||||
listener.onPacketEventExternal((PacketEvent) this);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class EventManager {
|
||||
* be the final decider whether the event has been cancelled or not.
|
||||
*
|
||||
* @param event {@link PacketEvent}
|
||||
* @param postCallListenerAction The action to be ran after all the listeners have finished processing
|
||||
* @param postCallListenerAction The action to be run after all the listeners have finished processing
|
||||
*/
|
||||
public void callEvent(PacketEvent event, @Nullable Runnable postCallListenerAction) {
|
||||
for (PacketListenerCommon listener : listeners) {
|
||||
@@ -84,7 +84,7 @@ public class EventManager {
|
||||
event.call(listener);
|
||||
} catch (Exception t) {
|
||||
// ignore handshake exceptions
|
||||
if (t.getClass() != InvalidHandshakeException.class) {
|
||||
if (t.getClass() != InvalidHandshakeException.class && (t.getCause() == null || t.getCause().getClass() != InvalidHandshakeException.class)) {
|
||||
PacketEvents.getAPI().getLogger().log(Level.WARNING, "PacketEvents caught an unhandled exception while calling your listener.", t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.util.TimeStampMode;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* An event in both of PacketEvents' event systems.
|
||||
@@ -28,7 +29,9 @@ import com.github.retrooper.packetevents.util.TimeStampMode;
|
||||
* @author retrooper
|
||||
* @since 1.2.6
|
||||
*/
|
||||
@NullMarked
|
||||
public abstract class PacketEvent implements CallableEvent {
|
||||
|
||||
private final long timestamp;
|
||||
|
||||
public PacketEvent() {
|
||||
@@ -60,4 +63,4 @@ public abstract class PacketEvent implements CallableEvent {
|
||||
public void callPacketEventExternal(PacketListenerCommon listener) {
|
||||
listener.onPacketEventExternal(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,17 +24,25 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.PacketSide;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketReceiveEvent extends ProtocolPacketEvent {
|
||||
protected PacketReceiveEvent(Object channel, User user, Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
protected PacketReceiveEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(PacketSide.CLIENT, channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketReceiveEvent(int packetID, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel, User user, Object player,
|
||||
Object byteBuf) throws PacketProcessException {
|
||||
protected PacketReceiveEvent(
|
||||
int packetID, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetID, packetType, serverVersion,
|
||||
channel, user, player, byteBuf);
|
||||
}
|
||||
@@ -46,13 +54,8 @@ public class PacketReceiveEvent extends ProtocolPacketEvent {
|
||||
|
||||
@Override
|
||||
public PacketReceiveEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
}
|
||||
@@ -18,32 +18,38 @@
|
||||
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.event.simple.PacketHandshakeSendEvent;
|
||||
import com.github.retrooper.packetevents.exception.PacketProcessException;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.PacketSide;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@NullMarked
|
||||
public class PacketSendEvent extends ProtocolPacketEvent {
|
||||
private List<Runnable> tasksAfterSend = null;
|
||||
|
||||
protected PacketSendEvent(Object channel, User user, Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
private @Nullable List<Runnable> tasksAfterSend = null;
|
||||
|
||||
protected PacketSendEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(PacketSide.SERVER, channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketSendEvent(int packetID, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
Object player, Object byteBuf) throws PacketProcessException {
|
||||
super(packetID, packetType,
|
||||
serverVersion,
|
||||
channel, user, player, byteBuf);
|
||||
protected PacketSendEvent(
|
||||
int packetID, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetID, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,13 +71,8 @@ public class PacketSendEvent extends ProtocolPacketEvent {
|
||||
|
||||
@Override
|
||||
public PacketSendEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
}
|
||||
@@ -18,17 +18,22 @@
|
||||
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Every event that has an associated player is recommended to implement this interface.
|
||||
*
|
||||
* @author retrooper
|
||||
* @since 1.6.9
|
||||
*/
|
||||
@NullMarked
|
||||
public interface PlayerEvent {
|
||||
|
||||
/**
|
||||
* Associated player.
|
||||
*
|
||||
* @return Player.
|
||||
*/
|
||||
<T> T getPlayer();
|
||||
<T> @UnknownNullability T getPlayer();
|
||||
}
|
||||
+38
-27
@@ -33,40 +33,49 @@ import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@NullMarked
|
||||
public abstract class ProtocolPacketEvent extends PacketEvent implements PlayerEvent, CancellableEvent, UserEvent {
|
||||
private final Object channel;
|
||||
private final ConnectionState connectionState;
|
||||
private final User user;
|
||||
private Object player;
|
||||
private Object byteBuf;
|
||||
|
||||
private final int packetID;
|
||||
private final PacketTypeCommon packetType;
|
||||
private ServerVersion serverVersion;
|
||||
|
||||
private final Object channel;
|
||||
private final ConnectionState connectionState;
|
||||
private final User user;
|
||||
|
||||
private @UnknownNullability Object player;
|
||||
private Object byteBuf;
|
||||
|
||||
private boolean cancel;
|
||||
private PacketWrapper<?> lastUsedWrapper;
|
||||
private List<Runnable> postTasks = null;
|
||||
private @Nullable PacketWrapper<?> lastUsedWrapper;
|
||||
private @Nullable List<Runnable> postTasks = null;
|
||||
|
||||
private boolean cloned;
|
||||
private boolean needsReEncode = PacketEvents.getAPI().getSettings().reEncodeByDefault();
|
||||
|
||||
public ProtocolPacketEvent(PacketSide packetSide, Object channel,
|
||||
User user, Object player, Object byteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
public ProtocolPacketEvent(
|
||||
PacketSide packetSide, Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
this.channel = channel;
|
||||
this.user = user;
|
||||
this.player = player;
|
||||
|
||||
if (autoProtocolTranslation || user.getClientVersion() == null) {
|
||||
this.serverVersion = PacketEvents.getAPI().getServerManager().getVersion();
|
||||
} else {
|
||||
//TODO Optimize
|
||||
this.serverVersion = user.getClientVersion().toServerVersion();
|
||||
this.serverVersion = user.getPacketVersion().toServerVersion();
|
||||
}
|
||||
|
||||
this.byteBuf = byteBuf;
|
||||
@@ -79,22 +88,25 @@ public abstract class ProtocolPacketEvent extends PacketEvent implements PlayerE
|
||||
} catch (Exception e) {
|
||||
throw new PacketProcessException("Failed to read the Packet ID of a packet. (Size: " + size + ")");
|
||||
}
|
||||
|
||||
ClientVersion version = serverVersion.toClientVersion();
|
||||
ConnectionState state = packetSide == PacketSide.CLIENT ? user.getDecoderState() : user.getEncoderState();
|
||||
this.packetType = PacketType.getById(packetSide, state,
|
||||
version, packetID);
|
||||
if (this.packetType == null) {
|
||||
this.connectionState = packetSide == PacketSide.CLIENT ? user.getDecoderState() : user.getEncoderState();
|
||||
PacketTypeCommon packetType = PacketType.getById(packetSide, this.connectionState, version, this.packetID);
|
||||
if (packetType == null) {
|
||||
// mojang messed up and keeps sending disconnect packets in the wrong protocol state
|
||||
if (PacketType.getById(packetSide, ConnectionState.PLAY, version, packetID) == PacketType.Play.Server.DISCONNECT) {
|
||||
throw new InvalidDisconnectPacketSend();
|
||||
}
|
||||
throw new PacketProcessException("Failed to map the Packet ID " + packetID + " to a PacketType constant. Bound: " + packetSide.getOpposite() + ", Connection state: " + user.getDecoderState() + ", Server version: " + serverVersion.getReleaseName());
|
||||
}
|
||||
this.connectionState = state;
|
||||
this.packetType = packetType;
|
||||
}
|
||||
|
||||
public ProtocolPacketEvent(int packetID, PacketTypeCommon packetType, ServerVersion serverVersion, Object channel,
|
||||
User user, Object player, Object byteBuf) {
|
||||
public ProtocolPacketEvent(
|
||||
int packetID, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) {
|
||||
this.channel = channel;
|
||||
this.user = user;
|
||||
this.player = player;
|
||||
@@ -105,7 +117,7 @@ public abstract class ProtocolPacketEvent extends PacketEvent implements PlayerE
|
||||
|
||||
this.connectionState = (packetType != null && packetType.getSide() == PacketSide.SERVER)
|
||||
? user.getEncoderState() : user.getDecoderState();
|
||||
cloned = true;
|
||||
this.cloned = true;
|
||||
}
|
||||
|
||||
public void markForReEncode(boolean needsReEncode) {
|
||||
@@ -116,7 +128,6 @@ public abstract class ProtocolPacketEvent extends PacketEvent implements PlayerE
|
||||
return needsReEncode;
|
||||
}
|
||||
|
||||
|
||||
public boolean isClone() {
|
||||
return cloned;
|
||||
}
|
||||
@@ -142,7 +153,7 @@ public abstract class ProtocolPacketEvent extends PacketEvent implements PlayerE
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getPlayer() {
|
||||
public <T> @UnknownNullability T getPlayer() {
|
||||
return (T) player;
|
||||
}
|
||||
|
||||
@@ -159,14 +170,13 @@ public abstract class ProtocolPacketEvent extends PacketEvent implements PlayerE
|
||||
return connectionState;
|
||||
}
|
||||
|
||||
//TODO Possibly put clientversion inside User class and remove here
|
||||
@Deprecated
|
||||
public ClientVersion getClientVersion() {
|
||||
return user.getClientVersion();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setClientVersion(@NotNull ClientVersion clientVersion) {
|
||||
public void setClientVersion(ClientVersion clientVersion) {
|
||||
PacketEvents.getAPI().getLogManager().debug("Setting client version with deprecated method " + clientVersion.getReleaseName());
|
||||
user.setClientVersion(clientVersion);
|
||||
}
|
||||
@@ -175,7 +185,8 @@ public abstract class ProtocolPacketEvent extends PacketEvent implements PlayerE
|
||||
return serverVersion;
|
||||
}
|
||||
|
||||
public void setServerVersion(@NotNull ServerVersion serverVersion) {
|
||||
@Deprecated
|
||||
public void setServerVersion(ServerVersion serverVersion) {
|
||||
this.serverVersion = serverVersion;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,11 @@
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class UserConnectEvent extends PacketEvent implements CancellableEvent, UserEvent {
|
||||
|
||||
public class UserConnectEvent extends PacketEvent implements CancellableEvent, UserEvent{
|
||||
private final User user;
|
||||
private boolean cancelled;
|
||||
|
||||
|
||||
@@ -19,8 +19,11 @@
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class UserDisconnectEvent extends PacketEvent implements UserEvent {
|
||||
|
||||
private final User user;
|
||||
|
||||
public UserDisconnectEvent(User user) {
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Event that involves users.
|
||||
@@ -26,6 +27,8 @@ import com.github.retrooper.packetevents.protocol.player.User;
|
||||
* @author retrooper
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@NullMarked
|
||||
public interface UserEvent {
|
||||
|
||||
User getUser();
|
||||
}
|
||||
@@ -19,8 +19,11 @@
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class UserLoginEvent extends PacketEvent implements CallableEvent, UserEvent, PlayerEvent {
|
||||
|
||||
private final User user;
|
||||
private final Object player;
|
||||
|
||||
|
||||
+16
-15
@@ -25,32 +25,33 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketConfigReceiveEvent extends PacketReceiveEvent {
|
||||
|
||||
public PacketConfigReceiveEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
public PacketConfigReceiveEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketConfigReceiveEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketConfigReceiveEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketConfigReceiveEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketConfigReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketConfigReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Configuration.Client getPacketType() {
|
||||
|
||||
+16
-15
@@ -25,32 +25,33 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketConfigSendEvent extends PacketSendEvent {
|
||||
|
||||
public PacketConfigSendEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
public PacketConfigSendEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketConfigSendEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketConfigSendEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketConfigSendEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketConfigSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketConfigSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Configuration.Server getPacketType() {
|
||||
|
||||
+17
-15
@@ -25,31 +25,33 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketHandshakeReceiveEvent extends PacketReceiveEvent {
|
||||
public PacketHandshakeReceiveEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketHandshakeReceiveEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketHandshakeReceiveEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketHandshakeReceiveEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketHandshakeReceiveEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketHandshakeReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketHandshakeReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Handshaking.Client getPacketType() {
|
||||
|
||||
+17
-15
@@ -7,31 +7,33 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketHandshakeSendEvent extends PacketSendEvent {
|
||||
public PacketHandshakeSendEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketHandshakeSendEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketHandshakeSendEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketHandshakeSendEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketHandshakeSendEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketHandshakeSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketHandshakeSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Handshaking.Client getPacketType() {
|
||||
|
||||
+17
-15
@@ -25,31 +25,33 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketLoginReceiveEvent extends PacketReceiveEvent {
|
||||
public PacketLoginReceiveEvent(Object channel, User user, Object player,
|
||||
Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketLoginReceiveEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketLoginReceiveEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketLoginReceiveEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketLoginReceiveEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketLoginReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketLoginReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+17
-14
@@ -25,30 +25,33 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketLoginSendEvent extends PacketSendEvent {
|
||||
public PacketLoginSendEvent(Object channel, User user, Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketLoginSendEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketLoginSendEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketLoginSendEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketLoginSendEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketLoginSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketLoginSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Login.Server getPacketType() {
|
||||
|
||||
+17
-15
@@ -25,31 +25,33 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketPlayReceiveEvent extends PacketReceiveEvent {
|
||||
public PacketPlayReceiveEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketPlayReceiveEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketPlayReceiveEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketPlayReceiveEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketPlayReceiveEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketPlayReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketPlayReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Play.Client getPacketType() {
|
||||
|
||||
+17
-15
@@ -25,31 +25,33 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketPlaySendEvent extends PacketSendEvent {
|
||||
public PacketPlaySendEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketPlaySendEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketPlaySendEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketPlaySendEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketPlaySendEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketPlaySendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketPlaySendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Play.Server getPacketType() {
|
||||
|
||||
+17
-15
@@ -25,31 +25,33 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketStatusReceiveEvent extends PacketReceiveEvent {
|
||||
public PacketStatusReceiveEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketStatusReceiveEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketStatusReceiveEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketStatusReceiveEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketStatusReceiveEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketStatusReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketStatusReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Status.Client getPacketType() {
|
||||
|
||||
+17
-14
@@ -25,30 +25,33 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketStatusSendEvent extends PacketSendEvent {
|
||||
public PacketStatusSendEvent(Object channel, User user, Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketStatusSendEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketStatusSendEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketStatusSendEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketStatusSendEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketStatusSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketStatusSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
@@ -32,6 +32,7 @@ import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import com.github.retrooper.packetevents.protocol.player.UserProfile;
|
||||
import com.github.retrooper.packetevents.util.LogManager;
|
||||
import com.github.retrooper.packetevents.util.mappings.SynchronizedRegistriesHandler;
|
||||
import com.github.retrooper.packetevents.wrapper.configuration.server.WrapperConfigServerConfigurationEnd;
|
||||
import com.github.retrooper.packetevents.wrapper.configuration.server.WrapperConfigServerRegistryData;
|
||||
import com.github.retrooper.packetevents.wrapper.handshaking.client.WrapperHandshakingClientHandshake;
|
||||
import com.github.retrooper.packetevents.wrapper.login.server.WrapperLoginServerLoginSuccess;
|
||||
@@ -106,6 +107,7 @@ public class InternalPacketListener extends PacketListenerAbstract {
|
||||
if (joinGame.getDimensionCodec() != null) { // 1.16 to 1.20.1
|
||||
SynchronizedRegistriesHandler.handleLegacyRegistries(user, joinGame,
|
||||
joinGame.getDimensionCodec());
|
||||
user.finalizeRegistries(joinGame);
|
||||
}
|
||||
|
||||
user.setDimensionType(joinGame.getDimensionType());
|
||||
@@ -119,6 +121,7 @@ public class InternalPacketListener extends PacketListenerAbstract {
|
||||
user.setEncoderState(ConnectionState.CONFIGURATION);
|
||||
} else if (event.getPacketType() == PacketType.Configuration.Server.CONFIGURATION_END) {
|
||||
user.setEncoderState(ConnectionState.PLAY);
|
||||
user.finalizeRegistries(new WrapperConfigServerConfigurationEnd(event));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -50,8 +50,8 @@ public enum ServerVersion {
|
||||
V_1_19(759), V_1_19_1(760), V_1_19_2(760), V_1_19_3(761), V_1_19_4(762),
|
||||
//1.20 and 1.20.1 have the same protocol version. 1.20.3 and 1.20.4 have the same protocol version. 1.20.5 and 1.20.6 have the same protocol version
|
||||
V_1_20(763), V_1_20_1(763), V_1_20_2(764), V_1_20_3(765), V_1_20_4(765), V_1_20_5(766), V_1_20_6(766),
|
||||
//1.21 and 1.21.1 have the same protocol version. 1.21.2 and 1.21.3 have the same protocol version
|
||||
V_1_21(767), V_1_21_1(767), V_1_21_2(768), V_1_21_3(768), V_1_21_4(769), V_1_21_5(770), V_1_21_6(771), V_1_21_7(772), V_1_21_8(772),
|
||||
//1.21 and 1.21.1 have the same protocol version. 1.21.2 and 1.21.3 have the same protocol version. 1.21.7 and 1.21.8 have the same protocol version. 1.21.9 and 1.21.10 have the same protocol version
|
||||
V_1_21(767), V_1_21_1(767), V_1_21_2(768), V_1_21_3(768), V_1_21_4(769), V_1_21_5(770), V_1_21_6(771), V_1_21_7(772), V_1_21_8(772), V_1_21_9(773), V_1_21_10(773), V_1_21_11(774),
|
||||
//TODO UPDATE Add server version constant
|
||||
ERROR(-1, true);
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
package com.github.retrooper.packetevents.manager.server;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* System Operating system.
|
||||
*
|
||||
@@ -36,9 +38,9 @@ public enum SystemOS {
|
||||
* @return Operating System.
|
||||
*/
|
||||
public static SystemOS getOSNoCache() {
|
||||
final String os = System.getProperty("os.name").toLowerCase();
|
||||
final String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);
|
||||
for (SystemOS sysos : values()) {
|
||||
if (os.contains(sysos.name().toLowerCase())) {
|
||||
if (os.contains(sysos.name().toLowerCase(Locale.ROOT))) {
|
||||
return sysos;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +103,10 @@ public class ByteBufHelper {
|
||||
PacketEvents.getAPI().getNettyManager().getByteBufOperator().writeShort(buffer, value);
|
||||
}
|
||||
|
||||
public static void writeShortLE(Object buffer, int value) {
|
||||
PacketEvents.getAPI().getNettyManager().getByteBufOperator().writeShortLE(buffer, value);
|
||||
}
|
||||
|
||||
public static int readMedium(Object buffer) {
|
||||
return PacketEvents.getAPI().getNettyManager().getByteBufOperator().readMedium(buffer);
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public interface ByteBufOperator {
|
||||
|
||||
void writeByte(Object buffer, int value);
|
||||
void writeShort(Object buffer, int value);
|
||||
void writeShortLE(Object buffer, int value);
|
||||
void writeMedium(Object buffer, int value);
|
||||
void writeInt(Object buffer, int value);
|
||||
void writeLong(Object buffer, long value);
|
||||
|
||||
@@ -31,13 +31,15 @@ import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.util.Index;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.github.retrooper.packetevents.util.adventure.AdventureIndexUtil.indexValueOrThrow;
|
||||
|
||||
@NullMarked
|
||||
public interface ChatType extends MappedEntity, CopyableEntity<ChatType>, DeepComparableEntity {
|
||||
|
||||
@UnknownNullability("only nullable for 1.19")
|
||||
|
||||
+7
-6
@@ -21,11 +21,13 @@ package com.github.retrooper.packetevents.protocol.chat;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@NullMarked
|
||||
public class StaticChatType extends AbstractMappedEntity implements ChatType {
|
||||
|
||||
private final @UnknownNullability("only nullable for 1.19") ChatTypeDecoration chatDecoration;
|
||||
@@ -61,9 +63,9 @@ public class StaticChatType extends AbstractMappedEntity implements ChatType {
|
||||
@ApiStatus.Internal
|
||||
public StaticChatType(
|
||||
@Nullable TypesBuilderData data,
|
||||
@UnknownNullability("only nullable for 1.19") ChatTypeDecoration chatDecoration,
|
||||
@Nullable ChatTypeDecoration chatDecoration,
|
||||
@Nullable ChatTypeDecoration overlayDecoration,
|
||||
@UnknownNullability("only nullable for 1.19") ChatTypeDecoration narrationDecoration,
|
||||
@Nullable ChatTypeDecoration narrationDecoration,
|
||||
@Nullable NarrationPriority narrationPriority
|
||||
) {
|
||||
super(data);
|
||||
@@ -100,10 +102,9 @@ public class StaticChatType extends AbstractMappedEntity implements ChatType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deepEquals(Object obj) {
|
||||
public boolean deepEquals(@Nullable Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof StaticChatType)) return false;
|
||||
if (!super.equals(obj)) return false;
|
||||
StaticChatType that = (StaticChatType) obj;
|
||||
if (!Objects.equals(this.chatDecoration, that.chatDecoration)) return false;
|
||||
if (!Objects.equals(this.overlayDecoration, that.overlayDecoration)) return false;
|
||||
@@ -113,7 +114,7 @@ public class StaticChatType extends AbstractMappedEntity implements ChatType {
|
||||
|
||||
@Override
|
||||
public int deepHashCode() {
|
||||
return Objects.hash(super.hashCode(), this.chatDecoration, this.overlayDecoration, this.narrationDecoration, this.narrationPriority);
|
||||
return Objects.hash(this.chatDecoration, this.overlayDecoration, this.narrationDecoration, this.narrationPriority);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat.message.reader.impl;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.chat.ChatTypes;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessage;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessageLegacy;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.reader.ChatMessageProcessor;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ChatMessageProcessor_v1_7 implements ChatMessageProcessor {
|
||||
@Override
|
||||
public ChatMessage readChatMessage(@NotNull PacketWrapper<?> wrapper) {
|
||||
Component chatContent = wrapper.readComponent();
|
||||
return new ChatMessageLegacy(chatContent, ChatTypes.CHAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeChatMessage(@NotNull PacketWrapper<?> wrapper, @NotNull ChatMessage data) {
|
||||
wrapper.writeComponent(data.getChatContent());
|
||||
}
|
||||
}
|
||||
+93
-18
@@ -27,10 +27,14 @@ import com.github.retrooper.packetevents.protocol.nbt.NBTType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.util.MathUtil;
|
||||
import org.jetbrains.annotations.Range;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public final class AlphaColor extends Color {
|
||||
|
||||
public static final AlphaColor WHITE = new AlphaColor(0xFFFFFFFF);
|
||||
public static final AlphaColor BLACK = new AlphaColor(0xFF000000);
|
||||
public static final AlphaColor TRANSPARENT = new AlphaColor(0x00000000);
|
||||
|
||||
private final int alpha;
|
||||
|
||||
@@ -49,7 +53,7 @@ public final class AlphaColor extends Color {
|
||||
@Range(from = 0L, to = 255L) int blue
|
||||
) {
|
||||
super(red, green, blue);
|
||||
this.alpha = alpha;
|
||||
this.alpha = MathUtil.clamp(alpha, 0, 255);
|
||||
}
|
||||
|
||||
public AlphaColor(
|
||||
@@ -101,8 +105,9 @@ public final class AlphaColor extends Color {
|
||||
return list;
|
||||
}
|
||||
|
||||
public AlphaColor withAlpha(@Range(from = 0L, to = 255L) int alpha) {
|
||||
return new AlphaColor(alpha, this.red, this.green, this.blue);
|
||||
@Override
|
||||
public AlphaColor withAlpha() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -125,22 +130,92 @@ public final class AlphaColor extends Color {
|
||||
return (this.alpha << 24) | (this.red << 16) | (this.green << 8) | this.blue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor plus(Color other) {
|
||||
return new AlphaColor(
|
||||
this.alpha,
|
||||
this.red + other.red,
|
||||
this.green + other.green,
|
||||
this.blue + other.blue
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor minus(Color other) {
|
||||
return new AlphaColor(
|
||||
this.alpha,
|
||||
this.red - other.red,
|
||||
this.green - other.green,
|
||||
this.blue - other.blue
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor times(Color other) {
|
||||
if (other.alpha() == 255 && other.red == 255 && other.green == 255 && other.blue == 255) {
|
||||
return this;
|
||||
}
|
||||
return new AlphaColor(
|
||||
(this.alpha * other.alpha()) / 255,
|
||||
(this.red * other.red) / 255,
|
||||
(this.green * other.green) / 255,
|
||||
(this.blue * other.blue) / 255
|
||||
);
|
||||
}
|
||||
|
||||
public AlphaColor blendWith(AlphaColor source) {
|
||||
int srcAlpha = source.alpha;
|
||||
if (srcAlpha == 255) {
|
||||
return source;
|
||||
} else if (srcAlpha == 0) {
|
||||
return this;
|
||||
}
|
||||
int alpha = srcAlpha + (this.alpha * (255 - srcAlpha)) / 255;
|
||||
return new AlphaColor(
|
||||
alpha,
|
||||
alphaBlendChannel(alpha, srcAlpha, this.red, source.red),
|
||||
alphaBlendChannel(alpha, srcAlpha, this.green, source.green),
|
||||
alphaBlendChannel(alpha, srcAlpha, this.blue, source.blue)
|
||||
);
|
||||
}
|
||||
|
||||
protected static int alphaBlendChannel(int alpha, int srcAlpha, int dest, int src) {
|
||||
return (src * srcAlpha + dest * (alpha - srcAlpha)) / alpha;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor asGrayscale() {
|
||||
int grayscale = (int) ((float) this.red * 0.30f + (float) this.green * 0.59f + (float) this.blue * 0.11f);
|
||||
return new AlphaColor(this.alpha, grayscale, grayscale, grayscale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor scale(float scale) {
|
||||
return this.scale(scale, scale, scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor scale(float redScale, float greenScale, float blueScale) {
|
||||
return new AlphaColor(
|
||||
this.alpha,
|
||||
(int) ((float) this.red * redScale),
|
||||
(int) ((float) this.green * greenScale),
|
||||
(int) ((float) this.blue * blueScale)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor lerpSrgb(Color dest, float t) {
|
||||
return new AlphaColor(
|
||||
MathUtil.lerp(t, this.alpha, dest.alpha()),
|
||||
MathUtil.lerp(t, this.red, dest.red),
|
||||
MathUtil.lerp(t, this.green, dest.green),
|
||||
MathUtil.lerp(t, this.blue, dest.blue)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Range(from = 0L, to = 255L) int alpha() {
|
||||
return this.alpha;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Range(from = 0L, to = 255L) int red() {
|
||||
return this.red;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Range(from = 0L, to = 255L) int green() {
|
||||
return this.green;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Range(from = 0L, to = 255L) int blue() {
|
||||
return this.blue;
|
||||
}
|
||||
}
|
||||
@@ -28,19 +28,29 @@ import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.util.MathUtil;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.util.RGBLike;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Range;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@NullMarked
|
||||
public class Color implements RGBLike {
|
||||
|
||||
public static final Color WHITE = new Color(0xFFFFFFFF);
|
||||
public static final Color BLACK = new Color(0xFF000000);
|
||||
|
||||
protected static final int BIT_MASK = 0xFF;
|
||||
|
||||
protected final int red, green, blue;
|
||||
|
||||
public Color(@Range(from = 0L, to = 255L) int red, @Range(from = 0L, to = 255L) int green, @Range(from = 0L, to = 255L) int blue) {
|
||||
this.red = red;
|
||||
this.green = green;
|
||||
this.blue = blue;
|
||||
public Color(
|
||||
@Range(from = 0L, to = 255L) int red,
|
||||
@Range(from = 0L, to = 255L) int green,
|
||||
@Range(from = 0L, to = 255L) int blue
|
||||
) {
|
||||
this.red = MathUtil.clamp(red, 0, 255);
|
||||
this.green = MathUtil.clamp(green, 0, 255);
|
||||
this.blue = MathUtil.clamp(blue, 0, 255);
|
||||
}
|
||||
|
||||
public Color(
|
||||
@@ -75,6 +85,11 @@ public class Color implements RGBLike {
|
||||
wrapper.writeByte(color.blue);
|
||||
}
|
||||
|
||||
public static Color decode(NBT nbt, PacketWrapper<?> wrapper) {
|
||||
return decode(nbt, wrapper.getServerVersion().toClientVersion());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Color decode(NBT nbt, ClientVersion version) {
|
||||
if (nbt instanceof NBTNumber) {
|
||||
return new Color(((NBTNumber) nbt).getAsInt());
|
||||
@@ -86,6 +101,11 @@ public class Color implements RGBLike {
|
||||
return new Color(red, green, blue);
|
||||
}
|
||||
|
||||
public static NBT encode(PacketWrapper<?> wrapper, Color color) {
|
||||
return encode(color, wrapper.getServerVersion().toClientVersion());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static NBT encode(Color color, ClientVersion version) {
|
||||
if (version.isNewerThanOrEquals(ClientVersion.V_1_21_2)) {
|
||||
return new NBTInt(color.asRGB());
|
||||
@@ -97,15 +117,23 @@ public class Color implements RGBLike {
|
||||
return list;
|
||||
}
|
||||
|
||||
public @NotNull Color withRed(@Range(from = 0L, to = 255L) int red) {
|
||||
public AlphaColor withAlpha() {
|
||||
return this.withAlpha(255);
|
||||
}
|
||||
|
||||
public AlphaColor withAlpha(@Range(from = 0L, to = 255L) int alpha) {
|
||||
return new AlphaColor(alpha, this.red, this.green, this.blue);
|
||||
}
|
||||
|
||||
public Color withRed(@Range(from = 0L, to = 255L) int red) {
|
||||
return new Color(red, green, blue);
|
||||
}
|
||||
|
||||
public @NotNull Color withGreen(@Range(from = 0L, to = 255L) int green) {
|
||||
public Color withGreen(@Range(from = 0L, to = 255L) int green) {
|
||||
return new Color(red, green, blue);
|
||||
}
|
||||
|
||||
public @NotNull Color withBlue(@Range(from = 0L, to = 255L) int blue) {
|
||||
public Color withBlue(@Range(from = 0L, to = 255L) int blue) {
|
||||
return new Color(red, green, blue);
|
||||
}
|
||||
|
||||
@@ -113,6 +141,86 @@ public class Color implements RGBLike {
|
||||
return (this.red << 16) | (this.green << 8) | this.blue;
|
||||
}
|
||||
|
||||
public Color plus(Color other) {
|
||||
return new Color(
|
||||
this.red + other.red,
|
||||
this.green + other.green,
|
||||
this.blue + other.blue
|
||||
);
|
||||
}
|
||||
|
||||
public Color minus(Color other) {
|
||||
return new Color(
|
||||
this.red - other.red,
|
||||
this.green - other.green,
|
||||
this.blue - other.blue
|
||||
);
|
||||
}
|
||||
|
||||
public Color times(Color other) {
|
||||
if (other instanceof AlphaColor) {
|
||||
return other.times(this);
|
||||
} else if (this.red == 255 && this.green == 255 && this.blue == 255) {
|
||||
return other;
|
||||
} else if (other.red == 255 && other.green == 255 && other.blue == 255) {
|
||||
return this;
|
||||
}
|
||||
return new Color(
|
||||
(this.red * other.red) / 255,
|
||||
(this.green * other.green) / 255,
|
||||
(this.blue * other.blue) / 255
|
||||
);
|
||||
}
|
||||
|
||||
public AlphaColor blendWith(AlphaColor source) {
|
||||
int srcAlpha = source.alpha();
|
||||
if (srcAlpha == 255) {
|
||||
return source;
|
||||
} else if (srcAlpha == 0) {
|
||||
return this.withAlpha();
|
||||
}
|
||||
int alpha = srcAlpha + (255 - srcAlpha);
|
||||
return new AlphaColor(
|
||||
alpha,
|
||||
alphaBlendChannel(alpha, srcAlpha, this.red, source.red),
|
||||
alphaBlendChannel(alpha, srcAlpha, this.green, source.green),
|
||||
alphaBlendChannel(alpha, srcAlpha, this.blue, source.blue)
|
||||
);
|
||||
}
|
||||
|
||||
protected static int alphaBlendChannel(int alpha, int srcAlpha, int dest, int src) {
|
||||
return (src * srcAlpha + dest * (alpha - srcAlpha)) / alpha;
|
||||
}
|
||||
|
||||
public Color asGrayscale() {
|
||||
int grayscale = (int) ((float) this.red * 0.30f + (float) this.green * 0.59f + (float) this.blue * 0.11f);
|
||||
return new Color(grayscale, grayscale, grayscale);
|
||||
}
|
||||
|
||||
public Color scale(float scale) {
|
||||
return this.scale(scale, scale, scale);
|
||||
}
|
||||
|
||||
public Color scale(float redScale, float greenScale, float blueScale) {
|
||||
return new Color(
|
||||
(int) ((float) this.red * redScale),
|
||||
(int) ((float) this.green * greenScale),
|
||||
(int) ((float) this.blue * blueScale)
|
||||
);
|
||||
}
|
||||
|
||||
public Color lerpSrgb(Color dest, float t) {
|
||||
return new Color(
|
||||
MathUtil.lerp(t, this.red, dest.red),
|
||||
MathUtil.lerp(t, this.green, dest.green),
|
||||
MathUtil.lerp(t, this.blue, dest.blue)
|
||||
);
|
||||
}
|
||||
|
||||
public @Range(from = 0L, to = 255L) int alpha() {
|
||||
return 255;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Range(from = 0L, to = 255L) int red() {
|
||||
return red;
|
||||
@@ -127,4 +235,17 @@ public class Color implements RGBLike {
|
||||
public @Range(from = 0L, to = 255L) int blue() {
|
||||
return blue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof Color) {
|
||||
return this.asRGB() == ((Color) obj).asRGB();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.asRGB());
|
||||
}
|
||||
}
|
||||
+61
-4
@@ -39,10 +39,13 @@ import com.github.retrooper.packetevents.protocol.component.builtin.ShulkerColor
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.TropicalFishBaseColorComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.TropicalFishPatternColorComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.TropicalFishPatternComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.TypedBlockEntityData;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.TypedEntityData;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.VillagerVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.WolfCollarComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.WolfSoundVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.WolfVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.ZombieNautilusVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ArmorTrim;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.BannerLayers;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.BundleContents;
|
||||
@@ -52,6 +55,7 @@ import com.github.retrooper.packetevents.protocol.component.builtin.item.DebugSt
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.FireworkExplosion;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.FoodProperties;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemAdventurePredicate;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemAttackRange;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemAttributeModifiers;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemBees;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemBlockStateProperties;
|
||||
@@ -62,6 +66,7 @@ import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemCon
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemContainerLoot;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemCustomModelData;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemDamageResistant;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemDamageType;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemDeathProtection;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemDyeColor;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemEnchantable;
|
||||
@@ -70,11 +75,14 @@ import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemEqu
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemFireworks;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemInstrument;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemJukeboxPlayable;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemKineticWeapon;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemLock;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemLore;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemMapDecorations;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemMapPostProcessingState;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemMinimumAttackCharge;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemModel;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemPiercingWeapon;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemPotionContents;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemPotionDurationScale;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemProfile;
|
||||
@@ -83,11 +91,13 @@ import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemPro
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemRarity;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemRecipes;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemRepairable;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemSwingAnimation;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemTool;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemTooltipDisplay;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemTooltipStyle;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemUnbreakable;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemUseCooldown;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemUseEffects;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemUseRemainder;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemWeapon;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.LodestoneTracker;
|
||||
@@ -245,12 +255,18 @@ public final class ComponentTypes {
|
||||
ArmorTrim::read, ArmorTrim::write);
|
||||
public static final ComponentType<DebugStickState> DEBUG_STICK_STATE = define("debug_stick_state",
|
||||
DebugStickState::read, DebugStickState::write);
|
||||
public static final ComponentType<NBTCompound> ENTITY_DATA = define("entity_data",
|
||||
PacketWrapper::readNBT, PacketWrapper::writeNBT);
|
||||
public static final ComponentType<TypedEntityData> TYPED_ENTITY_DATA = define("entity_data",
|
||||
TypedEntityData::read, TypedEntityData::write);
|
||||
@Deprecated
|
||||
public static final ComponentType<NBTCompound> ENTITY_DATA = TYPED_ENTITY_DATA
|
||||
.legacyMap(TypedEntityData::getCompound, TypedEntityData::new);
|
||||
public static final ComponentType<NBTCompound> BUCKET_ENTITY_DATA = define("bucket_entity_data",
|
||||
PacketWrapper::readNBT, PacketWrapper::writeNBT);
|
||||
public static final ComponentType<NBTCompound> BLOCK_ENTITY_DATA = define("block_entity_data",
|
||||
PacketWrapper::readNBT, PacketWrapper::writeNBT);
|
||||
public static final ComponentType<TypedBlockEntityData> TYPED_BLOCK_ENTITY_DATA = define("block_entity_data",
|
||||
TypedBlockEntityData::read, TypedBlockEntityData::write);
|
||||
@Deprecated
|
||||
public static final ComponentType<NBTCompound> BLOCK_ENTITY_DATA = TYPED_BLOCK_ENTITY_DATA
|
||||
.legacyMap(TypedBlockEntityData::getCompound, TypedBlockEntityData::new);
|
||||
public static final ComponentType<ItemInstrument> ITEM_INSTRUMENT = define("instrument",
|
||||
ItemInstrument::read, ItemInstrument::write);
|
||||
@Deprecated
|
||||
@@ -472,6 +488,47 @@ public final class ComponentTypes {
|
||||
public static final ComponentType<ShulkerColorComponent> SHULKER_COLOR = define("shulker/color",
|
||||
ShulkerColorComponent::read, ShulkerColorComponent::write);
|
||||
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ItemUseEffects> USE_EFFECTS = define("use_effects",
|
||||
ItemUseEffects::read, ItemUseEffects::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ItemMinimumAttackCharge> MINIMUM_ATTACK_CHARGE = define("minimum_attack_charge",
|
||||
ItemMinimumAttackCharge::read, ItemMinimumAttackCharge::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ItemDamageType> DAMAGE_TYPE = define("damage_type",
|
||||
ItemDamageType::read, ItemDamageType::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ItemAttackRange> ATTACK_RANGE = define("attack_range",
|
||||
ItemAttackRange::read, ItemAttackRange::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ItemPiercingWeapon> PIERCING_WEAPON = define("piercing_weapon",
|
||||
ItemPiercingWeapon::read, ItemPiercingWeapon::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ItemKineticWeapon> KINETIC_WEAPON = define("kinetic_weapon",
|
||||
ItemKineticWeapon::read, ItemKineticWeapon::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ItemSwingAnimation> SWING_ANIMATION = define("swing_animation",
|
||||
ItemSwingAnimation::read, ItemSwingAnimation::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ZombieNautilusVariantComponent> ZOMBIE_NAUTILUS_VARIANT = define("zombie_nautilus/variant",
|
||||
ZombieNautilusVariantComponent::read, ZombieNautilusVariantComponent::write);
|
||||
|
||||
/**
|
||||
* Returns an immutable view of the component types.
|
||||
*
|
||||
|
||||
+6
@@ -113,6 +113,12 @@ public final class EnchantEffectComponentTypes {
|
||||
public static ComponentType<NBT> TRIDENT_SPIN_ATTACK_STRENGTH = define("trident_spin_attack_strength",
|
||||
(nbt, version) -> nbt, (val, version) -> val);
|
||||
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static ComponentType<NBT> POST_PIERCING_ATTACK = define("post_piercing_attack",
|
||||
(nbt, version) -> nbt, (val, version) -> val);
|
||||
|
||||
static {
|
||||
REGISTRY.unloadMappings();
|
||||
}
|
||||
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.world.blockentity.BlockEntityType;
|
||||
import com.github.retrooper.packetevents.protocol.world.blockentity.BlockEntityTypes;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@NullMarked
|
||||
public final class TypedBlockEntityData {
|
||||
|
||||
private static final BlockEntityType FALLBACK_TYPE = BlockEntityTypes.FURNACE;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
private final BlockEntityType type;
|
||||
private final NBTCompound compound;
|
||||
|
||||
public TypedBlockEntityData(NBTCompound compound) {
|
||||
this(FALLBACK_TYPE, compound);
|
||||
}
|
||||
|
||||
public TypedBlockEntityData(BlockEntityType type, NBTCompound compound) {
|
||||
this.type = type;
|
||||
this.compound = compound;
|
||||
}
|
||||
|
||||
public static TypedBlockEntityData read(PacketWrapper<?> wrapper) {
|
||||
BlockEntityType type = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_9)
|
||||
? wrapper.readMappedEntity(BlockEntityTypes.getRegistry()) : FALLBACK_TYPE;
|
||||
NBTCompound compound = wrapper.readNBT();
|
||||
return new TypedBlockEntityData(type, compound);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, TypedBlockEntityData data) {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_9)) {
|
||||
wrapper.writeMappedEntity(data.type);
|
||||
}
|
||||
wrapper.writeNBT(data.compound);
|
||||
}
|
||||
|
||||
public BlockEntityType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public NBTCompound getCompound() {
|
||||
return this.compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || this.getClass() != obj.getClass()) return false;
|
||||
TypedBlockEntityData that = (TypedBlockEntityData) obj;
|
||||
if (!this.type.equals(that.type)) return false;
|
||||
return this.compound.equals(that.compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.type, this.compound);
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@NullMarked
|
||||
public final class TypedEntityData {
|
||||
|
||||
private static final EntityType FALLBACK_TYPE = EntityTypes.PIG;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
private final EntityType type;
|
||||
private final NBTCompound compound;
|
||||
|
||||
public TypedEntityData(NBTCompound compound) {
|
||||
this(FALLBACK_TYPE, compound);
|
||||
}
|
||||
|
||||
public TypedEntityData(EntityType type, NBTCompound compound) {
|
||||
this.type = type;
|
||||
this.compound = compound;
|
||||
}
|
||||
|
||||
public static TypedEntityData read(PacketWrapper<?> wrapper) {
|
||||
EntityType type = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_9)
|
||||
? wrapper.readMappedEntity(EntityTypes.getRegistry()) : FALLBACK_TYPE;
|
||||
NBTCompound compound = wrapper.readNBT();
|
||||
return new TypedEntityData(type, compound);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, TypedEntityData data) {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_9)) {
|
||||
wrapper.writeMappedEntity(data.type);
|
||||
}
|
||||
wrapper.writeNBT(data.compound);
|
||||
}
|
||||
|
||||
public EntityType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public NBTCompound getCompound() {
|
||||
return this.compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || this.getClass() != obj.getClass()) return false;
|
||||
TypedEntityData that = (TypedEntityData) obj;
|
||||
if (!this.type.equals(that.type)) return false;
|
||||
return this.compound.equals(that.compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.type, this.compound);
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.nautilus.ZombieNautilusVariant;
|
||||
import com.github.retrooper.packetevents.protocol.entity.nautilus.ZombieNautilusVariants;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MaybeMappedEntity;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public class ZombieNautilusVariantComponent {
|
||||
|
||||
private MaybeMappedEntity<ZombieNautilusVariant> variant;
|
||||
|
||||
public ZombieNautilusVariantComponent(MaybeMappedEntity<ZombieNautilusVariant> variant) {
|
||||
this.variant = variant;
|
||||
}
|
||||
|
||||
public static ZombieNautilusVariantComponent read(PacketWrapper<?> wrapper) {
|
||||
MaybeMappedEntity<ZombieNautilusVariant> variant = MaybeMappedEntity.read(wrapper,
|
||||
ZombieNautilusVariants.getRegistry(), ZombieNautilusVariant::read);
|
||||
return new ZombieNautilusVariantComponent(variant);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ZombieNautilusVariantComponent component) {
|
||||
MaybeMappedEntity.write(wrapper, component.variant, ZombieNautilusVariant::write);
|
||||
}
|
||||
|
||||
public MaybeMappedEntity<ZombieNautilusVariant> getVariant() {
|
||||
return this.variant;
|
||||
}
|
||||
|
||||
public void setVariant(MaybeMappedEntity<ZombieNautilusVariant> variant) {
|
||||
this.variant = variant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof ZombieNautilusVariantComponent)) return false;
|
||||
ZombieNautilusVariantComponent that = (ZombieNautilusVariantComponent) obj;
|
||||
return this.variant.equals(that.variant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.variant);
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -21,6 +21,7 @@ package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBT;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTString;
|
||||
import com.github.retrooper.packetevents.util.adventure.AdventureNbtUtil;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
public class CustomData {
|
||||
@@ -34,7 +35,8 @@ public class CustomData {
|
||||
return (NBTCompound) nbt;
|
||||
}
|
||||
if (nbt instanceof NBTString) {
|
||||
// TODO: parse nbt string
|
||||
String nbtString = ((NBTString) nbt).getValue();
|
||||
return (NBTCompound) AdventureNbtUtil.fromString(nbtString);
|
||||
}
|
||||
throw new UnsupportedOperationException("Unsupported custom data nbt type: " + nbt.getType());
|
||||
}
|
||||
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
@NullMarked
|
||||
public class ItemAttackRange {
|
||||
|
||||
private float minRange;
|
||||
private float maxRange;
|
||||
private float minCreativeRange;
|
||||
private float maxCreativeRange;
|
||||
private float hitboxMargin;
|
||||
private float mobFactor;
|
||||
|
||||
public ItemAttackRange(
|
||||
float minRange, float maxRange,
|
||||
float minCreativeRange, float maxCreativeRange,
|
||||
float hitboxMargin, float mobFactor
|
||||
) {
|
||||
this.minRange = minRange;
|
||||
this.maxRange = maxRange;
|
||||
this.minCreativeRange = minCreativeRange;
|
||||
this.maxCreativeRange = maxCreativeRange;
|
||||
this.hitboxMargin = hitboxMargin;
|
||||
this.mobFactor = mobFactor;
|
||||
}
|
||||
|
||||
public static ItemAttackRange read(PacketWrapper<?> wrapper) {
|
||||
float minRange = wrapper.readFloat();
|
||||
float maxRange = wrapper.readFloat();
|
||||
float minCreativeRange = wrapper.readFloat();
|
||||
float maxCreativeRange = wrapper.readFloat();
|
||||
float hitboxMargin = wrapper.readFloat();
|
||||
float mobFactor = wrapper.readFloat();
|
||||
return new ItemAttackRange(minRange, maxRange, minCreativeRange, maxCreativeRange, hitboxMargin, mobFactor);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemAttackRange component) {
|
||||
wrapper.writeFloat(component.minRange);
|
||||
wrapper.writeFloat(component.maxRange);
|
||||
wrapper.writeFloat(component.minCreativeRange);
|
||||
wrapper.writeFloat(component.maxCreativeRange);
|
||||
wrapper.writeFloat(component.hitboxMargin);
|
||||
wrapper.writeFloat(component.mobFactor);
|
||||
}
|
||||
|
||||
public float getMinRange() {
|
||||
return this.minRange;
|
||||
}
|
||||
|
||||
public void setMinRange(float minRange) {
|
||||
this.minRange = minRange;
|
||||
}
|
||||
|
||||
public float getMaxRange() {
|
||||
return this.maxRange;
|
||||
}
|
||||
|
||||
public void setMaxRange(float maxRange) {
|
||||
this.maxRange = maxRange;
|
||||
}
|
||||
|
||||
public float getMinCreativeRange() {
|
||||
return this.minCreativeRange;
|
||||
}
|
||||
|
||||
public void setMinCreativeRange(float minCreativeRange) {
|
||||
this.minCreativeRange = minCreativeRange;
|
||||
}
|
||||
|
||||
public float getMaxCreativeRange() {
|
||||
return this.maxCreativeRange;
|
||||
}
|
||||
|
||||
public void setMaxCreativeRange(float maxCreativeRange) {
|
||||
this.maxCreativeRange = maxCreativeRange;
|
||||
}
|
||||
|
||||
public float getHitboxMargin() {
|
||||
return this.hitboxMargin;
|
||||
}
|
||||
|
||||
public void setHitboxMargin(float hitboxMargin) {
|
||||
this.hitboxMargin = hitboxMargin;
|
||||
}
|
||||
|
||||
public float getMobFactor() {
|
||||
return this.mobFactor;
|
||||
}
|
||||
|
||||
public void setMobFactor(float mobFactor) {
|
||||
this.mobFactor = mobFactor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ItemAttackRange that = (ItemAttackRange) obj;
|
||||
if (Float.compare(that.minRange, this.minRange) != 0) return false;
|
||||
if (Float.compare(that.maxRange, this.maxRange) != 0) return false;
|
||||
if (Float.compare(that.minCreativeRange, this.minCreativeRange) != 0) return false;
|
||||
if (Float.compare(that.maxCreativeRange, this.maxCreativeRange) != 0) return false;
|
||||
if (Float.compare(that.hitboxMargin, this.hitboxMargin) != 0) return false;
|
||||
return Float.compare(that.mobFactor, this.mobFactor) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.minRange, this.maxRange, this.minCreativeRange, this.maxCreativeRange, this.hitboxMargin, this.mobFactor);
|
||||
}
|
||||
}
|
||||
+19
-5
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.TypedEntityData;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
@@ -68,37 +69,50 @@ public class ItemBees {
|
||||
|
||||
public static class BeeEntry {
|
||||
|
||||
private NBTCompound entityData;
|
||||
private TypedEntityData entityData;
|
||||
private int ticksInHive;
|
||||
private int minTicksInHive;
|
||||
|
||||
@Deprecated
|
||||
public BeeEntry(NBTCompound entityData, int ticksInHive, int minTicksInHive) {
|
||||
this(new TypedEntityData(entityData), ticksInHive, minTicksInHive);
|
||||
}
|
||||
|
||||
public BeeEntry(TypedEntityData entityData, int ticksInHive, int minTicksInHive) {
|
||||
this.entityData = entityData;
|
||||
this.ticksInHive = ticksInHive;
|
||||
this.minTicksInHive = minTicksInHive;
|
||||
}
|
||||
|
||||
public static BeeEntry read(PacketWrapper<?> wrapper) {
|
||||
NBTCompound entityData = wrapper.readNBT();
|
||||
TypedEntityData entityData = TypedEntityData.read(wrapper);
|
||||
int ticksInHive = wrapper.readVarInt();
|
||||
int minTicksInHive = wrapper.readVarInt();
|
||||
return new BeeEntry(entityData, ticksInHive, minTicksInHive);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, BeeEntry bee) {
|
||||
wrapper.writeNBT(bee.entityData);
|
||||
TypedEntityData.write(wrapper, bee.entityData);
|
||||
wrapper.writeVarInt(bee.ticksInHive);
|
||||
wrapper.writeVarInt(bee.minTicksInHive);
|
||||
}
|
||||
|
||||
public NBTCompound getEntityData() {
|
||||
public TypedEntityData getTypedEntityData() {
|
||||
return this.entityData;
|
||||
}
|
||||
|
||||
public void setEntityData(NBTCompound entityData) {
|
||||
public void setTypedEntityData(TypedEntityData entityData) {
|
||||
this.entityData = entityData;
|
||||
}
|
||||
|
||||
public NBTCompound getEntityData() {
|
||||
return this.entityData.getCompound();
|
||||
}
|
||||
|
||||
public void setEntityData(NBTCompound entityData) {
|
||||
this.entityData = new TypedEntityData(entityData);
|
||||
}
|
||||
|
||||
public int getTicksInHive() {
|
||||
return this.ticksInHive;
|
||||
}
|
||||
|
||||
+22
@@ -25,6 +25,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Custom model data was completely rewritten with 1.21.4.
|
||||
@@ -131,4 +132,25 @@ public class ItemCustomModelData {
|
||||
this.floats.set(0, (float) legacyId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof ItemCustomModelData)) return false;
|
||||
ItemCustomModelData that = (ItemCustomModelData) obj;
|
||||
if (!floats.equals(that.floats)) return false;
|
||||
if (!flags.equals(that.flags)) return false;
|
||||
if (!strings.equals(that.strings)) return false;
|
||||
return colors.equals(that.colors);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.floats, this.flags, this.strings, this.colors);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ItemCustomModelData{floats=" + floats + ", flags=" + ", strings=" + flags + strings + ", colors=" + colors + '}';
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MaybeMappedEntity;
|
||||
import com.github.retrooper.packetevents.protocol.world.damagetype.DamageType;
|
||||
import com.github.retrooper.packetevents.protocol.world.damagetype.DamageTypes;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
@NullMarked
|
||||
public class ItemDamageType {
|
||||
|
||||
private MaybeMappedEntity<DamageType> damageType;
|
||||
|
||||
public ItemDamageType(DamageType damageType) {
|
||||
this(new MaybeMappedEntity<>(damageType));
|
||||
}
|
||||
|
||||
public ItemDamageType(MaybeMappedEntity<DamageType> damageType) {
|
||||
this.damageType = damageType;
|
||||
}
|
||||
|
||||
public static ItemDamageType read(PacketWrapper<?> wrapper) {
|
||||
MaybeMappedEntity<DamageType> damageType = MaybeMappedEntity.read(wrapper,
|
||||
DamageTypes.getRegistry(), DamageType::read);
|
||||
return new ItemDamageType(damageType);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemDamageType component) {
|
||||
MaybeMappedEntity.write(wrapper, component.damageType, DamageType::write);
|
||||
}
|
||||
|
||||
public MaybeMappedEntity<DamageType> getDamageType() {
|
||||
return this.damageType;
|
||||
}
|
||||
|
||||
public void setDamageType(DamageType damageType) {
|
||||
this.setDamageType(new MaybeMappedEntity<>(damageType));
|
||||
}
|
||||
|
||||
public void setDamageType(MaybeMappedEntity<DamageType> damageType) {
|
||||
this.damageType = damageType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ItemDamageType that = (ItemDamageType) obj;
|
||||
return this.damageType.equals(that.damageType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.damageType);
|
||||
}
|
||||
}
|
||||
+243
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.sound.Sound;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
@NullMarked
|
||||
public class ItemKineticWeapon {
|
||||
|
||||
private int contactCooldownTicks;
|
||||
private int delayTicks;
|
||||
private @Nullable Condition dismountConditions;
|
||||
private @Nullable Condition knockbackConditions;
|
||||
private @Nullable Condition damageConditions;
|
||||
private float forwardMovement;
|
||||
private float damageMultiplier;
|
||||
private @Nullable Sound sound;
|
||||
private @Nullable Sound hitSound;
|
||||
|
||||
public ItemKineticWeapon(
|
||||
int contactCooldownTicks, int delayTicks, @Nullable Condition dismountConditions,
|
||||
@Nullable Condition knockbackConditions, @Nullable Condition damageConditions,
|
||||
float forwardMovement, float damageMultiplier, @Nullable Sound sound, @Nullable Sound hitSound
|
||||
) {
|
||||
this.contactCooldownTicks = contactCooldownTicks;
|
||||
this.delayTicks = delayTicks;
|
||||
this.dismountConditions = dismountConditions;
|
||||
this.knockbackConditions = knockbackConditions;
|
||||
this.damageConditions = damageConditions;
|
||||
this.forwardMovement = forwardMovement;
|
||||
this.damageMultiplier = damageMultiplier;
|
||||
this.sound = sound;
|
||||
this.hitSound = hitSound;
|
||||
}
|
||||
|
||||
public static ItemKineticWeapon read(PacketWrapper<?> wrapper) {
|
||||
int contactCooldownTicks = wrapper.readVarInt();
|
||||
int delayTicks = wrapper.readVarInt();
|
||||
Condition dismountConditions = wrapper.readOptional(Condition::read);
|
||||
Condition knockbackConditions = wrapper.readOptional(Condition::read);
|
||||
Condition damageConditions = wrapper.readOptional(Condition::read);
|
||||
float forwardMovement = wrapper.readFloat();
|
||||
float damageMultiplier = wrapper.readFloat();
|
||||
Sound sound = wrapper.readOptional(Sound::read);
|
||||
Sound hitSound = wrapper.readOptional(Sound::read);
|
||||
return new ItemKineticWeapon(contactCooldownTicks, delayTicks, dismountConditions,
|
||||
knockbackConditions, damageConditions, forwardMovement, damageMultiplier, sound, hitSound);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemKineticWeapon component) {
|
||||
wrapper.writeVarInt(component.contactCooldownTicks);
|
||||
wrapper.writeVarInt(component.delayTicks);
|
||||
wrapper.writeOptional(component.dismountConditions, Condition::write);
|
||||
wrapper.writeOptional(component.knockbackConditions, Condition::write);
|
||||
wrapper.writeOptional(component.damageConditions, Condition::write);
|
||||
wrapper.writeFloat(component.forwardMovement);
|
||||
wrapper.writeFloat(component.damageMultiplier);
|
||||
wrapper.writeOptional(component.sound, Sound::write);
|
||||
wrapper.writeOptional(component.hitSound, Sound::write);
|
||||
}
|
||||
|
||||
public int getContactCooldownTicks() {
|
||||
return this.contactCooldownTicks;
|
||||
}
|
||||
|
||||
public void setContactCooldownTicks(int contactCooldownTicks) {
|
||||
this.contactCooldownTicks = contactCooldownTicks;
|
||||
}
|
||||
|
||||
public int getDelayTicks() {
|
||||
return this.delayTicks;
|
||||
}
|
||||
|
||||
public void setDelayTicks(int delayTicks) {
|
||||
this.delayTicks = delayTicks;
|
||||
}
|
||||
|
||||
public @Nullable Condition getDismountConditions() {
|
||||
return this.dismountConditions;
|
||||
}
|
||||
|
||||
public void setDismountConditions(@Nullable Condition dismountConditions) {
|
||||
this.dismountConditions = dismountConditions;
|
||||
}
|
||||
|
||||
public @Nullable Condition getKnockbackConditions() {
|
||||
return this.knockbackConditions;
|
||||
}
|
||||
|
||||
public void setKnockbackConditions(@Nullable Condition knockbackConditions) {
|
||||
this.knockbackConditions = knockbackConditions;
|
||||
}
|
||||
|
||||
public @Nullable Condition getDamageConditions() {
|
||||
return this.damageConditions;
|
||||
}
|
||||
|
||||
public void setDamageConditions(@Nullable Condition damageConditions) {
|
||||
this.damageConditions = damageConditions;
|
||||
}
|
||||
|
||||
public float getForwardMovement() {
|
||||
return this.forwardMovement;
|
||||
}
|
||||
|
||||
public void setForwardMovement(float forwardMovement) {
|
||||
this.forwardMovement = forwardMovement;
|
||||
}
|
||||
|
||||
public float getDamageMultiplier() {
|
||||
return this.damageMultiplier;
|
||||
}
|
||||
|
||||
public void setDamageMultiplier(float damageMultiplier) {
|
||||
this.damageMultiplier = damageMultiplier;
|
||||
}
|
||||
|
||||
public @Nullable Sound getSound() {
|
||||
return this.sound;
|
||||
}
|
||||
|
||||
public void setSound(@Nullable Sound sound) {
|
||||
this.sound = sound;
|
||||
}
|
||||
|
||||
public @Nullable Sound getHitSound() {
|
||||
return this.hitSound;
|
||||
}
|
||||
|
||||
public void setHitSound(@Nullable Sound hitSound) {
|
||||
this.hitSound = hitSound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ItemKineticWeapon that = (ItemKineticWeapon) obj;
|
||||
if (this.contactCooldownTicks != that.contactCooldownTicks) return false;
|
||||
if (this.delayTicks != that.delayTicks) return false;
|
||||
if (Float.compare(that.forwardMovement, this.forwardMovement) != 0) return false;
|
||||
if (Float.compare(that.damageMultiplier, this.damageMultiplier) != 0) return false;
|
||||
if (!Objects.equals(this.dismountConditions, that.dismountConditions)) return false;
|
||||
if (!Objects.equals(this.knockbackConditions, that.knockbackConditions)) return false;
|
||||
if (!Objects.equals(this.damageConditions, that.damageConditions)) return false;
|
||||
if (!Objects.equals(this.sound, that.sound)) return false;
|
||||
return Objects.equals(this.hitSound, that.hitSound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.contactCooldownTicks, this.delayTicks, this.dismountConditions,
|
||||
this.knockbackConditions, this.damageConditions, this.forwardMovement,
|
||||
this.damageMultiplier, this.sound, this.hitSound);
|
||||
}
|
||||
|
||||
public static class Condition {
|
||||
|
||||
private int maxDurationTicks;
|
||||
private float minSpeed;
|
||||
private float minRelativeSpeed;
|
||||
|
||||
public Condition(int maxDurationTicks, float minSpeed, float minRelativeSpeed) {
|
||||
this.maxDurationTicks = maxDurationTicks;
|
||||
this.minSpeed = minSpeed;
|
||||
this.minRelativeSpeed = minRelativeSpeed;
|
||||
}
|
||||
|
||||
public static Condition read(PacketWrapper<?> wrapper) {
|
||||
int maxDurationTicks = wrapper.readVarInt();
|
||||
float minSpeed = wrapper.readFloat();
|
||||
float minRelativeSpeed = wrapper.readFloat();
|
||||
return new Condition(maxDurationTicks, minSpeed, minRelativeSpeed);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, Condition condition) {
|
||||
wrapper.writeVarInt(condition.maxDurationTicks);
|
||||
wrapper.writeFloat(condition.minSpeed);
|
||||
wrapper.writeFloat(condition.minRelativeSpeed);
|
||||
}
|
||||
|
||||
public int getMaxDurationTicks() {
|
||||
return this.maxDurationTicks;
|
||||
}
|
||||
|
||||
public void setMaxDurationTicks(int maxDurationTicks) {
|
||||
this.maxDurationTicks = maxDurationTicks;
|
||||
}
|
||||
|
||||
public float getMinSpeed() {
|
||||
return this.minSpeed;
|
||||
}
|
||||
|
||||
public void setMinSpeed(float minSpeed) {
|
||||
this.minSpeed = minSpeed;
|
||||
}
|
||||
|
||||
public float getMinRelativeSpeed() {
|
||||
return this.minRelativeSpeed;
|
||||
}
|
||||
|
||||
public void setMinRelativeSpeed(float minRelativeSpeed) {
|
||||
this.minRelativeSpeed = minRelativeSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Condition condition = (Condition) obj;
|
||||
if (this.maxDurationTicks != condition.maxDurationTicks) return false;
|
||||
if (Float.compare(condition.minSpeed, this.minSpeed) != 0) return false;
|
||||
return Float.compare(condition.minRelativeSpeed, this.minRelativeSpeed) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.maxDurationTicks, this.minSpeed, this.minRelativeSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
+60
-6
@@ -18,46 +18,100 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTString;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@NullMarked
|
||||
public class ItemLock {
|
||||
|
||||
private String code;
|
||||
private static final String FALLBACK_LOCK_STRING = "packetevents$invalid_lock";
|
||||
|
||||
/**
|
||||
* @versions 1.20.5-1.21.1
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
private String code;
|
||||
/**
|
||||
* @versions 1.21.2+
|
||||
*/
|
||||
private NBTCompound predicate;
|
||||
|
||||
/**
|
||||
* @versions 1.20.5-1.21.1
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public ItemLock(String code) {
|
||||
this.code = code;
|
||||
this.predicate = new NBTCompound();
|
||||
}
|
||||
|
||||
public ItemLock(NBTCompound predicate) {
|
||||
this.code = FALLBACK_LOCK_STRING;
|
||||
this.predicate = predicate;
|
||||
}
|
||||
|
||||
public static ItemLock read(PacketWrapper<?> wrapper) {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_2)) {
|
||||
return new ItemLock(wrapper.readNBT());
|
||||
}
|
||||
NBTString codeTag = (NBTString) wrapper.readNBTRaw();
|
||||
return new ItemLock(codeTag.getValue());
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemLock lock) {
|
||||
wrapper.writeNBTRaw(new NBTString(lock.code));
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_2)) {
|
||||
wrapper.writeNBT(lock.predicate);
|
||||
} else {
|
||||
wrapper.writeNBTRaw(new NBTString(lock.code));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 1.20.5-1.21.1
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public String getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 1.20.5-1.21.1
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 1.21.2+
|
||||
*/
|
||||
public NBTCompound getPredicate() {
|
||||
return this.predicate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 1.21.2+
|
||||
*/
|
||||
public void setPredicate(NBTCompound predicate) {
|
||||
this.predicate = predicate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof ItemLock)) return false;
|
||||
if (obj == null || this.getClass() != obj.getClass()) return false;
|
||||
ItemLock itemLock = (ItemLock) obj;
|
||||
return this.code.equals(itemLock.code);
|
||||
if (!this.code.equals(itemLock.code)) return false;
|
||||
return this.predicate.equals(itemLock.predicate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.code);
|
||||
return Objects.hash(this.code, this.predicate);
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
@NullMarked
|
||||
public class ItemMinimumAttackCharge {
|
||||
|
||||
private float value;
|
||||
|
||||
public ItemMinimumAttackCharge(float value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static ItemMinimumAttackCharge read(PacketWrapper<?> wrapper) {
|
||||
return new ItemMinimumAttackCharge(wrapper.readFloat());
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemMinimumAttackCharge component) {
|
||||
wrapper.writeFloat(component.value);
|
||||
}
|
||||
|
||||
public float getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(float value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ItemMinimumAttackCharge that = (ItemMinimumAttackCharge) obj;
|
||||
return Float.compare(that.value, this.value) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.value);
|
||||
}
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.sound.Sound;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
@NullMarked
|
||||
public class ItemPiercingWeapon {
|
||||
|
||||
private boolean dealsKnockback;
|
||||
private boolean dismounts;
|
||||
private @Nullable Sound sound;
|
||||
private @Nullable Sound hitSound;
|
||||
|
||||
public ItemPiercingWeapon(
|
||||
boolean dealsKnockback, boolean dismounts,
|
||||
@Nullable Sound sound, @Nullable Sound hitSound
|
||||
) {
|
||||
this.dealsKnockback = dealsKnockback;
|
||||
this.dismounts = dismounts;
|
||||
this.sound = sound;
|
||||
this.hitSound = hitSound;
|
||||
}
|
||||
|
||||
public static ItemPiercingWeapon read(PacketWrapper<?> wrapper) {
|
||||
boolean dealsKnockback = wrapper.readBoolean();
|
||||
boolean dismounts = wrapper.readBoolean();
|
||||
Sound sound = wrapper.readOptional(Sound::read);
|
||||
Sound hitSound = wrapper.readOptional(Sound::read);
|
||||
return new ItemPiercingWeapon(dealsKnockback, dismounts, sound, hitSound);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemPiercingWeapon component) {
|
||||
wrapper.writeBoolean(component.dealsKnockback);
|
||||
wrapper.writeBoolean(component.dismounts);
|
||||
wrapper.writeOptional(component.sound, Sound::write);
|
||||
wrapper.writeOptional(component.hitSound, Sound::write);
|
||||
}
|
||||
|
||||
public boolean isDealsKnockback() {
|
||||
return this.dealsKnockback;
|
||||
}
|
||||
|
||||
public void setDealsKnockback(boolean dealsKnockback) {
|
||||
this.dealsKnockback = dealsKnockback;
|
||||
}
|
||||
|
||||
public boolean isDismounts() {
|
||||
return this.dismounts;
|
||||
}
|
||||
|
||||
public void setDismounts(boolean dismounts) {
|
||||
this.dismounts = dismounts;
|
||||
}
|
||||
|
||||
public @Nullable Sound getSound() {
|
||||
return this.sound;
|
||||
}
|
||||
|
||||
public void setSound(@Nullable Sound sound) {
|
||||
this.sound = sound;
|
||||
}
|
||||
|
||||
public @Nullable Sound getHitSound() {
|
||||
return this.hitSound;
|
||||
}
|
||||
|
||||
public void setHitSound(@Nullable Sound hitSound) {
|
||||
this.hitSound = hitSound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ItemPiercingWeapon that = (ItemPiercingWeapon) obj;
|
||||
if (this.dealsKnockback != that.dealsKnockback) return false;
|
||||
if (this.dismounts != that.dismounts) return false;
|
||||
if (!Objects.equals(this.sound, that.sound)) return false;
|
||||
return Objects.equals(this.hitSound, that.hitSound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.dealsKnockback, this.dismounts, this.sound, this.hitSound);
|
||||
}
|
||||
}
|
||||
+274
-9
@@ -18,40 +18,148 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBT;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTString;
|
||||
import com.github.retrooper.packetevents.protocol.player.PlayerModelType;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtCodec;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtCodecException;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtCodecs;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtMapCodec;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import net.kyori.adventure.text.object.PlayerHeadObjectContents;
|
||||
import net.kyori.adventure.text.object.PlayerHeadObjectContents.ProfileProperty;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ItemProfile {
|
||||
import static net.kyori.adventure.text.object.PlayerHeadObjectContents.property;
|
||||
|
||||
@NullMarked
|
||||
public final class ItemProfile {
|
||||
|
||||
private @Nullable String name;
|
||||
private @Nullable UUID id;
|
||||
private List<Property> properties;
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
private SkinPatch skinPatch;
|
||||
|
||||
public ItemProfile(
|
||||
@Nullable String name,
|
||||
@Nullable UUID id,
|
||||
List<Property> properties
|
||||
) {
|
||||
this(name, id, properties, SkinPatch.EMPTY);
|
||||
}
|
||||
|
||||
public ItemProfile(
|
||||
@Nullable String name,
|
||||
@Nullable UUID id,
|
||||
List<Property> properties,
|
||||
SkinPatch skinPatch
|
||||
) {
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
this.properties = properties;
|
||||
this.skinPatch = skinPatch;
|
||||
}
|
||||
|
||||
public static ItemProfile read(PacketWrapper<?> wrapper) {
|
||||
String name = wrapper.readOptional(ew -> ew.readString(16));
|
||||
UUID id = wrapper.readOptional(PacketWrapper::readUUID);
|
||||
String name;
|
||||
UUID id;
|
||||
boolean partial = wrapper.getServerVersion().isOlderThan(ServerVersion.V_1_21_9) || !wrapper.readBoolean();
|
||||
if (!partial) {
|
||||
id = wrapper.readUUID();
|
||||
name = wrapper.readString(16);
|
||||
} else {
|
||||
name = wrapper.readOptional(ew -> ew.readString(16));
|
||||
id = wrapper.readOptional(PacketWrapper::readUUID);
|
||||
}
|
||||
List<Property> properties = wrapper.readList(Property::read);
|
||||
return new ItemProfile(name, id, properties);
|
||||
SkinPatch skinPatch = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_9)
|
||||
? SkinPatch.read(wrapper) : SkinPatch.EMPTY;
|
||||
return new ItemProfile(name, id, properties, skinPatch);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemProfile profile) {
|
||||
wrapper.writeOptional(profile.name, (ew, name) -> ew.writeString(name, 16));
|
||||
wrapper.writeOptional(profile.id, PacketWrapper::writeUUID);
|
||||
boolean partial;
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_9)) {
|
||||
partial = profile.name == null || profile.id == null;
|
||||
wrapper.writeBoolean(!partial);
|
||||
} else {
|
||||
// always partial profile (which is way simpler, why did they change this?)
|
||||
partial = true;
|
||||
}
|
||||
if (!partial) {
|
||||
wrapper.writeUUID(profile.id);
|
||||
wrapper.writeString(profile.name, 16);
|
||||
} else {
|
||||
wrapper.writeOptional(profile.name, (ew, name) -> ew.writeString(name, 16));
|
||||
wrapper.writeOptional(profile.id, PacketWrapper::writeUUID);
|
||||
}
|
||||
wrapper.writeList(profile.properties, Property::write);
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_9)) {
|
||||
SkinPatch.write(wrapper, profile.skinPatch);
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemProfile decode(NBT nbt, PacketWrapper<?> wrapper) {
|
||||
if (nbt instanceof NBTString) {
|
||||
String name = ((NBTString) nbt).getValue();
|
||||
return new ItemProfile(name, null, new ArrayList<>());
|
||||
}
|
||||
NBTCompound compound = (NBTCompound) nbt;
|
||||
UUID id = compound.getOrNull("id", NbtCodecs.UUID, wrapper);
|
||||
String name = compound.getStringTagValueOrNull("name");
|
||||
List<Property> properties = compound.getOrSupply("properties",
|
||||
Property.PROPERTY_MAP, ArrayList::new, wrapper);
|
||||
SkinPatch patch = SkinPatch.decode(compound, wrapper);
|
||||
return new ItemProfile(name, id, properties, patch);
|
||||
}
|
||||
|
||||
public static NBT encode(PacketWrapper<?> wrapper, ItemProfile profile) {
|
||||
NBTCompound compound = new NBTCompound();
|
||||
if (profile.id != null) {
|
||||
compound.set("id", profile.id, NbtCodecs.UUID, wrapper);
|
||||
}
|
||||
if (profile.name != null) {
|
||||
compound.setTag("name", new NBTString(profile.name));
|
||||
}
|
||||
if (!profile.properties.isEmpty()) {
|
||||
compound.set("properties", profile.properties, Property.PROPERTY_MAP, wrapper);
|
||||
}
|
||||
SkinPatch.encode(compound, wrapper, profile.skinPatch);
|
||||
return compound;
|
||||
}
|
||||
|
||||
public static ItemProfile fromAdventure(PlayerHeadObjectContents headContents) {
|
||||
List<ProfileProperty> advProps = headContents.profileProperties();
|
||||
List<Property> properties = new ArrayList<>(advProps.size());
|
||||
for (ProfileProperty property : advProps) {
|
||||
properties.add(Property.fromAdventure(property));
|
||||
}
|
||||
return new ItemProfile(headContents.name(), headContents.id(), properties);
|
||||
}
|
||||
|
||||
public List<ProfileProperty> getAdventureProperties() {
|
||||
if (this.properties.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<ProfileProperty> properties = new ArrayList<>(this.properties.size());
|
||||
for (Property property : this.properties) {
|
||||
properties.add(property.asAdventure());
|
||||
}
|
||||
return Collections.unmodifiableList(properties);
|
||||
}
|
||||
|
||||
public @Nullable String getName() {
|
||||
@@ -82,6 +190,20 @@ public class ItemProfile {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
public SkinPatch getSkinPatch() {
|
||||
return this.skinPatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
public void setSkinPatch(SkinPatch skinPatch) {
|
||||
this.skinPatch = skinPatch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
@@ -89,16 +211,60 @@ public class ItemProfile {
|
||||
ItemProfile that = (ItemProfile) obj;
|
||||
if (!Objects.equals(this.name, that.name)) return false;
|
||||
if (!Objects.equals(this.id, that.id)) return false;
|
||||
return this.properties.equals(that.properties);
|
||||
if (!this.properties.equals(that.properties)) return false;
|
||||
return this.skinPatch.equals(that.skinPatch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.name, this.id, this.properties);
|
||||
return Objects.hash(this.name, this.id, this.properties, this.skinPatch);
|
||||
}
|
||||
|
||||
public static class Property {
|
||||
|
||||
public static final NbtCodec<Property> CODEC = new NbtMapCodec<Property>() {
|
||||
@Override
|
||||
public Property decode(NBTCompound compound, PacketWrapper<?> wrapper) throws NbtCodecException {
|
||||
String name = compound.getStringTagValueOrThrow("name");
|
||||
String value = compound.getStringTagValueOrThrow("value");
|
||||
String signature = compound.getStringTagValueOrNull("signature");
|
||||
return new ItemProfile.Property(name, value, signature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(NBTCompound compound, PacketWrapper<?> wrapper, Property value) throws NbtCodecException {
|
||||
compound.setTag("name", new NBTString(value.getName()));
|
||||
compound.setTag("value", new NBTString(value.getValue()));
|
||||
if (value.getSignature() != null) {
|
||||
compound.setTag("signature", new NBTString(value.getSignature()));
|
||||
}
|
||||
}
|
||||
}.codec();
|
||||
|
||||
public static final NbtCodec<List<ItemProfile.Property>> PROPERTY_MAP = new NbtCodec<List<ItemProfile.Property>>() {
|
||||
private final NbtCodec<List<ItemProfile.Property>> propertyList = CODEC.applyList();
|
||||
|
||||
@Override
|
||||
public List<ItemProfile.Property> decode(NBT nbt, PacketWrapper<?> wrapper) {
|
||||
if (nbt instanceof NBTCompound) {
|
||||
Map<String, NBT> tags = ((NBTCompound) nbt).getTags();
|
||||
List<ItemProfile.Property> properties = new ArrayList<>(tags.size());
|
||||
for (Map.Entry<String, NBT> entry : tags.entrySet()) {
|
||||
for (String value : NbtCodecs.STRING_LIST.decode(entry.getValue(), wrapper)) {
|
||||
properties.add(new ItemProfile.Property(entry.getKey(), value, null));
|
||||
}
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
return this.propertyList.decode(nbt, wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBT encode(PacketWrapper<?> wrapper, List<ItemProfile.Property> value) {
|
||||
return this.propertyList.encode(wrapper, value);
|
||||
}
|
||||
};
|
||||
|
||||
private String name;
|
||||
private String value;
|
||||
private @Nullable String signature;
|
||||
@@ -123,6 +289,14 @@ public class ItemProfile {
|
||||
(ew, signature) -> ew.writeString(signature, 1024));
|
||||
}
|
||||
|
||||
public static Property fromAdventure(ProfileProperty property) {
|
||||
return new Property(property.name(), property.value(), property.signature());
|
||||
}
|
||||
|
||||
public ProfileProperty asAdventure() {
|
||||
return property(this.name, this.value, this.signature);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
@@ -162,4 +336,95 @@ public class ItemProfile {
|
||||
return Objects.hash(this.name, this.value, this.signature);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SkinPatch {
|
||||
|
||||
public static final SkinPatch EMPTY = new SkinPatch(null, null, null, null);
|
||||
|
||||
private final @Nullable ResourceLocation body;
|
||||
private final @Nullable ResourceLocation cape;
|
||||
private final @Nullable ResourceLocation elytra;
|
||||
private final @Nullable PlayerModelType model;
|
||||
|
||||
public SkinPatch(
|
||||
@Nullable ResourceLocation body,
|
||||
@Nullable ResourceLocation cape,
|
||||
@Nullable ResourceLocation elytra,
|
||||
@Nullable PlayerModelType model
|
||||
) {
|
||||
this.body = body;
|
||||
this.cape = cape;
|
||||
this.elytra = elytra;
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public static SkinPatch read(PacketWrapper<?> wrapper) {
|
||||
ResourceLocation body = wrapper.readOptional(ResourceLocation::read);
|
||||
ResourceLocation cape = wrapper.readOptional(ResourceLocation::read);
|
||||
ResourceLocation elytra = wrapper.readOptional(ResourceLocation::read);
|
||||
PlayerModelType model = wrapper.readOptional(PlayerModelType::read);
|
||||
return new SkinPatch(body, cape, elytra, model);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, SkinPatch patch) {
|
||||
wrapper.writeOptional(patch.body, ResourceLocation::write);
|
||||
wrapper.writeOptional(patch.cape, ResourceLocation::write);
|
||||
wrapper.writeOptional(patch.elytra, ResourceLocation::write);
|
||||
wrapper.writeOptional(patch.model, PlayerModelType::write);
|
||||
}
|
||||
|
||||
public static SkinPatch decode(NBTCompound nbt, PacketWrapper<?> wrapper) {
|
||||
ResourceLocation body = nbt.getOrNull("texture", ResourceLocation.CODEC, wrapper);
|
||||
ResourceLocation cape = nbt.getOrNull("cape", ResourceLocation.CODEC, wrapper);
|
||||
ResourceLocation elytra = nbt.getOrNull("elytra", ResourceLocation.CODEC, wrapper);
|
||||
PlayerModelType model = nbt.getOrNull("model", PlayerModelType.CODEC, wrapper);
|
||||
return new SkinPatch(body, cape, elytra, model);
|
||||
}
|
||||
|
||||
public static void encode(NBTCompound compound, PacketWrapper<?> wrapper, SkinPatch patch) {
|
||||
if (patch.body != null) {
|
||||
compound.set("texture", patch.body, ResourceLocation.CODEC, wrapper);
|
||||
}
|
||||
if (patch.cape != null) {
|
||||
compound.set("cape", patch.cape, ResourceLocation.CODEC, wrapper);
|
||||
}
|
||||
if (patch.elytra != null) {
|
||||
compound.set("elytra", patch.elytra, ResourceLocation.CODEC, wrapper);
|
||||
}
|
||||
if (patch.model != null) {
|
||||
compound.set("model", patch.model, PlayerModelType.CODEC, wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
public @Nullable ResourceLocation getBody() {
|
||||
return this.body;
|
||||
}
|
||||
|
||||
public @Nullable ResourceLocation getCape() {
|
||||
return this.cape;
|
||||
}
|
||||
|
||||
public @Nullable ResourceLocation getElytra() {
|
||||
return this.elytra;
|
||||
}
|
||||
|
||||
public @Nullable PlayerModelType getModel() {
|
||||
return this.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || this.getClass() != obj.getClass()) return false;
|
||||
SkinPatch skinPatch = (SkinPatch) obj;
|
||||
if (!Objects.equals(this.body, skinPatch.body)) return false;
|
||||
if (!Objects.equals(this.cape, skinPatch.cape)) return false;
|
||||
if (!Objects.equals(this.elytra, skinPatch.elytra)) return false;
|
||||
return this.model == skinPatch.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.body, this.cape, this.elytra, this.model);
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -37,8 +37,9 @@ public class ItemRecipes {
|
||||
|
||||
public static ItemRecipes read(PacketWrapper<?> wrapper) {
|
||||
NBTList<?> recipes = (NBTList<?>) wrapper.readNBTRaw();
|
||||
List<ResourceLocation> recipeKeys = new ArrayList<>(recipes.size());
|
||||
for (int i = 0; i < recipes.size(); i++) {
|
||||
int size = recipes.size();
|
||||
List<ResourceLocation> recipeKeys = new ArrayList<>(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
NBTString tag = (NBTString) recipes.getTag(i);
|
||||
recipeKeys.add(new ResourceLocation(tag.getValue()));
|
||||
}
|
||||
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
@NullMarked
|
||||
public class ItemSwingAnimation {
|
||||
|
||||
private static final Type[] TYPES = Type.values();
|
||||
|
||||
private Type type;
|
||||
private int duration;
|
||||
|
||||
public ItemSwingAnimation(Type type, int duration) {
|
||||
this.type = type;
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public static ItemSwingAnimation read(PacketWrapper<?> wrapper) {
|
||||
Type type = wrapper.readEnum(TYPES, Type.NONE);
|
||||
int duration = wrapper.readVarInt();
|
||||
return new ItemSwingAnimation(type, duration);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemSwingAnimation component) {
|
||||
wrapper.writeEnum(component.type);
|
||||
wrapper.writeVarInt(component.duration);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void setType(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return this.duration;
|
||||
}
|
||||
|
||||
public void setDuration(int duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ItemSwingAnimation that = (ItemSwingAnimation) obj;
|
||||
if (this.duration != that.duration) return false;
|
||||
return this.type == that.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.type, this.duration);
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
NONE,
|
||||
WHACK,
|
||||
STAB,
|
||||
}
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
@NullMarked
|
||||
public class ItemUseEffects {
|
||||
|
||||
private boolean canSprint;
|
||||
private boolean interactVibrations;
|
||||
private float speedMultiplier;
|
||||
|
||||
public ItemUseEffects(boolean canSprint, boolean interactVibrations, float speedMultiplier) {
|
||||
this.canSprint = canSprint;
|
||||
this.interactVibrations = interactVibrations;
|
||||
this.speedMultiplier = speedMultiplier;
|
||||
}
|
||||
|
||||
public static ItemUseEffects read(PacketWrapper<?> wrapper) {
|
||||
boolean canSprint = wrapper.readBoolean();
|
||||
boolean interactVibrations = wrapper.readBoolean();
|
||||
float speedMultiplier = wrapper.readFloat();
|
||||
return new ItemUseEffects(canSprint, interactVibrations, speedMultiplier);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemUseEffects component) {
|
||||
wrapper.writeBoolean(component.canSprint);
|
||||
wrapper.writeBoolean(component.interactVibrations);
|
||||
wrapper.writeFloat(component.speedMultiplier);
|
||||
}
|
||||
|
||||
public boolean isCanSprint() {
|
||||
return this.canSprint;
|
||||
}
|
||||
|
||||
public void setCanSprint(boolean canSprint) {
|
||||
this.canSprint = canSprint;
|
||||
}
|
||||
|
||||
public boolean isInteractVibrations() {
|
||||
return this.interactVibrations;
|
||||
}
|
||||
|
||||
public void setInteractVibrations(boolean interactVibrations) {
|
||||
this.interactVibrations = interactVibrations;
|
||||
}
|
||||
|
||||
public float getSpeedMultiplier() {
|
||||
return this.speedMultiplier;
|
||||
}
|
||||
|
||||
public void setSpeedMultiplier(float speedMultiplier) {
|
||||
this.speedMultiplier = speedMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ItemUseEffects that = (ItemUseEffects) obj;
|
||||
if (this.canSprint != that.canSprint) return false;
|
||||
if (this.interactVibrations != that.interactVibrations) return false;
|
||||
return Float.compare(that.speedMultiplier, this.speedMultiplier) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.canSprint, this.interactVibrations, this.speedMultiplier);
|
||||
}
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public interface DebugSubscription<T> extends MappedEntity {
|
||||
|
||||
T read(PacketWrapper<?> wrapper);
|
||||
|
||||
void write(PacketWrapper<?> wrapper, T value);
|
||||
|
||||
final class Event<T> {
|
||||
|
||||
private final DebugSubscription<T> subscription;
|
||||
private final T value;
|
||||
|
||||
public Event(DebugSubscription<T> subscription, T value) {
|
||||
this.subscription = subscription;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static Event<?> read(PacketWrapper<?> wrapper) {
|
||||
@SuppressWarnings("unchecked")
|
||||
DebugSubscription<? super Object> subscription = (DebugSubscription<? super Object>) wrapper.readMappedEntity(DebugSubscriptions.getRegistry());
|
||||
Object value = subscription.read(wrapper);
|
||||
return new Event<>(subscription, value);
|
||||
}
|
||||
|
||||
public static <T> void write(PacketWrapper<?> wrapper, Event<T> event) {
|
||||
wrapper.writeMappedEntity(event.subscription);
|
||||
event.subscription.write(wrapper, event.value);
|
||||
}
|
||||
|
||||
public DebugSubscription<T> getSubscription() {
|
||||
return this.subscription;
|
||||
}
|
||||
|
||||
public T getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
final class Update<T> {
|
||||
|
||||
private final DebugSubscription<T> subscription;
|
||||
private final @Nullable T value;
|
||||
|
||||
public Update(DebugSubscription<T> subscription, @Nullable T value) {
|
||||
this.subscription = subscription;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static Update<?> read(PacketWrapper<?> wrapper) {
|
||||
@SuppressWarnings("unchecked")
|
||||
DebugSubscription<? super Object> subscription = (DebugSubscription<? super Object>) wrapper.readMappedEntity(DebugSubscriptions.getRegistry());
|
||||
Object value = wrapper.readOptional(subscription::read);
|
||||
return new Update<>(subscription, value);
|
||||
}
|
||||
|
||||
public static <T> void write(PacketWrapper<?> wrapper, Update<T> event) {
|
||||
wrapper.writeMappedEntity(event.subscription);
|
||||
wrapper.writeOptional(event.value, event.subscription::write);
|
||||
}
|
||||
|
||||
public DebugSubscription<T> getSubscription() {
|
||||
return this.subscription;
|
||||
}
|
||||
|
||||
public @Nullable T getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.debug.struct.DebugBeeInfo;
|
||||
import com.github.retrooper.packetevents.protocol.debug.struct.DebugBrainDump;
|
||||
import com.github.retrooper.packetevents.protocol.debug.struct.DebugBreezeInfo;
|
||||
import com.github.retrooper.packetevents.protocol.debug.struct.DebugEntityBlockIntersection;
|
||||
import com.github.retrooper.packetevents.protocol.debug.struct.DebugGameEventInfo;
|
||||
import com.github.retrooper.packetevents.protocol.debug.struct.DebugGameEventListenerInfo;
|
||||
import com.github.retrooper.packetevents.protocol.debug.struct.DebugGoalInfo;
|
||||
import com.github.retrooper.packetevents.protocol.debug.struct.DebugHiveInfo;
|
||||
import com.github.retrooper.packetevents.protocol.debug.struct.DebugNeighborUpdateInfo;
|
||||
import com.github.retrooper.packetevents.protocol.debug.struct.DebugPathInfo;
|
||||
import com.github.retrooper.packetevents.protocol.debug.struct.DebugPoiInfo;
|
||||
import com.github.retrooper.packetevents.protocol.debug.struct.DebugRaidsInfo;
|
||||
import com.github.retrooper.packetevents.protocol.debug.struct.DebugStructureInfos;
|
||||
import com.github.retrooper.packetevents.protocol.debug.struct.DebugVillageSections;
|
||||
import com.github.retrooper.packetevents.protocol.debug.struct.RedstoneOrientation;
|
||||
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public final class DebugSubscriptions {
|
||||
|
||||
private static final VersionedRegistry<DebugSubscription<?>> REGISTRY = new VersionedRegistry<>("debug_subscription");
|
||||
|
||||
private DebugSubscriptions() {
|
||||
}
|
||||
|
||||
public static VersionedRegistry<DebugSubscription<?>> getRegistry() {
|
||||
return REGISTRY;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static <T> DebugSubscription<T> define(String name) {
|
||||
return define(name, null, null);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static <T> DebugSubscription<T> define(
|
||||
String name,
|
||||
PacketWrapper.@Nullable Reader<T> reader,
|
||||
PacketWrapper.@Nullable Writer<T> writer
|
||||
) {
|
||||
return REGISTRY.define(name, data -> new StaticDebugSubscription<>(data, reader, writer));
|
||||
}
|
||||
|
||||
public static final DebugSubscription<?> DEDICATED_SERVER_TICK_TIME = define("dedicated_server_tick_time");
|
||||
public static final DebugSubscription<DebugBeeInfo> BEES = define("bees", DebugBeeInfo::read, DebugBeeInfo::write);
|
||||
public static final DebugSubscription<DebugBrainDump> BRAINS = define("brains", DebugBrainDump::read, DebugBrainDump::write);
|
||||
public static final DebugSubscription<DebugBreezeInfo> BREEZES = define("breezes", DebugBreezeInfo::read, DebugBreezeInfo::write);
|
||||
public static final DebugSubscription<DebugGoalInfo> GOAL_SELECTORS = define("goal_selectors", DebugGoalInfo::read, DebugGoalInfo::write);
|
||||
public static final DebugSubscription<DebugPathInfo> ENTITY_PATHS = define("entity_paths", DebugPathInfo::read, DebugPathInfo::write);
|
||||
public static final DebugSubscription<DebugEntityBlockIntersection> ENTITY_BLOCK_INTERSECTIONS = define("entity_block_intersections", DebugEntityBlockIntersection::read, DebugEntityBlockIntersection::write);
|
||||
public static final DebugSubscription<DebugHiveInfo> BEE_HIVES = define("bee_hives", DebugHiveInfo::read, DebugHiveInfo::write);
|
||||
public static final DebugSubscription<DebugPoiInfo> POIS = define("pois", DebugPoiInfo::read, DebugPoiInfo::write);
|
||||
public static final DebugSubscription<RedstoneOrientation> REDSTONE_WIRE_ORIENTATIONS = define("redstone_wire_orientations", RedstoneOrientation::read, RedstoneOrientation::write);
|
||||
public static final DebugSubscription<DebugVillageSections> VILLAGE_SECTIONS = define("village_sections", DebugVillageSections::read, DebugVillageSections::write);
|
||||
public static final DebugSubscription<DebugRaidsInfo> RAIDS = define("raids", DebugRaidsInfo::read, DebugRaidsInfo::write);
|
||||
public static final DebugSubscription<DebugStructureInfos> STRUCTURES = define("structures", DebugStructureInfos::read, DebugStructureInfos::write);
|
||||
public static final DebugSubscription<DebugGameEventListenerInfo> GAME_EVENT_LISTENERS = define("game_event_listeners", DebugGameEventListenerInfo::read, DebugGameEventListenerInfo::write);
|
||||
public static final DebugSubscription<DebugNeighborUpdateInfo> NEIGHBOR_UPDATES = define("neighbor_updates", DebugNeighborUpdateInfo::read, DebugNeighborUpdateInfo::write);
|
||||
public static final DebugSubscription<DebugGameEventInfo> GAME_EVENTS = define("game_events", DebugGameEventInfo::read, DebugGameEventInfo::write);
|
||||
|
||||
static {
|
||||
REGISTRY.unloadMappings();
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public class StaticDebugSubscription<T> extends AbstractMappedEntity implements DebugSubscription<T> {
|
||||
|
||||
private final PacketWrapper.@Nullable Reader<T> reader;
|
||||
private final PacketWrapper.@Nullable Writer<T> writer;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public StaticDebugSubscription(
|
||||
@Nullable TypesBuilderData data,
|
||||
PacketWrapper.@Nullable Reader<T> reader,
|
||||
PacketWrapper.@Nullable Writer<T> writer
|
||||
) {
|
||||
super(data);
|
||||
this.reader = reader;
|
||||
this.writer = writer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T read(PacketWrapper<?> wrapper) {
|
||||
if (this.reader == null) {
|
||||
throw new IllegalStateException(this + " doesn't support network reading");
|
||||
}
|
||||
return this.reader.apply(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketWrapper<?> wrapper, T value) {
|
||||
if (this.writer == null) {
|
||||
throw new IllegalStateException(this + " doesn't support network writing");
|
||||
}
|
||||
this.writer.accept(wrapper, value);
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug.path;
|
||||
|
||||
import com.github.retrooper.packetevents.util.Vector3i;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public final class DebugNode {
|
||||
|
||||
private final Vector3i pos;
|
||||
private final float walkedDistance;
|
||||
private final float costMalus;
|
||||
private final boolean closed;
|
||||
private final DebugPathType type;
|
||||
private final float f;
|
||||
|
||||
public DebugNode(
|
||||
Vector3i pos, float walkedDistance, float costMalus,
|
||||
boolean closed, DebugPathType type, float f
|
||||
) {
|
||||
this.pos = pos;
|
||||
this.walkedDistance = walkedDistance;
|
||||
this.costMalus = costMalus;
|
||||
this.closed = closed;
|
||||
this.type = type;
|
||||
this.f = f;
|
||||
}
|
||||
|
||||
public static DebugNode read(PacketWrapper<?> wrapper) {
|
||||
Vector3i pos = new Vector3i(wrapper.readInt(), wrapper.readInt(), wrapper.readInt());
|
||||
float walkedDistance = wrapper.readFloat();
|
||||
float costMalus = wrapper.readFloat();
|
||||
boolean closed = wrapper.readBoolean();
|
||||
DebugPathType type = wrapper.readEnum(DebugPathType.values());
|
||||
float f = wrapper.readFloat();
|
||||
return new DebugNode(pos, walkedDistance, costMalus, closed, type, f);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, DebugNode node) {
|
||||
wrapper.writeInt(node.pos.x);
|
||||
wrapper.writeInt(node.pos.y);
|
||||
wrapper.writeInt(node.pos.z);
|
||||
wrapper.writeFloat(node.walkedDistance);
|
||||
wrapper.writeFloat(node.costMalus);
|
||||
wrapper.writeBoolean(node.closed);
|
||||
wrapper.writeEnum(node.type);
|
||||
wrapper.writeFloat(node.f);
|
||||
}
|
||||
|
||||
public Vector3i getPos() {
|
||||
return this.pos;
|
||||
}
|
||||
|
||||
public float getWalkedDistance() {
|
||||
return this.walkedDistance;
|
||||
}
|
||||
|
||||
public float getCostMalus() {
|
||||
return this.costMalus;
|
||||
}
|
||||
|
||||
public boolean isClosed() {
|
||||
return this.closed;
|
||||
}
|
||||
|
||||
public DebugPathType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public float getF() {
|
||||
return this.f;
|
||||
}
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug.path;
|
||||
|
||||
import com.github.retrooper.packetevents.util.Vector3i;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Network structure for representing vanilla pathfinder paths.
|
||||
*
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public final class DebugPath {
|
||||
|
||||
private final boolean reached;
|
||||
private final int nextNodeIndex;
|
||||
private final Vector3i target;
|
||||
private final List<DebugNode> nodes;
|
||||
private final Set<DebugNode> targetNodes;
|
||||
private final List<DebugNode> openSet;
|
||||
private final List<DebugNode> closedSet;
|
||||
|
||||
public DebugPath(
|
||||
boolean reached, int nextNodeIndex, Vector3i target, List<DebugNode> nodes,
|
||||
Set<DebugNode> targetNodes, List<DebugNode> openSet, List<DebugNode> closedSet
|
||||
) {
|
||||
this.reached = reached;
|
||||
this.nextNodeIndex = nextNodeIndex;
|
||||
this.target = target;
|
||||
this.nodes = nodes;
|
||||
this.targetNodes = targetNodes;
|
||||
this.openSet = openSet;
|
||||
this.closedSet = closedSet;
|
||||
}
|
||||
|
||||
public static DebugPath read(PacketWrapper<?> wrapper) {
|
||||
boolean reached = wrapper.readBoolean();
|
||||
int nextNodeIndex = wrapper.readInt();
|
||||
Vector3i target = wrapper.readBlockPosition();
|
||||
List<DebugNode> nodes = wrapper.readList(DebugNode::read);
|
||||
Set<DebugNode> targetNodes = wrapper.readSet(DebugNode::read);
|
||||
List<DebugNode> openSet = wrapper.readList(DebugNode::read);
|
||||
List<DebugNode> closedSet = wrapper.readList(DebugNode::read);
|
||||
return new DebugPath(reached, nextNodeIndex, target, nodes, targetNodes, openSet, closedSet);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, DebugPath path) {
|
||||
wrapper.writeBoolean(path.reached);
|
||||
wrapper.writeInt(path.nextNodeIndex);
|
||||
wrapper.writeBlockPosition(path.target);
|
||||
wrapper.writeList(path.nodes, DebugNode::write);
|
||||
wrapper.writeSet(path.targetNodes, DebugNode::write);
|
||||
wrapper.writeList(path.openSet, DebugNode::write);
|
||||
wrapper.writeList(path.closedSet, DebugNode::write);
|
||||
}
|
||||
|
||||
public boolean isReached() {
|
||||
return this.reached;
|
||||
}
|
||||
|
||||
public int getNextNodeIndex() {
|
||||
return this.nextNodeIndex;
|
||||
}
|
||||
|
||||
public Vector3i getTarget() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
public List<DebugNode> getNodes() {
|
||||
return this.nodes;
|
||||
}
|
||||
|
||||
public Set<DebugNode> getTargetNodes() {
|
||||
return this.targetNodes;
|
||||
}
|
||||
|
||||
public List<DebugNode> getOpenSet() {
|
||||
return this.openSet;
|
||||
}
|
||||
|
||||
public List<DebugNode> getClosedSet() {
|
||||
return this.closedSet;
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug.path;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public enum DebugPathType {
|
||||
|
||||
BLOCKED,
|
||||
OPEN,
|
||||
WALKABLE,
|
||||
WALKABLE_DOOR,
|
||||
TRAPDOOR,
|
||||
POWDER_SNOW,
|
||||
DANGER_POWDER_SNOW,
|
||||
FENCE,
|
||||
LAVA,
|
||||
WATER,
|
||||
WATER_BORDER,
|
||||
RAIL,
|
||||
UNPASSABLE_RAIL,
|
||||
DANGER_FIRE,
|
||||
DAMAGE_FIRE,
|
||||
DANGER_OTHER,
|
||||
DAMAGE_OTHER,
|
||||
DOOR_OPEN,
|
||||
DOOR_WOOD_CLOSED,
|
||||
DOOR_IRON_CLOSED,
|
||||
BREACH,
|
||||
LEAVES,
|
||||
STICKY_HONEY,
|
||||
COCOA,
|
||||
DAMAGE_CAUTIOUS,
|
||||
DANGER_TRAPDOOR,
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug.poi;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public interface PoiType extends MappedEntity {
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug.poi;
|
||||
|
||||
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public final class PoiTypes {
|
||||
|
||||
private static final VersionedRegistry<PoiType> REGISTRY = new VersionedRegistry<>("point_of_interest_type");
|
||||
|
||||
private PoiTypes() {
|
||||
}
|
||||
|
||||
public static VersionedRegistry<PoiType> getRegistry() {
|
||||
return REGISTRY;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static PoiType define(String name) {
|
||||
return REGISTRY.define(name, StaticPoiType::new);
|
||||
}
|
||||
|
||||
public static final PoiType ARMORER = define("armorer");
|
||||
public static final PoiType BUTCHER = define("butcher");
|
||||
public static final PoiType CARTOGRAPHER = define("cartographer");
|
||||
public static final PoiType CLERIC = define("cleric");
|
||||
public static final PoiType FARMER = define("farmer");
|
||||
public static final PoiType FISHERMAN = define("fisherman");
|
||||
public static final PoiType FLETCHER = define("fletcher");
|
||||
public static final PoiType LEATHERWORKER = define("leatherworker");
|
||||
public static final PoiType LIBRARIAN = define("librarian");
|
||||
public static final PoiType MASON = define("mason");
|
||||
public static final PoiType SHEPHERD = define("shepherd");
|
||||
public static final PoiType TOOLSMITH = define("toolsmith");
|
||||
public static final PoiType WEAPONSMITH = define("weaponsmith");
|
||||
public static final PoiType HOME = define("home");
|
||||
public static final PoiType MEETING = define("meeting");
|
||||
public static final PoiType BEEHIVE = define("beehive");
|
||||
public static final PoiType BEE_NEST = define("bee_nest");
|
||||
public static final PoiType NETHER_PORTAL = define("nether_portal");
|
||||
public static final PoiType LODESTONE = define("lodestone");
|
||||
public static final PoiType TEST_INSTANCE = define("test_instance");
|
||||
public static final PoiType LIGHTNING_ROD = define("lightning_rod");
|
||||
|
||||
static {
|
||||
REGISTRY.unloadMappings();
|
||||
}
|
||||
}
|
||||
+12
-12
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2024 retrooper and contributors
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -16,19 +16,19 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.github.retrooper.packetevents.sponge.injector.connection;
|
||||
package com.github.retrooper.packetevents.protocol.debug.poi;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
public class ServerChannelHandler extends ChannelInboundHandlerAdapter {
|
||||
@NullMarked
|
||||
public class StaticPoiType extends AbstractMappedEntity implements PoiType {
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
Channel channel = (Channel) msg;
|
||||
channel.pipeline().addLast(PacketEvents.SERVER_CHANNEL_HANDLER_NAME, new PreChannelInitializer());
|
||||
super.channelRead(ctx, msg);
|
||||
@ApiStatus.Internal
|
||||
public StaticPoiType(@Nullable TypesBuilderData data) {
|
||||
super(data);
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug.struct;
|
||||
|
||||
import com.github.retrooper.packetevents.util.Vector3i;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public final class DebugBeeInfo {
|
||||
|
||||
private final @Nullable Vector3i hivePos;
|
||||
private final @Nullable Vector3i flowerPos;
|
||||
private final int travelTicks;
|
||||
private final List<Vector3i> blacklistedHives;
|
||||
|
||||
public DebugBeeInfo(
|
||||
@Nullable Vector3i hivePos, @Nullable Vector3i flowerPos,
|
||||
int travelTicks, List<Vector3i> blacklistedHives
|
||||
) {
|
||||
this.hivePos = hivePos;
|
||||
this.flowerPos = flowerPos;
|
||||
this.travelTicks = travelTicks;
|
||||
this.blacklistedHives = blacklistedHives;
|
||||
}
|
||||
|
||||
public static DebugBeeInfo read(PacketWrapper<?> wrapper) {
|
||||
Vector3i hivePos = wrapper.readOptional(PacketWrapper::readBlockPosition);
|
||||
Vector3i flowerPos = wrapper.readOptional(PacketWrapper::readBlockPosition);
|
||||
int travelTicks = wrapper.readVarInt();
|
||||
List<Vector3i> blacklistedHives = wrapper.readList(PacketWrapper::readBlockPosition);
|
||||
return new DebugBeeInfo(hivePos, flowerPos, travelTicks, blacklistedHives);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, DebugBeeInfo info) {
|
||||
wrapper.writeOptional(info.hivePos, PacketWrapper::writeBlockPosition);
|
||||
wrapper.writeOptional(info.flowerPos, PacketWrapper::writeBlockPosition);
|
||||
wrapper.writeVarInt(info.travelTicks);
|
||||
wrapper.writeList(info.blacklistedHives, PacketWrapper::writeBlockPosition);
|
||||
}
|
||||
|
||||
public @Nullable Vector3i getHivePos() {
|
||||
return this.hivePos;
|
||||
}
|
||||
|
||||
public @Nullable Vector3i getFlowerPos() {
|
||||
return this.flowerPos;
|
||||
}
|
||||
|
||||
public int getTravelTicks() {
|
||||
return this.travelTicks;
|
||||
}
|
||||
|
||||
public List<Vector3i> getBlacklistedHives() {
|
||||
return this.blacklistedHives;
|
||||
}
|
||||
}
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug.struct;
|
||||
|
||||
import com.github.retrooper.packetevents.util.Vector3i;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public final class DebugBrainDump {
|
||||
|
||||
private final String name;
|
||||
private final String profession;
|
||||
private final int xp;
|
||||
private final float health;
|
||||
private final float maxHealth;
|
||||
private final String inventory;
|
||||
private final boolean wantsGolem;
|
||||
private final int angerLevel;
|
||||
private final List<String> activities;
|
||||
private final List<String> behaviors;
|
||||
private final List<String> memories;
|
||||
private final List<String> gossips;
|
||||
private final Set<Vector3i> pois;
|
||||
private final Set<Vector3i> potentialPois;
|
||||
|
||||
public DebugBrainDump(
|
||||
String name, String profession, int xp, float health, float maxHealth,
|
||||
String inventory, boolean wantsGolem, int angerLevel, List<String> activities,
|
||||
List<String> behaviors, List<String> memories, List<String> gossips,
|
||||
Set<Vector3i> pois, Set<Vector3i> potentialPois
|
||||
) {
|
||||
this.name = name;
|
||||
this.profession = profession;
|
||||
this.xp = xp;
|
||||
this.health = health;
|
||||
this.maxHealth = maxHealth;
|
||||
this.inventory = inventory;
|
||||
this.wantsGolem = wantsGolem;
|
||||
this.angerLevel = angerLevel;
|
||||
this.activities = activities;
|
||||
this.behaviors = behaviors;
|
||||
this.memories = memories;
|
||||
this.gossips = gossips;
|
||||
this.pois = pois;
|
||||
this.potentialPois = potentialPois;
|
||||
}
|
||||
|
||||
public static DebugBrainDump read(PacketWrapper<?> wrapper) {
|
||||
String name = wrapper.readString();
|
||||
String profession = wrapper.readString();
|
||||
int xp = wrapper.readInt();
|
||||
float health = wrapper.readFloat();
|
||||
float maxHealth = wrapper.readFloat();
|
||||
String inventory = wrapper.readString();
|
||||
boolean wantsGolem = wrapper.readBoolean();
|
||||
int angerLevel = wrapper.readInt();
|
||||
List<String> activities = wrapper.readList(PacketWrapper::readString);
|
||||
List<String> behaviors = wrapper.readList(PacketWrapper::readString);
|
||||
List<String> memories = wrapper.readList(PacketWrapper::readString);
|
||||
List<String> gossips = wrapper.readList(PacketWrapper::readString);
|
||||
Set<Vector3i> pois = wrapper.readSet(PacketWrapper::readBlockPosition);
|
||||
Set<Vector3i> potentialPois = wrapper.readSet(PacketWrapper::readBlockPosition);
|
||||
return new DebugBrainDump(
|
||||
name, profession, xp, health, maxHealth, inventory, wantsGolem,
|
||||
angerLevel, activities, behaviors, memories, gossips, pois, potentialPois
|
||||
);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, DebugBrainDump info) {
|
||||
wrapper.writeString(info.name);
|
||||
wrapper.writeString(info.profession);
|
||||
wrapper.writeInt(info.xp);
|
||||
wrapper.writeFloat(info.health);
|
||||
wrapper.writeFloat(info.maxHealth);
|
||||
wrapper.writeString(info.inventory);
|
||||
wrapper.writeBoolean(info.wantsGolem);
|
||||
wrapper.writeInt(info.angerLevel);
|
||||
wrapper.writeList(info.activities, PacketWrapper::writeString);
|
||||
wrapper.writeList(info.behaviors, PacketWrapper::writeString);
|
||||
wrapper.writeList(info.memories, PacketWrapper::writeString);
|
||||
wrapper.writeList(info.gossips, PacketWrapper::writeString);
|
||||
wrapper.writeSet(info.pois, PacketWrapper::writeBlockPosition);
|
||||
wrapper.writeSet(info.potentialPois, PacketWrapper::writeBlockPosition);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getProfession() {
|
||||
return this.profession;
|
||||
}
|
||||
|
||||
public int getXp() {
|
||||
return this.xp;
|
||||
}
|
||||
|
||||
public float getHealth() {
|
||||
return this.health;
|
||||
}
|
||||
|
||||
public float getMaxHealth() {
|
||||
return this.maxHealth;
|
||||
}
|
||||
|
||||
public String getInventory() {
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
public boolean isWantsGolem() {
|
||||
return this.wantsGolem;
|
||||
}
|
||||
|
||||
public int getAngerLevel() {
|
||||
return this.angerLevel;
|
||||
}
|
||||
|
||||
public List<String> getActivities() {
|
||||
return this.activities;
|
||||
}
|
||||
|
||||
public List<String> getBehaviors() {
|
||||
return this.behaviors;
|
||||
}
|
||||
|
||||
public List<String> getMemories() {
|
||||
return this.memories;
|
||||
}
|
||||
|
||||
public List<String> getGossips() {
|
||||
return this.gossips;
|
||||
}
|
||||
|
||||
public Set<Vector3i> getPois() {
|
||||
return this.pois;
|
||||
}
|
||||
|
||||
public Set<Vector3i> getPotentialPois() {
|
||||
return this.potentialPois;
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug.struct;
|
||||
|
||||
import com.github.retrooper.packetevents.util.Vector3i;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public final class DebugBreezeInfo {
|
||||
|
||||
private final @Nullable Integer attackTarget;
|
||||
private final @Nullable Vector3i jumpTarget;
|
||||
|
||||
public DebugBreezeInfo(@Nullable Integer attackTarget, @Nullable Vector3i jumpTarget) {
|
||||
this.attackTarget = attackTarget;
|
||||
this.jumpTarget = jumpTarget;
|
||||
}
|
||||
|
||||
public static DebugBreezeInfo read(PacketWrapper<?> wrapper) {
|
||||
Integer attackTarget = wrapper.readOptional(PacketWrapper::readVarInt);
|
||||
Vector3i jumpTarget = wrapper.readOptional(PacketWrapper::readBlockPosition);
|
||||
return new DebugBreezeInfo(attackTarget, jumpTarget);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, DebugBreezeInfo info) {
|
||||
wrapper.writeOptional(info.attackTarget, PacketWrapper::writeVarInt);
|
||||
wrapper.writeOptional(info.jumpTarget, PacketWrapper::writeBlockPosition);
|
||||
}
|
||||
|
||||
public @Nullable Integer getAttackTarget() {
|
||||
return this.attackTarget;
|
||||
}
|
||||
|
||||
public @Nullable Vector3i getJumpTarget() {
|
||||
return this.jumpTarget;
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug.struct;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public final class DebugEntityBlockIntersection {
|
||||
|
||||
private final IntersectionType type;
|
||||
|
||||
public DebugEntityBlockIntersection(IntersectionType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static DebugEntityBlockIntersection read(PacketWrapper<?> wrapper) {
|
||||
IntersectionType type = wrapper.readEnum(IntersectionType.values());
|
||||
return new DebugEntityBlockIntersection(type);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, DebugEntityBlockIntersection intersection) {
|
||||
wrapper.writeEnum(intersection.type);
|
||||
}
|
||||
|
||||
public IntersectionType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public enum IntersectionType {
|
||||
IN_BLOCK,
|
||||
IN_FLUID,
|
||||
IN_AIR,
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug.struct;
|
||||
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.util.Vector3d;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public final class DebugGameEventInfo {
|
||||
|
||||
/**
|
||||
* Possible values include all keys of the built-in <code>minecraft:game_event</code> registry.
|
||||
*/
|
||||
private final ResourceLocation event;
|
||||
private final Vector3d pos;
|
||||
|
||||
public DebugGameEventInfo(ResourceLocation event, Vector3d pos) {
|
||||
this.event = event;
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
public static DebugGameEventInfo read(PacketWrapper<?> wrapper) {
|
||||
ResourceLocation event = ResourceLocation.read(wrapper);
|
||||
Vector3d pos = Vector3d.read(wrapper);
|
||||
return new DebugGameEventInfo(event, pos);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, DebugGameEventInfo info) {
|
||||
ResourceLocation.write(wrapper, info.event);
|
||||
Vector3d.write(wrapper, info.pos);
|
||||
}
|
||||
|
||||
public ResourceLocation getEvent() {
|
||||
return this.event;
|
||||
}
|
||||
|
||||
public Vector3d getPos() {
|
||||
return this.pos;
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug.struct;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public final class DebugGameEventListenerInfo {
|
||||
|
||||
private final int listenerRadius;
|
||||
|
||||
public DebugGameEventListenerInfo(int listenerRadius) {
|
||||
this.listenerRadius = listenerRadius;
|
||||
}
|
||||
|
||||
public static DebugGameEventListenerInfo read(PacketWrapper<?> wrapper) {
|
||||
int listenerRadius = wrapper.readVarInt();
|
||||
return new DebugGameEventListenerInfo(listenerRadius);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, DebugGameEventListenerInfo info) {
|
||||
wrapper.writeVarInt(info.listenerRadius);
|
||||
}
|
||||
|
||||
public int getListenerRadius() {
|
||||
return this.listenerRadius;
|
||||
}
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug.struct;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public final class DebugGoalInfo {
|
||||
|
||||
private final List<DebugGoal> goals;
|
||||
|
||||
public DebugGoalInfo(List<DebugGoal> goals) {
|
||||
this.goals = goals;
|
||||
}
|
||||
|
||||
public static DebugGoalInfo read(PacketWrapper<?> wrapper) {
|
||||
List<DebugGoal> goals = wrapper.readList(DebugGoal::read);
|
||||
return new DebugGoalInfo(goals);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, DebugGoalInfo info) {
|
||||
wrapper.writeList(info.goals, DebugGoal::write);
|
||||
}
|
||||
|
||||
public List<DebugGoal> getGoals() {
|
||||
return this.goals;
|
||||
}
|
||||
|
||||
public static final class DebugGoal {
|
||||
|
||||
private final int priority;
|
||||
private final boolean running;
|
||||
private final String name;
|
||||
|
||||
public DebugGoal(int priority, boolean running, String name) {
|
||||
this.priority = priority;
|
||||
this.running = running;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static DebugGoal read(PacketWrapper<?> wrapper) {
|
||||
int priority = wrapper.readVarInt();
|
||||
boolean running = wrapper.readBoolean();
|
||||
String name = wrapper.readString(255);
|
||||
return new DebugGoal(priority, running, name);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, DebugGoal goal) {
|
||||
wrapper.writeVarInt(goal.priority);
|
||||
wrapper.writeBoolean(goal.running);
|
||||
wrapper.writeString(goal.name, 255);
|
||||
}
|
||||
|
||||
public int getPriority() {
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
return this.running;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug.struct;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.world.states.type.StateType;
|
||||
import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public final class DebugHiveInfo {
|
||||
|
||||
private final StateType type;
|
||||
private final int occupantCount;
|
||||
private final int honeyLevel;
|
||||
private final boolean sedated;
|
||||
|
||||
public DebugHiveInfo(StateType type, int occupantCount, int honeyLevel, boolean sedated) {
|
||||
this.type = type;
|
||||
this.occupantCount = occupantCount;
|
||||
this.honeyLevel = honeyLevel;
|
||||
this.sedated = sedated;
|
||||
}
|
||||
|
||||
public static DebugHiveInfo read(PacketWrapper<?> wrapper) {
|
||||
StateType type = wrapper.readMappedEntity(StateTypes.getRegistry()).getStateType();
|
||||
int occupantCount = wrapper.readVarInt();
|
||||
int honeyLevel = wrapper.readVarInt();
|
||||
boolean sedated = wrapper.readBoolean();
|
||||
return new DebugHiveInfo(type, occupantCount, honeyLevel, sedated);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, DebugHiveInfo info) {
|
||||
wrapper.writeMappedEntity(info.type.getMapped());
|
||||
wrapper.writeVarInt(info.occupantCount);
|
||||
wrapper.writeVarInt(info.honeyLevel);
|
||||
wrapper.writeBoolean(info.sedated);
|
||||
}
|
||||
|
||||
public StateType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public int getOccupantCount() {
|
||||
return this.occupantCount;
|
||||
}
|
||||
|
||||
public int getHoneyLevel() {
|
||||
return this.honeyLevel;
|
||||
}
|
||||
|
||||
public boolean isSedated() {
|
||||
return this.sedated;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug.struct;
|
||||
|
||||
import com.github.retrooper.packetevents.util.Vector3i;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public final class DebugNeighborUpdateInfo {
|
||||
|
||||
private final Vector3i pos;
|
||||
|
||||
public DebugNeighborUpdateInfo(Vector3i pos) {
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
public static DebugNeighborUpdateInfo read(PacketWrapper<?> wrapper) {
|
||||
Vector3i pos = wrapper.readBlockPosition();
|
||||
return new DebugNeighborUpdateInfo(pos);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, DebugNeighborUpdateInfo info) {
|
||||
wrapper.writeBlockPosition(info.pos);
|
||||
}
|
||||
|
||||
public Vector3i getPos() {
|
||||
return this.pos;
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug.struct;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.debug.path.DebugPath;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public final class DebugPathInfo {
|
||||
|
||||
private final DebugPath path;
|
||||
private final float maxNodeDistance;
|
||||
|
||||
public DebugPathInfo(DebugPath path, float maxNodeDistance) {
|
||||
this.path = path;
|
||||
this.maxNodeDistance = maxNodeDistance;
|
||||
}
|
||||
|
||||
public static DebugPathInfo read(PacketWrapper<?> wrapper) {
|
||||
DebugPath path = DebugPath.read(wrapper);
|
||||
float maxNodeDistance = wrapper.readFloat();
|
||||
return new DebugPathInfo(path, maxNodeDistance);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, DebugPathInfo info) {
|
||||
DebugPath.write(wrapper, info.path);
|
||||
wrapper.writeFloat(info.maxNodeDistance);
|
||||
}
|
||||
|
||||
public DebugPath getPath() {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
public float getMaxNodeDistance() {
|
||||
return this.maxNodeDistance;
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug.struct;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.debug.poi.PoiType;
|
||||
import com.github.retrooper.packetevents.protocol.debug.poi.PoiTypes;
|
||||
import com.github.retrooper.packetevents.util.Vector3i;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public final class DebugPoiInfo {
|
||||
|
||||
private final Vector3i pos;
|
||||
private final PoiType poiType;
|
||||
private final int freeTicketCount;
|
||||
|
||||
public DebugPoiInfo(Vector3i pos, PoiType poiType, int freeTicketCount) {
|
||||
this.pos = pos;
|
||||
this.poiType = poiType;
|
||||
this.freeTicketCount = freeTicketCount;
|
||||
}
|
||||
|
||||
public static DebugPoiInfo read(PacketWrapper<?> wrapper) {
|
||||
Vector3i pos = wrapper.readBlockPosition();
|
||||
PoiType poiType = wrapper.readMappedEntity(PoiTypes.getRegistry());
|
||||
int freeTicketCount = wrapper.readVarInt();
|
||||
return new DebugPoiInfo(pos,poiType,freeTicketCount);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, DebugPoiInfo info) {
|
||||
wrapper.writeBlockPosition(info.pos);
|
||||
wrapper.writeMappedEntity(info.poiType);
|
||||
wrapper.writeVarInt(info.freeTicketCount);
|
||||
}
|
||||
|
||||
public Vector3i getPos() {
|
||||
return this.pos;
|
||||
}
|
||||
|
||||
public PoiType getPoiType() {
|
||||
return this.poiType;
|
||||
}
|
||||
|
||||
public int getFreeTicketCount() {
|
||||
return this.freeTicketCount;
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug.struct;
|
||||
|
||||
import com.github.retrooper.packetevents.util.Vector3i;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public final class DebugRaidsInfo {
|
||||
|
||||
private final List<Vector3i> positions;
|
||||
|
||||
public DebugRaidsInfo(List<Vector3i> positions) {
|
||||
this.positions = positions;
|
||||
}
|
||||
|
||||
public static DebugRaidsInfo read(PacketWrapper<?> wrapper) {
|
||||
List<Vector3i> positions = wrapper.readList(PacketWrapper::readBlockPosition);
|
||||
return new DebugRaidsInfo(positions);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, DebugRaidsInfo info) {
|
||||
wrapper.writeList(info.positions, PacketWrapper::writeBlockPosition);
|
||||
}
|
||||
|
||||
public List<Vector3i> getPositions() {
|
||||
return this.positions;
|
||||
}
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug.struct;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.world.BlockBoundingBox;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public final class DebugStructureInfos {
|
||||
|
||||
private final List<DebugStructureInfo> infos;
|
||||
|
||||
public DebugStructureInfos(List<DebugStructureInfo> infos) {
|
||||
this.infos = infos;
|
||||
}
|
||||
|
||||
public static DebugStructureInfos read(PacketWrapper<?> wrapper) {
|
||||
List<DebugStructureInfo> infos = wrapper.readList(DebugStructureInfo::read);
|
||||
return new DebugStructureInfos(infos);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, DebugStructureInfos infos) {
|
||||
wrapper.writeList(infos.infos, DebugStructureInfo::write);
|
||||
}
|
||||
|
||||
public List<DebugStructureInfo> getInfos() {
|
||||
return this.infos;
|
||||
}
|
||||
|
||||
public static final class DebugStructureInfo {
|
||||
|
||||
private final BlockBoundingBox boundingBox;
|
||||
private final List<Piece> pieces;
|
||||
|
||||
public DebugStructureInfo(BlockBoundingBox boundingBox, List<Piece> pieces) {
|
||||
this.boundingBox = boundingBox;
|
||||
this.pieces = pieces;
|
||||
}
|
||||
|
||||
public static DebugStructureInfo read(PacketWrapper<?> wrapper) {
|
||||
BlockBoundingBox box = BlockBoundingBox.read(wrapper);
|
||||
List<Piece> pieces = wrapper.readList(Piece::read);
|
||||
return new DebugStructureInfo(box, pieces);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, DebugStructureInfo info) {
|
||||
BlockBoundingBox.write(wrapper, info.boundingBox);
|
||||
wrapper.writeList(info.pieces, Piece::write);
|
||||
}
|
||||
|
||||
public BlockBoundingBox getBoundingBox() {
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
public List<Piece> getPieces() {
|
||||
return this.pieces;
|
||||
}
|
||||
|
||||
public static final class Piece {
|
||||
|
||||
private final BlockBoundingBox boundingBox;
|
||||
private final boolean start;
|
||||
|
||||
public Piece(BlockBoundingBox boundingBox, boolean start) {
|
||||
this.boundingBox = boundingBox;
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public static Piece read(PacketWrapper<?> wrapper) {
|
||||
BlockBoundingBox boundingBox = BlockBoundingBox.read(wrapper);
|
||||
boolean start = wrapper.readBoolean();
|
||||
return new Piece(boundingBox, start);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, Piece piece) {
|
||||
BlockBoundingBox.write(wrapper, piece.boundingBox);
|
||||
wrapper.writeBoolean(piece.start);
|
||||
}
|
||||
|
||||
public BlockBoundingBox getBoundingBox() {
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
public boolean isStart() {
|
||||
return this.start;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
-13
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2024 retrooper and contributors
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -16,22 +16,27 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.github.retrooper.packetevents;
|
||||
package com.github.retrooper.packetevents.protocol.debug.struct;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import io.github.retrooper.packetevents.factory.fabric.FabricPacketEventsAPI;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
public class PacketEventsServerMod implements PreLaunchEntrypoint {
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public final class DebugVillageSections {
|
||||
|
||||
public static FabricPacketEventsAPI constructApi(String modid) {
|
||||
return new FabricPacketEventsAPI(modid, EnvType.SERVER);
|
||||
public static final DebugVillageSections INSTANCE = new DebugVillageSections();
|
||||
|
||||
private DebugVillageSections() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPreLaunch() {
|
||||
PacketEvents.setAPI(constructApi(PacketEventsMod.MOD_ID));
|
||||
PacketEvents.getAPI().load();
|
||||
public static DebugVillageSections read(PacketWrapper<?> wrapper) {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, DebugVillageSections sections) {
|
||||
// NO-OP
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.debug.struct;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public final class RedstoneOrientation {
|
||||
|
||||
private final int index;
|
||||
|
||||
public RedstoneOrientation(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public static RedstoneOrientation read(PacketWrapper<?> wrapper) {
|
||||
int index = wrapper.readVarInt();
|
||||
return new RedstoneOrientation(index);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, RedstoneOrientation orientation) {
|
||||
wrapper.writeVarInt(orientation.index);
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return this.index;
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -24,8 +24,8 @@ import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -87,9 +87,8 @@ public class ConfirmationDialog extends AbstractMappedEntity implements Dialog {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deepEquals(Object obj) {
|
||||
public boolean deepEquals(@Nullable Object obj) {
|
||||
if (!(obj instanceof ConfirmationDialog)) return false;
|
||||
if (!super.equals(obj)) return false;
|
||||
ConfirmationDialog that = (ConfirmationDialog) obj;
|
||||
if (!this.common.equals(that.common)) return false;
|
||||
if (!this.yesButton.equals(that.yesButton)) return false;
|
||||
@@ -98,6 +97,6 @@ public class ConfirmationDialog extends AbstractMappedEntity implements Dialog {
|
||||
|
||||
@Override
|
||||
public int deepHashCode() {
|
||||
return Objects.hash(super.hashCode(), this.common, this.yesButton, this.noButton);
|
||||
return Objects.hash(this.common, this.yesButton, this.noButton);
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,8 @@ import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.dialog.DialogLike;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@NullMarked
|
||||
public interface Dialog extends MappedEntity, DeepComparableEntity, CopyableEntity<Dialog>, DialogLike {
|
||||
|
||||
+3
-4
@@ -27,8 +27,8 @@ import com.github.retrooper.packetevents.protocol.nbt.NBTInt;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -120,9 +120,8 @@ public class DialogListDialog extends AbstractMappedEntity implements Dialog {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deepEquals(Object obj) {
|
||||
public boolean deepEquals(@Nullable Object obj) {
|
||||
if (!(obj instanceof DialogListDialog)) return false;
|
||||
if (!super.equals(obj)) return false;
|
||||
DialogListDialog that = (DialogListDialog) obj;
|
||||
if (this.columns != that.columns) return false;
|
||||
if (this.buttonWidth != that.buttonWidth) return false;
|
||||
@@ -133,6 +132,6 @@ public class DialogListDialog extends AbstractMappedEntity implements Dialog {
|
||||
|
||||
@Override
|
||||
public int deepHashCode() {
|
||||
return Objects.hash(super.hashCode(), this.common, this.dialogs, this.exitAction, this.columns, this.buttonWidth);
|
||||
return Objects.hash(this.common, this.dialogs, this.exitAction, this.columns, this.buttonWidth);
|
||||
}
|
||||
}
|
||||
+3
-5
@@ -25,8 +25,8 @@ import com.github.retrooper.packetevents.protocol.nbt.NBTInt;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -68,7 +68,6 @@ public class MultiActionDialog extends AbstractMappedEntity implements Dialog {
|
||||
List<ActionButton> actions = compound.getListOrThrow("actions", ActionButton::decode, wrapper);
|
||||
ActionButton action = compound.getOrNull("exit_action", ActionButton::decode, wrapper);
|
||||
int columns = compound.getNumberTagValueOrDefault("columns", 2).intValue();
|
||||
int buttonWidth = compound.getNumberTagValueOrDefault("button_width", 150).intValue();
|
||||
return new MultiActionDialog(null, common, actions, action, columns);
|
||||
}
|
||||
|
||||
@@ -110,9 +109,8 @@ public class MultiActionDialog extends AbstractMappedEntity implements Dialog {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deepEquals(Object obj) {
|
||||
public boolean deepEquals(@Nullable Object obj) {
|
||||
if (!(obj instanceof MultiActionDialog)) return false;
|
||||
if (!super.equals(obj)) return false;
|
||||
MultiActionDialog that = (MultiActionDialog) obj;
|
||||
if (this.columns != that.columns) return false;
|
||||
if (!this.common.equals(that.common)) return false;
|
||||
@@ -122,6 +120,6 @@ public class MultiActionDialog extends AbstractMappedEntity implements Dialog {
|
||||
|
||||
@Override
|
||||
public int deepHashCode() {
|
||||
return Objects.hash(super.hashCode(), this.common, this.actions, this.exitAction, this.columns);
|
||||
return Objects.hash(this.common, this.actions, this.exitAction, this.columns);
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -26,8 +26,8 @@ import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -85,9 +85,8 @@ public class NoticeDialog extends AbstractMappedEntity implements Dialog {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deepEquals(Object obj) {
|
||||
public boolean deepEquals(@Nullable Object obj) {
|
||||
if (!(obj instanceof NoticeDialog)) return false;
|
||||
if (!super.equals(obj)) return false;
|
||||
NoticeDialog that = (NoticeDialog) obj;
|
||||
if (!this.common.equals(that.common)) return false;
|
||||
return this.action.equals(that.action);
|
||||
@@ -95,6 +94,6 @@ public class NoticeDialog extends AbstractMappedEntity implements Dialog {
|
||||
|
||||
@Override
|
||||
public int deepHashCode() {
|
||||
return Objects.hash(super.hashCode(), this.common, this.action);
|
||||
return Objects.hash(this.common, this.action);
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -25,8 +25,8 @@ import com.github.retrooper.packetevents.protocol.nbt.NBTInt;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -108,9 +108,8 @@ public class ServerLinksDialog extends AbstractMappedEntity implements Dialog {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deepEquals(Object obj) {
|
||||
public boolean deepEquals(@Nullable Object obj) {
|
||||
if (!(obj instanceof ServerLinksDialog)) return false;
|
||||
if (!super.equals(obj)) return false;
|
||||
ServerLinksDialog that = (ServerLinksDialog) obj;
|
||||
if (this.columns != that.columns) return false;
|
||||
if (this.buttonWidth != that.buttonWidth) return false;
|
||||
@@ -120,6 +119,6 @@ public class ServerLinksDialog extends AbstractMappedEntity implements Dialog {
|
||||
|
||||
@Override
|
||||
public int deepHashCode() {
|
||||
return Objects.hash(super.hashCode(), this.common, this.exitAction, this.columns, this.buttonWidth);
|
||||
return Objects.hash(this.common, this.exitAction, this.columns, this.buttonWidth);
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -28,8 +28,10 @@ import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@NullMarked
|
||||
public interface CatVariant extends MappedEntity, CopyableEntity<CatVariant>, DeepComparableEntity {
|
||||
|
||||
ResourceLocation getAssetId();
|
||||
|
||||
+5
-4
@@ -22,10 +22,12 @@ import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@NullMarked
|
||||
public class StaticCatVariant extends AbstractMappedEntity implements CatVariant {
|
||||
|
||||
private final ResourceLocation assetId;
|
||||
@@ -51,15 +53,14 @@ public class StaticCatVariant extends AbstractMappedEntity implements CatVariant
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deepEquals(Object obj) {
|
||||
public boolean deepEquals(@Nullable Object obj) {
|
||||
if (!(obj instanceof StaticCatVariant)) return false;
|
||||
if (!super.equals(obj)) return false;
|
||||
StaticCatVariant that = (StaticCatVariant) obj;
|
||||
return this.assetId.equals(that.assetId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deepHashCode() {
|
||||
return Objects.hash(super.hashCode(), this.assetId);
|
||||
return Objects.hash(this.assetId);
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -30,8 +30,10 @@ import com.github.retrooper.packetevents.util.adventure.AdventureIndexUtil;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.util.Index;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@NullMarked
|
||||
public interface ChickenVariant extends MappedEntity, CopyableEntity<ChickenVariant>, DeepComparableEntity {
|
||||
|
||||
ModelType getModelType();
|
||||
|
||||
+5
-4
@@ -22,10 +22,12 @@ import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@NullMarked
|
||||
public class StaticChickenVariant extends AbstractMappedEntity implements ChickenVariant {
|
||||
|
||||
private final ModelType modelType;
|
||||
@@ -58,9 +60,8 @@ public class StaticChickenVariant extends AbstractMappedEntity implements Chicke
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deepEquals(Object obj) {
|
||||
public boolean deepEquals(@Nullable Object obj) {
|
||||
if (!(obj instanceof StaticChickenVariant)) return false;
|
||||
if (!super.equals(obj)) return false;
|
||||
StaticChickenVariant that = (StaticChickenVariant) obj;
|
||||
if (!this.modelType.equals(that.modelType)) return false;
|
||||
return this.assetId.equals(that.assetId);
|
||||
@@ -68,6 +69,6 @@ public class StaticChickenVariant extends AbstractMappedEntity implements Chicke
|
||||
|
||||
@Override
|
||||
public int deepHashCode() {
|
||||
return Objects.hash(super.hashCode(), this.modelType, this.assetId);
|
||||
return Objects.hash(this.modelType, this.assetId);
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -30,8 +30,10 @@ import com.github.retrooper.packetevents.util.adventure.AdventureIndexUtil;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.util.Index;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@NullMarked
|
||||
public interface CowVariant extends MappedEntity, CopyableEntity<CowVariant>, DeepComparableEntity {
|
||||
|
||||
ModelType getModelType();
|
||||
|
||||
+2
@@ -22,7 +22,9 @@ import com.github.retrooper.packetevents.protocol.entity.cow.CowVariant.ModelTyp
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public final class CowVariants {
|
||||
|
||||
private static final VersionedRegistry<CowVariant> REGISTRY =
|
||||
|
||||
+5
-4
@@ -22,10 +22,12 @@ import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@NullMarked
|
||||
public class StaticCowVariant extends AbstractMappedEntity implements CowVariant {
|
||||
|
||||
private final ModelType modelType;
|
||||
@@ -58,9 +60,8 @@ public class StaticCowVariant extends AbstractMappedEntity implements CowVariant
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deepEquals(Object obj) {
|
||||
public boolean deepEquals(@Nullable Object obj) {
|
||||
if (!(obj instanceof StaticCowVariant)) return false;
|
||||
if (!super.equals(obj)) return false;
|
||||
StaticCowVariant that = (StaticCowVariant) obj;
|
||||
if (!this.modelType.equals(that.modelType)) return false;
|
||||
return this.assetId.equals(that.assetId);
|
||||
@@ -68,6 +69,6 @@ public class StaticCowVariant extends AbstractMappedEntity implements CowVariant
|
||||
|
||||
@Override
|
||||
public int deepHashCode() {
|
||||
return Objects.hash(super.hashCode(), this.modelType, this.assetId);
|
||||
return Objects.hash(this.modelType, this.assetId);
|
||||
}
|
||||
}
|
||||
+47
-12
@@ -19,11 +19,15 @@
|
||||
package com.github.retrooper.packetevents.protocol.entity.data;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemProfile;
|
||||
import com.github.retrooper.packetevents.protocol.entity.armadillo.ArmadilloState;
|
||||
import com.github.retrooper.packetevents.protocol.entity.cat.CatVariant;
|
||||
import com.github.retrooper.packetevents.protocol.entity.chicken.ChickenVariant;
|
||||
import com.github.retrooper.packetevents.protocol.entity.cow.CowVariant;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.struct.CopperGolemState;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.struct.WeatheringCopperState;
|
||||
import com.github.retrooper.packetevents.protocol.entity.frog.FrogVariant;
|
||||
import com.github.retrooper.packetevents.protocol.entity.nautilus.ZombieNautilusVariant;
|
||||
import com.github.retrooper.packetevents.protocol.entity.pig.PigVariant;
|
||||
import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose;
|
||||
import com.github.retrooper.packetevents.protocol.entity.sniffer.SnifferState;
|
||||
@@ -34,6 +38,7 @@ import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.particle.Particle;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.HumanoidArm;
|
||||
import com.github.retrooper.packetevents.protocol.world.BlockFace;
|
||||
import com.github.retrooper.packetevents.protocol.world.WorldBlockPosition;
|
||||
import com.github.retrooper.packetevents.protocol.world.painting.PaintingVariant;
|
||||
@@ -45,12 +50,15 @@ import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@NullMarked
|
||||
public final class EntityDataTypes {
|
||||
|
||||
private static final VersionedRegistry<EntityDataType<?>> REGISTRY = new VersionedRegistry<>("entity_data_serializer");
|
||||
@@ -150,7 +158,10 @@ public final class EntityDataTypes {
|
||||
|
||||
public static final EntityDataType<Integer> OPTIONAL_BLOCK_STATE = define("optional_block_state", readIntDeserializer(), writeIntSerializer());
|
||||
|
||||
// nbt was added in 1.12
|
||||
/**
|
||||
* @versions 1.12-1.21.8
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public static final EntityDataType<NBTCompound> NBT = define("nbt", PacketWrapper::readNBT, PacketWrapper::writeNBT);
|
||||
|
||||
public static final EntityDataType<Particle<?>> PARTICLE = define("particle", Particle::read, Particle::write);
|
||||
@@ -226,52 +237,76 @@ public final class EntityDataTypes {
|
||||
});
|
||||
|
||||
/**
|
||||
* Added with 1.20.5
|
||||
* @versions 1.20.5+
|
||||
*/
|
||||
public static final EntityDataType<ArmadilloState> ARMADILLO_STATE = define("armadillo_state",
|
||||
(PacketWrapper<?> wrapper) -> ArmadilloState.values()[wrapper.readVarInt()],
|
||||
(PacketWrapper<?> wrapper, ArmadilloState value) -> wrapper.writeVarInt(value.ordinal())
|
||||
);
|
||||
/**
|
||||
* Added with 1.20.5
|
||||
* @versions 1.20.5+
|
||||
*/
|
||||
public static final EntityDataType<List<Particle<?>>> PARTICLES = define("particles",
|
||||
wrapper -> wrapper.readList(Particle::read),
|
||||
(wrapper, particles) -> wrapper.writeList(particles, Particle::write)
|
||||
);
|
||||
/**
|
||||
* Added with 1.20.5
|
||||
*
|
||||
* @versions 1.20.5+
|
||||
* @deprecated use {@link #TYPED_WOLF_VARIANT} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static final EntityDataType<Integer> WOLF_VARIANT =
|
||||
define("wolf_variant_type", readIntDeserializer(), writeIntSerializer());
|
||||
/**
|
||||
* Added with 1.20.5
|
||||
* @versions 1.20.5+
|
||||
*/
|
||||
public static final EntityDataType<WolfVariant> TYPED_WOLF_VARIANT =
|
||||
define("wolf_variant_type", WolfVariant::read, WolfVariant::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
* @versions 1.21.5+
|
||||
*/
|
||||
public static final EntityDataType<CowVariant> COW_VARIANT =
|
||||
define("cow_variant_type", CowVariant::read, CowVariant::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
* @versions 1.21.5+
|
||||
*/
|
||||
public static final EntityDataType<WolfSoundVariant> WOLF_SOUND_VARIANT =
|
||||
define("wolf_sound_variant_type", WolfSoundVariant::read, WolfSoundVariant::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
* @versions 1.21.5+
|
||||
*/
|
||||
public static final EntityDataType<PigVariant> PIG_VARIANT =
|
||||
define("pig_variant_type", PigVariant::read, PigVariant::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
* @versions 1.21.5+
|
||||
*/
|
||||
public static final EntityDataType<ChickenVariant> CHICKEN_VARIANT =
|
||||
define("chicken_variant_type", ChickenVariant::read, ChickenVariant::write);
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
public static final EntityDataType<CopperGolemState> COPPER_GOLEM_STATE =
|
||||
define("copper_golem_state", CopperGolemState::read, CopperGolemState::write);
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
public static final EntityDataType<WeatheringCopperState> WEATHERING_COPPER_STATE =
|
||||
define("weathering_copper_state", WeatheringCopperState::read, WeatheringCopperState::write);
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
public static final EntityDataType<ItemProfile> RESOLVABLE_PROFILE =
|
||||
define("resolvable_profile", ItemProfile::read, ItemProfile::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final EntityDataType<ZombieNautilusVariant> ZOMBIE_NAUTILUS_VARIANT =
|
||||
define("zombie_nautilus_variant", ZombieNautilusVariant::read, ZombieNautilusVariant::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final EntityDataType<HumanoidArm> HUMANOID_ARM =
|
||||
define("humanoid_arm", HumanoidArm::read, HumanoidArm::write);
|
||||
|
||||
private EntityDataTypes() {
|
||||
}
|
||||
@@ -289,11 +324,11 @@ public final class EntityDataTypes {
|
||||
return REGISTRY.getEntries();
|
||||
}
|
||||
|
||||
public static EntityDataType<?> getById(ClientVersion version, int id) {
|
||||
public static @Nullable EntityDataType<?> getById(ClientVersion version, int id) {
|
||||
return REGISTRY.getById(version, id);
|
||||
}
|
||||
|
||||
public static EntityDataType<?> getByName(String name) {
|
||||
public static @Nullable EntityDataType<?> getByName(String name) {
|
||||
return REGISTRY.getByName(name);
|
||||
}
|
||||
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.entity.data.struct;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
@NullMarked
|
||||
public enum CopperGolemState {
|
||||
|
||||
IDLE,
|
||||
GETTING_ITEM,
|
||||
GETTING_NO_ITEM,
|
||||
DROPPING_ITEM,
|
||||
DROPPING_NO_ITEM,
|
||||
;
|
||||
|
||||
private static final CopperGolemState[] STATES = values();
|
||||
|
||||
public static CopperGolemState read(PacketWrapper<?> wrapper){
|
||||
return wrapper.readEnum(STATES);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, CopperGolemState state) {
|
||||
wrapper.writeEnum(state);
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.entity.data.struct;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public enum WeatheringCopperState {
|
||||
|
||||
UNAFFECTED,
|
||||
EXPOSED,
|
||||
WEATHERED,
|
||||
OXIDIZED,
|
||||
;
|
||||
|
||||
private static final WeatheringCopperState[] STATES = values();
|
||||
|
||||
public static WeatheringCopperState read(PacketWrapper<?> wrapper) {
|
||||
return wrapper.readEnum(STATES);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, WeatheringCopperState state) {
|
||||
wrapper.writeEnum(state);
|
||||
}
|
||||
}
|
||||
+2
@@ -29,7 +29,9 @@ import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public interface FrogVariant extends MappedEntity, CopyableEntity<FrogVariant>, DeepComparableEntity {
|
||||
|
||||
ResourceLocation getAssetId();
|
||||
|
||||
+5
-4
@@ -22,10 +22,12 @@ import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@NullMarked
|
||||
public class StaticFrogVariant extends AbstractMappedEntity implements FrogVariant {
|
||||
|
||||
private final ResourceLocation assetId;
|
||||
@@ -51,15 +53,14 @@ public class StaticFrogVariant extends AbstractMappedEntity implements FrogVaria
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deepEquals(Object obj) {
|
||||
public boolean deepEquals(@Nullable Object obj) {
|
||||
if (!(obj instanceof StaticFrogVariant)) return false;
|
||||
if (!super.equals(obj)) return false;
|
||||
StaticFrogVariant that = (StaticFrogVariant) obj;
|
||||
return this.assetId.equals(that.assetId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deepHashCode() {
|
||||
return Objects.hash(super.hashCode(), this.assetId);
|
||||
return Objects.hash(this.assetId);
|
||||
}
|
||||
}
|
||||
Loaded 100 of 422 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user