mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2026-11-04 17:00:06 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d566100fb | ||
|
|
212cca1d65 | ||
|
|
1f40811877 | ||
|
|
f45d2f8567 | ||
|
|
9b19bfc6df | ||
|
|
c2a8400751 | ||
|
|
3cbfbd3b9f | ||
|
|
ea6808b697 | ||
|
|
85f868c37e | ||
|
|
f6e036df76 | ||
|
|
55ed56668e | ||
|
|
705509489a | ||
|
|
57a42e1156 | ||
|
|
7181f485eb | ||
|
|
5f3dc1be53 | ||
|
|
4f06afc2bd | ||
|
|
c267a754e7 | ||
|
|
7657a59b07 | ||
|
|
f95ec49d6f | ||
|
|
1be574bc21 | ||
|
|
0640e2468c | ||
|
|
2adfee3b60 | ||
|
|
b65d7af793 | ||
|
|
8f7fd34fa4 | ||
|
|
5bf0e9b22a | ||
|
|
808605e06a | ||
|
|
fb387bf9c5 | ||
|
|
a3ff540cb3 | ||
|
|
1cafd08326 | ||
|
|
d5458145a0 | ||
|
|
316e6ac1ba | ||
|
|
6b66611810 | ||
|
|
89176f4f11 | ||
|
|
0808c52317 | ||
|
|
e93199fcfe | ||
|
|
04e5dfdc4e | ||
|
|
cba704fe3d | ||
|
|
f2ef57673c | ||
|
|
6f7e24ac9e | ||
|
|
54bd8fb5f7 | ||
|
|
22c0ddc5de | ||
|
|
43bb38f4cf | ||
|
|
b9f110219e | ||
|
|
4fc70ad603 | ||
|
|
8c33faa4f5 | ||
|
|
6375718b10 | ||
|
|
e51ea0eeb6 | ||
|
|
5ce209e0e9 | ||
|
|
d232242997 | ||
|
|
3e6d17274d | ||
|
|
4350c7f614 | ||
|
|
aea0c6c76f | ||
|
|
5b8b8f5e10 | ||
|
|
b46f771103 | ||
|
|
fb8430518b | ||
|
|
9a686ee527 | ||
|
|
cb3dd89c78 | ||
|
|
5689389f3a | ||
|
|
ed07809c84 | ||
|
|
081fc0db41 | ||
|
|
74d60c2126 | ||
|
|
d45f2cdd64 | ||
|
|
09898c8c1e | ||
|
|
131660d89f | ||
|
|
1c066873fd | ||
|
|
8429689837 | ||
|
|
19c8a1ce1b | ||
|
|
c6fdaf507f | ||
|
|
7b097b3e54 | ||
|
|
c14928defa | ||
|
|
6b4e74abe9 | ||
|
|
1fb3aa8c7a | ||
|
|
f175a903a3 | ||
|
|
7c80e37e3a | ||
|
|
ff61e1d897 | ||
|
|
d49272a41f | ||
|
|
bea6df1174 | ||
|
|
4ca84f6001 | ||
|
|
61c079af19 | ||
|
|
e0b9deb128 | ||
|
|
1d89bc7f95 | ||
|
|
28c18c33fa | ||
|
|
d08cb1b743 | ||
|
|
fb18f69a0b | ||
|
|
56e1d32aa0 | ||
|
|
d4aa5a2fb3 | ||
|
|
b54a87f465 | ||
|
|
5acfa9faf7 | ||
|
|
638f4cd19a | ||
|
|
baf12dd516 | ||
|
|
4b6b26fbba | ||
|
|
5c5784795d | ||
|
|
1f8e7515b1 | ||
|
|
3778698018 | ||
|
|
40dd2be139 | ||
|
|
edbe2c92ce | ||
|
|
b9ae1ef43e | ||
|
|
4631fd1977 | ||
|
|
3d25686745 | ||
|
|
18b5b2626a | ||
|
|
219ad4737a | ||
|
|
b9368ae80a | ||
|
|
03c80ccff8 | ||
|
|
f6aed5578f | ||
|
|
646de0b1af | ||
|
|
4e33a40ede | ||
|
|
21b0ac7a43 | ||
|
|
15d3944700 | ||
|
|
acd9a6f57c | ||
|
|
d5fe4e22b4 | ||
|
|
9f0c38915a | ||
|
|
bc7f081b3a | ||
|
|
46b6627f9f | ||
|
|
51cc1843ad | ||
|
|
98d1d2cb49 | ||
|
|
556560a0f3 | ||
|
|
be2534c6e6 | ||
|
|
d40d1bd232 | ||
|
|
6143f78ccf | ||
|
|
52cdebc3d3 | ||
|
|
cdccae95e0 | ||
|
|
b0c45e3ed3 | ||
|
|
3ba518650c | ||
|
|
5a303996a1 | ||
|
|
695534e8a8 | ||
|
|
16ba011243 | ||
|
|
0ea7271157 | ||
|
|
dc2b2f1407 | ||
|
|
85baefc69b | ||
|
|
41e0fdc20f | ||
|
|
5c328fba33 | ||
|
|
91b11878fb | ||
|
|
0ea5e07d63 | ||
|
|
152e4e77a8 | ||
|
|
cf20c6397d | ||
|
|
981672e2cf | ||
|
|
d10b600e72 | ||
|
|
de9cec36c7 | ||
|
|
6eb561607c | ||
|
|
db3e1f605a | ||
|
|
31583fc2d3 | ||
|
|
6096ce4eea | ||
|
|
873da12233 | ||
|
|
78191ea366 | ||
|
|
f8d7c5c193 | ||
|
|
bc9c979e7d | ||
|
|
d686a9ddf0 | ||
|
|
9dd610605f | ||
|
|
219e163ac2 | ||
|
|
925e7b4664 | ||
|
|
5a9f040af8 | ||
|
|
992ad7f35a | ||
|
|
bb93ac011c | ||
|
|
4070ea9f02 | ||
|
|
499efa1608 | ||
|
|
0196d9c83e | ||
|
|
4c316de042 | ||
|
|
8ee5d7e680 | ||
|
|
64c128d414 | ||
|
|
77d11fc593 | ||
|
|
2c72a09809 | ||
|
|
3dbd81da76 | ||
|
|
a0116c7ea7 | ||
|
|
fd5dadbe01 | ||
|
|
df87a02c38 | ||
|
|
bb293b3e5d | ||
|
|
ff03892b25 | ||
|
|
eb51306d82 | ||
|
|
81eb3362f3 | ||
|
|
7f06b03453 | ||
|
|
c16432de2a | ||
|
|
b162dbdff0 | ||
|
|
dfbe57e304 | ||
|
|
6f6dc2c641 | ||
|
|
06990ec0c9 | ||
|
|
351b42b5e5 | ||
|
|
20e3c832fb | ||
|
|
ec9c121da2 | ||
|
|
12c773edea | ||
|
|
97b411aa6d | ||
|
|
24f6c4f0fd | ||
|
|
9409c7d22a | ||
|
|
17d94a17f0 | ||
|
|
a1cb4d3691 | ||
|
|
1d5070a480 | ||
|
|
f612adbd0a | ||
|
|
6716beec5a | ||
|
|
d22b00e4a6 | ||
|
|
fe9ca49920 | ||
|
|
e1837dc578 | ||
|
|
66eead2927 | ||
|
|
937a2a2532 | ||
|
|
bee45ef9ef | ||
|
|
1946a65ab2 | ||
|
|
f594a946d4 | ||
|
|
7a0ec492d1 | ||
|
|
b4fac61eb9 | ||
|
|
7817b7a422 | ||
|
|
ed266d296e | ||
|
|
3ce324c1e1 | ||
|
|
835dc4733d | ||
|
|
aa66a6b482 | ||
|
|
406855d427 | ||
|
|
fe5ba84f7a | ||
|
|
f49495162b | ||
|
|
be5c451f42 | ||
|
|
1517596a9f | ||
|
|
6a89b84879 | ||
|
|
c414458f1c | ||
|
|
ec9086abc4 | ||
|
|
d6c16677fc | ||
|
|
7cd3a75ef8 | ||
|
|
0677cbaa3c | ||
|
|
ab8b5abc48 | ||
|
|
60c67659d0 | ||
|
|
814190c2df | ||
|
|
04d647bfef | ||
|
|
930bf67229 | ||
|
|
51c3085180 | ||
|
|
b981223e0a | ||
|
|
3951cff03a | ||
|
|
77a6ae37c0 | ||
|
|
12e201633f | ||
|
|
8eb005e775 | ||
|
|
4d39c0007f | ||
|
|
d9609e60b8 | ||
|
|
ab3927dff7 | ||
|
|
1a60c52fa3 | ||
|
|
f88dae1828 | ||
|
|
2626773267 | ||
|
|
f16f1905b7 | ||
|
|
cc435b2b02 | ||
|
|
eb2d603aae | ||
|
|
c30e0f45bc | ||
|
|
ebb24c73a2 | ||
|
|
575c5b9abf | ||
|
|
812694d74d | ||
|
|
1efaffbc7d | ||
|
|
b03b5f7da7 | ||
|
|
3554db9e3a | ||
|
|
a6d58fc02b | ||
|
|
e2045295a0 | ||
|
|
a6b219c0df | ||
|
|
0b5721d81e | ||
|
|
5bad61e210 | ||
|
|
e597d8faaa | ||
|
|
d9eb7109bd | ||
|
|
77d68306b6 | ||
|
|
16aec9c0a1 | ||
|
|
c6cde5fc10 | ||
|
|
bf84eb0141 | ||
|
|
4dfc3bd2be | ||
|
|
b0c53ffdd3 | ||
|
|
d65b2abc46 | ||
|
|
03313a1681 | ||
|
|
78c5e2c8e3 | ||
|
|
e467c7c03f | ||
|
|
0c01425641 | ||
|
|
01d26e7ac5 | ||
|
|
99ea6c32ad | ||
|
|
cf231d92b1 | ||
|
|
f555188428 | ||
|
|
93d6fa2e78 | ||
|
|
162fcafb36 | ||
|
|
3d0a0fe590 | ||
|
|
b06556a84e | ||
|
|
ac8bb104b3 | ||
|
|
4b85ca7691 | ||
|
|
ebd8eb79c1 | ||
|
|
09cffbfb33 | ||
|
|
49a1bffc98 | ||
|
|
da022a0b63 | ||
|
|
3beddaf522 | ||
|
|
70139c6838 |
No files matched your search
@@ -50,21 +50,12 @@ body:
|
||||
label: Steps to Reproduce
|
||||
description: |
|
||||
List the steps on how we can reproduce the issue. Make sure we can easily understand what you mean with each step.
|
||||
**Please always include the client version(s) with which the issue happens. Ideally also try to find out, from what specific version onward/in what version range the issue happens.**
|
||||
placeholder: |
|
||||
Example:
|
||||
1. Login with a 1.21.3 client
|
||||
2. Place a sign
|
||||
3. The sign text is displayed wrong
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Expected Behavior
|
||||
description: |
|
||||
Describe what exactly you expected to happen.
|
||||
placeholder: |
|
||||
Example: "Placed sign text should not disappear."
|
||||
3. The sign text disappears
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
cooldown:
|
||||
default-days: 7
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
interval: "monthly"
|
||||
@@ -1,23 +1,23 @@
|
||||
name: Java CI with Gradle
|
||||
|
||||
on: [push, pull_request]
|
||||
name: Build
|
||||
on: [pull_request, push, workflow_dispatch]
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# Only run on PRs if the source branch is on a different repo. We do not need to run everything twice.
|
||||
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
|
||||
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # 6.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@v4
|
||||
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # 5.0.0
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # 5.0.0
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
@@ -27,7 +27,8 @@ jobs:
|
||||
- name: Upload Artifacts to GitHub
|
||||
# Only upload on the preview repository as there is no CI job for it.
|
||||
if: ${{ github.repository == 'ViaVersion/ViaVersionDev' && github.ref_name == 'preview' }}
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # 5.0.0
|
||||
with:
|
||||
name: Artifacts
|
||||
path: build/libs/
|
||||
if-no-files-found: error
|
||||
@@ -4,26 +4,38 @@ on:
|
||||
branches:
|
||||
- master
|
||||
- dev
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
if: github.repository_owner == 'ViaVersion'
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # 6.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@v4
|
||||
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # 5.0.0
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # 5.0.0
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
check-latest: true
|
||||
- name: Publish
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
- name: Publish to Hangar
|
||||
env:
|
||||
HANGAR_TOKEN: ${{ secrets.HANGAR_TOKEN }}
|
||||
run: ./gradlew publishAllPublicationsToHangar --stacktrace
|
||||
continue-on-error: true
|
||||
- name: Publish to Modrinth
|
||||
env:
|
||||
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
|
||||
run: ./gradlew build modrinth publishAllPublicationsToHangar --stacktrace
|
||||
run: ./gradlew modrinth --stacktrace
|
||||
continue-on-error: true
|
||||
@@ -4,13 +4,19 @@ on:
|
||||
schedule:
|
||||
- cron: "0 0 * * 0"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
update-gradle-wrapper:
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # 6.0.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
- name: Update Gradle Wrapper
|
||||
uses: gradle-update/update-gradle-wrapper-action@v2
|
||||
uses: gradle-update/update-gradle-wrapper-action@512b1875f3b6270828abfe77b247d5895a2da1e5 # 2.1.0
|
||||
+19
-98
@@ -1,115 +1,36 @@
|
||||
### Java files ###
|
||||
*.class
|
||||
# Gradle
|
||||
|
||||
# Package Files
|
||||
#*.jar
|
||||
*.war
|
||||
*.ear
|
||||
.gradle/
|
||||
build/
|
||||
out/
|
||||
classes/
|
||||
.kotlin/
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
# Eclipse
|
||||
|
||||
*.launch
|
||||
|
||||
# Idea
|
||||
|
||||
### Intellij ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
|
||||
# Ignore project files
|
||||
*.iml
|
||||
|
||||
# Ignore IDEA directory
|
||||
.idea/*
|
||||
.idea/
|
||||
!.idea/copyright/*
|
||||
!.idea/scopes/*
|
||||
|
||||
# Include the project's dictionary
|
||||
!.idea/dictionaries/
|
||||
!.idea/dictionaries/*
|
||||
|
||||
# File-based project format:
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
### Plugin-specific files: ###
|
||||
# IntelliJ
|
||||
/out/
|
||||
# VSCode
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
|
||||
|
||||
|
||||
### Eclipse ###
|
||||
*.pydevproject
|
||||
.metadata
|
||||
.gradle
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.settings/
|
||||
.loadpath
|
||||
|
||||
# Eclipse Core
|
||||
.vscode/
|
||||
bin/
|
||||
.classpath
|
||||
.project
|
||||
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
# macOS
|
||||
|
||||
# Locally stored "Eclipse launch configurations"
|
||||
*.launch
|
||||
|
||||
# CDT-specific
|
||||
.cproject
|
||||
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
.classpath
|
||||
|
||||
# PDT-specific
|
||||
.buildpath
|
||||
|
||||
# sbteclipse plugin
|
||||
.target
|
||||
|
||||
# TeXlipse plugin
|
||||
.texlipse
|
||||
|
||||
|
||||
|
||||
### Maven ###
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
|
||||
|
||||
|
||||
### NetBeans ###
|
||||
nbproject/private/
|
||||
build/
|
||||
nbbuild/
|
||||
dist/
|
||||
nbdist/
|
||||
nbactions.xml
|
||||
nb-configuration.xml
|
||||
.nb-gradle/
|
||||
|
||||
### MacOS ###
|
||||
.DS_Store
|
||||
|
||||
### Run Folder (ViaProxy) ###
|
||||
common/run/
|
||||
# Misc
|
||||
|
||||
run/
|
||||
@@ -8,7 +8,7 @@
|
||||
it works on any platform you can think of.**
|
||||
|
||||
The base ViaVersion jar runs on Paper and Velocity. We also have projects integrating ViaVersion to run
|
||||
on Fabric, Forge, Bungee, Sponge, or as a standalone proxy to join from basically any client version on
|
||||
on Fabric, Forge, Sponge, or as a standalone proxy to join from basically any client version on
|
||||
any server version from the past decade. **See [HERE](https://viaversion.com) for an overview of the different Via\* projects.**
|
||||
|
||||
Note that ViaVersion will be able to **run best on either Paper servers or through [ViaFabricPlus](https://github.com/ViaVersion/ViaFabricPlus?tab=readme-ov-file#viafabricplus)** due to having
|
||||
@@ -16,7 +16,7 @@ direct access to client/server state and more extensive API.
|
||||
|
||||
Supported Versions:
|
||||
|
||||

|
||||

|
||||
|
||||
**User Docs:** https://docs.viaversion.com
|
||||
|
||||
@@ -87,12 +87,10 @@ of the `build/libs` directory.
|
||||
|
||||
You need JDK 17 or newer to build ViaVersion.
|
||||
|
||||
|
||||
Mapping Files
|
||||
--------------
|
||||
Mapping files are generated and managed in our [Mappings repository](https://github.com/ViaVersion/Mappings). The generated mapping output is stored [here](./common/src/main/resources/assets/viaversion).
|
||||
|
||||
|
||||
Resources
|
||||
--------
|
||||
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
# Security Policy
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
If you discover a **security vulnerability**, please **do not** open a public issue. Instead, use one of the following **confidential contact methods**:
|
||||
|
||||
* **Email:** [security@viaversion.com](mailto:security@viaversion.com)
|
||||
* **Discord:** Join our [Discord server](https://discord.gg/viaversion) and visit the [#exploit-report](https://discord.com/channels/316206679014244363/1388847764137316485) channel for further instructions.
|
||||
|
||||
If your issue is **not security-related** (e.g., bug reports, feature requests, or usage questions), please use the [GitHub Issues page](https://github.com/ViaVersion/ViaVersion/issues) or contact us via the [Discord server](https://discord.gg/viaversion).
|
||||
@@ -24,13 +24,16 @@ dependencies {
|
||||
}
|
||||
implementation(rootProject.libs.text) {
|
||||
exclude("com.google.code.gson", "gson")
|
||||
exclude("com.google.guava", "guava")
|
||||
exclude("com.viaversion", "nbt")
|
||||
}
|
||||
api(libs.snakeYaml)
|
||||
|
||||
compileOnlyApi(libs.netty)
|
||||
compileOnlyApi(libs.guava)
|
||||
compileOnlyApi(libs.guava) {
|
||||
exclude("com.google.errorprone", "error_prone_annotations")
|
||||
exclude("org.jspecify", "jspecify")
|
||||
exclude("com.google.j2objc", "j2objc-annotations")
|
||||
}
|
||||
compileOnlyApi(libs.checkerQual)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -123,7 +123,7 @@ public interface ViaAPI<T> {
|
||||
boolean isInjected(UUID uuid);
|
||||
|
||||
/**
|
||||
* Returns whether Via injected into this player connection. Note that this method may not work on
|
||||
* Returns the injected UserConnection if present. Note that this method may not work on
|
||||
* clientside implementations and is generally not recommended to be used. Use {@link ConnectionManager} instead.
|
||||
*
|
||||
* @param uuid uuid of the player
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.configuration;
|
||||
|
||||
public record RateLimitConfig(boolean enabled, int maxRate, String maxRateKickMessage, int warningRate, int maxWarnings,
|
||||
long trackingPeriodNanos, String warningKickMessage, String ratePlaceholder) {
|
||||
}
|
||||
+81
-18
@@ -27,6 +27,7 @@ import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.WorldIdentifiers;
|
||||
import com.viaversion.viaversion.api.protocol.version.BlockedProtocolVersions;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public interface ViaVersionConfig extends Config {
|
||||
|
||||
@@ -67,11 +68,16 @@ public interface ViaVersionConfig extends Config {
|
||||
boolean isShowNewDeathMessages();
|
||||
|
||||
/**
|
||||
* Get if entity data errors will be suppressed
|
||||
* Get if entity data errors will be logged
|
||||
*
|
||||
* @return true if entity data errors suppression is enabled
|
||||
* @return true if entity data error logging is enabled
|
||||
*/
|
||||
boolean isSuppressMetadataErrors();
|
||||
boolean logEntityDataErrors();
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
default boolean isSuppressMetadataErrors() {
|
||||
return !logEntityDataErrors();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if blocking in 1.9 & 1.10 appears as a player holding a shield
|
||||
@@ -147,42 +153,64 @@ public interface ViaVersionConfig extends Config {
|
||||
*
|
||||
* @return The number of packets a client can send per second.
|
||||
*/
|
||||
int getMaxPPS();
|
||||
@Deprecated(forRemoval = true)
|
||||
default int getMaxPPS() {
|
||||
return getPacketTrackerConfig().maxRate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the kick message sent if the user hits the max packets per second.
|
||||
*
|
||||
* @return Kick message, with colour codes using '&amp;'
|
||||
*/
|
||||
String getMaxPPSKickMessage();
|
||||
@Deprecated(forRemoval = true)
|
||||
default String getMaxPPSKickMessage() {
|
||||
return getPacketTrackerConfig().maxRateKickMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* The time in seconds that should be tracked for warnings
|
||||
*
|
||||
* @return Time in seconds that should be tracked for warnings
|
||||
*/
|
||||
int getTrackingPeriod();
|
||||
@Deprecated(forRemoval = true)
|
||||
default int getTrackingPeriod() {
|
||||
return (int) TimeUnit.NANOSECONDS.toSeconds(getPacketTrackerConfig().trackingPeriodNanos());
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of packets per second to count as a warning
|
||||
*
|
||||
* @return The number of packets per second to count as a warning.
|
||||
*/
|
||||
int getWarningPPS();
|
||||
@Deprecated(forRemoval = true)
|
||||
default int getWarningPPS() {
|
||||
return getPacketTrackerConfig().warningRate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum number of warnings the client can have in the interval
|
||||
*
|
||||
* @return The number of packets a client can send per second.
|
||||
*/
|
||||
int getMaxWarnings();
|
||||
@Deprecated(forRemoval = true)
|
||||
default int getMaxWarnings() {
|
||||
return getPacketTrackerConfig().maxWarnings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the kick message sent if the user goes over the warnings in the interval
|
||||
*
|
||||
* @return Kick message, with colour codes using '&amp;'
|
||||
*/
|
||||
String getMaxWarningsKickMessage();
|
||||
@Deprecated(forRemoval = true)
|
||||
default String getMaxWarningsKickMessage() {
|
||||
return getPacketTrackerConfig().warningKickMessage();
|
||||
}
|
||||
|
||||
RateLimitConfig getPacketTrackerConfig();
|
||||
|
||||
RateLimitConfig getPacketSizeTrackerConfig();
|
||||
|
||||
/**
|
||||
* Send supported versions in the status response packet
|
||||
@@ -233,13 +261,6 @@ public interface ViaVersionConfig extends Config {
|
||||
*/
|
||||
boolean isChunkBorderFix();
|
||||
|
||||
/**
|
||||
* Should we fix nbt array's in json chat messages for 1.12 clients
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean is1_12NBTArrayFix();
|
||||
|
||||
/**
|
||||
* Should we make team colours based on the last colour in team prefix
|
||||
*
|
||||
@@ -270,6 +291,8 @@ public interface ViaVersionConfig extends Config {
|
||||
*/
|
||||
String getBlockedDisconnectMsg();
|
||||
|
||||
boolean logBlockedJoins();
|
||||
|
||||
/**
|
||||
* Get the message sent to players being kicked on reload.
|
||||
* Players are kicked to stop the server crashing
|
||||
@@ -279,11 +302,28 @@ public interface ViaVersionConfig extends Config {
|
||||
String getReloadDisconnectMsg();
|
||||
|
||||
/**
|
||||
* Should we hide errors that occur when trying to convert block and item data over versions?
|
||||
* Should we log warnings on issues when trying to convert data over versions?
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean isSuppressConversionWarnings();
|
||||
boolean logOtherConversionWarnings();
|
||||
|
||||
/**
|
||||
* Should we log errors that occur when trying to convert text components?
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean logTextComponentConversionErrors();
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
default boolean isSuppressConversionWarnings() {
|
||||
return !logOtherConversionWarnings();
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
default boolean isSuppressTextComponentConversionWarnings() {
|
||||
return !logTextComponentConversionErrors();
|
||||
}
|
||||
|
||||
/**
|
||||
* Should we disable the 1.13 auto-complete feature to stop spam kicks? (for any server lower than 1.13)
|
||||
@@ -478,4 +518,27 @@ public interface ViaVersionConfig extends Config {
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean fix1_21PlacementRotation();
|
||||
|
||||
/**
|
||||
* If enabled, cancel swing packets sent while having an inventory opened on 1.15.2 and below servers.
|
||||
* This can cause false positives with anti-cheat plugins.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean cancelSwingInInventory();
|
||||
|
||||
/**
|
||||
* Returns the max length of error messages. Longer messages will be truncated unless in debug mode.
|
||||
*
|
||||
* @return the max length of error messages
|
||||
*/
|
||||
int maxErrorLength();
|
||||
|
||||
/**
|
||||
* If enabled, 1.21.11+ clients on 1.8 (or older) servers will get wider entity hitboxes,
|
||||
* but only when attacking with an item.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean use1_8HitboxMargin();
|
||||
}
|
||||
@@ -30,15 +30,6 @@ package com.viaversion.viaversion.api.connection;
|
||||
*/
|
||||
public interface StorableObject {
|
||||
|
||||
/**
|
||||
* Returns whether the object should be uncached on a server switch.
|
||||
*
|
||||
* @return whether the object should be uncached on a server switch
|
||||
*/
|
||||
default boolean clearOnServerSwitch() {
|
||||
return true;
|
||||
}
|
||||
|
||||
default void onRemove() {
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.connection;
|
||||
|
||||
import com.viaversion.viaversion.api.configuration.ViaVersionConfig;
|
||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||
import com.viaversion.viaversion.api.data.item.ItemHasher;
|
||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketTracker;
|
||||
@@ -99,6 +100,23 @@ public interface UserConnection {
|
||||
*/
|
||||
void addEntityTracker(Class<? extends Protocol> protocolClass, EntityTracker tracker);
|
||||
|
||||
/**
|
||||
* Adds an item hasher to the user connection.
|
||||
*
|
||||
* @param protocolClass protocol class
|
||||
* @param itemHasher item hasher
|
||||
*/
|
||||
void addItemHasher(Class<? extends Protocol> protocolClass, ItemHasher itemHasher);
|
||||
|
||||
/**
|
||||
* Returns the item hasher by the given protocol class if present.
|
||||
*
|
||||
* @param protocolClass protocol class
|
||||
* @param <T> item hasher type
|
||||
* @return item hasher if present
|
||||
*/
|
||||
@Nullable <T extends ItemHasher> T getItemHasher(Class<? extends Protocol> protocolClass);
|
||||
|
||||
/**
|
||||
* Returns the client world by the given protocol class if present.
|
||||
*
|
||||
@@ -121,17 +139,7 @@ public interface UserConnection {
|
||||
/**
|
||||
* Clear stored objects, entity trackers and client worlds.
|
||||
*/
|
||||
default void clearStoredObjects() {
|
||||
clearStoredObjects(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear stored objects, entity trackers and client worlds.
|
||||
* If cleared for a proxy server switch, some stored objects and tracker data will be retained.
|
||||
*
|
||||
* @param isServerSwitch whether the clear is due to a server switch
|
||||
*/
|
||||
void clearStoredObjects(boolean isServerSwitch);
|
||||
void clearStoredObjects();
|
||||
|
||||
/**
|
||||
* Sends a raw packet to the connection on the current thread.
|
||||
@@ -186,9 +194,15 @@ public interface UserConnection {
|
||||
/**
|
||||
* Monitors serverbound packets and returns whether a packet can/should be processed.
|
||||
*
|
||||
* @param bytes the number of bytes in the packet
|
||||
* @return false if this packet should be cancelled
|
||||
*/
|
||||
boolean checkServerboundPacket();
|
||||
boolean checkServerboundPacket(int bytes);
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
default boolean checkServerboundPacket() {
|
||||
return checkServerboundPacket(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitors clientbound packets and returns whether a packet can/should be processed.
|
||||
@@ -201,6 +215,11 @@ public interface UserConnection {
|
||||
* @see #checkClientboundPacket()
|
||||
* @see #checkServerboundPacket()
|
||||
*/
|
||||
default boolean checkIncomingPacket(final int bytes) {
|
||||
return isClientSide() ? checkClientboundPacket() : checkServerboundPacket(bytes);
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
default boolean checkIncomingPacket() {
|
||||
return isClientSide() ? checkClientboundPacket() : checkServerboundPacket();
|
||||
}
|
||||
|
||||
@@ -22,9 +22,13 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryKey;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.TagData;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface MappingData {
|
||||
@@ -140,12 +144,14 @@ public interface MappingData {
|
||||
|
||||
@Nullable Mappings getBlockMappings();
|
||||
|
||||
@Nullable Mappings getBlockEntityMappings();
|
||||
@Nullable FullMappings getFullBlockMappings();
|
||||
|
||||
@Nullable Mappings getBlockStateMappings();
|
||||
|
||||
@Nullable Mappings getSoundMappings();
|
||||
|
||||
@Nullable FullMappings getFullSoundMappings();
|
||||
|
||||
@Nullable Mappings getStatisticsMappings();
|
||||
|
||||
@Nullable Mappings getMenuMappings();
|
||||
@@ -154,6 +160,8 @@ public interface MappingData {
|
||||
|
||||
@Nullable Mappings getPaintingMappings();
|
||||
|
||||
@Nullable FullMappings getBlockEntityMappings();
|
||||
|
||||
@Nullable FullMappings getAttributeMappings();
|
||||
|
||||
@Nullable FullMappings getEntityMappings();
|
||||
@@ -163,4 +171,32 @@ public interface MappingData {
|
||||
@Nullable FullMappings getRecipeSerializerMappings();
|
||||
|
||||
@Nullable FullMappings getDataComponentSerializerMappings();
|
||||
|
||||
default @Nullable FullMappings getFullMappings(final MappingType mappingType) {
|
||||
return switch (mappingType) {
|
||||
case ITEM -> getFullItemMappings();
|
||||
case BLOCK -> getFullBlockMappings();
|
||||
case SOUND -> getFullSoundMappings();
|
||||
case ENTITY_TYPE -> getEntityMappings();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Set of block (not block state) ids that had their base type or properties changed.
|
||||
*
|
||||
* @return set of changed block ids, or null if not tracked/none are present
|
||||
*/
|
||||
@Nullable IntSet changedBlocks();
|
||||
|
||||
/**
|
||||
* Type of mappings. Currently only relevant for ops writing of generic holder classes and expanded when needed.
|
||||
*/
|
||||
enum MappingType implements RegistryKey {
|
||||
ITEM, BLOCK, SOUND, ENTITY_TYPE;
|
||||
|
||||
@Override
|
||||
public Key key() {
|
||||
return Key.of(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,8 @@ import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.TagData;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
@@ -44,17 +46,21 @@ public class MappingDataBase implements MappingData {
|
||||
protected FullMappings recipeSerializerMappings;
|
||||
protected FullMappings itemDataSerializerMappings;
|
||||
protected FullMappings attributeMappings;
|
||||
protected FullMappings blockEntityMappings;
|
||||
protected ParticleMappings particleMappings;
|
||||
protected BiMappings itemMappings;
|
||||
protected BiMappings blockMappings;
|
||||
protected Mappings blockStateMappings;
|
||||
protected Mappings blockEntityMappings;
|
||||
protected Mappings soundMappings;
|
||||
protected Mappings statisticsMappings;
|
||||
protected Mappings enchantmentMappings;
|
||||
protected Mappings paintingMappings;
|
||||
protected Mappings menuMappings;
|
||||
protected Map<RegistryType, List<TagData>> tags;
|
||||
/**
|
||||
* Set of block ids that have had type or property changes.
|
||||
*/
|
||||
protected IntSet changedBlocks;
|
||||
|
||||
public MappingDataBase(final String unmappedVersion, final String mappedVersion) {
|
||||
this.unmappedVersion = unmappedVersion;
|
||||
@@ -68,10 +74,7 @@ public class MappingDataBase implements MappingData {
|
||||
}
|
||||
|
||||
final CompoundTag data = readMappingsFile("mappings-" + unmappedVersion + "to" + mappedVersion + ".nbt");
|
||||
blockMappings = loadBiMappings(data, "blocks");
|
||||
blockStateMappings = loadMappings(data, "blockstates");
|
||||
blockEntityMappings = loadMappings(data, "blockentities");
|
||||
soundMappings = loadMappings(data, "sounds");
|
||||
statisticsMappings = loadMappings(data, "statistics");
|
||||
menuMappings = loadMappings(data, "menus");
|
||||
enchantmentMappings = loadMappings(data, "enchantments");
|
||||
@@ -80,12 +83,16 @@ public class MappingDataBase implements MappingData {
|
||||
final CompoundTag unmappedIdentifierData = readUnmappedIdentifiersFile("identifiers-" + unmappedVersion + ".nbt");
|
||||
final CompoundTag mappedIdentifierData = readMappedIdentifiersFile("identifiers-" + mappedVersion + ".nbt");
|
||||
if (unmappedIdentifierData != null && mappedIdentifierData != null) {
|
||||
itemMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "items");
|
||||
itemMappings = loadFullOrBiMappings(data, unmappedIdentifierData, mappedIdentifierData, "items");
|
||||
blockMappings = loadFullOrBiMappings(data, unmappedIdentifierData, mappedIdentifierData, "blocks");
|
||||
soundMappings = loadFullOrBiMappings(data, unmappedIdentifierData, mappedIdentifierData, "sounds");
|
||||
|
||||
entityMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "entities");
|
||||
argumentTypeMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "argumenttypes");
|
||||
recipeSerializerMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "recipe_serializers");
|
||||
itemDataSerializerMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "data_component_type");
|
||||
attributeMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "attributes");
|
||||
blockEntityMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "blockentities");
|
||||
|
||||
final List<String> unmappedParticles = identifiersFromGlobalIds(unmappedIdentifierData, "particles");
|
||||
final List<String> mappedParticles = identifiersFromGlobalIds(mappedIdentifierData, "particles");
|
||||
@@ -99,6 +106,8 @@ public class MappingDataBase implements MappingData {
|
||||
} else {
|
||||
// Might not have identifiers in older versions
|
||||
itemMappings = loadBiMappings(data, "items");
|
||||
blockMappings = loadBiMappings(data, "blocks");
|
||||
soundMappings = loadMappings(data, "sounds");
|
||||
}
|
||||
|
||||
final CompoundTag tagsTag = data.getCompoundTag("tags");
|
||||
@@ -109,6 +118,11 @@ public class MappingDataBase implements MappingData {
|
||||
loadTags(RegistryType.ENTITY, tagsTag);
|
||||
}
|
||||
|
||||
final IntArrayTag changedBlocks = data.getIntArrayTag("changed_blocks");
|
||||
if (changedBlocks != null) {
|
||||
this.changedBlocks = new IntOpenHashSet(changedBlocks.getValue());
|
||||
}
|
||||
|
||||
loadExtras(data);
|
||||
}
|
||||
|
||||
@@ -132,6 +146,11 @@ public class MappingDataBase implements MappingData {
|
||||
return MappingDataLoader.INSTANCE.loadMappings(data, key);
|
||||
}
|
||||
|
||||
protected @Nullable BiMappings loadFullOrBiMappings(final CompoundTag data, final CompoundTag unmappedIdentifiersTag, final CompoundTag mappedIdentifiersTag, final String key) {
|
||||
final FullMappings mappings = loadFullMappings(data, unmappedIdentifiersTag, mappedIdentifiersTag, key);
|
||||
return mappings != null ? mappings : loadBiMappings(data, key);
|
||||
}
|
||||
|
||||
protected @Nullable FullMappings loadFullMappings(final CompoundTag data, final CompoundTag unmappedIdentifiersTag, final CompoundTag mappedIdentifiersTag, final String key) {
|
||||
if (!unmappedIdentifiersTag.contains(key) || !mappedIdentifiersTag.contains(key)) {
|
||||
return null;
|
||||
@@ -153,7 +172,7 @@ public class MappingDataBase implements MappingData {
|
||||
}
|
||||
|
||||
private void loadTags(final RegistryType type, final CompoundTag data) {
|
||||
final CompoundTag tag = data.getCompoundTag(type.resourceLocation());
|
||||
final CompoundTag tag = data.getCompoundTag(type.identifier());
|
||||
if (tag == null) {
|
||||
return;
|
||||
}
|
||||
@@ -208,8 +227,8 @@ public class MappingDataBase implements MappingData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOldSoundId(final int i) {
|
||||
return soundMappings.getNewIdOrDefault(i, 0);
|
||||
public int getOldSoundId(final int id) {
|
||||
return soundMappings.inverse().getNewIdOrDefault(id, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -224,8 +243,8 @@ public class MappingDataBase implements MappingData {
|
||||
|
||||
@Override
|
||||
public @Nullable FullMappings getFullItemMappings() {
|
||||
if (itemMappings instanceof FullMappings) {
|
||||
return (FullMappings) itemMappings;
|
||||
if (itemMappings instanceof FullMappings fullItemMappings) {
|
||||
return fullItemMappings;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -241,7 +260,15 @@ public class MappingDataBase implements MappingData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Mappings getBlockEntityMappings() {
|
||||
public @Nullable FullMappings getFullBlockMappings() {
|
||||
if (blockMappings instanceof FullMappings fullBlockMappings) {
|
||||
return fullBlockMappings;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable FullMappings getBlockEntityMappings() {
|
||||
return blockEntityMappings;
|
||||
}
|
||||
|
||||
@@ -255,6 +282,14 @@ public class MappingDataBase implements MappingData {
|
||||
return soundMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable FullMappings getFullSoundMappings() {
|
||||
if (soundMappings instanceof FullMappings fullSoundMappings) {
|
||||
return fullSoundMappings;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Mappings getStatisticsMappings() {
|
||||
return statisticsMappings;
|
||||
@@ -300,6 +335,11 @@ public class MappingDataBase implements MappingData {
|
||||
return recipeSerializerMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable IntSet changedBlocks() {
|
||||
return changedBlocks;
|
||||
}
|
||||
|
||||
protected Logger getLogger() {
|
||||
return Via.getPlatform().getLogger();
|
||||
}
|
||||
@@ -314,7 +354,7 @@ public class MappingDataBase implements MappingData {
|
||||
*/
|
||||
protected int checkValidity(final int id, final int mappedId, final String type) {
|
||||
if (mappedId == -1) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings()) {
|
||||
if (Via.getConfig().logOtherConversionWarnings()) {
|
||||
getLogger().warning(String.format("Missing %s %s for %s %s %d", mappedVersion, type, unmappedVersion, type, id));
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -210,7 +210,7 @@ public class MappingDataLoader {
|
||||
return null;
|
||||
}
|
||||
|
||||
final int mappedSize = tag.getIntTag("mappedSize").asInt();
|
||||
final int mappedSize = tag.getInt("mappedSize", -1);
|
||||
final byte strategy = tag.getByteTag("id").asByte();
|
||||
final V mappings;
|
||||
if (strategy == DIRECT_ID) {
|
||||
|
||||
@@ -82,6 +82,11 @@ public interface EntityTracker {
|
||||
*/
|
||||
void clearEntities();
|
||||
|
||||
/**
|
||||
* Clears all stored data, including entity types, entity data and client entity id.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Returns the stored entity data if an entity with the id is tracked, else null.
|
||||
* If no data has been initialized yet, it will be done and returned by this method.
|
||||
@@ -180,6 +185,20 @@ public interface EntityTracker {
|
||||
*/
|
||||
void setCurrentWorld(String currentWorld);
|
||||
|
||||
/**
|
||||
* Returns the id of the current dimension, or -1 if unset (i.e. before 1.20.5).
|
||||
*
|
||||
* @return id of the current dimension, or -1 if unset
|
||||
*/
|
||||
int currentDimensionId();
|
||||
|
||||
/**
|
||||
* Sets the id of the current dimension.
|
||||
*
|
||||
* @param currentDimensionId id of the current dimension
|
||||
*/
|
||||
void setCurrentDimensionId(int currentDimensionId);
|
||||
|
||||
int biomesSent();
|
||||
|
||||
void setBiomesSent(int biomesSent);
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data.item;
|
||||
|
||||
/**
|
||||
* Used for converting items to hashed items and caching them for later use during serverbound packets.
|
||||
* <p>
|
||||
* Most of this stays in the internal module given non-permanent, imperfect caching as well as missing converters.
|
||||
*/
|
||||
public interface ItemHasher {
|
||||
|
||||
/**
|
||||
* Returns whether this connection is currently processing a clientbound player inventory packet.
|
||||
* <p>
|
||||
* Used for checking when it is necessary to track/process item data hashes.
|
||||
*
|
||||
* @return true if processing a clientbound inventory packet, false otherwise
|
||||
*/
|
||||
boolean isProcessingClientboundInventoryPacket();
|
||||
|
||||
void setProcessingClientboundInventoryPacket(boolean processingClientboundInventoryPacket);
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public interface DebugHandler {
|
||||
void addPacketTypeNameToLog(String packetTypeName);
|
||||
|
||||
/**
|
||||
* Adds a packet id to the list of packet types to log.
|
||||
* Adds a packet type to the list of packet types to log.
|
||||
* Packets will be checked on each protocol transformer, so this is best used on single protocol pipes.
|
||||
*
|
||||
* @param packetType packet type
|
||||
@@ -66,6 +66,13 @@ public interface DebugHandler {
|
||||
*/
|
||||
boolean removePacketTypeNameToLog(String packetTypeName);
|
||||
|
||||
/**
|
||||
* Removes a packet type from the list of packet types to log.
|
||||
*
|
||||
* @param packetType Packet type to remove
|
||||
*/
|
||||
boolean removePacketTypeToLog(PacketType packetType);
|
||||
|
||||
/**
|
||||
* Resets packet type filters.
|
||||
*/
|
||||
@@ -121,7 +128,12 @@ public interface DebugHandler {
|
||||
*/
|
||||
boolean shouldLog(PacketWrapper wrapper, Direction direction);
|
||||
|
||||
default void enableAndLogIds(final PacketType... packetTypes) {
|
||||
/**
|
||||
* Enables debug mode and adds the given packet types to the log list.
|
||||
*
|
||||
* @param packetTypes packet types to log
|
||||
*/
|
||||
default void enableAndLogTypes(final PacketType... packetTypes) {
|
||||
setEnabled(true);
|
||||
for (final PacketType packetType : packetTypes) {
|
||||
addPacketTypeToLog(packetType);
|
||||
@@ -135,7 +147,7 @@ public interface DebugHandler {
|
||||
* @param t thrown exception
|
||||
*/
|
||||
default void error(final String error, final Throwable t) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || enabled()) {
|
||||
if (Via.getConfig().logOtherConversionWarnings() || enabled()) {
|
||||
Via.getPlatform().getLogger().log(Level.SEVERE, error, t);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ public class BlockChangeRecord1_16_2 implements BlockChangeRecord {
|
||||
|
||||
@Override
|
||||
public short getY(int chunkSectionY) {
|
||||
Preconditions.checkArgument(chunkSectionY >= 0, "Invalid chunkSectionY: " + chunkSectionY);
|
||||
Preconditions.checkArgument(chunkSectionY >= 0, "Invalid chunkSectionY: %s", chunkSectionY);
|
||||
return (short) ((chunkSectionY << 4) + sectionY);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ public enum BlockFace {
|
||||
TOP((byte) 0, (byte) 1, (byte) 0, EnumAxis.Y),
|
||||
BOTTOM((byte) 0, (byte) -1, (byte) 0, EnumAxis.Y);
|
||||
|
||||
public static final BlockFace[] HORIZONTAL = {NORTH, SOUTH, EAST, WEST};
|
||||
private static final Map<BlockFace, BlockFace> opposites = new EnumMap<>(BlockFace.class);
|
||||
|
||||
static {
|
||||
|
||||
@@ -22,11 +22,35 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public record GameProfile(@Nullable String name, @Nullable UUID id, Property[] properties) {
|
||||
public record GameProfile(@Nullable String name, @Nullable UUID id, Property[] properties, boolean dynamic) {
|
||||
|
||||
public GameProfile(@Nullable final String name, @Nullable final UUID id, final Property[] properties) {
|
||||
this(name, id, properties, true);
|
||||
}
|
||||
|
||||
public GameProfile(@Nullable final String name, @Nullable final UUID id) {
|
||||
this(name, id, new Property[0]);
|
||||
}
|
||||
|
||||
public Map<String, List<Property>> propertiesMap() {
|
||||
final Map<String, List<Property>> map = new HashMap<>();
|
||||
for (Property property : properties) {
|
||||
map.computeIfAbsent(property.name(), k -> new ArrayList<>()).add(property);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public record Property(String name, String value, @Nullable String signature) {
|
||||
|
||||
public Property(final String name, final String value) {
|
||||
this(name, value, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,8 @@
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public interface Holder<T> {
|
||||
|
||||
@@ -88,5 +90,24 @@ public interface Holder<T> {
|
||||
* @param rewriteFunction the function to rewrite the id
|
||||
* @return a new holder with the id rewritten, or self
|
||||
*/
|
||||
Holder<T> updateId(final Int2IntFunction rewriteFunction);
|
||||
default Holder<T> updateId(final Int2IntFunction rewriteFunction) {
|
||||
return this.updateId(rewriteFunction, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new holder with the id rewritten using the given function, or self if this is a direct holder or the id did not change.
|
||||
*
|
||||
* @param rewriteFunction the function to rewrite the id
|
||||
* @param ifMissing a supplier that provides a new holder if the id is missing (i.e. -1)
|
||||
* @return a new holder with the id rewritten, or self
|
||||
*/
|
||||
Holder<T> updateId(Int2IntFunction rewriteFunction, Supplier<Holder<T>> ifMissing);
|
||||
|
||||
/**
|
||||
* Returns a new holder with the value rewritten using the given function, or self if this is an id holder or the value did not change.
|
||||
*
|
||||
* @param rewriteFunction the function to rewrite the value
|
||||
* @return a new holder with the value rewritten, or self
|
||||
*/
|
||||
Holder<T> updateValue(final Function<T, T> rewriteFunction);
|
||||
}
|
||||
@@ -22,7 +22,11 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.viaversion.nbt.tag.ListTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Set of ids that either holds a string tag key or an array of ids.
|
||||
@@ -32,7 +36,7 @@ public interface HolderSet {
|
||||
/**
|
||||
* Creates a new holder set for the given tag.
|
||||
*
|
||||
* @param tagKey the tag key
|
||||
* @param tagKey the tag key, not including '#'
|
||||
* @return a new holder set
|
||||
*/
|
||||
static HolderSet of(final String tagKey) {
|
||||
@@ -49,10 +53,29 @@ public interface HolderSet {
|
||||
return new HolderSetImpl.Ids(ids);
|
||||
}
|
||||
|
||||
static HolderSet fromTag(final Tag tag, final Function<String, Integer> mappingFunction) {
|
||||
if (tag instanceof StringTag stringTag) {
|
||||
if (stringTag.getValue().startsWith("#")) {
|
||||
return HolderSet.of(stringTag.getValue().substring(1));
|
||||
}
|
||||
|
||||
final int id = mappingFunction.apply(stringTag.getValue());
|
||||
return HolderSet.of(new int[]{id});
|
||||
} else if (tag instanceof ListTag<?> listTag) {
|
||||
final int[] ids = new int[listTag.size()];
|
||||
for (int i = 0; i < listTag.size(); i++) {
|
||||
final String value = ((StringTag) listTag.get(i)).getValue();
|
||||
ids[i] = mappingFunction.apply(value);
|
||||
}
|
||||
return HolderSet.of(ids);
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tag key.
|
||||
* Gets the tag key, not including '#'.
|
||||
*
|
||||
* @return the tag key
|
||||
* @return the tag key without a '#'
|
||||
* @see #hasTagKey()
|
||||
*/
|
||||
String tagKey();
|
||||
|
||||
@@ -67,11 +67,17 @@ final class HolderSetImpl {
|
||||
|
||||
@Override
|
||||
public HolderSet rewrite(final Int2IntFunction idRewriter) {
|
||||
// Filter out negative ids as they would come from missing VB mapping data. This happens especially
|
||||
// with block ids which are not mapped and thus written as -1 so VV rewriters can cancel them nicely.
|
||||
final int[] mappedIds = new int[ids.length];
|
||||
for (int i = 0; i < mappedIds.length; i++) {
|
||||
mappedIds[i] = idRewriter.applyAsInt(ids[i]);
|
||||
int validCount = 0;
|
||||
for (final int id : ids) {
|
||||
final int mappedId = idRewriter.applyAsInt(id);
|
||||
if (mappedId != -1) {
|
||||
mappedIds[validCount++] = mappedId;
|
||||
}
|
||||
}
|
||||
return new Ids(mappedIds);
|
||||
return new Ids(validCount == ids.length ? mappedIds : Arrays.copyOf(mappedIds, validCount));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,6 +24,8 @@ package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
record IdHolder<T>(int id) implements Holder<T> {
|
||||
|
||||
@@ -47,14 +49,22 @@ record IdHolder<T>(int id) implements Holder<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Holder<T> updateId(final Int2IntFunction rewriteFunction) {
|
||||
public Holder<T> updateId(final Int2IntFunction rewriteFunction, final Supplier<Holder<T>> ifMissing) {
|
||||
final int rewrittenId = rewriteFunction.applyAsInt(id);
|
||||
if (rewrittenId == id) {
|
||||
return this;
|
||||
}
|
||||
if (rewrittenId == -1) {
|
||||
if (ifMissing != null) {
|
||||
return ifMissing.get();
|
||||
}
|
||||
throw new IllegalArgumentException("Received invalid id in updateId");
|
||||
}
|
||||
return Holder.of(rewrittenId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Holder<T> updateValue(final Function<T, T> rewriteFunction) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,10 @@
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viaversion.api.minecraft.codec.Ops;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.misc.HolderType;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
@@ -69,5 +71,21 @@ public record PaintingVariant(int width, int height, String assetId, @Nullable T
|
||||
Types.OPTIONAL_TAG.write(buffer, variant.title());
|
||||
Types.OPTIONAL_TAG.write(buffer, variant.author());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDirect(final Ops ops, final PaintingVariant value) {
|
||||
// Unused, cannot be direct despite having a direct network codec
|
||||
ops.writeMap(map -> map
|
||||
.write("width", Types.INT, value.width())
|
||||
.write("height", Types.INT, value.height())
|
||||
.write("asset_id", Types.IDENTIFIER, Key.of(value.assetId()))
|
||||
.writeOptional("title", Types.TAG, value.title())
|
||||
.writeOptional("author", Types.TAG, value.author()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Key identifier(final Ops ops, final int id) {
|
||||
return ops.context().registryAccess().registryKey("painting_variant", id);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public final class Particle implements IdHolder, Copyable {
|
||||
|
||||
@Override
|
||||
public ParticleData<T> copy() {
|
||||
return new ParticleData<>(type, copy(value));
|
||||
return new ParticleData<>(type, Copyable.copy(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.data.MappingData.MappingType;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
|
||||
/**
|
||||
* Holds a key for a registry.
|
||||
* Depending on the context, the key may be used to get registry entries from either synchronized or hardcoded registries.
|
||||
*
|
||||
* @see MappingType
|
||||
* @see #of(String)
|
||||
*/
|
||||
public interface RegistryKey {
|
||||
|
||||
Key key();
|
||||
|
||||
static RegistryKey of(final String key) {
|
||||
return new SimpleRegistryKey(Key.of(key));
|
||||
}
|
||||
}
|
||||
@@ -22,11 +22,12 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public enum RegistryType {
|
||||
public enum RegistryType implements RegistryKey {
|
||||
|
||||
BLOCK("block"),
|
||||
ITEM("item"),
|
||||
@@ -40,7 +41,7 @@ public enum RegistryType {
|
||||
|
||||
static {
|
||||
for (RegistryType type : getValues()) {
|
||||
MAP.put(type.resourceLocation, type);
|
||||
MAP.put(type.identifier, type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,17 +49,22 @@ public enum RegistryType {
|
||||
return VALUES;
|
||||
}
|
||||
|
||||
public static @Nullable RegistryType getByKey(String resourceKey) {
|
||||
return MAP.get(resourceKey);
|
||||
public static @Nullable RegistryType getByKey(String identifier) {
|
||||
return MAP.get(identifier);
|
||||
}
|
||||
|
||||
private final String resourceLocation;
|
||||
private final String identifier;
|
||||
|
||||
RegistryType(final String resourceLocation) {
|
||||
this.resourceLocation = resourceLocation;
|
||||
RegistryType(final String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public String resourceLocation() {
|
||||
return resourceLocation;
|
||||
public String identifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key key() {
|
||||
return Key.of(identifier);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Profile that can be either dynamically filled by the client or is already static.
|
||||
* The additional fields are optional overrides.
|
||||
*/
|
||||
public record ResolvableProfile(GameProfile profile, @Nullable String bodyTexture, @Nullable String capeTexture,
|
||||
@Nullable String elytraTexture, @Nullable Integer modelType) {
|
||||
|
||||
public ResolvableProfile(final GameProfile profile) {
|
||||
this(profile, null, null, null, null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
|
||||
record SimpleRegistryKey(Key key) implements RegistryKey {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return key.toString();
|
||||
}
|
||||
}
|
||||
@@ -22,11 +22,21 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public record SoundEvent(String identifier, @Nullable Float fixedRange) {
|
||||
|
||||
private static final Holder<SoundEvent> UNKNOWN = Holder.of(new SoundEvent("viaversion:unknown", 0F));
|
||||
|
||||
public SoundEvent withIdentifier(final String identifier) {
|
||||
return new SoundEvent(identifier, this.fixedRange);
|
||||
}
|
||||
|
||||
public static @Nullable Holder<SoundEvent> rewriteHolder(@Nullable final Holder<SoundEvent> holder, final Int2IntFunction soundRewriteFunction) {
|
||||
if (holder == null) {
|
||||
return null;
|
||||
}
|
||||
return holder.updateId(soundRewriteFunction, () -> UNKNOWN);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,8 @@
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
record ValueHolder<T>(T value) implements Holder<T> {
|
||||
|
||||
@@ -42,7 +44,13 @@ record ValueHolder<T>(T value) implements Holder<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Holder<T> updateId(final Int2IntFunction rewriteFunction) {
|
||||
public Holder<T> updateId(final Int2IntFunction rewriteFunction, final Supplier<Holder<T>> ifMissing) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Holder<T> updateValue(final Function<T, T> rewriteFunction) {
|
||||
final T rewrittenValue = rewriteFunction.apply(value);
|
||||
return rewrittenValue != value ? Holder.of(rewrittenValue) : this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public record Vector3d(double x, double y, double z) {
|
||||
|
||||
public static final Vector3d ZERO = new Vector3d(0, 0, 0);
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.codec;
|
||||
|
||||
import com.viaversion.viaversion.api.data.MappingData;
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
|
||||
public interface CodecContext {
|
||||
|
||||
RegistryAccess registryAccess();
|
||||
|
||||
boolean mapped();
|
||||
|
||||
boolean isSupported(StructuredDataKey<?> key);
|
||||
|
||||
interface RegistryAccess {
|
||||
|
||||
Key item(int id);
|
||||
|
||||
Key attributeModifier(int id);
|
||||
|
||||
Key dataComponentType(int id);
|
||||
|
||||
Key entity(int id);
|
||||
|
||||
Key blockEntity(int id);
|
||||
|
||||
Key sound(int id);
|
||||
|
||||
/**
|
||||
* Returns the key for a stored mapping type and its numeric id.
|
||||
*
|
||||
* @param mappingType mapping type
|
||||
* @param id numeric id
|
||||
* @return the key
|
||||
*/
|
||||
Key key(MappingData.MappingType mappingType, int id);
|
||||
|
||||
/**
|
||||
* Returns the numeric id for a stored mapping type and its identifier.
|
||||
*
|
||||
* @param mappingType mapping type
|
||||
* @param identifier identifier
|
||||
* @return the numeric id, or -1 if not found
|
||||
*/
|
||||
int id(MappingData.MappingType mappingType, String identifier);
|
||||
|
||||
static RegistryAccess of(final Protocol<?, ?, ?, ?> protocol) {
|
||||
return new RegistryAccessImpl(protocol);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for a client-synchronized registry element.
|
||||
*
|
||||
* @param registry registry key
|
||||
* @param id numeric id
|
||||
* @return the key
|
||||
*/
|
||||
Key registryKey(String registry, int id);
|
||||
|
||||
RegistryAccess withMapped(boolean mapped);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.codec;
|
||||
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class DelegatingOps implements Ops {
|
||||
|
||||
private final Ops delegate;
|
||||
|
||||
public DelegatingOps(final Ops delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodecContext context() {
|
||||
return delegate.context();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeByte(final byte b) {
|
||||
delegate.writeByte(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBytes(final byte[] array) {
|
||||
delegate.writeBytes(array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBoolean(final boolean b) {
|
||||
delegate.writeBoolean(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeShort(final short s) {
|
||||
delegate.writeShort(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeString(final CharSequence sequence) {
|
||||
delegate.writeString(sequence);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeInt(final int i) {
|
||||
delegate.writeInt(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeLong(final long l) {
|
||||
delegate.writeLong(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeFloat(final float f) {
|
||||
delegate.writeFloat(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDouble(final double d) {
|
||||
delegate.writeDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeInts(final int[] array) {
|
||||
delegate.writeInts(array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeLongs(final long[] array) {
|
||||
delegate.writeLongs(array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeList(final Consumer<ListSerializer> consumer) {
|
||||
delegate.writeList(consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeMap(final Consumer<MapSerializer> consumer) {
|
||||
delegate.writeMap(consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> void write(final Type<V> type, final V value) {
|
||||
delegate.write(type, value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.codec;
|
||||
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface Ops {
|
||||
|
||||
CodecContext context();
|
||||
|
||||
void writeByte(byte b);
|
||||
|
||||
void writeBytes(byte[] array);
|
||||
|
||||
void writeBoolean(boolean b);
|
||||
|
||||
void writeShort(short s);
|
||||
|
||||
void writeString(CharSequence sequence);
|
||||
|
||||
void writeInt(int i);
|
||||
|
||||
void writeLong(long l);
|
||||
|
||||
void writeFloat(float f);
|
||||
|
||||
void writeDouble(double d);
|
||||
|
||||
void writeInts(int[] array);
|
||||
|
||||
void writeLongs(long[] array);
|
||||
|
||||
void writeList(Consumer<ListSerializer> consumer);
|
||||
|
||||
void writeMap(Consumer<MapSerializer> consumer);
|
||||
|
||||
<V> void write(final Type<V> type, final V value);
|
||||
|
||||
interface ListSerializer {
|
||||
|
||||
<V> ListSerializer write(Type<V> valueType, V value);
|
||||
|
||||
ListSerializer writeList(Consumer<ListSerializer> consumer);
|
||||
|
||||
ListSerializer writeMap(Consumer<MapSerializer> consumer);
|
||||
}
|
||||
|
||||
interface MapSerializer {
|
||||
|
||||
<K, V> MapSerializer write(Type<K> keyType, K key, Type<V> valueType, V value);
|
||||
|
||||
default <V> MapSerializer write(final String key, final Type<V> type, final V value) {
|
||||
write(Types.STRING, key, type, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the given value or default value if the value is null.
|
||||
*
|
||||
* @param key map key
|
||||
* @param type type of the value
|
||||
* @param value the value to write, or null
|
||||
* @param def default value to write if the value is null
|
||||
* @return self
|
||||
* @param <V> value type
|
||||
*/
|
||||
default <V> MapSerializer write(final String key, final Type<V> type, @Nullable final V value, final V def) {
|
||||
write(Types.STRING, key, type, value != null ? value : def);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the given value if it is not null.
|
||||
*
|
||||
* @param key map key
|
||||
* @param type type of the value
|
||||
* @param value the value to write, or null
|
||||
* @return self
|
||||
* @param <V> value type
|
||||
*/
|
||||
default <V> MapSerializer writeOptional(final String key, final Type<V> type, @Nullable final V value) {
|
||||
if (value != null) {
|
||||
write(Types.STRING, key, type, value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the given value if it is not null and not equal to the default value.
|
||||
*
|
||||
* @param key map key
|
||||
* @param type type of the value
|
||||
* @param value the value to write, or null
|
||||
* @param def default value to compare against
|
||||
* @return self
|
||||
* @param <V> value type
|
||||
*/
|
||||
default <V> MapSerializer writeOptional(final String key, final Type<V> type, @Nullable final V value, final V def) {
|
||||
if (value != null && !Objects.deepEquals(value, def)) {
|
||||
write(Types.STRING, key, type, value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
MapSerializer writeList(String key, Consumer<ListSerializer> consumer);
|
||||
|
||||
MapSerializer writeMap(String key, Consumer<MapSerializer> consumer);
|
||||
|
||||
<T> MapSerializer writeInlinedMap(Type<T> valueType, T value);
|
||||
}
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.codec;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.api.data.FullMappings;
|
||||
import com.viaversion.viaversion.api.data.MappingData;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.rewriter.RegistryDataRewriter;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import com.viaversion.viaversion.util.KeyMappings;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
final class RegistryAccessImpl implements CodecContext.RegistryAccess {
|
||||
private final RegistryDataRewriter registryDataRewriter;
|
||||
private final MappingData mappingData;
|
||||
private final boolean mapped;
|
||||
|
||||
RegistryAccessImpl(final Protocol<?, ?, ?, ?> protocol) {
|
||||
this.mappingData = protocol.getMappingData();
|
||||
this.registryDataRewriter = protocol.getRegistryDataRewriter();
|
||||
this.mapped = false;
|
||||
}
|
||||
|
||||
private RegistryAccessImpl(final MappingData mappingData, final RegistryDataRewriter registryDataRewriter, final boolean mapped) {
|
||||
this.mappingData = mappingData;
|
||||
this.registryDataRewriter = registryDataRewriter;
|
||||
this.mapped = mapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key item(final int id) {
|
||||
return key(mappingData.getFullItemMappings(), id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key attributeModifier(final int id) {
|
||||
return key(mappingData.getAttributeMappings(), id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key dataComponentType(final int id) {
|
||||
return key(mappingData.getDataComponentSerializerMappings(), id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key entity(final int id) {
|
||||
return key(mappingData.getEntityMappings(), id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key blockEntity(final int id) {
|
||||
return key(mappingData.getBlockEntityMappings(), id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key sound(final int id) {
|
||||
return key(mappingData.getFullSoundMappings(), id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key key(final MappingData.MappingType mappingType, final int id) {
|
||||
return key(mappingData.getFullMappings(mappingType), id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id(final MappingData.MappingType mappingType, final String identifier) {
|
||||
final FullMappings mappings = mappingData.getFullMappings(mappingType);
|
||||
return mapped ? mappings.mappedId(identifier) : mappings.id(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key registryKey(final String registry, final int id) {
|
||||
final KeyMappings mappings = registryDataRewriter.getMappings(registry);
|
||||
Preconditions.checkNotNull(mappings, "No registry mappings for registry: " + registry);
|
||||
final String identifier = id >= 0 && id < mappings.size() ? mappings.idToKey(id) : null;
|
||||
return key(identifier, id);
|
||||
}
|
||||
|
||||
private Key key(final FullMappings mappings, final int id) {
|
||||
final String identifier = mapped ? mappings.mappedIdentifier(id) : mappings.identifier(id);
|
||||
return key(identifier, id);
|
||||
}
|
||||
|
||||
private Key key(@Nullable final String identifier, final int id) {
|
||||
return identifier != null ? Key.of(identifier) : Key.of("viaversion", "unknown/" + id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodecContext.RegistryAccess withMapped(final boolean mapped) {
|
||||
return this.mapped == mapped ? this : new RegistryAccessImpl(this.mappingData, this.registryDataRewriter, mapped);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.codec;
|
||||
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ThrowingOps implements Ops {
|
||||
|
||||
@Override
|
||||
public CodecContext context() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeByte(final byte b) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBytes(final byte[] array) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBoolean(final boolean b) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeShort(final short s) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeString(final CharSequence sequence) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeInt(final int i) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeLong(final long l) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeFloat(final float f) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDouble(final double d) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeInts(final int[] array) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeLongs(final long[] array) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeList(final Consumer<ListSerializer> consumer) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeMap(final Consumer<MapSerializer> consumer) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> void write(final Type<V> type, final V value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.codec.hash;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.codec.Ops;
|
||||
|
||||
/**
|
||||
* Hash operations. Note that this is different from Vanilla codecs, where this
|
||||
* instead acts as a (re-usable) hasher directly rather than each method having
|
||||
* self-contained return values.
|
||||
*/
|
||||
public interface Hasher extends Ops {
|
||||
|
||||
/**
|
||||
* Returns the current hash value.
|
||||
*
|
||||
* @return the current hash value
|
||||
*/
|
||||
int hash();
|
||||
|
||||
/**
|
||||
* Resets the hasher to its initial state.
|
||||
*/
|
||||
void reset();
|
||||
}
|
||||
+4
-2
@@ -23,6 +23,8 @@
|
||||
package com.viaversion.viaversion.api.minecraft.data;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.util.ArrayUtil;
|
||||
import com.viaversion.viaversion.util.Copyable;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -61,7 +63,7 @@ final class FilledStructuredData<T> implements StructuredData<T> {
|
||||
|
||||
@Override
|
||||
public StructuredData<T> copy() {
|
||||
return new FilledStructuredData<>(this.key, this.copy(this.value), this.id);
|
||||
return new FilledStructuredData<>(this.key, Copyable.copy(this.value), this.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,7 +103,7 @@ final class FilledStructuredData<T> implements StructuredData<T> {
|
||||
public String toString() {
|
||||
return "FilledStructuredData{" +
|
||||
"key=" + key +
|
||||
", value=" + value +
|
||||
", value=" + ArrayUtil.toString(value) +
|
||||
", id=" + id +
|
||||
'}';
|
||||
}
|
||||
|
||||
+5
-1
@@ -241,7 +241,7 @@ public final class StructuredDataContainer implements Copyable {
|
||||
/**
|
||||
* Sets the lookup for serializer ids. Required to call most of the other methods.
|
||||
*
|
||||
* @param protocol protocol to retreive the id of the serializer from
|
||||
* @param protocol protocol to retrieve the id of the serializer from
|
||||
* @param mappedNames if the names are mapped (true if structures from the mapped version are added, false for the unmapped version)
|
||||
*/
|
||||
public void setIdLookup(final Protocol<?, ?, ?, ?> protocol, final boolean mappedNames) {
|
||||
@@ -284,6 +284,10 @@ public final class StructuredDataContainer implements Copyable {
|
||||
return data;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return data.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StructuredDataContainer{" +
|
||||
|
||||
+101
-71
@@ -27,57 +27,81 @@ import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viaversion.api.minecraft.EitherHolder;
|
||||
import com.viaversion.viaversion.api.minecraft.GameProfile;
|
||||
import com.viaversion.viaversion.api.minecraft.Holder;
|
||||
import com.viaversion.viaversion.api.minecraft.HolderSet;
|
||||
import com.viaversion.viaversion.api.minecraft.PaintingVariant;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryKey;
|
||||
import com.viaversion.viaversion.api.minecraft.ResolvableProfile;
|
||||
import com.viaversion.viaversion.api.minecraft.SoundEvent;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.data.version.StructuredDataKeys1_20_5;
|
||||
import com.viaversion.viaversion.api.minecraft.data.version.StructuredDataKeys1_21_11;
|
||||
import com.viaversion.viaversion.api.minecraft.data.version.StructuredDataKeys1_21_2;
|
||||
import com.viaversion.viaversion.api.minecraft.data.version.StructuredDataKeys1_21_5;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.AdventureModePredicate;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.AdventureModePredicate.AdventureModePredicateType1_21_5;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.ArmorTrim;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.AttackRange;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers1_20_5;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers1_21;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.BannerPatternLayer;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.Bee;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.BlockEntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.BlockStateProperties;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.BlocksAttacks;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.Consumable1_21_2;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.CustomModelData1_21_4;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.DamageResistant;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.DamageType;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.DeathProtection;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.DebugStickState;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.DyedColor;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.Enchantable;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.Enchantments;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.EntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.EnumTypes;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.Equippable;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.FilterableString;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.FireworkExplosion;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.Fireworks;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.FoodProperties1_20_5;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.FoodProperties1_21_2;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.Instrument1_20_5;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.Instrument1_21_2;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.ItemModel;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.JukeboxPlayable;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.KineticWeapon;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.LockCode;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.LodestoneTracker;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.PiercingWeapon;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.PotDecorations;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.PotionContents;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.ProvidesTrimMaterial;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.Repairable;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.SuspiciousStewEffect;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.SwingAnimation;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.ToolProperties;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.TooltipDisplay;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.TropicalFishPattern;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.Unbreakable;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.UseCooldown;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.UseEffects;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.Weapon;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.WritableBook;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.WrittenBook;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.ArrayType;
|
||||
import com.viaversion.viaversion.api.type.types.EitherType;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_21;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_21_2;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_21_4;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_21_5;
|
||||
import com.viaversion.viaversion.api.type.types.misc.SynchronizedRegistryEitherType;
|
||||
import com.viaversion.viaversion.api.type.types.misc.SynchronizedRegistryValueType;
|
||||
import com.viaversion.viaversion.api.type.types.version.VersionedTypes;
|
||||
import com.viaversion.viaversion.util.Either;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import com.viaversion.viaversion.util.Unit;
|
||||
|
||||
/**
|
||||
* Holds data component keys.
|
||||
*
|
||||
* @param identifier string identifier
|
||||
* @param type data type
|
||||
* @param <T> data type
|
||||
* @see VersionedTypes
|
||||
*/
|
||||
public record StructuredDataKey<T>(String identifier, Type<T> type) {
|
||||
|
||||
public static final StructuredDataKey<CompoundTag> CUSTOM_DATA = new StructuredDataKey<>("custom_data", Types.COMPOUND_TAG);
|
||||
@@ -85,21 +109,24 @@ public record StructuredDataKey<T>(String identifier, Type<T> type) {
|
||||
public static final StructuredDataKey<Integer> MAX_DAMAGE = new StructuredDataKey<>("max_damage", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> DAMAGE = new StructuredDataKey<>("damage", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Unbreakable> UNBREAKABLE1_20_5 = new StructuredDataKey<>("unbreakable", Unbreakable.TYPE);
|
||||
public static final StructuredDataKey<UseEffects> USE_EFFECTS = new StructuredDataKey<>("use_effects", UseEffects.TYPE);
|
||||
public static final StructuredDataKey<Unit> UNBREAKABLE1_21_5 = new StructuredDataKey<>("unbreakable", Types.EMPTY);
|
||||
public static final StructuredDataKey<Tag> CUSTOM_NAME = new StructuredDataKey<>("custom_name", Types.TAG);
|
||||
public static final StructuredDataKey<Tag> ITEM_NAME = new StructuredDataKey<>("item_name", Types.TAG);
|
||||
public static final StructuredDataKey<String> ITEM_MODEL = new StructuredDataKey<>("item_model", Types.STRING);
|
||||
public static final StructuredDataKey<Tag[]> LORE = new StructuredDataKey<>("lore", new ArrayType<>(Types.TAG, 256));
|
||||
public static final StructuredDataKey<Integer> RARITY = new StructuredDataKey<>("rarity", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Tag> CUSTOM_NAME = new StructuredDataKey<>("custom_name", Types.TEXT_COMPONENT_TAG);
|
||||
public static final StructuredDataKey<Float> MINIMUM_ATTACK_CHARGE = new StructuredDataKey<>("minimum_attack_charge", Types.FLOAT);
|
||||
public static final StructuredDataKey<DamageType> DAMAGE_TYPE = new StructuredDataKey<>("damage_type", DamageType.TYPE);
|
||||
public static final StructuredDataKey<Tag> ITEM_NAME = new StructuredDataKey<>("item_name", Types.TEXT_COMPONENT_TAG);
|
||||
public static final StructuredDataKey<ItemModel> ITEM_MODEL = new StructuredDataKey<>("item_model", ItemModel.TYPE);
|
||||
public static final StructuredDataKey<Tag[]> LORE = new StructuredDataKey<>("lore", new ArrayType<>(Types.TEXT_COMPONENT_TAG, 256));
|
||||
public static final StructuredDataKey<Integer> RARITY = new StructuredDataKey<>("rarity", EnumTypes.RARITY);
|
||||
public static final StructuredDataKey<Enchantments> ENCHANTMENTS1_20_5 = new StructuredDataKey<>("enchantments", Enchantments.TYPE1_20_5);
|
||||
public static final StructuredDataKey<Enchantments> ENCHANTMENTS1_21_5 = new StructuredDataKey<>("enchantments", Enchantments.TYPE1_21_5);
|
||||
// 1.21.5+ predicates are in their own key classes
|
||||
public static final StructuredDataKey<AdventureModePredicate> CAN_PLACE_ON1_20_5 = new StructuredDataKey<>("can_place_on", AdventureModePredicate.TYPE1_20_5);
|
||||
public static final StructuredDataKey<AdventureModePredicate> CAN_PLACE_ON1_21_5 = new StructuredDataKey<>("can_place_on", new AdventureModePredicateType1_21_5(Types1_21_5.STRUCTURED_DATA_ARRAY));
|
||||
public static final StructuredDataKey<AdventureModePredicate> CAN_BREAK1_20_5 = new StructuredDataKey<>("can_break", AdventureModePredicate.TYPE1_20_5);
|
||||
public static final StructuredDataKey<AdventureModePredicate> CAN_BREAK1_21_5 = new StructuredDataKey<>("can_break", new AdventureModePredicateType1_21_5(Types1_21_5.STRUCTURED_DATA_ARRAY));
|
||||
public static final StructuredDataKey<AttributeModifiers1_20_5> ATTRIBUTE_MODIFIERS1_20_5 = new StructuredDataKey<>("attribute_modifiers", AttributeModifiers1_20_5.TYPE);
|
||||
public static final StructuredDataKey<AttributeModifiers1_21> ATTRIBUTE_MODIFIERS1_21 = new StructuredDataKey<>("attribute_modifiers", AttributeModifiers1_21.TYPE1_21);
|
||||
public static final StructuredDataKey<AttributeModifiers1_21> ATTRIBUTE_MODIFIERS1_21_5 = new StructuredDataKey<>("attribute_modifiers", AttributeModifiers1_21.TYPE1_21_5);
|
||||
public static final StructuredDataKey<AttributeModifiers1_21> ATTRIBUTE_MODIFIERS1_21_6 = new StructuredDataKey<>("attribute_modifiers", AttributeModifiers1_21.TYPE1_21_6);
|
||||
public static final StructuredDataKey<Integer> CUSTOM_MODEL_DATA1_20_5 = new StructuredDataKey<>("custom_model_data", Types.VAR_INT);
|
||||
public static final StructuredDataKey<CustomModelData1_21_4> CUSTOM_MODEL_DATA1_21_4 = new StructuredDataKey<>("custom_model_data", CustomModelData1_21_4.TYPE);
|
||||
public static final StructuredDataKey<Unit> HIDE_ADDITIONAL_TOOLTIP = new StructuredDataKey<>("hide_additional_tooltip", Types.EMPTY);
|
||||
@@ -113,23 +140,25 @@ public record StructuredDataKey<T>(String identifier, Type<T> type) {
|
||||
public static final StructuredDataKey<FoodProperties1_20_5> FOOD1_21 = new StructuredDataKey<>("food", FoodProperties1_20_5.TYPE1_21);
|
||||
public static final StructuredDataKey<FoodProperties1_21_2> FOOD1_21_2 = new StructuredDataKey<>("food", FoodProperties1_21_2.TYPE);
|
||||
public static final StructuredDataKey<Consumable1_21_2> CONSUMABLE1_21_2 = new StructuredDataKey<>("consumable", Consumable1_21_2.TYPE);
|
||||
public static final StructuredDataKey<Item> USE_REMAINDER1_21_2 = new StructuredDataKey<>("use_remainder", Types1_21_2.ITEM);
|
||||
public static final StructuredDataKey<Item> USE_REMAINDER1_21_4 = new StructuredDataKey<>("use_remainder", Types1_21_4.ITEM);
|
||||
public static final StructuredDataKey<Item> USE_REMAINDER1_21_5 = new StructuredDataKey<>("use_remainder", Types1_21_5.ITEM);
|
||||
public static final StructuredDataKey<UseCooldown> USE_COOLDOWN = new StructuredDataKey<>("use_cooldown", UseCooldown.TYPE);
|
||||
public static final StructuredDataKey<Unit> FIRE_RESISTANT = new StructuredDataKey<>("fire_resistant", Types.EMPTY);
|
||||
public static final StructuredDataKey<DamageResistant> DAMAGE_RESISTANT = new StructuredDataKey<>("damage_resistant", DamageResistant.TYPE);
|
||||
public static final StructuredDataKey<ToolProperties> TOOL1_20_5 = new StructuredDataKey<>("tool", ToolProperties.TYPE1_20_5);
|
||||
public static final StructuredDataKey<ToolProperties> TOOL1_21_5 = new StructuredDataKey<>("tool", ToolProperties.TYPE1_21_5);
|
||||
public static final StructuredDataKey<Weapon> WEAPON = new StructuredDataKey<>("weapon", Weapon.TYPE);
|
||||
public static final StructuredDataKey<Integer> ENCHANTABLE = new StructuredDataKey<>("enchantable", Types.VAR_INT);
|
||||
public static final StructuredDataKey<AttackRange> ATTACK_RANGE = new StructuredDataKey<>("attack_range", AttackRange.TYPE);
|
||||
public static final StructuredDataKey<Enchantable> ENCHANTABLE = new StructuredDataKey<>("enchantable", Enchantable.TYPE);
|
||||
public static final StructuredDataKey<Equippable> EQUIPPABLE1_21_2 = new StructuredDataKey<>("equippable", Equippable.TYPE1_21_2);
|
||||
public static final StructuredDataKey<Equippable> EQUIPPABLE1_21_5 = new StructuredDataKey<>("equippable", Equippable.TYPE1_21_5);
|
||||
public static final StructuredDataKey<HolderSet> REPAIRABLE = new StructuredDataKey<>("repairable", Types.HOLDER_SET);
|
||||
public static final StructuredDataKey<Equippable> EQUIPPABLE1_21_6 = new StructuredDataKey<>("equippable", Equippable.TYPE1_21_6);
|
||||
public static final StructuredDataKey<Repairable> REPAIRABLE = new StructuredDataKey<>("repairable", Repairable.TYPE);
|
||||
public static final StructuredDataKey<Unit> GLIDER = new StructuredDataKey<>("glider", Types.EMPTY);
|
||||
public static final StructuredDataKey<String> TOOLTIP_STYLE = new StructuredDataKey<>("tooltip_style", Types.STRING);
|
||||
public static final StructuredDataKey<Key> TOOLTIP_STYLE = new StructuredDataKey<>("tooltip_style", Types.IDENTIFIER);
|
||||
public static final StructuredDataKey<DeathProtection> DEATH_PROTECTION = new StructuredDataKey<>("death_protection", DeathProtection.TYPE);
|
||||
public static final StructuredDataKey<BlocksAttacks> BLOCKS_ATTACKS = new StructuredDataKey<>("blocks_attacks", BlocksAttacks.TYPE);
|
||||
public static final StructuredDataKey<PiercingWeapon> PIERCING_WEAPON = new StructuredDataKey<>("piercing_weapon", PiercingWeapon.TYPE);
|
||||
public static final StructuredDataKey<KineticWeapon> KINETIC_WEAPON = new StructuredDataKey<>("kinetic_weapon", KineticWeapon.TYPE);
|
||||
public static final StructuredDataKey<SwingAnimation> SWING_ANIMATION = new StructuredDataKey<>("swing_animation", SwingAnimation.TYPE);
|
||||
public static final StructuredDataKey<Enchantments> STORED_ENCHANTMENTS1_20_5 = new StructuredDataKey<>("stored_enchantments", Enchantments.TYPE1_20_5);
|
||||
public static final StructuredDataKey<Enchantments> STORED_ENCHANTMENTS1_21_5 = new StructuredDataKey<>("stored_enchantments", Enchantments.TYPE1_21_5);
|
||||
public static final StructuredDataKey<DyedColor> DYED_COLOR1_20_5 = new StructuredDataKey<>("dyed_color", DyedColor.TYPE1_20_5);
|
||||
@@ -138,30 +167,22 @@ public record StructuredDataKey<T>(String identifier, Type<T> type) {
|
||||
public static final StructuredDataKey<Integer> MAP_ID = new StructuredDataKey<>("map_id", Types.VAR_INT);
|
||||
public static final StructuredDataKey<CompoundTag> MAP_DECORATIONS = new StructuredDataKey<>("map_decorations", Types.COMPOUND_TAG);
|
||||
public static final StructuredDataKey<Integer> MAP_POST_PROCESSING = new StructuredDataKey<>("map_post_processing", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Item[]> CHARGED_PROJECTILES1_20_5 = new StructuredDataKey<>("charged_projectiles", Types1_20_5.ITEM_ARRAY);
|
||||
public static final StructuredDataKey<Item[]> CHARGED_PROJECTILES1_21 = new StructuredDataKey<>("charged_projectiles", Types1_21.ITEM_ARRAY);
|
||||
public static final StructuredDataKey<Item[]> CHARGED_PROJECTILES1_21_2 = new StructuredDataKey<>("charged_projectiles", Types1_21_2.ITEM_ARRAY);
|
||||
public static final StructuredDataKey<Item[]> CHARGED_PROJECTILES1_21_4 = new StructuredDataKey<>("charged_projectiles", Types1_21_4.ITEM_ARRAY);
|
||||
public static final StructuredDataKey<Item[]> CHARGED_PROJECTILES1_21_5 = new StructuredDataKey<>("charged_projectiles", Types1_21_5.ITEM_ARRAY);
|
||||
public static final StructuredDataKey<Item[]> BUNDLE_CONTENTS1_20_5 = new StructuredDataKey<>("bundle_contents", Types1_20_5.ITEM_ARRAY);
|
||||
public static final StructuredDataKey<Item[]> BUNDLE_CONTENTS1_21 = new StructuredDataKey<>("bundle_contents", Types1_21.ITEM_ARRAY);
|
||||
public static final StructuredDataKey<Item[]> BUNDLE_CONTENTS1_21_2 = new StructuredDataKey<>("bundle_contents", Types1_21_2.ITEM_ARRAY);
|
||||
public static final StructuredDataKey<Item[]> BUNDLE_CONTENTS1_21_4 = new StructuredDataKey<>("bundle_contents", Types1_21_4.ITEM_ARRAY);
|
||||
public static final StructuredDataKey<Item[]> BUNDLE_CONTENTS1_21_5 = new StructuredDataKey<>("bundle_contents", Types1_21_5.ITEM_ARRAY);
|
||||
public static final StructuredDataKey<PotionContents> POTION_CONTENTS1_20_5 = new StructuredDataKey<>("potion_contents", PotionContents.TYPE1_20_5);
|
||||
public static final StructuredDataKey<PotionContents> POTION_CONTENTS1_21_2 = new StructuredDataKey<>("potion_contents", PotionContents.TYPE1_21_2);
|
||||
public static final StructuredDataKey<Float> POTION_DURATION_SCALE = new StructuredDataKey<>("potion_duration_scale", Types.FLOAT);
|
||||
public static final StructuredDataKey<SuspiciousStewEffect[]> SUSPICIOUS_STEW_EFFECTS = new StructuredDataKey<>("suspicious_stew_effects", SuspiciousStewEffect.ARRAY_TYPE);
|
||||
public static final StructuredDataKey<FilterableString[]> WRITABLE_BOOK_CONTENT = new StructuredDataKey<>("writable_book_content", FilterableString.ARRAY_TYPE);
|
||||
public static final StructuredDataKey<WritableBook> WRITABLE_BOOK_CONTENT = new StructuredDataKey<>("writable_book_content", WritableBook.TYPE);
|
||||
public static final StructuredDataKey<WrittenBook> WRITTEN_BOOK_CONTENT = new StructuredDataKey<>("written_book_content", WrittenBook.TYPE);
|
||||
public static final StructuredDataKey<ArmorTrim> TRIM1_20_5 = new StructuredDataKey<>("trim", ArmorTrim.TYPE1_20_5);
|
||||
public static final StructuredDataKey<ArmorTrim> TRIM1_21_2 = new StructuredDataKey<>("trim", ArmorTrim.TYPE1_21_2);
|
||||
public static final StructuredDataKey<ArmorTrim> TRIM1_21_4 = new StructuredDataKey<>("trim", ArmorTrim.TYPE1_21_4);
|
||||
public static final StructuredDataKey<ArmorTrim> TRIM1_21_5 = new StructuredDataKey<>("trim", ArmorTrim.TYPE1_21_5);
|
||||
public static final StructuredDataKey<CompoundTag> DEBUG_STICK_STATE = new StructuredDataKey<>("debug_stick_state", Types.COMPOUND_TAG);
|
||||
public static final StructuredDataKey<CompoundTag> ENTITY_DATA = new StructuredDataKey<>("entity_data", Types.COMPOUND_TAG);
|
||||
public static final StructuredDataKey<DebugStickState> DEBUG_STICK_STATE = new StructuredDataKey<>("debug_stick_state", DebugStickState.TYPE);
|
||||
public static final StructuredDataKey<CompoundTag> ENTITY_DATA1_20_5 = new StructuredDataKey<>("entity_data", Types.COMPOUND_TAG);
|
||||
public static final StructuredDataKey<EntityData> ENTITY_DATA1_21_9 = new StructuredDataKey<>("entity_data", EntityData.TYPE);
|
||||
public static final StructuredDataKey<CompoundTag> BUCKET_ENTITY_DATA = new StructuredDataKey<>("bucket_entity_data", Types.COMPOUND_TAG);
|
||||
public static final StructuredDataKey<CompoundTag> BLOCK_ENTITY_DATA = new StructuredDataKey<>("block_entity_data", Types.COMPOUND_TAG);
|
||||
public static final StructuredDataKey<CompoundTag> BLOCK_ENTITY_DATA1_20_5 = new StructuredDataKey<>("block_entity_data", Types.COMPOUND_TAG);
|
||||
public static final StructuredDataKey<BlockEntityData> BLOCK_ENTITY_DATA1_21_9 = new StructuredDataKey<>("block_entity_data", BlockEntityData.TYPE);
|
||||
public static final StructuredDataKey<Holder<Instrument1_20_5>> INSTRUMENT1_20_5 = new StructuredDataKey<>("instrument", Instrument1_20_5.TYPE);
|
||||
public static final StructuredDataKey<Holder<Instrument1_21_2>> INSTRUMENT1_21_2 = new StructuredDataKey<>("instrument", Instrument1_21_2.TYPE);
|
||||
public static final StructuredDataKey<EitherHolder<Instrument1_21_2>> INSTRUMENT1_21_5 = new StructuredDataKey<>("instrument", Instrument1_21_2.EITHER_HOLDER_TYPE);
|
||||
@@ -169,51 +190,60 @@ public record StructuredDataKey<T>(String identifier, Type<T> type) {
|
||||
public static final StructuredDataKey<Integer> OMINOUS_BOTTLE_AMPLIFIER = new StructuredDataKey<>("ominous_bottle_amplifier", Types.VAR_INT);
|
||||
public static final StructuredDataKey<JukeboxPlayable> JUKEBOX_PLAYABLE1_21 = new StructuredDataKey<>("jukebox_playable", JukeboxPlayable.TYPE1_21);
|
||||
public static final StructuredDataKey<JukeboxPlayable> JUKEBOX_PLAYABLE1_21_5 = new StructuredDataKey<>("jukebox_playable", JukeboxPlayable.TYPE1_21_5);
|
||||
public static final StructuredDataKey<String> PROVIDES_BANNER_PATTERNS = new StructuredDataKey<>("provides_banner_patterns", Types.STRING);
|
||||
public static final StructuredDataKey<Key> PROVIDES_BANNER_PATTERNS = new StructuredDataKey<>("provides_banner_patterns", Types.TAG_KEY);
|
||||
public static final StructuredDataKey<Tag> RECIPES = new StructuredDataKey<>("recipes", Types.TAG);
|
||||
public static final StructuredDataKey<LodestoneTracker> LODESTONE_TRACKER = new StructuredDataKey<>("lodestone_tracker", LodestoneTracker.TYPE);
|
||||
public static final StructuredDataKey<FireworkExplosion> FIREWORK_EXPLOSION = new StructuredDataKey<>("firework_explosion", FireworkExplosion.TYPE);
|
||||
public static final StructuredDataKey<Fireworks> FIREWORKS = new StructuredDataKey<>("fireworks", Fireworks.TYPE);
|
||||
public static final StructuredDataKey<GameProfile> PROFILE = new StructuredDataKey<>("profile", Types.GAME_PROFILE);
|
||||
public static final StructuredDataKey<String> NOTE_BLOCK_SOUND = new StructuredDataKey<>("note_block_sound", Types.STRING);
|
||||
public static final StructuredDataKey<GameProfile> PROFILE1_20_5 = new StructuredDataKey<>("profile", Types.GAME_PROFILE);
|
||||
public static final StructuredDataKey<ResolvableProfile> PROFILE1_21_9 = new StructuredDataKey<>("profile", Types.RESOLVABLE_PROFILE);
|
||||
public static final StructuredDataKey<Key> NOTE_BLOCK_SOUND = new StructuredDataKey<>("note_block_sound", Types.IDENTIFIER);
|
||||
public static final StructuredDataKey<BannerPatternLayer[]> BANNER_PATTERNS = new StructuredDataKey<>("banner_patterns", BannerPatternLayer.ARRAY_TYPE);
|
||||
public static final StructuredDataKey<Integer> BASE_COLOR = new StructuredDataKey<>("base_color", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> BASE_COLOR = new StructuredDataKey<>("base_color", EnumTypes.DYE_COLOR);
|
||||
public static final StructuredDataKey<PotDecorations> POT_DECORATIONS = new StructuredDataKey<>("pot_decorations", PotDecorations.TYPE);
|
||||
public static final StructuredDataKey<Item[]> CONTAINER1_20_5 = new StructuredDataKey<>("container", Types1_20_5.ITEM_ARRAY);
|
||||
public static final StructuredDataKey<Item[]> CONTAINER1_21 = new StructuredDataKey<>("container", Types1_21.ITEM_ARRAY);
|
||||
public static final StructuredDataKey<Item[]> CONTAINER1_21_2 = new StructuredDataKey<>("container", new ArrayType<>(Types1_21_2.ITEM, 256));
|
||||
public static final StructuredDataKey<Item[]> CONTAINER1_21_4 = new StructuredDataKey<>("container", Types1_21_4.ITEM_ARRAY);
|
||||
public static final StructuredDataKey<Item[]> CONTAINER1_21_5 = new StructuredDataKey<>("container", Types1_21_5.ITEM_ARRAY);
|
||||
public static final StructuredDataKey<BlockStateProperties> BLOCK_STATE = new StructuredDataKey<>("block_state", BlockStateProperties.TYPE);
|
||||
public static final StructuredDataKey<Bee[]> BEES = new StructuredDataKey<>("bees", Bee.ARRAY_TYPE);
|
||||
public static final StructuredDataKey<Tag> LOCK = new StructuredDataKey<>("lock", Types.TAG);
|
||||
public static final StructuredDataKey<Bee[]> BEES1_20_5 = new StructuredDataKey<>("bees", Bee.ARRAY_TYPE1_20_5);
|
||||
public static final StructuredDataKey<Bee[]> BEES1_21_9 = new StructuredDataKey<>("bees", Bee.ARRAY_TYPE1_21_9);
|
||||
public static final StructuredDataKey<Tag> LOCK1_20_5 = new StructuredDataKey<>("lock", Types.TAG);
|
||||
public static final StructuredDataKey<LockCode> LOCK1_21_2 = new StructuredDataKey<>("lock", LockCode.TYPE);
|
||||
public static final StructuredDataKey<CompoundTag> CONTAINER_LOOT = new StructuredDataKey<>("container_loot", Types.COMPOUND_TAG);
|
||||
public static final StructuredDataKey<Holder<SoundEvent>> BREAK_SOUND = new StructuredDataKey<>("break_sound", Types.SOUND_EVENT);
|
||||
|
||||
public static final StructuredDataKey<Integer> VILLAGER_VARIANT = new StructuredDataKey<>("villager/variant", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> WOLF_VARIANT = new StructuredDataKey<>("wolf/variant", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> WOLF_SOUND_VARIANT = new StructuredDataKey<>("wolf/sound_variant", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> WOLF_COLLAR = new StructuredDataKey<>("wolf/collar", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> FOX_VARIANT = new StructuredDataKey<>("fox/variant", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> SALMON_SIZE = new StructuredDataKey<>("salmon/size", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> PARROT_VARIANT = new StructuredDataKey<>("parrot/variant", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> TROPICAL_FISH_PATTERN = new StructuredDataKey<>("tropical_fish/pattern", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> TROPICAL_FISH_BASE_COLOR = new StructuredDataKey<>("tropical_fish/base_color", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> TROPICAL_FISH_PATTERN_COLOR = new StructuredDataKey<>("tropical_fish/pattern_color", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> MOOSHROOM_VARIANT = new StructuredDataKey<>("mooshroom/variant", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> RABBIT_VARIANT = new StructuredDataKey<>("rabbit/variant", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> PIG_VARIANT = new StructuredDataKey<>("pig/variant", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> COW_VARIANT = new StructuredDataKey<>("cow/variant", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Either<Integer, String>> CHICKEN_VARIANT = new StructuredDataKey<>("chicken/variant", new EitherType<>(Types.VAR_INT, Types.STRING)); // ???
|
||||
public static final StructuredDataKey<Integer> FROG_VARIANT = new StructuredDataKey<>("frog/variant", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> HORSE_VARIANT = new StructuredDataKey<>("horse/variant", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> VILLAGER_VARIANT = new StructuredDataKey<>("villager/variant", EnumTypes.VILLAGER_TYPE);
|
||||
public static final StructuredDataKey<Integer> WOLF_VARIANT = new StructuredDataKey<>("wolf/variant", new SynchronizedRegistryValueType(RegistryKey.of("wolf_variant")));
|
||||
public static final StructuredDataKey<Integer> WOLF_SOUND_VARIANT = new StructuredDataKey<>("wolf/sound_variant", new SynchronizedRegistryValueType(RegistryKey.of("wolf_sound_variant")));
|
||||
public static final StructuredDataKey<Integer> WOLF_COLLAR = new StructuredDataKey<>("wolf/collar", EnumTypes.DYE_COLOR);
|
||||
public static final StructuredDataKey<Integer> FOX_VARIANT = new StructuredDataKey<>("fox/variant", EnumTypes.FOX_VARIANT);
|
||||
public static final StructuredDataKey<Integer> SALMON_SIZE = new StructuredDataKey<>("salmon/size", EnumTypes.SALMON_VARIANT);
|
||||
public static final StructuredDataKey<Integer> PARROT_VARIANT = new StructuredDataKey<>("parrot/variant", EnumTypes.PARROT_VARIANT);
|
||||
public static final StructuredDataKey<TropicalFishPattern> TROPICAL_FISH_PATTERN = new StructuredDataKey<>("tropical_fish/pattern", TropicalFishPattern.TYPE);
|
||||
public static final StructuredDataKey<Integer> TROPICAL_FISH_BASE_COLOR = new StructuredDataKey<>("tropical_fish/base_color", EnumTypes.DYE_COLOR);
|
||||
public static final StructuredDataKey<Integer> TROPICAL_FISH_PATTERN_COLOR = new StructuredDataKey<>("tropical_fish/pattern_color", EnumTypes.DYE_COLOR);
|
||||
public static final StructuredDataKey<Integer> MOOSHROOM_VARIANT = new StructuredDataKey<>("mooshroom/variant", EnumTypes.MUSHROOM_COW_VARIANT);
|
||||
public static final StructuredDataKey<Integer> RABBIT_VARIANT = new StructuredDataKey<>("rabbit/variant", EnumTypes.RABBIT_VARIANT);
|
||||
public static final StructuredDataKey<Integer> PIG_VARIANT = new StructuredDataKey<>("pig/variant", new SynchronizedRegistryValueType(RegistryKey.of("pig_variant")));
|
||||
public static final StructuredDataKey<Integer> COW_VARIANT = new StructuredDataKey<>("cow/variant", new SynchronizedRegistryValueType(RegistryKey.of("cow_variant")));
|
||||
public static final StructuredDataKey<Either<Integer, String>> CHICKEN_VARIANT = new StructuredDataKey<>("chicken/variant", new SynchronizedRegistryEitherType(RegistryKey.of("chicken_variant")));
|
||||
public static final StructuredDataKey<Either<Integer, String>> ZOMBIE_NAUTILUS_VARIANT = new StructuredDataKey<>("zombie_nautilus/variant", new SynchronizedRegistryEitherType(RegistryKey.of("zombie_nautilus_variant"))); // ???
|
||||
public static final StructuredDataKey<Integer> FROG_VARIANT = new StructuredDataKey<>("frog/variant", new SynchronizedRegistryValueType(RegistryKey.of("frog_variant")));
|
||||
public static final StructuredDataKey<Integer> HORSE_VARIANT = new StructuredDataKey<>("horse/variant", EnumTypes.HORSE_VARIANT);
|
||||
public static final StructuredDataKey<Holder<PaintingVariant>> PAINTING_VARIANT = new StructuredDataKey<>("painting/variant", PaintingVariant.TYPE1_21_2);
|
||||
public static final StructuredDataKey<Integer> LLAMA_VARIANT = new StructuredDataKey<>("llama/variant", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> AXOLOTL_VARIANT = new StructuredDataKey<>("axolotl/variant", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> CAT_VARIANT = new StructuredDataKey<>("cat/variant", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> CAT_COLLAR = new StructuredDataKey<>("cat/collar", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> SHEEP_COLOR = new StructuredDataKey<>("sheep/color", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> SHULKER_COLOR = new StructuredDataKey<>("shulker/color", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> LLAMA_VARIANT = new StructuredDataKey<>("llama/variant", EnumTypes.LLAMA_VARIANT);
|
||||
public static final StructuredDataKey<Integer> AXOLOTL_VARIANT = new StructuredDataKey<>("axolotl/variant", EnumTypes.AXOLOTL_VARIANT);
|
||||
public static final StructuredDataKey<Integer> CAT_VARIANT = new StructuredDataKey<>("cat/variant", new SynchronizedRegistryValueType(RegistryKey.of("cat_variant")));
|
||||
public static final StructuredDataKey<Integer> CAT_COLLAR = new StructuredDataKey<>("cat/collar", EnumTypes.DYE_COLOR);
|
||||
public static final StructuredDataKey<Integer> SHEEP_COLOR = new StructuredDataKey<>("sheep/color", EnumTypes.DYE_COLOR);
|
||||
public static final StructuredDataKey<Integer> SHULKER_COLOR = new StructuredDataKey<>("shulker/color", EnumTypes.DYE_COLOR);
|
||||
|
||||
// These are only safe to use after protocol loading
|
||||
public static final StructuredDataKeys1_20_5 V1_20_5 = VersionedTypes.V1_20_5.structuredDataKeys();
|
||||
public static final StructuredDataKeys1_20_5 V1_21 = VersionedTypes.V1_21.structuredDataKeys();
|
||||
public static final StructuredDataKeys1_21_2 V1_21_2 = VersionedTypes.V1_21_2.structuredDataKeys();
|
||||
public static final StructuredDataKeys1_21_2 V1_21_4 = VersionedTypes.V1_21_4.structuredDataKeys();
|
||||
public static final StructuredDataKeys1_21_5 V1_21_5 = VersionedTypes.V1_21_5.structuredDataKeys();
|
||||
public static final StructuredDataKeys1_21_5 V1_21_6 = VersionedTypes.V1_21_6.structuredDataKeys();
|
||||
public static final StructuredDataKeys1_21_5 V1_21_9 = VersionedTypes.V1_21_9.structuredDataKeys();
|
||||
public static final StructuredDataKeys1_21_11 V1_21_11 = VersionedTypes.V1_21_11.structuredDataKeys();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
+5
-3
@@ -30,23 +30,25 @@ public record DataComponentMatchers(StructuredData<?>[] exactPredicates, DataCom
|
||||
|
||||
public static final class DataComponentMatchersType extends Type<DataComponentMatchers> {
|
||||
private final Type<StructuredData<?>[]> dataArrayType;
|
||||
private final Type<DataComponentPredicate[]> predicateArrayType;
|
||||
|
||||
public DataComponentMatchersType(final Type<StructuredData<?>[]> dataArrayType) {
|
||||
public DataComponentMatchersType(final Type<StructuredData<?>[]> dataArrayType, final Type<DataComponentPredicate[]> predicateArrayType) {
|
||||
super(DataComponentMatchers.class);
|
||||
this.dataArrayType = dataArrayType;
|
||||
this.predicateArrayType = predicateArrayType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataComponentMatchers read(final ByteBuf buffer) {
|
||||
final StructuredData<?>[] exactPredicates = dataArrayType.read(buffer);
|
||||
final DataComponentPredicate[] partialPredicates = DataComponentPredicate.ARRAY_TYPE.read(buffer);
|
||||
final DataComponentPredicate[] partialPredicates = predicateArrayType.read(buffer);
|
||||
return new DataComponentMatchers(exactPredicates, partialPredicates);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final ByteBuf buffer, final DataComponentMatchers value) {
|
||||
dataArrayType.write(buffer, value.exactPredicates());
|
||||
DataComponentPredicate.ARRAY_TYPE.write(buffer, value.predicates());
|
||||
predicateArrayType.write(buffer, value.predicates());
|
||||
}
|
||||
}
|
||||
}
|
||||
+37
-4
@@ -28,9 +28,13 @@ import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.ArrayType;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public record DataComponentPredicate(int id, Tag predicate) {
|
||||
public record DataComponentPredicate(PredicateType type, Tag predicate) {
|
||||
|
||||
public static final Type<DataComponentPredicate> TYPE = new Type<>(DataComponentPredicate.class) {
|
||||
public DataComponentPredicate(final int predicateType, final Tag predicate) {
|
||||
this(PredicateType.ofPredicateType(predicateType), predicate);
|
||||
}
|
||||
|
||||
public static final Type<DataComponentPredicate> TYPE1_21_5 = new Type<>(DataComponentPredicate.class) {
|
||||
@Override
|
||||
public DataComponentPredicate read(final ByteBuf buffer) {
|
||||
final int id = Types.VAR_INT.readPrimitive(buffer);
|
||||
@@ -40,9 +44,38 @@ public record DataComponentPredicate(int id, Tag predicate) {
|
||||
|
||||
@Override
|
||||
public void write(final ByteBuf buffer, final DataComponentPredicate value) {
|
||||
Types.VAR_INT.writePrimitive(buffer, value.id());
|
||||
Types.VAR_INT.writePrimitive(buffer, value.type().id());
|
||||
Types.TAG.write(buffer, value.predicate());
|
||||
}
|
||||
};
|
||||
public static final Type<DataComponentPredicate[]> ARRAY_TYPE = new ArrayType<>(TYPE, 64);
|
||||
public static final Type<DataComponentPredicate[]> ARRAY_TYPE1_21_5 = new ArrayType<>(TYPE1_21_5, 64);
|
||||
|
||||
public static final Type<DataComponentPredicate> TYPE1_21_11 = new Type<>(DataComponentPredicate.class) {
|
||||
@Override
|
||||
public DataComponentPredicate read(final ByteBuf buffer) {
|
||||
final boolean isPredicateType = Types.BOOLEAN.read(buffer);
|
||||
final PredicateType type = new PredicateType(Types.VAR_INT.readPrimitive(buffer), isPredicateType);
|
||||
final Tag predicate = Types.TAG.read(buffer);
|
||||
return new DataComponentPredicate(type, predicate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final ByteBuf buffer, final DataComponentPredicate value) {
|
||||
Types.BOOLEAN.write(buffer, value.type().isPredicateType());
|
||||
Types.VAR_INT.writePrimitive(buffer, value.type().id());
|
||||
Types.TAG.write(buffer, value.predicate());
|
||||
}
|
||||
};
|
||||
public static final Type<DataComponentPredicate[]> ARRAY_TYPE1_21_11 = new ArrayType<>(TYPE1_21_11, 64);
|
||||
|
||||
public record PredicateType(int id, boolean isPredicateType) {
|
||||
|
||||
public static PredicateType ofPredicateType(final int id) {
|
||||
return new PredicateType(id, true);
|
||||
}
|
||||
|
||||
public static PredicateType ofDataComponentType(final int id) {
|
||||
return new PredicateType(id, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.data.version;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.type.types.version.VersionedTypesHolder;
|
||||
|
||||
public class StructuredDataKeys1_20_5 extends VersionedStructuredDataKeys {
|
||||
|
||||
public final StructuredDataKey<Item[]> container;
|
||||
public final StructuredDataKey<Item[]> chargedProjectiles;
|
||||
public final StructuredDataKey<Item[]> bundleContents;
|
||||
|
||||
public StructuredDataKeys1_20_5(final VersionedTypesHolder types) {
|
||||
this.container = add("container", types.itemArray());
|
||||
this.chargedProjectiles = add("charged_projectiles", types.itemArray());
|
||||
this.bundleContents = add("bundle_contents", types.itemArray());
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.data.version;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
|
||||
import com.viaversion.viaversion.api.minecraft.data.predicate.DataComponentPredicate;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.AdventureModePredicate;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.AdventureModePredicate.AdventureModePredicateType1_21_5;
|
||||
import com.viaversion.viaversion.api.type.types.version.VersionedTypesHolder;
|
||||
|
||||
public class StructuredDataKeys1_21_11 extends StructuredDataKeys1_21_2 {
|
||||
|
||||
public final StructuredDataKey<AdventureModePredicate> canPlaceOn;
|
||||
public final StructuredDataKey<AdventureModePredicate> canBreak;
|
||||
|
||||
public StructuredDataKeys1_21_11(final VersionedTypesHolder types) {
|
||||
super(types);
|
||||
final AdventureModePredicateType1_21_5 adventureModePredicateType = new AdventureModePredicateType1_21_5(types.structuredDataArray(), DataComponentPredicate.ARRAY_TYPE1_21_11);
|
||||
this.canPlaceOn = add("can_place_on", adventureModePredicateType);
|
||||
this.canBreak = add("can_break", adventureModePredicateType);
|
||||
this.unsupportedForOps.add(this.canPlaceOn);
|
||||
this.unsupportedForOps.add(this.canBreak);
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.data.version;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.ContainterContents.ContainerContentsType;
|
||||
import com.viaversion.viaversion.api.type.types.version.VersionedTypesHolder;
|
||||
|
||||
public class StructuredDataKeys1_21_2 extends VersionedStructuredDataKeys {
|
||||
|
||||
public final StructuredDataKey<Item[]> container;
|
||||
public final StructuredDataKey<Item[]> chargedProjectiles;
|
||||
public final StructuredDataKey<Item[]> bundleContents;
|
||||
public final StructuredDataKey<Item> useRemainder;
|
||||
|
||||
public StructuredDataKeys1_21_2(final VersionedTypesHolder types) {
|
||||
this.container = add("container", new ContainerContentsType(types.item()));
|
||||
this.chargedProjectiles = add("charged_projectiles", types.itemArray());
|
||||
this.bundleContents = add("bundle_contents", types.itemArray());
|
||||
this.useRemainder = add("use_remainder", types.item());
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.data.version;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
|
||||
import com.viaversion.viaversion.api.minecraft.data.predicate.DataComponentPredicate;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.AdventureModePredicate;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.AdventureModePredicate.AdventureModePredicateType1_21_5;
|
||||
import com.viaversion.viaversion.api.type.types.version.VersionedTypesHolder;
|
||||
|
||||
public class StructuredDataKeys1_21_5 extends StructuredDataKeys1_21_2 {
|
||||
|
||||
public final StructuredDataKey<AdventureModePredicate> canPlaceOn;
|
||||
public final StructuredDataKey<AdventureModePredicate> canBreak;
|
||||
|
||||
public StructuredDataKeys1_21_5(final VersionedTypesHolder types) {
|
||||
super(types);
|
||||
final AdventureModePredicateType1_21_5 adventureModePredicateType = new AdventureModePredicateType1_21_5(types.structuredDataArray(), DataComponentPredicate.ARRAY_TYPE1_21_5);
|
||||
this.canPlaceOn = add("can_place_on", adventureModePredicateType);
|
||||
this.canBreak = add("can_break", adventureModePredicateType);
|
||||
this.unsupportedForOps.add(this.canPlaceOn);
|
||||
this.unsupportedForOps.add(this.canBreak);
|
||||
}
|
||||
}
|
||||
+22
-16
@@ -20,25 +20,31 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.type.types.version;
|
||||
package com.viaversion.viaversion.api.minecraft.data.version;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkSectionType1_9;
|
||||
import com.viaversion.viaversion.api.type.types.entitydata.EntityDataListType;
|
||||
import com.viaversion.viaversion.api.type.types.entitydata.EntityDataType1_9;
|
||||
import it.unimi.dsi.fastutil.objects.ReferenceArraySet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public final class Types1_9 {
|
||||
/**
|
||||
* Entity data type for 1.9
|
||||
*/
|
||||
public static final Type<EntityData> ENTITY_DATA = new EntityDataType1_9();
|
||||
/**
|
||||
* Entity data list type for 1.9
|
||||
*/
|
||||
public static final Type<List<EntityData>> ENTITY_DATA_LIST = new EntityDataListType(ENTITY_DATA);
|
||||
public abstract class VersionedStructuredDataKeys {
|
||||
|
||||
public static final Type<ChunkSection> CHUNK_SECTION = new ChunkSectionType1_9();
|
||||
private final List<StructuredDataKey<?>> keys = new ArrayList<>();
|
||||
protected final Set<StructuredDataKey<?>> unsupportedForOps = new ReferenceArraySet<>();
|
||||
|
||||
protected <T> StructuredDataKey<T> add(final String identifier, final Type<T> type) {
|
||||
final StructuredDataKey<T> key = new StructuredDataKey<>(identifier, type);
|
||||
this.keys.add(key);
|
||||
return key;
|
||||
}
|
||||
|
||||
public List<StructuredDataKey<?>> keys() {
|
||||
return this.keys;
|
||||
}
|
||||
|
||||
public boolean supportsOps(final StructuredDataKey<?> key) {
|
||||
return !unsupportedForOps.contains(key);
|
||||
}
|
||||
}
|
||||
+9
-7
@@ -22,8 +22,8 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.entities;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public class EntityTypes1_10 {
|
||||
|
||||
@@ -143,7 +143,7 @@ public class EntityTypes1_10 {
|
||||
SPIDER(52, ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(59, SPIDER);
|
||||
|
||||
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||
private static final Int2ObjectMap<EntityType> TYPES;
|
||||
|
||||
private final int id;
|
||||
private final EntityType parent;
|
||||
@@ -184,7 +184,9 @@ public class EntityTypes1_10 {
|
||||
}
|
||||
|
||||
static {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
final EntityType[] values = EntityType.values();
|
||||
TYPES = new Int2ObjectOpenHashMap<>(values.length);
|
||||
for (EntityType type : values) {
|
||||
TYPES.put(type.id, type);
|
||||
}
|
||||
}
|
||||
@@ -230,7 +232,7 @@ public class EntityTypes1_10 {
|
||||
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
|
||||
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL);
|
||||
|
||||
private static final Map<Integer, Map<Integer, ObjectType>> TYPES = new HashMap<>();
|
||||
private static final Int2ObjectMap<Int2ObjectMap<ObjectType>> TYPES = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
private final int id;
|
||||
private final int data;
|
||||
@@ -238,7 +240,7 @@ public class EntityTypes1_10 {
|
||||
|
||||
static {
|
||||
for (ObjectType type : ObjectType.values()) {
|
||||
TYPES.computeIfAbsent(type.id, k -> new HashMap<>()).put(type.data, type);
|
||||
TYPES.computeIfAbsent(type.id, k -> new Int2ObjectOpenHashMap<>()).put(type.data, type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,7 +270,7 @@ public class EntityTypes1_10 {
|
||||
}
|
||||
|
||||
public static ObjectType findById(final int id, final int data) {
|
||||
final Map<Integer, ObjectType> types = TYPES.get(id);
|
||||
final Int2ObjectMap<ObjectType> types = TYPES.get(id);
|
||||
if (types == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+9
-7
@@ -22,8 +22,8 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.entities;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public class EntityTypes1_11 {
|
||||
|
||||
@@ -168,7 +168,7 @@ public class EntityTypes1_11 {
|
||||
EVOKER(34, ABSTRACT_MONSTER),
|
||||
VINDICATOR(36, ABSTRACT_MONSTER);
|
||||
|
||||
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||
private static final Int2ObjectMap<EntityType> TYPES;
|
||||
|
||||
private final int id;
|
||||
private final EntityType parent;
|
||||
@@ -209,7 +209,9 @@ public class EntityTypes1_11 {
|
||||
}
|
||||
|
||||
static {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
final EntityType[] values = EntityType.values();
|
||||
TYPES = new Int2ObjectOpenHashMap<>(values.length);
|
||||
for (EntityType type : values) {
|
||||
TYPES.put(type.id, type);
|
||||
}
|
||||
}
|
||||
@@ -257,7 +259,7 @@ public class EntityTypes1_11 {
|
||||
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
|
||||
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL);
|
||||
|
||||
private static final Map<Integer, Map<Integer, ObjectType>> TYPES = new HashMap<>();
|
||||
private static final Int2ObjectMap<Int2ObjectMap<ObjectType>> TYPES = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
private final int id;
|
||||
private final int data;
|
||||
@@ -265,7 +267,7 @@ public class EntityTypes1_11 {
|
||||
|
||||
static {
|
||||
for (ObjectType type : ObjectType.values()) {
|
||||
TYPES.computeIfAbsent(type.id, k -> new HashMap<>()).put(type.data, type);
|
||||
TYPES.computeIfAbsent(type.id, k -> new Int2ObjectOpenHashMap<>()).put(type.data, type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +297,7 @@ public class EntityTypes1_11 {
|
||||
}
|
||||
|
||||
public static ObjectType findById(final int id, final int data) {
|
||||
final Map<Integer, ObjectType> types = TYPES.get(id);
|
||||
final Int2ObjectMap<ObjectType> types = TYPES.get(id);
|
||||
if (types == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+9
-7
@@ -22,8 +22,8 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.entities;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public class EntityTypes1_12 {
|
||||
|
||||
@@ -174,7 +174,7 @@ public class EntityTypes1_12 {
|
||||
EVOKER(34, SPELLCASTER_ILLAGER),
|
||||
ILLUSIONER(37, SPELLCASTER_ILLAGER);
|
||||
|
||||
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||
private static final Int2ObjectMap<EntityType> TYPES;
|
||||
|
||||
private final int id;
|
||||
private final EntityType parent;
|
||||
@@ -215,7 +215,9 @@ public class EntityTypes1_12 {
|
||||
}
|
||||
|
||||
static {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
final EntityType[] values = EntityType.values();
|
||||
TYPES = new Int2ObjectOpenHashMap<>(values.length);
|
||||
for (EntityType type : values) {
|
||||
TYPES.put(type.id, type);
|
||||
}
|
||||
}
|
||||
@@ -263,7 +265,7 @@ public class EntityTypes1_12 {
|
||||
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
|
||||
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL);
|
||||
|
||||
private static final Map<Integer, Map<Integer, ObjectType>> TYPES = new HashMap<>();
|
||||
private static final Int2ObjectMap<Int2ObjectMap<ObjectType>> TYPES = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
private final int id;
|
||||
private final int data;
|
||||
@@ -271,7 +273,7 @@ public class EntityTypes1_12 {
|
||||
|
||||
static {
|
||||
for (ObjectType type : ObjectType.values()) {
|
||||
TYPES.computeIfAbsent(type.id, k -> new HashMap<>()).put(type.data, type);
|
||||
TYPES.computeIfAbsent(type.id, k -> new Int2ObjectOpenHashMap<>()).put(type.data, type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,7 +303,7 @@ public class EntityTypes1_12 {
|
||||
}
|
||||
|
||||
public static ObjectType findById(final int id, final int data) {
|
||||
final Map<Integer, ObjectType> types = TYPES.get(id);
|
||||
final Int2ObjectMap<ObjectType> types = TYPES.get(id);
|
||||
if (types == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+9
-7
@@ -22,8 +22,8 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.entities;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public class EntityTypes1_13 {
|
||||
|
||||
@@ -185,7 +185,7 @@ public class EntityTypes1_13 {
|
||||
EVOKER(21, SPELLCASTER_ILLAGER),
|
||||
ILLUSIONER(31, SPELLCASTER_ILLAGER);
|
||||
|
||||
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||
private static final Int2ObjectMap<EntityType> TYPES;
|
||||
|
||||
private final int id;
|
||||
private final EntityType parent;
|
||||
@@ -226,7 +226,9 @@ public class EntityTypes1_13 {
|
||||
}
|
||||
|
||||
static {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
final EntityType[] values = EntityType.values();
|
||||
TYPES = new Int2ObjectOpenHashMap<>(values.length);
|
||||
for (EntityType type : values) {
|
||||
TYPES.put(type.id, type);
|
||||
}
|
||||
}
|
||||
@@ -275,7 +277,7 @@ public class EntityTypes1_13 {
|
||||
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL),
|
||||
TRIDENT(94, EntityType.TRIDENT);
|
||||
|
||||
private static final Map<Integer, Map<Integer, ObjectType>> TYPES = new HashMap<>();
|
||||
private static final Int2ObjectMap<Int2ObjectMap<ObjectType>> TYPES = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
private final int id;
|
||||
private final int data;
|
||||
@@ -283,7 +285,7 @@ public class EntityTypes1_13 {
|
||||
|
||||
static {
|
||||
for (ObjectType type : ObjectType.values()) {
|
||||
TYPES.computeIfAbsent(type.id, k -> new HashMap<>()).put(type.data, type);
|
||||
TYPES.computeIfAbsent(type.id, k -> new Int2ObjectOpenHashMap<>()).put(type.data, type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +315,7 @@ public class EntityTypes1_13 {
|
||||
}
|
||||
|
||||
public static ObjectType findById(final int id, final int data) {
|
||||
final Map<Integer, ObjectType> types = TYPES.get(id);
|
||||
final Int2ObjectMap<ObjectType> types = TYPES.get(id);
|
||||
if (types == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+1
-1
@@ -213,7 +213,7 @@ public enum EntityTypes1_14 implements EntityType {
|
||||
|
||||
EntityTypes1_14(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_14(final EntityType parent, @Nullable final String identifier) {
|
||||
|
||||
+1
-1
@@ -214,7 +214,7 @@ public enum EntityTypes1_15 implements EntityType {
|
||||
|
||||
EntityTypes1_15(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_15(final EntityType parent, @Nullable final String identifier) {
|
||||
|
||||
+1
-1
@@ -218,7 +218,7 @@ public enum EntityTypes1_16 implements EntityType {
|
||||
|
||||
EntityTypes1_16(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_16(final EntityType parent, @Nullable final String identifier) {
|
||||
|
||||
+1
-1
@@ -221,7 +221,7 @@ public enum EntityTypes1_16_2 implements EntityType {
|
||||
|
||||
EntityTypes1_16_2(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_16_2(final EntityType parent, @Nullable final String identifier) {
|
||||
|
||||
+1
-1
@@ -227,7 +227,7 @@ public enum EntityTypes1_17 implements EntityType {
|
||||
|
||||
EntityTypes1_17(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_17(final EntityType parent, @Nullable final String identifier) {
|
||||
|
||||
+1
-1
@@ -232,7 +232,7 @@ public enum EntityTypes1_19 implements EntityType {
|
||||
|
||||
EntityTypes1_19(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_19(final EntityType parent, @Nullable final String identifier) {
|
||||
|
||||
+1
-1
@@ -233,7 +233,7 @@ public enum EntityTypes1_19_3 implements EntityType {
|
||||
|
||||
EntityTypes1_19_3(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_19_3(final EntityType parent, @Nullable final String identifier) {
|
||||
|
||||
+1
-1
@@ -240,7 +240,7 @@ public enum EntityTypes1_19_4 implements EntityType {
|
||||
|
||||
EntityTypes1_19_4(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_19_4(final EntityType parent, @Nullable final String identifier) {
|
||||
|
||||
+1
-1
@@ -242,7 +242,7 @@ public enum EntityTypes1_20_3 implements EntityType {
|
||||
|
||||
EntityTypes1_20_3(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_20_3(final EntityType parent, @Nullable final String identifier) {
|
||||
|
||||
+1
-1
@@ -248,7 +248,7 @@ public enum EntityTypes1_20_5 implements EntityType {
|
||||
|
||||
EntityTypes1_20_5(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_20_5(final EntityType parent, @Nullable final String identifier) {
|
||||
|
||||
+329
@@ -0,0 +1,329 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.entities;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.util.EntityTypeUtil;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import java.util.Locale;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public enum EntityTypes1_21_11 implements EntityType {
|
||||
|
||||
ENTITY(null, null),
|
||||
|
||||
AREA_EFFECT_CLOUD(ENTITY),
|
||||
END_CRYSTAL(ENTITY),
|
||||
EVOKER_FANGS(ENTITY),
|
||||
EXPERIENCE_ORB(ENTITY),
|
||||
EYE_OF_ENDER(ENTITY),
|
||||
FALLING_BLOCK(ENTITY),
|
||||
ITEM(ENTITY),
|
||||
TNT(ENTITY),
|
||||
OMINOUS_ITEM_SPAWNER(ENTITY),
|
||||
MARKER(ENTITY),
|
||||
LIGHTNING_BOLT(ENTITY),
|
||||
INTERACTION(ENTITY),
|
||||
|
||||
DISPLAY(ENTITY, null),
|
||||
BLOCK_DISPLAY(DISPLAY),
|
||||
ITEM_DISPLAY(DISPLAY),
|
||||
TEXT_DISPLAY(DISPLAY),
|
||||
|
||||
// Hanging entities
|
||||
HANGING_ENTITY(ENTITY, null),
|
||||
LEASH_KNOT(HANGING_ENTITY),
|
||||
PAINTING(HANGING_ENTITY),
|
||||
ITEM_FRAME(HANGING_ENTITY),
|
||||
GLOW_ITEM_FRAME(ITEM_FRAME),
|
||||
|
||||
// Projectiles
|
||||
PROJECTILE(ENTITY, null),
|
||||
ITEM_PROJECTILE(PROJECTILE, null),
|
||||
SNOWBALL(ITEM_PROJECTILE),
|
||||
ENDER_PEARL(ITEM_PROJECTILE),
|
||||
EGG(ITEM_PROJECTILE),
|
||||
EXPERIENCE_BOTTLE(ITEM_PROJECTILE),
|
||||
FIREWORK_ROCKET(PROJECTILE),
|
||||
LLAMA_SPIT(PROJECTILE),
|
||||
SHULKER_BULLET(PROJECTILE),
|
||||
FISHING_BOBBER(PROJECTILE),
|
||||
WITHER_SKULL(PROJECTILE),
|
||||
DRAGON_FIREBALL(PROJECTILE), // Doesn't actually inherit fireball
|
||||
|
||||
ABSTRACT_THROWN_POTION(ITEM_PROJECTILE, null),
|
||||
SPLASH_POTION(ABSTRACT_THROWN_POTION),
|
||||
LINGERING_POTION(ABSTRACT_THROWN_POTION),
|
||||
|
||||
ABSTRACT_ARROW(PROJECTILE, null),
|
||||
ARROW(ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(ABSTRACT_ARROW),
|
||||
TRIDENT(ABSTRACT_ARROW),
|
||||
|
||||
ABSTRACT_FIREBALL(ENTITY, null),
|
||||
FIREBALL(ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(ABSTRACT_FIREBALL),
|
||||
|
||||
ABSTRACT_WIND_CHARGE(PROJECTILE, null),
|
||||
WIND_CHARGE(ABSTRACT_WIND_CHARGE),
|
||||
BREEZE_WIND_CHARGE(ABSTRACT_WIND_CHARGE),
|
||||
|
||||
// Vehicles
|
||||
VEHICLE(ENTITY, null),
|
||||
|
||||
ABSTRACT_MINECART(VEHICLE, null),
|
||||
MINECART(ABSTRACT_MINECART),
|
||||
FURNACE_MINECART(ABSTRACT_MINECART),
|
||||
COMMAND_BLOCK_MINECART(ABSTRACT_MINECART),
|
||||
TNT_MINECART(ABSTRACT_MINECART),
|
||||
SPAWNER_MINECART(ABSTRACT_MINECART),
|
||||
|
||||
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART, null),
|
||||
CHEST_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
HOPPER_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
|
||||
ABSTRACT_BOAT(VEHICLE, null),
|
||||
ABSTRACT_CHEST_BOAT(ABSTRACT_BOAT, null),
|
||||
ACACIA_BOAT(ABSTRACT_BOAT),
|
||||
ACACIA_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
BAMBOO_CHEST_RAFT(ABSTRACT_CHEST_BOAT),
|
||||
BAMBOO_RAFT(ABSTRACT_BOAT),
|
||||
BIRCH_BOAT(ABSTRACT_BOAT),
|
||||
BIRCH_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
CHERRY_BOAT(ABSTRACT_BOAT),
|
||||
CHERRY_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
DARK_OAK_BOAT(ABSTRACT_BOAT),
|
||||
DARK_OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
JUNGLE_BOAT(ABSTRACT_BOAT),
|
||||
JUNGLE_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
MANGROVE_BOAT(ABSTRACT_BOAT),
|
||||
MANGROVE_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
OAK_BOAT(ABSTRACT_BOAT),
|
||||
OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
PALE_OAK_BOAT(ABSTRACT_BOAT),
|
||||
PALE_OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
SPRUCE_BOAT(ABSTRACT_BOAT),
|
||||
SPRUCE_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
|
||||
// Living entities as a larger subclass
|
||||
LIVING_ENTITY(ENTITY, null),
|
||||
ARMOR_STAND(LIVING_ENTITY),
|
||||
|
||||
// Players
|
||||
AVATAR(LIVING_ENTITY, null),
|
||||
MANNEQUIN(AVATAR),
|
||||
PLAYER(AVATAR),
|
||||
|
||||
// Mobs as a larger subclass
|
||||
MOB(LIVING_ENTITY, null),
|
||||
ENDER_DRAGON(MOB),
|
||||
|
||||
SLIME(MOB),
|
||||
MAGMA_CUBE(SLIME),
|
||||
|
||||
// Ambient mobs
|
||||
AMBIENT_CREATURE(MOB, null),
|
||||
BAT(AMBIENT_CREATURE),
|
||||
|
||||
// Flying mobs
|
||||
FLYING_MOB(MOB, null),
|
||||
GHAST(FLYING_MOB),
|
||||
PHANTOM(FLYING_MOB),
|
||||
|
||||
// Pathfinder mobs and its subclasses
|
||||
PATHFINDER_MOB(MOB, null),
|
||||
ALLAY(PATHFINDER_MOB),
|
||||
|
||||
ABSTRACT_GOLEM(PATHFINDER_MOB, null),
|
||||
SNOW_GOLEM(ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(ABSTRACT_GOLEM),
|
||||
SHULKER(ABSTRACT_GOLEM),
|
||||
COPPER_GOLEM(ABSTRACT_GOLEM),
|
||||
|
||||
// Ageable mobs and (tamable) animals
|
||||
ABSTRACT_AGEABLE(PATHFINDER_MOB, null),
|
||||
ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null),
|
||||
VILLAGER(ABSTRACT_VILLAGER),
|
||||
WANDERING_TRADER(ABSTRACT_VILLAGER),
|
||||
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
|
||||
AXOLOTL(ABSTRACT_ANIMAL),
|
||||
CHICKEN(ABSTRACT_ANIMAL),
|
||||
PANDA(ABSTRACT_ANIMAL),
|
||||
PIG(ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(ABSTRACT_ANIMAL),
|
||||
RABBIT(ABSTRACT_ANIMAL),
|
||||
SHEEP(ABSTRACT_ANIMAL),
|
||||
BEE(ABSTRACT_ANIMAL),
|
||||
TURTLE(ABSTRACT_ANIMAL),
|
||||
FOX(ABSTRACT_ANIMAL),
|
||||
FROG(ABSTRACT_ANIMAL),
|
||||
GOAT(ABSTRACT_ANIMAL),
|
||||
HOGLIN(ABSTRACT_ANIMAL),
|
||||
STRIDER(ABSTRACT_ANIMAL),
|
||||
SNIFFER(ABSTRACT_ANIMAL),
|
||||
ARMADILLO(ABSTRACT_ANIMAL),
|
||||
HAPPY_GHAST(ABSTRACT_ANIMAL),
|
||||
|
||||
ABSTRACT_COW(ABSTRACT_ANIMAL, null),
|
||||
COW(ABSTRACT_COW),
|
||||
MOOSHROOM(ABSTRACT_COW),
|
||||
|
||||
TAMABLE_ANIMAL(ABSTRACT_ANIMAL, null),
|
||||
CAT(TAMABLE_ANIMAL),
|
||||
OCELOT(TAMABLE_ANIMAL),
|
||||
WOLF(TAMABLE_ANIMAL),
|
||||
PARROT(TAMABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_NAUTILUS(TAMABLE_ANIMAL, null),
|
||||
NAUTILUS(ABSTRACT_NAUTILUS),
|
||||
ZOMBIE_NAUTILUS(ABSTRACT_NAUTILUS),
|
||||
|
||||
ABSTRACT_HORSE(ABSTRACT_ANIMAL, null),
|
||||
HORSE(ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(ABSTRACT_HORSE),
|
||||
CAMEL(ABSTRACT_HORSE),
|
||||
CAMEL_HUSK(CAMEL),
|
||||
|
||||
ABSTRACT_CHESTED_HORSE(ABSTRACT_HORSE, null),
|
||||
DONKEY(ABSTRACT_CHESTED_HORSE),
|
||||
MULE(ABSTRACT_CHESTED_HORSE),
|
||||
LLAMA(ABSTRACT_CHESTED_HORSE),
|
||||
TRADER_LLAMA(LLAMA),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(PATHFINDER_MOB, null),
|
||||
BLAZE(ABSTRACT_MONSTER),
|
||||
CREEPER(ABSTRACT_MONSTER),
|
||||
ENDERMITE(ABSTRACT_MONSTER),
|
||||
ENDERMAN(ABSTRACT_MONSTER),
|
||||
GIANT(ABSTRACT_MONSTER),
|
||||
SILVERFISH(ABSTRACT_MONSTER),
|
||||
VEX(ABSTRACT_MONSTER),
|
||||
WITHER(ABSTRACT_MONSTER),
|
||||
BREEZE(ABSTRACT_MONSTER),
|
||||
ZOGLIN(ABSTRACT_MONSTER),
|
||||
WARDEN(ABSTRACT_MONSTER),
|
||||
CREAKING(ABSTRACT_MONSTER),
|
||||
|
||||
ABSTRACT_SKELETON(ABSTRACT_MONSTER, null),
|
||||
SKELETON(ABSTRACT_SKELETON),
|
||||
STRAY(ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(ABSTRACT_SKELETON),
|
||||
BOGGED(ABSTRACT_SKELETON),
|
||||
PARCHED(ABSTRACT_SKELETON),
|
||||
|
||||
ZOMBIE(ABSTRACT_MONSTER),
|
||||
DROWNED(ZOMBIE),
|
||||
HUSK(ZOMBIE),
|
||||
ZOMBIFIED_PIGLIN(ZOMBIE),
|
||||
ZOMBIE_VILLAGER(ZOMBIE),
|
||||
|
||||
GUARDIAN(ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(GUARDIAN),
|
||||
|
||||
SPIDER(ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(SPIDER),
|
||||
|
||||
ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null),
|
||||
PIGLIN(ABSTRACT_PIGLIN),
|
||||
PIGLIN_BRUTE(ABSTRACT_PIGLIN),
|
||||
|
||||
// Water mobs
|
||||
AGEABLE_WATER_CREATURE(ABSTRACT_AGEABLE, null),
|
||||
DOLPHIN(AGEABLE_WATER_CREATURE),
|
||||
|
||||
SQUID(AGEABLE_WATER_CREATURE),
|
||||
GLOW_SQUID(SQUID),
|
||||
|
||||
WATER_ANIMAL(PATHFINDER_MOB, null),
|
||||
ABSTRACT_FISH(WATER_ANIMAL, null),
|
||||
PUFFERFISH(ABSTRACT_FISH),
|
||||
TADPOLE(ABSTRACT_FISH),
|
||||
|
||||
ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISH, null),
|
||||
COD(ABSTRACT_SCHOOLING_FISH),
|
||||
SALMON(ABSTRACT_SCHOOLING_FISH),
|
||||
TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH),
|
||||
|
||||
// Raiders
|
||||
ABSTRACT_RAIDER(ABSTRACT_MONSTER, null),
|
||||
WITCH(ABSTRACT_RAIDER),
|
||||
RAVAGER(ABSTRACT_RAIDER),
|
||||
|
||||
ABSTRACT_ILLAGER(ABSTRACT_RAIDER, null),
|
||||
SPELLCASTER_ILLAGER(ABSTRACT_ILLAGER, null),
|
||||
VINDICATOR(ABSTRACT_ILLAGER),
|
||||
PILLAGER(ABSTRACT_ILLAGER),
|
||||
EVOKER(SPELLCASTER_ILLAGER),
|
||||
ILLUSIONER(SPELLCASTER_ILLAGER);
|
||||
|
||||
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
|
||||
private final EntityType parent;
|
||||
private final String identifier;
|
||||
private int id = -1;
|
||||
|
||||
EntityTypes1_21_11(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_21_11(final EntityType parent, @Nullable final String identifier) {
|
||||
this.parent = parent;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
if (id == -1) {
|
||||
throw new IllegalStateException("Ids have not been initialized yet (type " + name() + ")");
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type");
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable EntityType getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return identifier == null;
|
||||
}
|
||||
|
||||
public static EntityType getTypeFromId(final int typeId) {
|
||||
return EntityTypeUtil.getTypeFromId(TYPES, typeId, PIG);
|
||||
}
|
||||
|
||||
public static void initialize(final Protocol<?, ?, ?, ?> protocol) {
|
||||
EntityTypeUtil.initialize(values(), TYPES, protocol, (type, id) -> type.id = id);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -272,7 +272,7 @@ public enum EntityTypes1_21_2 implements EntityType {
|
||||
|
||||
EntityTypes1_21_2(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_21_2(final EntityType parent, @Nullable final String identifier) {
|
||||
|
||||
+1
-1
@@ -271,7 +271,7 @@ public enum EntityTypes1_21_4 implements EntityType {
|
||||
|
||||
EntityTypes1_21_4(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_21_4(final EntityType parent, @Nullable final String identifier) {
|
||||
|
||||
+318
@@ -0,0 +1,318 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.entities;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.util.EntityTypeUtil;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import java.util.Locale;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public enum EntityTypes1_21_6 implements EntityType {
|
||||
|
||||
ENTITY(null, null),
|
||||
|
||||
AREA_EFFECT_CLOUD(ENTITY),
|
||||
END_CRYSTAL(ENTITY),
|
||||
EVOKER_FANGS(ENTITY),
|
||||
EXPERIENCE_ORB(ENTITY),
|
||||
EYE_OF_ENDER(ENTITY),
|
||||
FALLING_BLOCK(ENTITY),
|
||||
ITEM(ENTITY),
|
||||
TNT(ENTITY),
|
||||
OMINOUS_ITEM_SPAWNER(ENTITY),
|
||||
MARKER(ENTITY),
|
||||
LIGHTNING_BOLT(ENTITY),
|
||||
INTERACTION(ENTITY),
|
||||
|
||||
DISPLAY(ENTITY, null),
|
||||
BLOCK_DISPLAY(DISPLAY),
|
||||
ITEM_DISPLAY(DISPLAY),
|
||||
TEXT_DISPLAY(DISPLAY),
|
||||
|
||||
// Hanging entities
|
||||
HANGING_ENTITY(ENTITY, null),
|
||||
LEASH_KNOT(HANGING_ENTITY),
|
||||
PAINTING(HANGING_ENTITY),
|
||||
ITEM_FRAME(HANGING_ENTITY),
|
||||
GLOW_ITEM_FRAME(ITEM_FRAME),
|
||||
|
||||
// Projectiles
|
||||
PROJECTILE(ENTITY, null),
|
||||
ITEM_PROJECTILE(PROJECTILE, null),
|
||||
SNOWBALL(ITEM_PROJECTILE),
|
||||
ENDER_PEARL(ITEM_PROJECTILE),
|
||||
EGG(ITEM_PROJECTILE),
|
||||
EXPERIENCE_BOTTLE(ITEM_PROJECTILE),
|
||||
FIREWORK_ROCKET(PROJECTILE),
|
||||
LLAMA_SPIT(PROJECTILE),
|
||||
SHULKER_BULLET(PROJECTILE),
|
||||
FISHING_BOBBER(PROJECTILE),
|
||||
WITHER_SKULL(PROJECTILE),
|
||||
DRAGON_FIREBALL(PROJECTILE), // Doesn't actually inherit fireball
|
||||
|
||||
ABSTRACT_THROWN_POTION(ITEM_PROJECTILE, null),
|
||||
SPLASH_POTION(ABSTRACT_THROWN_POTION),
|
||||
LINGERING_POTION(ABSTRACT_THROWN_POTION),
|
||||
|
||||
ABSTRACT_ARROW(PROJECTILE, null),
|
||||
ARROW(ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(ABSTRACT_ARROW),
|
||||
TRIDENT(ABSTRACT_ARROW),
|
||||
|
||||
ABSTRACT_FIREBALL(ENTITY, null),
|
||||
FIREBALL(ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(ABSTRACT_FIREBALL),
|
||||
|
||||
ABSTRACT_WIND_CHARGE(PROJECTILE, null),
|
||||
WIND_CHARGE(ABSTRACT_WIND_CHARGE),
|
||||
BREEZE_WIND_CHARGE(ABSTRACT_WIND_CHARGE),
|
||||
|
||||
// Vehicles
|
||||
VEHICLE(ENTITY, null),
|
||||
|
||||
ABSTRACT_MINECART(VEHICLE, null),
|
||||
MINECART(ABSTRACT_MINECART),
|
||||
FURNACE_MINECART(ABSTRACT_MINECART),
|
||||
COMMAND_BLOCK_MINECART(ABSTRACT_MINECART),
|
||||
TNT_MINECART(ABSTRACT_MINECART),
|
||||
SPAWNER_MINECART(ABSTRACT_MINECART),
|
||||
|
||||
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART, null),
|
||||
CHEST_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
HOPPER_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
|
||||
ABSTRACT_BOAT(VEHICLE, null),
|
||||
ABSTRACT_CHEST_BOAT(ABSTRACT_BOAT, null),
|
||||
ACACIA_BOAT(ABSTRACT_BOAT),
|
||||
ACACIA_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
BAMBOO_CHEST_RAFT(ABSTRACT_CHEST_BOAT),
|
||||
BAMBOO_RAFT(ABSTRACT_BOAT),
|
||||
BIRCH_BOAT(ABSTRACT_BOAT),
|
||||
BIRCH_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
CHERRY_BOAT(ABSTRACT_BOAT),
|
||||
CHERRY_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
DARK_OAK_BOAT(ABSTRACT_BOAT),
|
||||
DARK_OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
JUNGLE_BOAT(ABSTRACT_BOAT),
|
||||
JUNGLE_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
MANGROVE_BOAT(ABSTRACT_BOAT),
|
||||
MANGROVE_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
OAK_BOAT(ABSTRACT_BOAT),
|
||||
OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
PALE_OAK_BOAT(ABSTRACT_BOAT),
|
||||
PALE_OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
SPRUCE_BOAT(ABSTRACT_BOAT),
|
||||
SPRUCE_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
|
||||
// Living entities as a larger subclass
|
||||
LIVING_ENTITY(ENTITY, null),
|
||||
ARMOR_STAND(LIVING_ENTITY),
|
||||
PLAYER(LIVING_ENTITY),
|
||||
|
||||
// Mobs as a larger subclass
|
||||
MOB(LIVING_ENTITY, null),
|
||||
ENDER_DRAGON(MOB),
|
||||
|
||||
SLIME(MOB),
|
||||
MAGMA_CUBE(SLIME),
|
||||
|
||||
// Ambient mobs
|
||||
AMBIENT_CREATURE(MOB, null),
|
||||
BAT(AMBIENT_CREATURE),
|
||||
|
||||
// Flying mobs
|
||||
FLYING_MOB(MOB, null),
|
||||
GHAST(FLYING_MOB),
|
||||
PHANTOM(FLYING_MOB),
|
||||
|
||||
// Pathfinder mobs and its subclasses
|
||||
PATHFINDER_MOB(MOB, null),
|
||||
ALLAY(PATHFINDER_MOB),
|
||||
|
||||
ABSTRACT_GOLEM(PATHFINDER_MOB, null),
|
||||
SNOW_GOLEM(ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(ABSTRACT_GOLEM),
|
||||
SHULKER(ABSTRACT_GOLEM),
|
||||
|
||||
// Ageable mobs and (tamable) animals
|
||||
ABSTRACT_AGEABLE(PATHFINDER_MOB, null),
|
||||
ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null),
|
||||
VILLAGER(ABSTRACT_VILLAGER),
|
||||
WANDERING_TRADER(ABSTRACT_VILLAGER),
|
||||
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
|
||||
AXOLOTL(ABSTRACT_ANIMAL),
|
||||
CHICKEN(ABSTRACT_ANIMAL),
|
||||
PANDA(ABSTRACT_ANIMAL),
|
||||
PIG(ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(ABSTRACT_ANIMAL),
|
||||
RABBIT(ABSTRACT_ANIMAL),
|
||||
SHEEP(ABSTRACT_ANIMAL),
|
||||
BEE(ABSTRACT_ANIMAL),
|
||||
TURTLE(ABSTRACT_ANIMAL),
|
||||
FOX(ABSTRACT_ANIMAL),
|
||||
FROG(ABSTRACT_ANIMAL),
|
||||
GOAT(ABSTRACT_ANIMAL),
|
||||
HOGLIN(ABSTRACT_ANIMAL),
|
||||
STRIDER(ABSTRACT_ANIMAL),
|
||||
SNIFFER(ABSTRACT_ANIMAL),
|
||||
ARMADILLO(ABSTRACT_ANIMAL),
|
||||
HAPPY_GHAST(ABSTRACT_ANIMAL),
|
||||
|
||||
ABSTRACT_COW(ABSTRACT_ANIMAL, null),
|
||||
COW(ABSTRACT_COW),
|
||||
MOOSHROOM(ABSTRACT_COW),
|
||||
|
||||
TAMABLE_ANIMAL(ABSTRACT_ANIMAL, null),
|
||||
CAT(TAMABLE_ANIMAL),
|
||||
OCELOT(TAMABLE_ANIMAL),
|
||||
WOLF(TAMABLE_ANIMAL),
|
||||
PARROT(TAMABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_HORSE(ABSTRACT_ANIMAL, null),
|
||||
HORSE(ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(ABSTRACT_HORSE),
|
||||
CAMEL(ABSTRACT_HORSE),
|
||||
|
||||
ABSTRACT_CHESTED_HORSE(ABSTRACT_HORSE, null),
|
||||
DONKEY(ABSTRACT_CHESTED_HORSE),
|
||||
MULE(ABSTRACT_CHESTED_HORSE),
|
||||
LLAMA(ABSTRACT_CHESTED_HORSE),
|
||||
TRADER_LLAMA(LLAMA),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(PATHFINDER_MOB, null),
|
||||
BLAZE(ABSTRACT_MONSTER),
|
||||
CREEPER(ABSTRACT_MONSTER),
|
||||
ENDERMITE(ABSTRACT_MONSTER),
|
||||
ENDERMAN(ABSTRACT_MONSTER),
|
||||
GIANT(ABSTRACT_MONSTER),
|
||||
SILVERFISH(ABSTRACT_MONSTER),
|
||||
VEX(ABSTRACT_MONSTER),
|
||||
WITHER(ABSTRACT_MONSTER),
|
||||
BREEZE(ABSTRACT_MONSTER),
|
||||
ZOGLIN(ABSTRACT_MONSTER),
|
||||
WARDEN(ABSTRACT_MONSTER),
|
||||
CREAKING(ABSTRACT_MONSTER),
|
||||
|
||||
ABSTRACT_SKELETON(ABSTRACT_MONSTER, null),
|
||||
SKELETON(ABSTRACT_SKELETON),
|
||||
STRAY(ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(ABSTRACT_SKELETON),
|
||||
BOGGED(ABSTRACT_SKELETON),
|
||||
|
||||
ZOMBIE(ABSTRACT_MONSTER),
|
||||
DROWNED(ZOMBIE),
|
||||
HUSK(ZOMBIE),
|
||||
ZOMBIFIED_PIGLIN(ZOMBIE),
|
||||
ZOMBIE_VILLAGER(ZOMBIE),
|
||||
|
||||
GUARDIAN(ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(GUARDIAN),
|
||||
|
||||
SPIDER(ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(SPIDER),
|
||||
|
||||
ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null),
|
||||
PIGLIN(ABSTRACT_PIGLIN),
|
||||
PIGLIN_BRUTE(ABSTRACT_PIGLIN),
|
||||
|
||||
// Water mobs
|
||||
AGEABLE_WATER_CREATURE(ABSTRACT_AGEABLE, null),
|
||||
DOLPHIN(AGEABLE_WATER_CREATURE),
|
||||
|
||||
SQUID(AGEABLE_WATER_CREATURE),
|
||||
GLOW_SQUID(SQUID),
|
||||
|
||||
WATER_ANIMAL(PATHFINDER_MOB, null),
|
||||
ABSTRACT_FISH(WATER_ANIMAL, null),
|
||||
PUFFERFISH(ABSTRACT_FISH),
|
||||
TADPOLE(ABSTRACT_FISH),
|
||||
|
||||
ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISH, null),
|
||||
COD(ABSTRACT_SCHOOLING_FISH),
|
||||
SALMON(ABSTRACT_SCHOOLING_FISH),
|
||||
TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH),
|
||||
|
||||
// Raiders
|
||||
ABSTRACT_RAIDER(ABSTRACT_MONSTER, null),
|
||||
WITCH(ABSTRACT_RAIDER),
|
||||
RAVAGER(ABSTRACT_RAIDER),
|
||||
|
||||
ABSTRACT_ILLAGER(ABSTRACT_RAIDER, null),
|
||||
SPELLCASTER_ILLAGER(ABSTRACT_ILLAGER, null),
|
||||
VINDICATOR(ABSTRACT_ILLAGER),
|
||||
PILLAGER(ABSTRACT_ILLAGER),
|
||||
EVOKER(SPELLCASTER_ILLAGER),
|
||||
ILLUSIONER(SPELLCASTER_ILLAGER);
|
||||
|
||||
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
|
||||
private final EntityType parent;
|
||||
private final String identifier;
|
||||
private int id = -1;
|
||||
|
||||
EntityTypes1_21_6(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_21_6(final EntityType parent, @Nullable final String identifier) {
|
||||
this.parent = parent;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
if (id == -1) {
|
||||
throw new IllegalStateException("Ids have not been initialized yet (type " + name() + ")");
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type");
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable EntityType getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return identifier == null;
|
||||
}
|
||||
|
||||
public static EntityType getTypeFromId(final int typeId) {
|
||||
return EntityTypeUtil.getTypeFromId(TYPES, typeId, PIG);
|
||||
}
|
||||
|
||||
public static void initialize(final Protocol<?, ?, ?, ?> protocol) {
|
||||
EntityTypeUtil.initialize(values(), TYPES, protocol, (type, id) -> type.id = id);
|
||||
}
|
||||
}
|
||||
+323
@@ -0,0 +1,323 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.entities;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.util.EntityTypeUtil;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import java.util.Locale;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public enum EntityTypes1_21_9 implements EntityType {
|
||||
|
||||
ENTITY(null, null),
|
||||
|
||||
AREA_EFFECT_CLOUD(ENTITY),
|
||||
END_CRYSTAL(ENTITY),
|
||||
EVOKER_FANGS(ENTITY),
|
||||
EXPERIENCE_ORB(ENTITY),
|
||||
EYE_OF_ENDER(ENTITY),
|
||||
FALLING_BLOCK(ENTITY),
|
||||
ITEM(ENTITY),
|
||||
TNT(ENTITY),
|
||||
OMINOUS_ITEM_SPAWNER(ENTITY),
|
||||
MARKER(ENTITY),
|
||||
LIGHTNING_BOLT(ENTITY),
|
||||
INTERACTION(ENTITY),
|
||||
|
||||
DISPLAY(ENTITY, null),
|
||||
BLOCK_DISPLAY(DISPLAY),
|
||||
ITEM_DISPLAY(DISPLAY),
|
||||
TEXT_DISPLAY(DISPLAY),
|
||||
|
||||
// Hanging entities
|
||||
HANGING_ENTITY(ENTITY, null),
|
||||
LEASH_KNOT(HANGING_ENTITY),
|
||||
PAINTING(HANGING_ENTITY),
|
||||
ITEM_FRAME(HANGING_ENTITY),
|
||||
GLOW_ITEM_FRAME(ITEM_FRAME),
|
||||
|
||||
// Projectiles
|
||||
PROJECTILE(ENTITY, null),
|
||||
ITEM_PROJECTILE(PROJECTILE, null),
|
||||
SNOWBALL(ITEM_PROJECTILE),
|
||||
ENDER_PEARL(ITEM_PROJECTILE),
|
||||
EGG(ITEM_PROJECTILE),
|
||||
EXPERIENCE_BOTTLE(ITEM_PROJECTILE),
|
||||
FIREWORK_ROCKET(PROJECTILE),
|
||||
LLAMA_SPIT(PROJECTILE),
|
||||
SHULKER_BULLET(PROJECTILE),
|
||||
FISHING_BOBBER(PROJECTILE),
|
||||
WITHER_SKULL(PROJECTILE),
|
||||
DRAGON_FIREBALL(PROJECTILE), // Doesn't actually inherit fireball
|
||||
|
||||
ABSTRACT_THROWN_POTION(ITEM_PROJECTILE, null),
|
||||
SPLASH_POTION(ABSTRACT_THROWN_POTION),
|
||||
LINGERING_POTION(ABSTRACT_THROWN_POTION),
|
||||
|
||||
ABSTRACT_ARROW(PROJECTILE, null),
|
||||
ARROW(ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(ABSTRACT_ARROW),
|
||||
TRIDENT(ABSTRACT_ARROW),
|
||||
|
||||
ABSTRACT_FIREBALL(ENTITY, null),
|
||||
FIREBALL(ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(ABSTRACT_FIREBALL),
|
||||
|
||||
ABSTRACT_WIND_CHARGE(PROJECTILE, null),
|
||||
WIND_CHARGE(ABSTRACT_WIND_CHARGE),
|
||||
BREEZE_WIND_CHARGE(ABSTRACT_WIND_CHARGE),
|
||||
|
||||
// Vehicles
|
||||
VEHICLE(ENTITY, null),
|
||||
|
||||
ABSTRACT_MINECART(VEHICLE, null),
|
||||
MINECART(ABSTRACT_MINECART),
|
||||
FURNACE_MINECART(ABSTRACT_MINECART),
|
||||
COMMAND_BLOCK_MINECART(ABSTRACT_MINECART),
|
||||
TNT_MINECART(ABSTRACT_MINECART),
|
||||
SPAWNER_MINECART(ABSTRACT_MINECART),
|
||||
|
||||
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART, null),
|
||||
CHEST_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
HOPPER_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
|
||||
ABSTRACT_BOAT(VEHICLE, null),
|
||||
ABSTRACT_CHEST_BOAT(ABSTRACT_BOAT, null),
|
||||
ACACIA_BOAT(ABSTRACT_BOAT),
|
||||
ACACIA_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
BAMBOO_CHEST_RAFT(ABSTRACT_CHEST_BOAT),
|
||||
BAMBOO_RAFT(ABSTRACT_BOAT),
|
||||
BIRCH_BOAT(ABSTRACT_BOAT),
|
||||
BIRCH_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
CHERRY_BOAT(ABSTRACT_BOAT),
|
||||
CHERRY_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
DARK_OAK_BOAT(ABSTRACT_BOAT),
|
||||
DARK_OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
JUNGLE_BOAT(ABSTRACT_BOAT),
|
||||
JUNGLE_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
MANGROVE_BOAT(ABSTRACT_BOAT),
|
||||
MANGROVE_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
OAK_BOAT(ABSTRACT_BOAT),
|
||||
OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
PALE_OAK_BOAT(ABSTRACT_BOAT),
|
||||
PALE_OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
SPRUCE_BOAT(ABSTRACT_BOAT),
|
||||
SPRUCE_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
|
||||
|
||||
// Living entities as a larger subclass
|
||||
LIVING_ENTITY(ENTITY, null),
|
||||
ARMOR_STAND(LIVING_ENTITY),
|
||||
|
||||
// Players
|
||||
AVATAR(LIVING_ENTITY, null),
|
||||
MANNEQUIN(AVATAR),
|
||||
PLAYER(AVATAR),
|
||||
|
||||
// Mobs as a larger subclass
|
||||
MOB(LIVING_ENTITY, null),
|
||||
ENDER_DRAGON(MOB),
|
||||
|
||||
SLIME(MOB),
|
||||
MAGMA_CUBE(SLIME),
|
||||
|
||||
// Ambient mobs
|
||||
AMBIENT_CREATURE(MOB, null),
|
||||
BAT(AMBIENT_CREATURE),
|
||||
|
||||
// Flying mobs
|
||||
FLYING_MOB(MOB, null),
|
||||
GHAST(FLYING_MOB),
|
||||
PHANTOM(FLYING_MOB),
|
||||
|
||||
// Pathfinder mobs and its subclasses
|
||||
PATHFINDER_MOB(MOB, null),
|
||||
ALLAY(PATHFINDER_MOB),
|
||||
|
||||
ABSTRACT_GOLEM(PATHFINDER_MOB, null),
|
||||
SNOW_GOLEM(ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(ABSTRACT_GOLEM),
|
||||
SHULKER(ABSTRACT_GOLEM),
|
||||
COPPER_GOLEM(ABSTRACT_GOLEM),
|
||||
|
||||
// Ageable mobs and (tamable) animals
|
||||
ABSTRACT_AGEABLE(PATHFINDER_MOB, null),
|
||||
ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null),
|
||||
VILLAGER(ABSTRACT_VILLAGER),
|
||||
WANDERING_TRADER(ABSTRACT_VILLAGER),
|
||||
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
|
||||
AXOLOTL(ABSTRACT_ANIMAL),
|
||||
CHICKEN(ABSTRACT_ANIMAL),
|
||||
PANDA(ABSTRACT_ANIMAL),
|
||||
PIG(ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(ABSTRACT_ANIMAL),
|
||||
RABBIT(ABSTRACT_ANIMAL),
|
||||
SHEEP(ABSTRACT_ANIMAL),
|
||||
BEE(ABSTRACT_ANIMAL),
|
||||
TURTLE(ABSTRACT_ANIMAL),
|
||||
FOX(ABSTRACT_ANIMAL),
|
||||
FROG(ABSTRACT_ANIMAL),
|
||||
GOAT(ABSTRACT_ANIMAL),
|
||||
HOGLIN(ABSTRACT_ANIMAL),
|
||||
STRIDER(ABSTRACT_ANIMAL),
|
||||
SNIFFER(ABSTRACT_ANIMAL),
|
||||
ARMADILLO(ABSTRACT_ANIMAL),
|
||||
HAPPY_GHAST(ABSTRACT_ANIMAL),
|
||||
|
||||
ABSTRACT_COW(ABSTRACT_ANIMAL, null),
|
||||
COW(ABSTRACT_COW),
|
||||
MOOSHROOM(ABSTRACT_COW),
|
||||
|
||||
TAMABLE_ANIMAL(ABSTRACT_ANIMAL, null),
|
||||
CAT(TAMABLE_ANIMAL),
|
||||
OCELOT(TAMABLE_ANIMAL),
|
||||
WOLF(TAMABLE_ANIMAL),
|
||||
PARROT(TAMABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_HORSE(ABSTRACT_ANIMAL, null),
|
||||
HORSE(ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(ABSTRACT_HORSE),
|
||||
CAMEL(ABSTRACT_HORSE),
|
||||
|
||||
ABSTRACT_CHESTED_HORSE(ABSTRACT_HORSE, null),
|
||||
DONKEY(ABSTRACT_CHESTED_HORSE),
|
||||
MULE(ABSTRACT_CHESTED_HORSE),
|
||||
LLAMA(ABSTRACT_CHESTED_HORSE),
|
||||
TRADER_LLAMA(LLAMA),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(PATHFINDER_MOB, null),
|
||||
BLAZE(ABSTRACT_MONSTER),
|
||||
CREEPER(ABSTRACT_MONSTER),
|
||||
ENDERMITE(ABSTRACT_MONSTER),
|
||||
ENDERMAN(ABSTRACT_MONSTER),
|
||||
GIANT(ABSTRACT_MONSTER),
|
||||
SILVERFISH(ABSTRACT_MONSTER),
|
||||
VEX(ABSTRACT_MONSTER),
|
||||
WITHER(ABSTRACT_MONSTER),
|
||||
BREEZE(ABSTRACT_MONSTER),
|
||||
ZOGLIN(ABSTRACT_MONSTER),
|
||||
WARDEN(ABSTRACT_MONSTER),
|
||||
CREAKING(ABSTRACT_MONSTER),
|
||||
|
||||
ABSTRACT_SKELETON(ABSTRACT_MONSTER, null),
|
||||
SKELETON(ABSTRACT_SKELETON),
|
||||
STRAY(ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(ABSTRACT_SKELETON),
|
||||
BOGGED(ABSTRACT_SKELETON),
|
||||
|
||||
ZOMBIE(ABSTRACT_MONSTER),
|
||||
DROWNED(ZOMBIE),
|
||||
HUSK(ZOMBIE),
|
||||
ZOMBIFIED_PIGLIN(ZOMBIE),
|
||||
ZOMBIE_VILLAGER(ZOMBIE),
|
||||
|
||||
GUARDIAN(ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(GUARDIAN),
|
||||
|
||||
SPIDER(ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(SPIDER),
|
||||
|
||||
ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null),
|
||||
PIGLIN(ABSTRACT_PIGLIN),
|
||||
PIGLIN_BRUTE(ABSTRACT_PIGLIN),
|
||||
|
||||
// Water mobs
|
||||
AGEABLE_WATER_CREATURE(ABSTRACT_AGEABLE, null),
|
||||
DOLPHIN(AGEABLE_WATER_CREATURE),
|
||||
|
||||
SQUID(AGEABLE_WATER_CREATURE),
|
||||
GLOW_SQUID(SQUID),
|
||||
|
||||
WATER_ANIMAL(PATHFINDER_MOB, null),
|
||||
ABSTRACT_FISH(WATER_ANIMAL, null),
|
||||
PUFFERFISH(ABSTRACT_FISH),
|
||||
TADPOLE(ABSTRACT_FISH),
|
||||
|
||||
ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISH, null),
|
||||
COD(ABSTRACT_SCHOOLING_FISH),
|
||||
SALMON(ABSTRACT_SCHOOLING_FISH),
|
||||
TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH),
|
||||
|
||||
// Raiders
|
||||
ABSTRACT_RAIDER(ABSTRACT_MONSTER, null),
|
||||
WITCH(ABSTRACT_RAIDER),
|
||||
RAVAGER(ABSTRACT_RAIDER),
|
||||
|
||||
ABSTRACT_ILLAGER(ABSTRACT_RAIDER, null),
|
||||
SPELLCASTER_ILLAGER(ABSTRACT_ILLAGER, null),
|
||||
VINDICATOR(ABSTRACT_ILLAGER),
|
||||
PILLAGER(ABSTRACT_ILLAGER),
|
||||
EVOKER(SPELLCASTER_ILLAGER),
|
||||
ILLUSIONER(SPELLCASTER_ILLAGER);
|
||||
|
||||
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
|
||||
private final EntityType parent;
|
||||
private final String identifier;
|
||||
private int id = -1;
|
||||
|
||||
EntityTypes1_21_9(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_21_9(final EntityType parent, @Nullable final String identifier) {
|
||||
this.parent = parent;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
if (id == -1) {
|
||||
throw new IllegalStateException("Ids have not been initialized yet (type " + name() + ")");
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type");
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable EntityType getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return identifier == null;
|
||||
}
|
||||
|
||||
public static EntityType getTypeFromId(final int typeId) {
|
||||
return EntityTypeUtil.getTypeFromId(TYPES, typeId, PIG);
|
||||
}
|
||||
|
||||
public static void initialize(final Protocol<?, ?, ?, ?> protocol) {
|
||||
EntityTypeUtil.initialize(values(), TYPES, protocol, (type, id) -> type.id = id);
|
||||
}
|
||||
}
|
||||
+9
-7
@@ -22,8 +22,8 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.entities;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public class EntityTypes1_8 {
|
||||
|
||||
@@ -135,7 +135,7 @@ public class EntityTypes1_8 {
|
||||
SPIDER(52, ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(59, SPIDER);
|
||||
|
||||
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||
private static final Int2ObjectMap<EntityType> TYPES;
|
||||
|
||||
private final int id;
|
||||
private final EntityType parent;
|
||||
@@ -176,7 +176,9 @@ public class EntityTypes1_8 {
|
||||
}
|
||||
|
||||
static {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
final EntityType[] values = EntityType.values();
|
||||
TYPES = new Int2ObjectOpenHashMap<>(values.length);
|
||||
for (EntityType type : values) {
|
||||
TYPES.put(type.id, type);
|
||||
}
|
||||
}
|
||||
@@ -218,7 +220,7 @@ public class EntityTypes1_8 {
|
||||
ARMOR_STAND(78, EntityType.ARMOR_STAND),
|
||||
FISHIHNG_HOOK(90, EntityType.FISHING_HOOK);
|
||||
|
||||
private static final Map<Integer, Map<Integer, ObjectType>> TYPES = new HashMap<>();
|
||||
private static final Int2ObjectMap<Int2ObjectMap<ObjectType>> TYPES = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
private final int id;
|
||||
private final int data;
|
||||
@@ -226,7 +228,7 @@ public class EntityTypes1_8 {
|
||||
|
||||
static {
|
||||
for (ObjectType type : ObjectType.values()) {
|
||||
TYPES.computeIfAbsent(type.id, k -> new HashMap<>()).put(type.data, type);
|
||||
TYPES.computeIfAbsent(type.id, k -> new Int2ObjectOpenHashMap<>()).put(type.data, type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,7 +258,7 @@ public class EntityTypes1_8 {
|
||||
}
|
||||
|
||||
public static ObjectType findById(final int id, final int data) {
|
||||
final Map<Integer, ObjectType> types = TYPES.get(id);
|
||||
final Int2ObjectMap<ObjectType> types = TYPES.get(id);
|
||||
if (types == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+9
-7
@@ -22,8 +22,8 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.entities;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public class EntityTypes1_9 {
|
||||
|
||||
@@ -142,7 +142,7 @@ public class EntityTypes1_9 {
|
||||
SPIDER(52, ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(59, SPIDER);
|
||||
|
||||
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||
private static final Int2ObjectMap<EntityType> TYPES;
|
||||
|
||||
private final int id;
|
||||
private final EntityType parent;
|
||||
@@ -183,7 +183,9 @@ public class EntityTypes1_9 {
|
||||
}
|
||||
|
||||
static {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
final EntityType[] values = EntityType.values();
|
||||
TYPES = new Int2ObjectOpenHashMap<>(values.length);
|
||||
for (EntityType type : values) {
|
||||
TYPES.put(type.id, type);
|
||||
}
|
||||
}
|
||||
@@ -229,7 +231,7 @@ public class EntityTypes1_9 {
|
||||
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
|
||||
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL);
|
||||
|
||||
private static final Map<Integer, Map<Integer, ObjectType>> TYPES = new HashMap<>();
|
||||
private static final Int2ObjectMap<Int2ObjectMap<ObjectType>> TYPES = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
private final int id;
|
||||
private final int data;
|
||||
@@ -237,7 +239,7 @@ public class EntityTypes1_9 {
|
||||
|
||||
static {
|
||||
for (ObjectType type : ObjectType.values()) {
|
||||
TYPES.computeIfAbsent(type.id, k -> new HashMap<>()).put(type.data, type);
|
||||
TYPES.computeIfAbsent(type.id, k -> new Int2ObjectOpenHashMap<>()).put(type.data, type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,7 +269,7 @@ public class EntityTypes1_9 {
|
||||
}
|
||||
|
||||
public static ObjectType findById(final int id, final int data) {
|
||||
final Map<Integer, ObjectType> types = TYPES.get(id);
|
||||
final Int2ObjectMap<ObjectType> types = TYPES.get(id);
|
||||
if (types == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+4
@@ -44,6 +44,10 @@ public abstract class AbstractEntityDataTypes implements EntityDataTypes {
|
||||
}
|
||||
|
||||
protected EntityDataType add(final int typeId, final Type<?> type) {
|
||||
if (values[typeId] != null) {
|
||||
throw new IllegalArgumentException("Entity data type ID " + typeId + " is already registered as " + values[typeId]);
|
||||
}
|
||||
|
||||
final EntityDataType dataType = EntityDataType.create(typeId, type);
|
||||
values[typeId] = dataType;
|
||||
return dataType;
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ public final class EntityDataTypes1_14 extends AbstractEntityDataTypes {
|
||||
public final EntityDataType optionalBlockStateType = add(13, Types.VAR_INT);
|
||||
public final EntityDataType compoundTagType = add(14, Types.NAMED_COMPOUND_TAG);
|
||||
public final EntityDataType particleType;
|
||||
public final EntityDataType villagerDatatType = add(16, Types.VILLAGER_DATA);
|
||||
public final EntityDataType villagerDataType = add(16, Types.VILLAGER_DATA);
|
||||
public final EntityDataType optionalVarIntType = add(17, Types.OPTIONAL_VAR_INT);
|
||||
public final EntityDataType poseType = add(18, Types.VAR_INT);
|
||||
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ public final class EntityDataTypes1_19 extends AbstractEntityDataTypes {
|
||||
public final EntityDataType optionalBlockStateType = add(13, Types.VAR_INT);
|
||||
public final EntityDataType compoundTagType = add(14, Types.NAMED_COMPOUND_TAG);
|
||||
public final EntityDataType particleType;
|
||||
public final EntityDataType villagerDatatType = add(16, Types.VILLAGER_DATA);
|
||||
public final EntityDataType villagerDataType = add(16, Types.VILLAGER_DATA);
|
||||
public final EntityDataType optionalVarIntType = add(17, Types.OPTIONAL_VAR_INT);
|
||||
public final EntityDataType poseType = add(18, Types.VAR_INT);
|
||||
public final EntityDataType catVariantType = add(19, Types.VAR_INT);
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ public final class EntityDataTypes1_19_3 extends AbstractEntityDataTypes {
|
||||
public final EntityDataType optionalBlockStateType = add(14, Types.VAR_INT);
|
||||
public final EntityDataType compoundTagType = add(15, Types.NAMED_COMPOUND_TAG);
|
||||
public final EntityDataType particleType;
|
||||
public final EntityDataType villagerDatatType = add(17, Types.VILLAGER_DATA);
|
||||
public final EntityDataType villagerDataType = add(17, Types.VILLAGER_DATA);
|
||||
public final EntityDataType optionalVarIntType = add(18, Types.OPTIONAL_VAR_INT);
|
||||
public final EntityDataType poseType = add(19, Types.VAR_INT);
|
||||
public final EntityDataType catVariantType = add(20, Types.VAR_INT);
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public final class EntityDataTypes1_19_4 extends AbstractEntityDataTypes {
|
||||
public final EntityDataType optionalBlockStateType = add(15, Types.VAR_INT);
|
||||
public final EntityDataType compoundTagType = add(16, Types.NAMED_COMPOUND_TAG);
|
||||
public final EntityDataType particleType;
|
||||
public final EntityDataType villagerDatatType = add(18, Types.VILLAGER_DATA);
|
||||
public final EntityDataType villagerDataType = add(18, Types.VILLAGER_DATA);
|
||||
public final EntityDataType optionalVarIntType = add(19, Types.OPTIONAL_VAR_INT);
|
||||
public final EntityDataType poseType = add(20, Types.VAR_INT);
|
||||
public final EntityDataType catVariantType = add(21, Types.VAR_INT);
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public final class EntityDataTypes1_20_2 extends AbstractEntityDataTypes {
|
||||
public final EntityDataType optionalBlockStateType = add(15, Types.VAR_INT);
|
||||
public final EntityDataType compoundTagType = add(16, Types.COMPOUND_TAG);
|
||||
public final EntityDataType particleType;
|
||||
public final EntityDataType villagerDatatType = add(18, Types.VILLAGER_DATA);
|
||||
public final EntityDataType villagerDataType = add(18, Types.VILLAGER_DATA);
|
||||
public final EntityDataType optionalVarIntType = add(19, Types.OPTIONAL_VAR_INT);
|
||||
public final EntityDataType poseType = add(20, Types.VAR_INT);
|
||||
public final EntityDataType catVariantType = add(21, Types.VAR_INT);
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public final class EntityDataTypes1_20_3 extends AbstractEntityDataTypes {
|
||||
public final EntityDataType optionalBlockStateType = add(15, Types.VAR_INT);
|
||||
public final EntityDataType compoundTagType = add(16, Types.COMPOUND_TAG);
|
||||
public final EntityDataType particleType;
|
||||
public final EntityDataType villagerDatatType = add(18, Types.VILLAGER_DATA);
|
||||
public final EntityDataType villagerDataType = add(18, Types.VILLAGER_DATA);
|
||||
public final EntityDataType optionalVarIntType = add(19, Types.OPTIONAL_VAR_INT);
|
||||
public final EntityDataType poseType = add(20, Types.VAR_INT);
|
||||
public final EntityDataType catVariantType = add(21, Types.VAR_INT);
|
||||
|
||||
+7
-9
@@ -22,12 +22,9 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.entitydata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.ArrayType;
|
||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
|
||||
import com.viaversion.viaversion.api.type.types.version.VersionedTypesHolder;
|
||||
|
||||
public final class EntityDataTypes1_20_5 extends AbstractEntityDataTypes {
|
||||
|
||||
@@ -38,7 +35,7 @@ public final class EntityDataTypes1_20_5 extends AbstractEntityDataTypes {
|
||||
public final EntityDataType stringType = add(4, Types.STRING);
|
||||
public final EntityDataType componentType = add(5, Types.TAG);
|
||||
public final EntityDataType optionalComponentType = add(6, Types.OPTIONAL_TAG);
|
||||
public final EntityDataType itemType = add(7, Types1_20_5.ITEM);
|
||||
public final EntityDataType itemType;
|
||||
public final EntityDataType booleanType = add(8, Types.BOOLEAN);
|
||||
public final EntityDataType rotationsType = add(9, Types.ROTATIONS);
|
||||
public final EntityDataType blockPositionType = add(10, Types.BLOCK_POSITION1_14);
|
||||
@@ -50,7 +47,7 @@ public final class EntityDataTypes1_20_5 extends AbstractEntityDataTypes {
|
||||
public final EntityDataType compoundTagType = add(16, Types.COMPOUND_TAG);
|
||||
public final EntityDataType particleType;
|
||||
public final EntityDataType particlesType;
|
||||
public final EntityDataType villagerDatatType = add(19, Types.VILLAGER_DATA);
|
||||
public final EntityDataType villagerDataType = add(19, Types.VILLAGER_DATA);
|
||||
public final EntityDataType optionalVarIntType = add(20, Types.OPTIONAL_VAR_INT);
|
||||
public final EntityDataType poseType = add(21, Types.VAR_INT);
|
||||
public final EntityDataType catVariantType = add(22, Types.VAR_INT);
|
||||
@@ -63,9 +60,10 @@ public final class EntityDataTypes1_20_5 extends AbstractEntityDataTypes {
|
||||
public final EntityDataType vector3FType = add(29, Types.VECTOR3F);
|
||||
public final EntityDataType quaternionType = add(30, Types.QUATERNION);
|
||||
|
||||
public EntityDataTypes1_20_5(final ParticleType particleType, final ArrayType<Particle> particlesType) {
|
||||
public EntityDataTypes1_20_5(final VersionedTypesHolder types) {
|
||||
super(31);
|
||||
this.particleType = add(17, particleType);
|
||||
this.particlesType = add(18, particlesType);
|
||||
this.itemType = add(7, types.item());
|
||||
this.particleType = add(17, types.particle());
|
||||
this.particlesType = add(18, types.particles());
|
||||
}
|
||||
}
|
||||
+6
-10
@@ -23,14 +23,10 @@
|
||||
package com.viaversion.viaversion.api.minecraft.entitydata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.PaintingVariant;
|
||||
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||
import com.viaversion.viaversion.api.minecraft.WolfVariant;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.ArrayType;
|
||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||
import com.viaversion.viaversion.api.type.types.version.VersionedTypesHolder;
|
||||
|
||||
public final class EntityDataTypes1_21 extends AbstractEntityDataTypes {
|
||||
|
||||
@@ -53,7 +49,7 @@ public final class EntityDataTypes1_21 extends AbstractEntityDataTypes {
|
||||
public final EntityDataType compoundTagType = add(16, Types.COMPOUND_TAG);
|
||||
public final EntityDataType particleType;
|
||||
public final EntityDataType particlesType;
|
||||
public final EntityDataType villagerDatatType = add(19, Types.VILLAGER_DATA);
|
||||
public final EntityDataType villagerDataType = add(19, Types.VILLAGER_DATA);
|
||||
public final EntityDataType optionalVarIntType = add(20, Types.OPTIONAL_VAR_INT);
|
||||
public final EntityDataType poseType = add(21, Types.VAR_INT);
|
||||
public final EntityDataType catVariantType = add(22, Types.VAR_INT);
|
||||
@@ -66,10 +62,10 @@ public final class EntityDataTypes1_21 extends AbstractEntityDataTypes {
|
||||
public final EntityDataType vector3FType = add(29, Types.VECTOR3F);
|
||||
public final EntityDataType quaternionType = add(30, Types.QUATERNION);
|
||||
|
||||
public EntityDataTypes1_21(final Type<Item> itemType, final ParticleType particleType, final ArrayType<Particle> particlesType) {
|
||||
public EntityDataTypes1_21(final VersionedTypesHolder types) {
|
||||
super(31);
|
||||
this.itemType = add(7, itemType);
|
||||
this.particleType = add(17, particleType);
|
||||
this.particlesType = add(18, particlesType);
|
||||
this.itemType = add(7, types.item());
|
||||
this.particleType = add(17, types.particle());
|
||||
this.particlesType = add(18, types.particles());
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.entitydata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.PaintingVariant;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.VersionedTypesHolder;
|
||||
|
||||
public final class EntityDataTypes1_21_11 extends AbstractEntityDataTypes {
|
||||
|
||||
public final EntityDataType byteType = add(0, Types.BYTE);
|
||||
public final EntityDataType varIntType = add(1, Types.VAR_INT);
|
||||
public final EntityDataType longType = add(2, Types.VAR_LONG);
|
||||
public final EntityDataType floatType = add(3, Types.FLOAT);
|
||||
public final EntityDataType stringType = add(4, Types.STRING);
|
||||
public final EntityDataType componentType = add(5, Types.TAG);
|
||||
public final EntityDataType optionalComponentType = add(6, Types.OPTIONAL_TAG);
|
||||
public final EntityDataType itemType;
|
||||
public final EntityDataType booleanType = add(8, Types.BOOLEAN);
|
||||
public final EntityDataType rotationsType = add(9, Types.ROTATIONS);
|
||||
public final EntityDataType blockPositionType = add(10, Types.BLOCK_POSITION1_14);
|
||||
public final EntityDataType optionalBlockPositionType = add(11, Types.OPTIONAL_POSITION_1_14);
|
||||
public final EntityDataType directionType = add(12, Types.VAR_INT);
|
||||
public final EntityDataType optionalUUIDType = add(13, Types.OPTIONAL_UUID);
|
||||
public final EntityDataType blockStateType = add(14, Types.VAR_INT);
|
||||
public final EntityDataType optionalBlockStateType = add(15, Types.VAR_INT);
|
||||
public final EntityDataType particleType;
|
||||
public final EntityDataType particlesType;
|
||||
public final EntityDataType villagerDatatType = add(18, Types.VILLAGER_DATA);
|
||||
public final EntityDataType optionalVarIntType = add(19, Types.OPTIONAL_VAR_INT);
|
||||
public final EntityDataType poseType = add(20, Types.VAR_INT);
|
||||
public final EntityDataType catVariantType = add(21, Types.VAR_INT);
|
||||
public final EntityDataType cowVariantType = add(22, Types.VAR_INT);
|
||||
public final EntityDataType wolfVariantType = add(23, Types.VAR_INT);
|
||||
public final EntityDataType wolfSoundVariantType = add(24, Types.VAR_INT);
|
||||
public final EntityDataType frogVariantType = add(25, Types.VAR_INT);
|
||||
public final EntityDataType pigVariantType = add(26, Types.VAR_INT);
|
||||
public final EntityDataType chickenVariantType = add(27, Types.VAR_INT);
|
||||
public final EntityDataType zombieNautilusVariantType = add(28, Types.VAR_INT);
|
||||
public final EntityDataType optionalGlobalPosition = add(29, Types.OPTIONAL_GLOBAL_POSITION);
|
||||
public final EntityDataType paintingVariantType = add(30, PaintingVariant.TYPE1_21_2);
|
||||
public final EntityDataType snifferState = add(31, Types.VAR_INT);
|
||||
public final EntityDataType armadilloState = add(32, Types.VAR_INT);
|
||||
public final EntityDataType copperGolemState = add(33, Types.VAR_INT);
|
||||
public final EntityDataType weatheringCopperState = add(34, Types.VAR_INT);
|
||||
public final EntityDataType vector3FType = add(35, Types.VECTOR3F);
|
||||
public final EntityDataType quaternionType = add(36, Types.QUATERNION);
|
||||
public final EntityDataType mannequinProfileType = add(37, Types.RESOLVABLE_PROFILE);
|
||||
public final EntityDataType humanoidArmType = add(38, Types.VAR_INT);
|
||||
|
||||
public EntityDataTypes1_21_11(final VersionedTypesHolder types) {
|
||||
super(39);
|
||||
this.itemType = add(7, types.item());
|
||||
this.particleType = add(16, types.particle());
|
||||
this.particlesType = add(17, types.particles());
|
||||
}
|
||||
}
|
||||
+6
-9
@@ -23,13 +23,10 @@
|
||||
package com.viaversion.viaversion.api.minecraft.entitydata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.PaintingVariant;
|
||||
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||
import com.viaversion.viaversion.api.minecraft.WolfVariant;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||
import com.viaversion.viaversion.api.type.types.version.VersionedTypesHolder;
|
||||
|
||||
public final class EntityDataTypes1_21_2 extends AbstractEntityDataTypes {
|
||||
|
||||
@@ -52,7 +49,7 @@ public final class EntityDataTypes1_21_2 extends AbstractEntityDataTypes {
|
||||
public final EntityDataType compoundTagType = add(16, Types.COMPOUND_TAG);
|
||||
public final EntityDataType particleType;
|
||||
public final EntityDataType particlesType;
|
||||
public final EntityDataType villagerDatatType = add(19, Types.VILLAGER_DATA);
|
||||
public final EntityDataType villagerDataType = add(19, Types.VILLAGER_DATA);
|
||||
public final EntityDataType optionalVarIntType = add(20, Types.OPTIONAL_VAR_INT);
|
||||
public final EntityDataType poseType = add(21, Types.VAR_INT);
|
||||
public final EntityDataType catVariantType = add(22, Types.VAR_INT);
|
||||
@@ -65,10 +62,10 @@ public final class EntityDataTypes1_21_2 extends AbstractEntityDataTypes {
|
||||
public final EntityDataType vector3FType = add(29, Types.VECTOR3F);
|
||||
public final EntityDataType quaternionType = add(30, Types.QUATERNION);
|
||||
|
||||
public EntityDataTypes1_21_2(final Type<Item> itemType, final ParticleType particleType, final Type<Particle[]> particlesType) {
|
||||
public EntityDataTypes1_21_2(final VersionedTypesHolder types) {
|
||||
super(31);
|
||||
this.itemType = add(7, itemType);
|
||||
this.particleType = add(17, particleType);
|
||||
this.particlesType = add(18, particlesType);
|
||||
this.itemType = add(7, types.item());
|
||||
this.particleType = add(17, types.particle());
|
||||
this.particlesType = add(18, types.particles());
|
||||
}
|
||||
}
|
||||
+6
-9
@@ -23,12 +23,9 @@
|
||||
package com.viaversion.viaversion.api.minecraft.entitydata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.PaintingVariant;
|
||||
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||
import com.viaversion.viaversion.api.type.types.version.VersionedTypesHolder;
|
||||
|
||||
public final class EntityDataTypes1_21_5 extends AbstractEntityDataTypes {
|
||||
|
||||
@@ -51,7 +48,7 @@ public final class EntityDataTypes1_21_5 extends AbstractEntityDataTypes {
|
||||
public final EntityDataType compoundTagType = add(16, Types.COMPOUND_TAG);
|
||||
public final EntityDataType particleType;
|
||||
public final EntityDataType particlesType;
|
||||
public final EntityDataType villagerDatatType = add(19, Types.VILLAGER_DATA);
|
||||
public final EntityDataType villagerDataType = add(19, Types.VILLAGER_DATA);
|
||||
public final EntityDataType optionalVarIntType = add(20, Types.OPTIONAL_VAR_INT);
|
||||
public final EntityDataType poseType = add(21, Types.VAR_INT);
|
||||
public final EntityDataType catVariantType = add(22, Types.VAR_INT);
|
||||
@@ -68,10 +65,10 @@ public final class EntityDataTypes1_21_5 extends AbstractEntityDataTypes {
|
||||
public final EntityDataType vector3FType = add(33, Types.VECTOR3F);
|
||||
public final EntityDataType quaternionType = add(34, Types.QUATERNION);
|
||||
|
||||
public EntityDataTypes1_21_5(final Type<Item> itemType, final ParticleType particleType, final Type<Particle[]> particlesType) {
|
||||
public EntityDataTypes1_21_5(final VersionedTypesHolder types) {
|
||||
super(35);
|
||||
this.itemType = add(7, itemType);
|
||||
this.particleType = add(17, particleType);
|
||||
this.particlesType = add(18, particlesType);
|
||||
this.itemType = add(7, types.item());
|
||||
this.particleType = add(17, types.particle());
|
||||
this.particlesType = add(18, types.particles());
|
||||
}
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.entitydata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.PaintingVariant;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.VersionedTypesHolder;
|
||||
|
||||
public final class EntityDataTypes1_21_9 extends AbstractEntityDataTypes {
|
||||
|
||||
public final EntityDataType byteType = add(0, Types.BYTE);
|
||||
public final EntityDataType varIntType = add(1, Types.VAR_INT);
|
||||
public final EntityDataType longType = add(2, Types.VAR_LONG);
|
||||
public final EntityDataType floatType = add(3, Types.FLOAT);
|
||||
public final EntityDataType stringType = add(4, Types.STRING);
|
||||
public final EntityDataType componentType = add(5, Types.TAG);
|
||||
public final EntityDataType optionalComponentType = add(6, Types.OPTIONAL_TAG);
|
||||
public final EntityDataType itemType;
|
||||
public final EntityDataType booleanType = add(8, Types.BOOLEAN);
|
||||
public final EntityDataType rotationsType = add(9, Types.ROTATIONS);
|
||||
public final EntityDataType blockPositionType = add(10, Types.BLOCK_POSITION1_14);
|
||||
public final EntityDataType optionalBlockPositionType = add(11, Types.OPTIONAL_POSITION_1_14);
|
||||
public final EntityDataType directionType = add(12, Types.VAR_INT);
|
||||
public final EntityDataType optionalUUIDType = add(13, Types.OPTIONAL_UUID);
|
||||
public final EntityDataType blockStateType = add(14, Types.VAR_INT);
|
||||
public final EntityDataType optionalBlockStateType = add(15, Types.VAR_INT);
|
||||
public final EntityDataType particleType;
|
||||
public final EntityDataType particlesType;
|
||||
public final EntityDataType villagerDataType = add(18, Types.VILLAGER_DATA);
|
||||
public final EntityDataType optionalVarIntType = add(19, Types.OPTIONAL_VAR_INT);
|
||||
public final EntityDataType poseType = add(20, Types.VAR_INT);
|
||||
public final EntityDataType catVariantType = add(21, Types.VAR_INT);
|
||||
public final EntityDataType cowVariantType = add(22, Types.VAR_INT);
|
||||
public final EntityDataType wolfVariantType = add(23, Types.VAR_INT);
|
||||
public final EntityDataType wolfSoundVariantType = add(24, Types.VAR_INT);
|
||||
public final EntityDataType frogVariantType = add(25, Types.VAR_INT);
|
||||
public final EntityDataType pigVariantType = add(26, Types.VAR_INT);
|
||||
public final EntityDataType chickenVariantType = add(27, Types.VAR_INT);
|
||||
public final EntityDataType optionalGlobalPosition = add(28, Types.OPTIONAL_GLOBAL_POSITION);
|
||||
public final EntityDataType paintingVariantType = add(29, PaintingVariant.TYPE1_21_2);
|
||||
public final EntityDataType snifferState = add(30, Types.VAR_INT);
|
||||
public final EntityDataType armadilloState = add(31, Types.VAR_INT);
|
||||
public final EntityDataType copperGolemState = add(32, Types.VAR_INT);
|
||||
public final EntityDataType weatheringCopperState = add(33, Types.VAR_INT);
|
||||
public final EntityDataType vector3FType = add(34, Types.VECTOR3F);
|
||||
public final EntityDataType quaternionType = add(35, Types.QUATERNION);
|
||||
public final EntityDataType mannequinProfileType = add(36, Types.RESOLVABLE_PROFILE);
|
||||
|
||||
public EntityDataTypes1_21_9(final VersionedTypesHolder types) {
|
||||
super(37);
|
||||
this.itemType = add(7, types.item());
|
||||
this.particleType = add(16, types.particle());
|
||||
this.particlesType = add(17, types.particles());
|
||||
}
|
||||
}
|
||||
@@ -39,4 +39,7 @@ public interface HashedItem extends ItemBase {
|
||||
Int2IntMap dataHashesById();
|
||||
|
||||
IntSet removedDataIds();
|
||||
|
||||
@Override
|
||||
HashedItem copy();
|
||||
}
|
||||
+5
@@ -79,6 +79,11 @@ public class HashedStructuredItem implements HashedItem {
|
||||
return this.removedData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashedItem copy() {
|
||||
return new HashedStructuredItem(identifier, amount, new Int2IntOpenHashMap(dataHashes), new IntOpenHashSet(removedData));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
|
||||
@@ -24,10 +24,9 @@ package com.viaversion.viaversion.api.minecraft.item;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
|
||||
import com.viaversion.viaversion.util.Copyable;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface Item extends ItemBase, Copyable {
|
||||
public interface Item extends ItemBase {
|
||||
|
||||
/**
|
||||
* Returns the item data. Always 0 for 1.13+ items.
|
||||
|
||||
@@ -22,11 +22,13 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.item;
|
||||
|
||||
import com.viaversion.viaversion.util.Copyable;
|
||||
|
||||
/**
|
||||
* @see Item
|
||||
* @see HashedItem
|
||||
*/
|
||||
public interface ItemBase {
|
||||
public interface ItemBase extends Copyable {
|
||||
|
||||
/**
|
||||
* Returns the item identifier.
|
||||
@@ -64,4 +66,7 @@ public interface ItemBase {
|
||||
default boolean isEmpty() {
|
||||
return identifier() == 0 || amount() <= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
ItemBase copy();
|
||||
}
|
||||
+13
-7
@@ -22,14 +22,18 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.item.data;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredData;
|
||||
import com.viaversion.viaversion.api.minecraft.data.predicate.DataComponentPredicate;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.ArrayType;
|
||||
import com.viaversion.viaversion.util.Copyable;
|
||||
import com.viaversion.viaversion.util.Rewritable;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
|
||||
|
||||
public record AdventureModePredicate(BlockPredicate[] predicates, boolean showInTooltip) implements Copyable {
|
||||
public record AdventureModePredicate(BlockPredicate[] predicates,
|
||||
boolean showInTooltip) implements Copyable, Rewritable {
|
||||
|
||||
public AdventureModePredicate(final BlockPredicate[] predicates) {
|
||||
this(predicates, true);
|
||||
@@ -50,12 +54,13 @@ public record AdventureModePredicate(BlockPredicate[] predicates, boolean showIn
|
||||
}
|
||||
};
|
||||
|
||||
// Shared with 1.21.11 too using the predicate array param
|
||||
public static final class AdventureModePredicateType1_21_5 extends Type<AdventureModePredicate> {
|
||||
private final Type<BlockPredicate[]> blockPredicateType;
|
||||
|
||||
public AdventureModePredicateType1_21_5(final Type<StructuredData<?>[]> dataArrayType) {
|
||||
public AdventureModePredicateType1_21_5(final Type<StructuredData<?>[]> dataArrayType, final Type<DataComponentPredicate[]> predicateArrayType) {
|
||||
super(AdventureModePredicate.class);
|
||||
this.blockPredicateType = new ArrayType<>(new BlockPredicate.BlockPredicateType1_21_5(dataArrayType));
|
||||
this.blockPredicateType = new ArrayType<>(new BlockPredicate.BlockPredicateType1_21_5(dataArrayType, predicateArrayType));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,16 +75,17 @@ public record AdventureModePredicate(BlockPredicate[] predicates, boolean showIn
|
||||
}
|
||||
}
|
||||
|
||||
public AdventureModePredicate rewrite(final Int2IntFunction blockIdRewriter) {
|
||||
@Override
|
||||
public AdventureModePredicate rewrite(final UserConnection connection, final Protocol<?, ?, ?, ?> protocol, final boolean clientbound) {
|
||||
final BlockPredicate[] predicates = new BlockPredicate[this.predicates.length];
|
||||
for (int i = 0; i < predicates.length; i++) {
|
||||
predicates[i] = this.predicates[i].rewrite(blockIdRewriter);
|
||||
predicates[i] = this.predicates[i].rewrite(connection, protocol, clientbound);
|
||||
}
|
||||
return new AdventureModePredicate(predicates, showInTooltip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdventureModePredicate copy() {
|
||||
return new AdventureModePredicate(copy(predicates), showInTooltip);
|
||||
return new AdventureModePredicate(Copyable.copy(predicates), showInTooltip);
|
||||
}
|
||||
}
|
||||
@@ -22,12 +22,16 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.item.data;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.Holder;
|
||||
import com.viaversion.viaversion.api.minecraft.codec.Ops;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.util.Rewritable;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
|
||||
|
||||
public record ArmorTrim(Holder<ArmorTrimMaterial> material, Holder<ArmorTrimPattern> pattern, boolean showInTooltip) {
|
||||
public record ArmorTrim(Holder<ArmorTrimMaterial> material, Holder<ArmorTrimPattern> pattern,
|
||||
boolean showInTooltip) implements Rewritable {
|
||||
|
||||
public ArmorTrim(Holder<ArmorTrimMaterial> material, Holder<ArmorTrimPattern> pattern) {
|
||||
this(material, pattern, true);
|
||||
@@ -94,17 +98,25 @@ public record ArmorTrim(Holder<ArmorTrimMaterial> material, Holder<ArmorTrimPatt
|
||||
ArmorTrimMaterial.TYPE1_21_5.write(buffer, value.material);
|
||||
ArmorTrimPattern.TYPE1_21_5.write(buffer, value.pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final Ops ops, final ArmorTrim value) {
|
||||
ops.writeMap(map -> map
|
||||
.write("material", ArmorTrimMaterial.TYPE1_21_5, value.material)
|
||||
.write("pattern", ArmorTrimPattern.TYPE1_21_5, value.pattern));
|
||||
}
|
||||
};
|
||||
|
||||
public ArmorTrim rewrite(final Int2IntFunction idRewriteFunction) {
|
||||
@Override
|
||||
public ArmorTrim rewrite(final UserConnection connection, final Protocol<?, ?, ?, ?> protocol, final boolean clientbound) {
|
||||
Holder<ArmorTrimMaterial> material = this.material;
|
||||
if (material.isDirect()) {
|
||||
material = Holder.of(material.value().rewrite(idRewriteFunction));
|
||||
material = Holder.of(material.value().rewrite(connection, protocol, clientbound));
|
||||
}
|
||||
|
||||
Holder<ArmorTrimPattern> pattern = this.pattern;
|
||||
if (pattern.isDirect()) {
|
||||
pattern = Holder.of(pattern.value().rewrite(idRewriteFunction));
|
||||
pattern = Holder.of(pattern.value().rewrite(connection, protocol, clientbound));
|
||||
}
|
||||
return new ArmorTrim(material, pattern, showInTooltip);
|
||||
}
|
||||
|
||||
+30
-4
@@ -23,16 +23,21 @@
|
||||
package com.viaversion.viaversion.api.minecraft.item.data;
|
||||
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.codec.Ops;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.misc.HolderType;
|
||||
import com.viaversion.viaversion.util.Copyable;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import com.viaversion.viaversion.util.Rewritable;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
|
||||
import java.util.Map;
|
||||
|
||||
public record ArmorTrimMaterial(String assetName, int itemId, float itemModelIndex,
|
||||
Map<String, String> overrideArmorMaterials, Tag description) implements Copyable {
|
||||
Map<String, String> overrideArmorMaterials,
|
||||
Tag description) implements Copyable, Rewritable {
|
||||
|
||||
public ArmorTrimMaterial(final String assetName, final int itemId, final Map<String, String> overrideArmorMaterials, final Tag description) {
|
||||
this(assetName, itemId, 0F, overrideArmorMaterials, description);
|
||||
@@ -173,10 +178,31 @@ public record ArmorTrimMaterial(String assetName, int itemId, float itemModelInd
|
||||
|
||||
Types.TAG.write(buffer, value.description());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDirect(final Ops ops, final ArmorTrimMaterial object) {
|
||||
ops.writeMap(map -> {
|
||||
map.write("asset_name", Types.STRING, object.assetName());
|
||||
if (!object.overrideArmorMaterials.isEmpty()) {
|
||||
map.writeMap("override_armor_assets", materials -> {
|
||||
for (final Map.Entry<String, String> entry : object.overrideArmorMaterials.entrySet()) {
|
||||
materials.write(Types.IDENTIFIER, Key.of(entry.getKey()), Types.STRING, entry.getValue());
|
||||
}
|
||||
});
|
||||
}
|
||||
map.write("description", Types.TEXT_COMPONENT_TAG, object.description());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Key identifier(final Ops ops, final int id) {
|
||||
return ops.context().registryAccess().registryKey("trim_material", id);
|
||||
}
|
||||
};
|
||||
|
||||
public ArmorTrimMaterial rewrite(final Int2IntFunction idRewriteFunction) {
|
||||
return new ArmorTrimMaterial(assetName, idRewriteFunction.applyAsInt(itemId), itemModelIndex, overrideArmorMaterials, description);
|
||||
@Override
|
||||
public ArmorTrimMaterial rewrite(final UserConnection connection, final Protocol<?, ?, ?, ?> protocol, final boolean clientbound) {
|
||||
return new ArmorTrimMaterial(assetName, Rewritable.rewriteItem(protocol, clientbound, itemId), itemModelIndex, overrideArmorMaterials, description);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+22
-4
@@ -23,13 +23,17 @@
|
||||
package com.viaversion.viaversion.api.minecraft.item.data;
|
||||
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.codec.Ops;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.misc.HolderType;
|
||||
import com.viaversion.viaversion.util.Copyable;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import com.viaversion.viaversion.util.Rewritable;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
|
||||
|
||||
public record ArmorTrimPattern(String assetName, int itemId, Tag description, boolean decal) implements Copyable {
|
||||
public record ArmorTrimPattern(String assetName, int itemId, Tag description, boolean decal) implements Copyable, Rewritable {
|
||||
|
||||
public ArmorTrimPattern(final String assetName, final Tag description, final boolean decal) {
|
||||
this(assetName, 0, description, decal);
|
||||
@@ -68,10 +72,24 @@ public record ArmorTrimPattern(String assetName, int itemId, Tag description, bo
|
||||
Types.TAG.write(buffer, value.description());
|
||||
buffer.writeBoolean(value.decal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDirect(final Ops ops, final ArmorTrimPattern object) {
|
||||
ops.writeMap(map -> map
|
||||
.write("asset_id", Types.IDENTIFIER, Key.of(object.assetName()))
|
||||
.write("description", Types.TEXT_COMPONENT_TAG, object.description())
|
||||
.write("decal", Types.BOOLEAN, object.decal()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Key identifier(final Ops ops, final int id) {
|
||||
return ops.context().registryAccess().registryKey("trim_pattern", id);
|
||||
}
|
||||
};
|
||||
|
||||
public ArmorTrimPattern rewrite(final Int2IntFunction idRewriteFunction) {
|
||||
return new ArmorTrimPattern(assetName, idRewriteFunction.applyAsInt(itemId), description, decal);
|
||||
@Override
|
||||
public ArmorTrimPattern rewrite(final UserConnection connection, final Protocol<?, ?, ?, ?> protocol, final boolean clientbound) {
|
||||
return new ArmorTrimPattern(assetName, Rewritable.rewriteItem(protocol, clientbound, itemId), description, decal);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.item.data;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.codec.Ops;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public record AttackRange(float minRange, float maxRange,
|
||||
float minCreativeRange, float maxCreativeRange,
|
||||
float hitboxMargin, float mobFactor) {
|
||||
|
||||
public static final Type<AttackRange> TYPE = new Type<>(AttackRange.class) {
|
||||
@Override
|
||||
public AttackRange read(final ByteBuf buffer) {
|
||||
final float minRange = Types.FLOAT.readPrimitive(buffer);
|
||||
final float maxRange = Types.FLOAT.readPrimitive(buffer);
|
||||
final float minCreativeRange = Types.FLOAT.readPrimitive(buffer);
|
||||
final float maxCreativeRange = Types.FLOAT.readPrimitive(buffer);
|
||||
final float hitboxMargin = Types.FLOAT.readPrimitive(buffer);
|
||||
final float mobFactor = Types.FLOAT.readPrimitive(buffer);
|
||||
return new AttackRange(minRange, maxRange, minCreativeRange, maxCreativeRange, hitboxMargin, mobFactor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final ByteBuf buffer, final AttackRange value) {
|
||||
Types.FLOAT.writePrimitive(buffer, value.minRange);
|
||||
Types.FLOAT.writePrimitive(buffer, value.maxRange);
|
||||
Types.FLOAT.writePrimitive(buffer, value.minCreativeRange);
|
||||
Types.FLOAT.writePrimitive(buffer, value.maxCreativeRange);
|
||||
Types.FLOAT.writePrimitive(buffer, value.hitboxMargin);
|
||||
Types.FLOAT.writePrimitive(buffer, value.mobFactor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final Ops ops, final AttackRange AttackRange) {
|
||||
ops.writeMap(map -> map
|
||||
.writeOptional("min_range", Types.FLOAT, AttackRange.minRange, 0F)
|
||||
.writeOptional("max_range", Types.FLOAT, AttackRange.maxRange, 3F)
|
||||
.writeOptional("min_creative_reach", Types.FLOAT, AttackRange.minCreativeRange, 0F)
|
||||
.writeOptional("max_creative_reach", Types.FLOAT, AttackRange.maxCreativeRange, 5F)
|
||||
.writeOptional("hitbox_margin", Types.FLOAT, AttackRange.hitboxMargin, 0.3F)
|
||||
.writeOptional("mob_factor", Types.FLOAT, AttackRange.mobFactor, 1F));
|
||||
}
|
||||
};
|
||||
}
|
||||
+26
-2
@@ -22,14 +22,21 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.item.data;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.FullMappings;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.ArrayType;
|
||||
import com.viaversion.viaversion.util.Copyable;
|
||||
import com.viaversion.viaversion.util.Rewritable;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public record AttributeModifiers1_20_5(AttributeModifier[] modifiers, boolean showInTooltip) implements Copyable {
|
||||
public record AttributeModifiers1_20_5(AttributeModifier[] modifiers,
|
||||
boolean showInTooltip) implements Copyable, Rewritable {
|
||||
|
||||
public static final Type<AttributeModifiers1_20_5> TYPE = new Type<>(AttributeModifiers1_20_5.class) {
|
||||
@Override
|
||||
@@ -48,7 +55,24 @@ public record AttributeModifiers1_20_5(AttributeModifier[] modifiers, boolean sh
|
||||
|
||||
@Override
|
||||
public AttributeModifiers1_20_5 copy() {
|
||||
return new AttributeModifiers1_20_5(copy(modifiers), showInTooltip);
|
||||
return new AttributeModifiers1_20_5(Copyable.copy(modifiers), showInTooltip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeModifiers1_20_5 rewrite(final UserConnection connection, final Protocol<?, ?, ?, ?> protocol, final boolean clientbound) {
|
||||
final FullMappings mappings = protocol.getMappingData().getAttributeMappings();
|
||||
if (mappings == null) {
|
||||
return this;
|
||||
}
|
||||
|
||||
final List<AttributeModifier> modifiers = new ArrayList<>(this.modifiers.length);
|
||||
for (final AttributeModifier modifier : this.modifiers) {
|
||||
final int mappedId = clientbound ? mappings.getNewId(modifier.attribute()) : mappings.inverse().getNewId(modifier.attribute());
|
||||
if (mappedId != -1) {
|
||||
modifiers.add(new AttributeModifier(mappedId, modifier.modifier(), modifier.slotType()));
|
||||
}
|
||||
}
|
||||
return new AttributeModifiers1_20_5(modifiers.toArray(AttributeModifier[]::new), this.showInTooltip);
|
||||
}
|
||||
|
||||
public record AttributeModifier(int attribute, ModifierData modifier, int slotType) {
|
||||
|
||||
+166
-10
@@ -22,14 +22,23 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.item.data;
|
||||
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.FullMappings;
|
||||
import com.viaversion.viaversion.api.minecraft.codec.Ops;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.ArrayType;
|
||||
import com.viaversion.viaversion.util.Copyable;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import com.viaversion.viaversion.util.Rewritable;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public record AttributeModifiers1_21(AttributeModifier[] modifiers, boolean showInTooltip) implements Copyable {
|
||||
public record AttributeModifiers1_21(AttributeModifier[] modifiers, boolean showInTooltip) implements Copyable, Rewritable {
|
||||
|
||||
public AttributeModifiers1_21(final AttributeModifier[] modifiers) {
|
||||
this(modifiers, true);
|
||||
@@ -38,27 +47,49 @@ public record AttributeModifiers1_21(AttributeModifier[] modifiers, boolean show
|
||||
public static final Type<AttributeModifiers1_21> TYPE1_21 = new Type<>(AttributeModifiers1_21.class) {
|
||||
@Override
|
||||
public AttributeModifiers1_21 read(final ByteBuf buffer) {
|
||||
final AttributeModifier[] modifiers = AttributeModifier.ARRAY_TYPE.read(buffer);
|
||||
final AttributeModifier[] modifiers = AttributeModifier.ARRAY_TYPE1_21.read(buffer);
|
||||
final boolean showInTooltip = buffer.readBoolean();
|
||||
return new AttributeModifiers1_21(modifiers, showInTooltip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final ByteBuf buffer, final AttributeModifiers1_21 value) {
|
||||
AttributeModifier.ARRAY_TYPE.write(buffer, value.modifiers());
|
||||
AttributeModifier.ARRAY_TYPE1_21.write(buffer, value.modifiers());
|
||||
buffer.writeBoolean(value.showInTooltip());
|
||||
}
|
||||
};
|
||||
public static final Type<AttributeModifiers1_21> TYPE1_21_5 = new Type<>(AttributeModifiers1_21.class) {
|
||||
@Override
|
||||
public AttributeModifiers1_21 read(final ByteBuf buffer) {
|
||||
final AttributeModifier[] modifiers = AttributeModifier.ARRAY_TYPE.read(buffer);
|
||||
final AttributeModifier[] modifiers = AttributeModifier.ARRAY_TYPE1_21.read(buffer);
|
||||
return new AttributeModifiers1_21(modifiers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final ByteBuf buffer, final AttributeModifiers1_21 value) {
|
||||
AttributeModifier.ARRAY_TYPE.write(buffer, value.modifiers());
|
||||
AttributeModifier.ARRAY_TYPE1_21.write(buffer, value.modifiers());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final Ops ops, final AttributeModifiers1_21 value) {
|
||||
ops.write(AttributeModifier.ARRAY_TYPE1_21, value.modifiers);
|
||||
}
|
||||
};
|
||||
public static final Type<AttributeModifiers1_21> TYPE1_21_6 = new Type<>(AttributeModifiers1_21.class) {
|
||||
@Override
|
||||
public AttributeModifiers1_21 read(final ByteBuf buffer) {
|
||||
final AttributeModifier[] modifiers = AttributeModifier.ARRAY_TYPE1_21_6.read(buffer);
|
||||
return new AttributeModifiers1_21(modifiers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final ByteBuf buffer, final AttributeModifiers1_21 value) {
|
||||
AttributeModifier.ARRAY_TYPE1_21_6.write(buffer, value.modifiers());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final Ops ops, final AttributeModifiers1_21 value) {
|
||||
ops.write(AttributeModifier.ARRAY_TYPE1_21_6, value.modifiers);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -66,19 +97,42 @@ public record AttributeModifiers1_21(AttributeModifier[] modifiers, boolean show
|
||||
final AttributeModifier[] modifiers = new AttributeModifier[this.modifiers.length];
|
||||
for (int i = 0; i < this.modifiers.length; i++) {
|
||||
final AttributeModifier modifier = this.modifiers[i];
|
||||
modifiers[i] = new AttributeModifier(rewriteFunction.applyAsInt(modifier.attribute()), modifier.modifier(), modifier.slotType());
|
||||
modifiers[i] = new AttributeModifier(rewriteFunction.applyAsInt(modifier.attribute()), modifier.modifier(), modifier.slotType(), modifier.display());
|
||||
}
|
||||
return new AttributeModifiers1_21(modifiers, showInTooltip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeModifiers1_21 copy() {
|
||||
return new AttributeModifiers1_21(copy(modifiers), showInTooltip);
|
||||
return new AttributeModifiers1_21(Copyable.copy(modifiers), showInTooltip);
|
||||
}
|
||||
|
||||
public record AttributeModifier(int attribute, ModifierData modifier, int slotType) {
|
||||
@Override
|
||||
public AttributeModifiers1_21 rewrite(final UserConnection connection, final Protocol<?, ?, ?, ?> protocol, final boolean clientbound) {
|
||||
final FullMappings mappings = protocol.getMappingData().getAttributeMappings();
|
||||
if (mappings == null) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static final Type<AttributeModifier> TYPE = new Type<>(AttributeModifier.class) {
|
||||
final List<AttributeModifier> modifiers = new ArrayList<>(this.modifiers.length);
|
||||
for (final AttributeModifier modifier : this.modifiers) {
|
||||
final int mappedId = clientbound ? mappings.getNewId(modifier.attribute()) : mappings.inverse().getNewId(modifier.attribute());
|
||||
if (mappedId != -1) {
|
||||
modifiers.add(new AttributeModifier(mappedId, modifier.modifier(), modifier.slotType(), modifier.display()));
|
||||
}
|
||||
}
|
||||
return new AttributeModifiers1_21(modifiers.toArray(AttributeModifier[]::new), this.showInTooltip);
|
||||
}
|
||||
|
||||
public record AttributeModifier(int attribute, ModifierData modifier, int slotType, Display display) {
|
||||
private static final String[] EQUIPMENT_SLOT_GROUPS = {"any", "mainhand", "offhand", "hand", "feet", "legs", "chest", "head", "armor", "body", "saddle"};
|
||||
private static final String[] OPERATION = {"add_value", "add_multiplied_base", "add_multiplied_total"};
|
||||
|
||||
public AttributeModifier(final int attribute, final ModifierData modifier, final int slotType) {
|
||||
this(attribute, modifier, slotType, Display.DEFAULT);
|
||||
}
|
||||
|
||||
public static final Type<AttributeModifier> TYPE1_21 = new Type<>(AttributeModifier.class) {
|
||||
@Override
|
||||
public AttributeModifier read(final ByteBuf buffer) {
|
||||
final int attribute = Types.VAR_INT.readPrimitive(buffer);
|
||||
@@ -93,8 +147,62 @@ public record AttributeModifiers1_21(AttributeModifier[] modifiers, boolean show
|
||||
ModifierData.TYPE.write(buffer, value.modifier);
|
||||
Types.VAR_INT.writePrimitive(buffer, value.slotType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final Ops ops, final AttributeModifier value) {
|
||||
final Key attribute = ops.context().registryAccess().attributeModifier(value.attribute);
|
||||
ops.writeMap(map -> map
|
||||
.write("type", Types.IDENTIFIER, attribute)
|
||||
.write("id", Types.IDENTIFIER, Key.of(value.modifier.id()))
|
||||
.write("amount", Types.DOUBLE, value.modifier.amount)
|
||||
.write("operation", Types.STRING, OPERATION[value.modifier.operation()])
|
||||
.writeOptional("slot", Types.STRING, EQUIPMENT_SLOT_GROUPS[value.slotType()], "any"));
|
||||
}
|
||||
};
|
||||
public static final Type<AttributeModifier[]> ARRAY_TYPE = new ArrayType<>(TYPE);
|
||||
public static final Type<AttributeModifier[]> ARRAY_TYPE1_21 = new ArrayType<>(TYPE1_21);
|
||||
|
||||
public static final Type<AttributeModifier> TYPE1_21_6 = new Type<>(AttributeModifier.class) {
|
||||
@Override
|
||||
public AttributeModifier read(final ByteBuf buffer) {
|
||||
final int attribute = Types.VAR_INT.readPrimitive(buffer);
|
||||
final ModifierData modifier = ModifierData.TYPE.read(buffer);
|
||||
final int slot = Types.VAR_INT.readPrimitive(buffer);
|
||||
final int displayType = Types.VAR_INT.readPrimitive(buffer);
|
||||
final Display display = displayType == OverrideText.ID ? new OverrideText(Types.TAG.read(buffer)) : new Display(displayType);
|
||||
return new AttributeModifier(attribute, modifier, slot, display);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final ByteBuf buffer, final AttributeModifier value) {
|
||||
Types.VAR_INT.writePrimitive(buffer, value.attribute);
|
||||
ModifierData.TYPE.write(buffer, value.modifier);
|
||||
Types.VAR_INT.writePrimitive(buffer, value.slotType);
|
||||
value.display.write(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final Ops ops, final AttributeModifier value) {
|
||||
final Key attribute = ops.context().registryAccess().attributeModifier(value.attribute);
|
||||
ops.writeMap(map -> {
|
||||
map.write("type", Types.IDENTIFIER, attribute)
|
||||
.write("id", Types.IDENTIFIER, Key.of(value.modifier.id()))
|
||||
.write("amount", Types.DOUBLE, value.modifier.amount)
|
||||
.write("operation", Types.STRING, OPERATION[value.modifier.operation()])
|
||||
.writeOptional("slot", Types.STRING, EQUIPMENT_SLOT_GROUPS[value.slotType()], "any");
|
||||
if (value.display.equals(Display.DEFAULT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
map.writeMap("display", display -> {
|
||||
display.write("type", Types.STRING, Display.DISPLAY_TYPES[value.display.id()]);
|
||||
if (value.display instanceof final OverrideText overrideText) {
|
||||
display.write("value", Types.TEXT_COMPONENT_TAG, overrideText.component);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
public static final Type<AttributeModifier[]> ARRAY_TYPE1_21_6 = new ArrayType<>(TYPE1_21_6);
|
||||
}
|
||||
|
||||
public record ModifierData(String id, double amount, int operation) {
|
||||
@@ -116,4 +224,52 @@ public record AttributeModifiers1_21(AttributeModifier[] modifiers, boolean show
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static class Display implements Copyable {
|
||||
public static final String[] DISPLAY_TYPES = {"default", "hidden", "override_text"};
|
||||
public static final Display DEFAULT = new Display(0);
|
||||
private final int id;
|
||||
|
||||
public Display(final int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int id() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void write(final ByteBuf buf) {
|
||||
Types.VAR_INT.writePrimitive(buf, this.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Display copy() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public static final class OverrideText extends Display {
|
||||
public static final int ID = 2;
|
||||
private final Tag component;
|
||||
|
||||
public OverrideText(final Tag component) {
|
||||
super(ID);
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
public Tag component() {
|
||||
return this.component;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final ByteBuf buf) {
|
||||
super.write(buf);
|
||||
Types.TAG.write(buf, this.component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OverrideText copy() {
|
||||
return new OverrideText(this.component.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
-1
@@ -22,8 +22,10 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.item.data;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.codec.Ops;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.misc.HolderType;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public record BannerPattern(String assetId, String translationKey) {
|
||||
@@ -41,6 +43,17 @@ public record BannerPattern(String assetId, String translationKey) {
|
||||
Types.STRING.write(buffer, value.assetId);
|
||||
Types.STRING.write(buffer, value.translationKey);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void writeDirect(final Ops ops, final BannerPattern object) {
|
||||
ops.writeMap(map -> map
|
||||
.write("asset_id", Types.IDENTIFIER, Key.of(object.assetId))
|
||||
.write("translation_key", Types.STRING, object.translationKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Key identifier(final Ops ops, final int id) {
|
||||
return ops.context().registryAccess().registryKey("banner_pattern", id);
|
||||
}
|
||||
};
|
||||
}
|
||||
+8
@@ -23,6 +23,7 @@
|
||||
package com.viaversion.viaversion.api.minecraft.item.data;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.Holder;
|
||||
import com.viaversion.viaversion.api.minecraft.codec.Ops;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.ArrayType;
|
||||
@@ -43,6 +44,13 @@ public record BannerPatternLayer(Holder<BannerPattern> pattern, int dyeColor) {
|
||||
BannerPattern.TYPE.write(buffer, value.pattern);
|
||||
Types.VAR_INT.writePrimitive(buffer, value.dyeColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final Ops ops, final BannerPatternLayer value) {
|
||||
ops.writeMap(map -> map
|
||||
.write("pattern", BannerPattern.TYPE, value.pattern)
|
||||
.write("color", EnumTypes.DYE_COLOR, value.dyeColor));
|
||||
}
|
||||
};
|
||||
public static final Type<BannerPatternLayer[]> ARRAY_TYPE = new ArrayType<>(TYPE);
|
||||
|
||||
|
||||
Loaded 100 of 502 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user