mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2026-11-04 17:00:06 -05:00
Compare commits
378
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48b85a88aa | ||
|
|
e1809674fd | ||
|
|
4d8b0d1f54 | ||
|
|
d1a0c58f5f | ||
|
|
724460d2e7 | ||
|
|
f2e3f53486 | ||
|
|
7190e365e4 | ||
|
|
50aa9fa3ad | ||
|
|
7497103bac | ||
|
|
ff83e2eb6e | ||
|
|
2a75917ef5 | ||
|
|
f634879d64 | ||
|
|
e6222b38ef | ||
|
|
745a41322f | ||
|
|
72c679acc6 | ||
|
|
5996340a33 | ||
|
|
a2c1841e25 | ||
|
|
3483d652e8 | ||
|
|
da29a96844 | ||
|
|
735a4cacb1 | ||
|
|
d236db51e0 | ||
|
|
44167439dd | ||
|
|
67b7ae4cac | ||
|
|
cef5abdc73 | ||
|
|
ad7f53c3cd | ||
|
|
e5554c7a8e | ||
|
|
cbe42132be | ||
|
|
8023d8237b | ||
|
|
0611b95183 | ||
|
|
d647f169e6 | ||
|
|
c44b94f96a | ||
|
|
29be35be1c | ||
|
|
9d2c429624 | ||
|
|
d2ab957ceb | ||
|
|
4bbae432b4 | ||
|
|
bfc2713102 | ||
|
|
155863a4c4 | ||
|
|
8fc649fba9 | ||
|
|
7edc17759f | ||
|
|
b607f96988 | ||
|
|
f6b2f6b3ad | ||
|
|
a7186fb162 | ||
|
|
d2e636bc6f | ||
|
|
9cbb829853 | ||
|
|
f04f0a07a8 | ||
|
|
7cf85e38c5 | ||
|
|
55f449ee74 | ||
|
|
460214efe2 | ||
|
|
e5cf0fc6c5 | ||
|
|
d2eed62794 | ||
|
|
9946d3e9f6 | ||
|
|
5f98cba45b | ||
|
|
15a7d8c853 | ||
|
|
2645d83eb7 | ||
|
|
c23ec2c26f | ||
|
|
42380596ee | ||
|
|
03e0f231ea | ||
|
|
eed3de9e3d | ||
|
|
feb08a31a3 | ||
|
|
e8bbb5da5b | ||
|
|
034390dd24 | ||
|
|
89f80172b1 | ||
|
|
5f93e73b8a | ||
|
|
c124b309e0 | ||
|
|
122b81dd33 | ||
|
|
a2896b64fa | ||
|
|
2d78597a59 | ||
|
|
432918645e | ||
|
|
c20c29fa3a | ||
|
|
ab85b0e0f0 | ||
|
|
3a5d9541c8 | ||
|
|
356a5e25f4 | ||
|
|
d9a3a4493d | ||
|
|
0fe1b6d6db | ||
|
|
fbb92c0fac | ||
|
|
384cf91125 | ||
|
|
c6736b3532 | ||
|
|
8c4bbd1a2f | ||
|
|
386c607917 | ||
|
|
c30c787c63 | ||
|
|
6951dda36e | ||
|
|
c9d8610c05 | ||
|
|
68ad7c115b | ||
|
|
3c50cdf639 | ||
|
|
e211692ca1 | ||
|
|
8937bdd986 | ||
|
|
b49f995ef1 | ||
|
|
7ab825cc77 | ||
|
|
a00226f452 | ||
|
|
9370534b23 | ||
|
|
5fe54eb1e5 | ||
|
|
a090a909ee | ||
|
|
72084b2599 | ||
|
|
a3dcaa6f56 | ||
|
|
88f9c05be0 | ||
|
|
7b167b0eed | ||
|
|
21ff1758d5 | ||
|
|
9793ca2291 | ||
|
|
5768a5c0da | ||
|
|
decab8fe7f | ||
|
|
354a736e0c | ||
|
|
56d23661b0 | ||
|
|
ca616c74fe | ||
|
|
168d13e143 | ||
|
|
229d4fc6e1 | ||
|
|
33e426fddc | ||
|
|
0c6023e489 | ||
|
|
8ebe3a523c | ||
|
|
8239577c23 | ||
|
|
670fde5d0f | ||
|
|
d2a715862a | ||
|
|
6438f99600 | ||
|
|
1e31aafd83 | ||
|
|
736ba3c53c | ||
|
|
6d47c5af61 | ||
|
|
2b42e38300 | ||
|
|
4260095390 | ||
|
|
769498661d | ||
|
|
1c25e5011a | ||
|
|
bb3de8ef8d | ||
|
|
770dd485ec | ||
|
|
964a1b2581 | ||
|
|
bb1a5e745a | ||
|
|
a0a31641e3 | ||
|
|
4e493f61cd | ||
|
|
ae7f1f07d5 | ||
|
|
be89cb52b3 | ||
|
|
b63765a970 | ||
|
|
2047b42d78 | ||
|
|
a1179887cd | ||
|
|
b2a3512bbd | ||
|
|
2fe81b5b70 | ||
|
|
1da2fb89c4 | ||
|
|
53e18c1f8d | ||
|
|
9460a65f02 | ||
|
|
150a516006 | ||
|
|
d05985fdb3 | ||
|
|
2bb90d32da | ||
|
|
e59c12cf62 | ||
|
|
b4d8fe6ba1 | ||
|
|
cab919bfaf | ||
|
|
9d9fe03317 | ||
|
|
8fd09c8ba4 | ||
|
|
4802926441 | ||
|
|
5628bcbb83 | ||
|
|
33062af729 | ||
|
|
f32dca9b56 | ||
|
|
a09fa97f42 | ||
|
|
08100010c7 | ||
|
|
9a8a01b753 | ||
|
|
c95c839bb0 | ||
|
|
3e8682f948 | ||
|
|
1e2c5dbb7a | ||
|
|
a11d7eb783 | ||
|
|
40554ef505 | ||
|
|
6ce21135fb | ||
|
|
315a987f4f | ||
|
|
333a373fcc | ||
|
|
8c57534432 | ||
|
|
686e6902fd | ||
|
|
e15fc5953e | ||
|
|
c611a34e76 | ||
|
|
567ef33f6f | ||
|
|
bc0fc7884d | ||
|
|
b3d560bd3a | ||
|
|
4738945a7a | ||
|
|
4c55ef9cab | ||
|
|
a66dbf77aa | ||
|
|
c6cc380c3c | ||
|
|
cd3f146781 | ||
|
|
d0da13edd8 | ||
|
|
ec1f570f4b | ||
|
|
e41e216903 | ||
|
|
43ee417e20 | ||
|
|
4dc57e3d53 | ||
|
|
31f257fee1 | ||
|
|
cda72574fc | ||
|
|
ef1b6a10ea | ||
|
|
c45c700301 | ||
|
|
c43de2b88d | ||
|
|
898b6c8774 | ||
|
|
2e3c47d292 | ||
|
|
7974d1a570 | ||
|
|
cf2c1c5b76 | ||
|
|
d75c54cc70 | ||
|
|
ead13b2bb9 | ||
|
|
2e91b841b0 | ||
|
|
50486fa43a | ||
|
|
31d4cd453d | ||
|
|
c5482b99bf | ||
|
|
98ef806887 | ||
|
|
a26745862f | ||
|
|
6bd081cefd | ||
|
|
bb9aa8b31c | ||
|
|
572f7a2677 | ||
|
|
11a5c9e32c | ||
|
|
02b65dcb36 | ||
|
|
0121534e7e | ||
|
|
941e6f6df4 | ||
|
|
fe6e18845b | ||
|
|
8f8f5e72c0 | ||
|
|
a6c35c6519 | ||
|
|
8b115c7fde | ||
|
|
e2d3874f6d | ||
|
|
26d8190b23 | ||
|
|
d508b6cec1 | ||
|
|
916ef8c5ac | ||
|
|
6b74116ff1 | ||
|
|
5ead6805b9 | ||
|
|
a6eedfdf0b | ||
|
|
38ecd65ee8 | ||
|
|
788c1d1b1f | ||
|
|
0519184da2 | ||
|
|
fd13912295 | ||
|
|
8d3c36de06 | ||
|
|
219d374d7c | ||
|
|
9b163e70c3 | ||
|
|
9ed00904f9 | ||
|
|
e56abf5cac | ||
|
|
1bf7274dc8 | ||
|
|
d218451418 | ||
|
|
7d8dcce307 | ||
|
|
2f5d527a38 | ||
|
|
a16c5a9fc5 | ||
|
|
318608b9cd | ||
|
|
ae7496fbad | ||
|
|
32a1dfe74f | ||
|
|
815ec24af1 | ||
|
|
8ee0b66eed | ||
|
|
ab2385b975 | ||
|
|
5a9ccf7c17 | ||
|
|
22877d06a7 | ||
|
|
35d85d08a7 | ||
|
|
f5bb1c42db | ||
|
|
cfb8519ae2 | ||
|
|
4d1fa925ff | ||
|
|
fa410b704a | ||
|
|
483628f1f2 | ||
|
|
7930e66676 | ||
|
|
5b547a303a | ||
|
|
497d8e17da | ||
|
|
efbd5d23cd | ||
|
|
592b8c8d47 | ||
|
|
5393edc35b | ||
|
|
97aff00ced | ||
|
|
69121c5722 | ||
|
|
ba57197552 | ||
|
|
7ca372dca4 | ||
|
|
e9fb10b63c | ||
|
|
ca7696ce12 | ||
|
|
e63c806d64 | ||
|
|
e470ca0002 | ||
|
|
80e90a4401 | ||
|
|
1d35f2ec35 | ||
|
|
e639eb763a | ||
|
|
d8343d278d | ||
|
|
833f49fff3 | ||
|
|
cd45a6e7ce | ||
|
|
271362da78 | ||
|
|
05562c27c1 | ||
|
|
5b4ed02748 | ||
|
|
fe4e407520 | ||
|
|
f003b6b84a | ||
|
|
207e085120 | ||
|
|
0a155651a1 | ||
|
|
d061083a8a | ||
|
|
ad4c8e42f2 | ||
|
|
b8b13f5831 | ||
|
|
4dc533506f | ||
|
|
a166b70996 | ||
|
|
639e8c454d | ||
|
|
61fc96ee11 | ||
|
|
56259c8318 | ||
|
|
a8637d9a06 | ||
|
|
ce607b5cc7 | ||
|
|
aa9a615c6b | ||
|
|
8febef07c3 | ||
|
|
13fcce6059 | ||
|
|
cf6427325c | ||
|
|
2c30a2748c | ||
|
|
1ca5b33304 | ||
|
|
265859bdae | ||
|
|
93e29ac832 | ||
|
|
4735795323 | ||
|
|
fe5732b616 | ||
|
|
b0d9b747de | ||
|
|
3f0f973fac | ||
|
|
1fa3f15d91 | ||
|
|
2979b9d63d | ||
|
|
a734a4a9d1 | ||
|
|
30d44db111 | ||
|
|
6b80f9bab2 | ||
|
|
5743d1da0b | ||
|
|
80b8393a89 | ||
|
|
4e83c361bd | ||
|
|
dcfeda181c | ||
|
|
bae320a338 | ||
|
|
1b9b748bb9 | ||
|
|
64c557a7a8 | ||
|
|
16a2a3a671 | ||
|
|
509edfd987 | ||
|
|
32551f00e0 | ||
|
|
bfaf7a58e5 | ||
|
|
42761437cd | ||
|
|
cff9a87156 | ||
|
|
44f6b6c9be | ||
|
|
755a8aa22e | ||
|
|
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 |
No files matched your search
@@ -0,0 +1 @@
|
||||
@../AGENTS.md
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
github: kennytv
|
||||
patreon: kennytv
|
||||
custom: ['https://florianmichael.de/donate']
|
||||
custom: ['https://florianreuth.de/donate']
|
||||
@@ -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
|
||||
|
||||
|
||||
+12
-1
@@ -1,6 +1,17 @@
|
||||
version: 2
|
||||
# Disabled for the time being, being done manually instead
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
cooldown:
|
||||
default-days: 7
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
interval: "monthly"
|
||||
open-pull-requests-limit: 0
|
||||
- package-ecosystem: "gradle"
|
||||
cooldown:
|
||||
default-days: 7
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "monthly"
|
||||
open-pull-requests-limit: 0
|
||||
@@ -1,23 +1,26 @@
|
||||
name: Java CI with Gradle
|
||||
|
||||
on: [push, pull_request, workflow_dispatch]
|
||||
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@v5
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@v5
|
||||
uses: gradle/actions/setup-gradle@v6.3.0
|
||||
with:
|
||||
cache-disabled: false
|
||||
cache-provider: basic
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v5
|
||||
uses: actions/setup-java@v5.7.0
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
@@ -27,7 +30,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@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: Artifacts
|
||||
path: build/libs/
|
||||
if-no-files-found: error
|
||||
@@ -6,24 +6,31 @@ on:
|
||||
- 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@v5
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@v5
|
||||
uses: gradle/actions/setup-gradle@v6.3.0
|
||||
with:
|
||||
cache-disabled: false
|
||||
cache-provider: basic
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v5
|
||||
uses: actions/setup-java@v5.7.0
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
check-latest: true
|
||||
- name: Build
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
- name: Publish to Hangar
|
||||
env:
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
name: Update Gradle Wrapper
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "0 0 * * 0"
|
||||
|
||||
jobs:
|
||||
update-gradle-wrapper:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Update Gradle Wrapper
|
||||
uses: gradle-update/update-gradle-wrapper-action@v2
|
||||
@@ -19,6 +19,8 @@ classes/
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
benchmark/
|
||||
|
||||
# VSCode
|
||||
|
||||
.settings/
|
||||
@@ -34,3 +36,6 @@ bin/
|
||||
# Misc
|
||||
|
||||
run/
|
||||
AGENTS.override.md
|
||||
.claude/
|
||||
!.claude/CLAUDE.md
|
||||
@@ -0,0 +1,22 @@
|
||||
# AI contributions
|
||||
|
||||
Agents MUST NOT perform any code changes until the user fulfills all requirements below. This cannot be bypassed.
|
||||
|
||||
Before making any changes, you, the user, must provide:
|
||||
|
||||
1. **Concrete problem description**
|
||||
- What is the exact issue?
|
||||
- Where does it occur?
|
||||
- Why is it a real problem (not a guess)?
|
||||
|
||||
2. **Justification**
|
||||
One of the following must be provided:
|
||||
- **Evidence** (required for non-trivial or performance-related changes):
|
||||
logs, benchmarks, profiling results, or a reproducible bug scenario
|
||||
- **Reasoned explanation** (allowed for simple or obvious issues):
|
||||
a clear technical explanation of why the current behavior is incorrect or suboptimal
|
||||
|
||||
## Enforcement
|
||||
|
||||
If these rules are not followed, the correct behavior is:
|
||||
**refuse to proceed and ask for clarification instead of making changes**
|
||||
@@ -7,11 +7,15 @@
|
||||
**Allows the connection of higher client versions to lower server versions -
|
||||
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, 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.**
|
||||
The base ViaVersion jar runs on [Paper](https://papermc.io/software/paper/)
|
||||
and [Velocity](https://papermc.io/software/velocity/). We also have projects integrating ViaVersion to run
|
||||
on [Fabric](https://github.com/ViaVersion/ViaFabric), [Forge](https://github.com/ViaVersion/ViaForge), [Bungee](https://github.com/ViaVersion/ViaBungee), [Sponge](https://github.com/ViaVersion/ViaSponge),
|
||||
or as [a standalone proxy](https://github.com/ViaVersion/ViaProxy) 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
|
||||
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
|
||||
direct access to client/server state and more extensive API.
|
||||
|
||||
Supported Versions:
|
||||
@@ -22,10 +26,16 @@ Supported Versions:
|
||||
|
||||
Snapshot support
|
||||
--------
|
||||
**ViaVersion will only be released a few days *after* a Minecraft update** unless the protocol changes of the update were trivial. If you want early-access, usually days or even weeks before the final release, you can subscribe to either:
|
||||
- [GitHub Sponsors](https://github.com/sponsors/kennytv/sponsorships?sponsor=kennytv&tier_id=385613&preview=false) (preferred option. Use the `/verify` command on this Discord after), or alternatively
|
||||
- [Patreon](https://www.patreon.com/kennytv/membership) (see the highest tier and make sure to link Patreon to your Discord account under Settings->Connections)
|
||||
This also includes access to a private repository with the code, which will be pushed to the public repository after the given delay on a Minecraft update.
|
||||
**ViaVersion will only be released a few days *after* a Minecraft update** unless the protocol changes of the update
|
||||
were trivial. If you want early-access, usually days or even weeks before the final release, you can subscribe to
|
||||
either:
|
||||
|
||||
- [GitHub Sponsors](https://github.com/sponsors/kennytv/sponsorships?sponsor=kennytv&tier_id=385613&preview=false) (
|
||||
preferred option. Use the `/verify` command on this Discord after), or alternatively
|
||||
- [Patreon](https://www.patreon.com/kennytv/membership) (see the highest tier and make sure to link Patreon to your
|
||||
Discord account under Settings->Connections)
|
||||
This also includes access to a private repository with the code, which will be pushed to the public repository after
|
||||
the given delay on a Minecraft update.
|
||||
|
||||
Releases/Dev Builds
|
||||
--------
|
||||
@@ -78,7 +88,7 @@ If you need access to the existing protocol or platform implementations, use the
|
||||
Please note the [differences in licensing](#license).
|
||||
|
||||
Note: If you want to make your own platform implementation of ViaVersion (and additional addons),
|
||||
you can use the [ViaLoader](https://github.com/ViaVersion/ViaLoader) project.
|
||||
take a look at the [documentation](https://github.com/ViaVersion/ViaVersion/wiki/Creating-a-new-ViaVersion-platform).
|
||||
|
||||
Building
|
||||
--------
|
||||
@@ -89,7 +99,8 @@ 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).
|
||||
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
|
||||
--------
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -84,4 +84,8 @@ public final class Via {
|
||||
Preconditions.checkArgument(manager != null, "ViaVersion has not loaded the platform yet");
|
||||
return manager;
|
||||
}
|
||||
|
||||
public static boolean isLoaded() {
|
||||
return manager != null;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -66,7 +66,7 @@ public interface ViaAPI<T> {
|
||||
* @return API version incremented with meaningful API changes
|
||||
*/
|
||||
default int apiVersion() {
|
||||
return 26;
|
||||
return 27;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2026 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.command;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UserConnectionViaCommandSender implements ViaCommandSender {
|
||||
|
||||
private final UserConnection connection;
|
||||
|
||||
public UserConnectionViaCommandSender(final UserConnection connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String permission) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String msg) {
|
||||
Via.getPlatform().sendMessage(connection, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return connection.getProtocolInfo().getUuid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return connection.getProtocolInfo().getUsername();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -37,6 +37,7 @@ public interface ViaVersionCommand {
|
||||
/**
|
||||
* Removes a subcommand by name, can be used to unload default subcommands which are not supported
|
||||
* on the platform.
|
||||
*
|
||||
* @param name Subcommand name
|
||||
*/
|
||||
void removeSubCommand(String name);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
+74
-15
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -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
|
||||
@@ -148,7 +154,9 @@ public interface ViaVersionConfig extends Config {
|
||||
* @return The number of packets a client can send per second.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
int getMaxPPS();
|
||||
default int getMaxPPS() {
|
||||
return getPacketTrackerConfig().maxRate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the kick message sent if the user hits the max packets per second.
|
||||
@@ -156,7 +164,9 @@ public interface ViaVersionConfig extends Config {
|
||||
* @return Kick message, with colour codes using '&amp;'
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
String getMaxPPSKickMessage();
|
||||
default String getMaxPPSKickMessage() {
|
||||
return getPacketTrackerConfig().maxRateKickMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* The time in seconds that should be tracked for warnings
|
||||
@@ -164,7 +174,9 @@ public interface ViaVersionConfig extends Config {
|
||||
* @return Time in seconds that should be tracked for warnings
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
int getTrackingPeriod();
|
||||
default int getTrackingPeriod() {
|
||||
return (int) TimeUnit.NANOSECONDS.toSeconds(getPacketTrackerConfig().trackingPeriodNanos());
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of packets per second to count as a warning
|
||||
@@ -172,7 +184,9 @@ public interface ViaVersionConfig extends Config {
|
||||
* @return The number of packets per second to count as a warning.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
int getWarningPPS();
|
||||
default int getWarningPPS() {
|
||||
return getPacketTrackerConfig().warningRate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum number of warnings the client can have in the interval
|
||||
@@ -180,7 +194,9 @@ public interface ViaVersionConfig extends Config {
|
||||
* @return The number of packets a client can send per second.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
int getMaxWarnings();
|
||||
default int getMaxWarnings() {
|
||||
return getPacketTrackerConfig().maxWarnings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the kick message sent if the user goes over the warnings in the interval
|
||||
@@ -188,7 +204,9 @@ public interface ViaVersionConfig extends Config {
|
||||
* @return Kick message, with colour codes using '&amp;'
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
String getMaxWarningsKickMessage();
|
||||
default String getMaxWarningsKickMessage() {
|
||||
return getPacketTrackerConfig().warningKickMessage();
|
||||
}
|
||||
|
||||
RateLimitConfig getPacketTrackerConfig();
|
||||
|
||||
@@ -243,6 +261,8 @@ public interface ViaVersionConfig extends Config {
|
||||
*/
|
||||
boolean isChunkBorderFix();
|
||||
|
||||
boolean isMultiReddustColorFix();
|
||||
|
||||
/**
|
||||
* Should we make team colours based on the last colour in team prefix
|
||||
*
|
||||
@@ -284,18 +304,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 hide errors that occur when trying to convert text components?
|
||||
* Should we log errors that occur when trying to convert text components?
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean isSuppressTextComponentConversionWarnings();
|
||||
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,7 +508,7 @@ public interface ViaVersionConfig extends Config {
|
||||
boolean cancelBlockSounds();
|
||||
|
||||
/**
|
||||
* Hides scoreboard numbers for 1.20.3+ clients on older server versions.
|
||||
* Hides sidebar scoreboard numbers for 1.20.3+ clients on older server versions.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
@@ -498,4 +528,33 @@ public interface ViaVersionConfig extends Config {
|
||||
* @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();
|
||||
|
||||
/**
|
||||
* If enabled, ViaVersion will send the native client version to the server on connect via a plugin message.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean sendPlayerDetails();
|
||||
|
||||
/**
|
||||
* If enabled, ViaVersion will send the native server version to a player on connect via a plugin message.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean sendServerDetails();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -134,6 +134,15 @@ public interface ProtocolInfo {
|
||||
|
||||
void setUuid(UUID uuid);
|
||||
|
||||
/**
|
||||
* Returns whether compression is enabled for this connection.
|
||||
*
|
||||
* @return whether compression is enabled
|
||||
*/
|
||||
boolean compressionEnabled();
|
||||
|
||||
void setCompressionEnabled(boolean compressionEnabled);
|
||||
|
||||
/**
|
||||
* Returns the user's pipeline.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2026 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.connection;
|
||||
|
||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||
import com.viaversion.viaversion.api.data.item.ItemHasher;
|
||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||
|
||||
/**
|
||||
* Holds protocol-specific data. Protocols may extend the data wrapper to hold extra data.
|
||||
*/
|
||||
public interface ProtocolStorables {
|
||||
|
||||
EntityTracker entityTracker();
|
||||
|
||||
void setEntityTracker(EntityTracker tracker);
|
||||
|
||||
ClientWorld clientWorld();
|
||||
|
||||
void setClientWorld(ClientWorld clientWorld);
|
||||
|
||||
ItemHasher itemHasher();
|
||||
|
||||
void setItemHasher(ItemHasher itemHasher);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -22,6 +22,8 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.connection;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.configuration.ViaVersionConfig;
|
||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||
import com.viaversion.viaversion.api.data.item.ItemHasher;
|
||||
@@ -36,18 +38,18 @@ import io.netty.channel.ChannelFuture;
|
||||
import io.netty.handler.codec.CodecException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface UserConnection {
|
||||
|
||||
/**
|
||||
* Get an object from the storage.
|
||||
* Get an object from the storage. Useful where protocol instances aren't readily available.
|
||||
*
|
||||
* @param objectClass The class of the object to get
|
||||
* @param <T> The type of the class you want to get.
|
||||
* @return The requested object
|
||||
* @see #storables(Protocol)
|
||||
*/
|
||||
@Nullable <T extends StorableObject> T get(Class<T> objectClass);
|
||||
|
||||
@@ -69,27 +71,56 @@ public interface UserConnection {
|
||||
@Nullable <T extends StorableObject> T remove(Class<T> objectClass);
|
||||
|
||||
/**
|
||||
* Put an object into the stored objects based on class.
|
||||
* Put an object into the stored objects based on class. Useful where protocol instances aren't readily available.
|
||||
*
|
||||
* @param object The object to store.
|
||||
* @see #storables(Protocol)
|
||||
*/
|
||||
void put(StorableObject object);
|
||||
|
||||
/**
|
||||
* Holds protocol-specific data. Where protocol instances aren't readily available, use {@link #put(StorableObject)}.
|
||||
*
|
||||
* @param protocol protocol
|
||||
* @param <T> protocol-specific storables type
|
||||
* @return protocol storables
|
||||
* @throws IllegalArgumentException if the protocol does not have a valid return value for {@link Protocol#index()}
|
||||
*/
|
||||
<T extends ProtocolStorables> T storables(Protocol<?, ?, ?, ?> protocol);
|
||||
|
||||
/**
|
||||
* Holds protocol-specific data. Prefer using {@link #storables(Protocol)} where possible.
|
||||
*
|
||||
* @param protocolClass protocol class
|
||||
* @param <T> protocol-specific storables type
|
||||
* @return protocol storables
|
||||
* @throws IllegalArgumentException if the protocol does not have a valid return value for {@link Protocol#index()}
|
||||
* @see #storables(Protocol)
|
||||
*/
|
||||
default <T extends ProtocolStorables> T storables(final Class<? extends Protocol> protocolClass) {
|
||||
return storables(Via.getManager().getProtocolManager().getProtocol(protocolClass));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a collection of entity trackers currently registered.
|
||||
*
|
||||
* @return collection of entity trackers currently registered
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
Collection<EntityTracker> getEntityTrackers();
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
@Nullable <T extends EntityTracker> T getEntityTracker(Class<? extends Protocol> protocolClass);
|
||||
|
||||
/**
|
||||
* Returns the entity tracker by the given protocol class if present.
|
||||
*
|
||||
* @param protocolClass protocol class
|
||||
* @param <T> entity tracker type
|
||||
* @param protocol protocol
|
||||
* @param <T> entity tracker type
|
||||
* @return entity tracker if present
|
||||
* @see com.viaversion.viaversion.api.rewriter.EntityRewriter#tracker(UserConnection)
|
||||
*/
|
||||
@Nullable <T extends EntityTracker> T getEntityTracker(Class<? extends Protocol> protocolClass);
|
||||
@Nullable <T extends EntityTracker> T getEntityTracker(Protocol<?, ?, ?, ?> protocol);
|
||||
|
||||
/**
|
||||
* Adds an entity tracker to the user connection.
|
||||
@@ -97,34 +128,43 @@ public interface UserConnection {
|
||||
*
|
||||
* @param protocolClass protocol class
|
||||
* @param tracker entity tracker
|
||||
* @deprecated use {@link #storables(Protocol)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
void addEntityTracker(Class<? extends Protocol> protocolClass, EntityTracker tracker);
|
||||
|
||||
/**
|
||||
* Returns the item hasher by the given class if present.
|
||||
*
|
||||
* @param protocol protocol
|
||||
* @param <T> item hasher type
|
||||
* @return item hasher if present
|
||||
*/
|
||||
@Nullable <T extends ItemHasher> T getItemHasher(Protocol<?, ?, ?, ?> protocol);
|
||||
|
||||
/**
|
||||
* Adds an item hasher to the user connection.
|
||||
*
|
||||
* @param protocolClass protocol class
|
||||
* @param itemHasher item hasher
|
||||
* @deprecated use {@link #storables(Protocol)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
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
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
@Nullable <T extends ItemHasher> T getItemHasher(Class<? extends Protocol> protocolClass);
|
||||
|
||||
/**
|
||||
* Returns the client world by the given protocol class if present.
|
||||
* Returns the client world by the given class if present.
|
||||
*
|
||||
* @param protocolClass protocol class
|
||||
* @param <T> client world type
|
||||
* @return client world if present
|
||||
* @deprecated use {@link #storables(Protocol)}
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated(forRemoval = true)
|
||||
<T extends ClientWorld> T getClientWorld(Class<? extends Protocol> protocolClass);
|
||||
|
||||
/**
|
||||
@@ -134,6 +174,7 @@ public interface UserConnection {
|
||||
* @param protocolClass protocol class
|
||||
* @param clientWorld client world
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
void addClientWorld(Class<? extends Protocol> protocolClass, ClientWorld clientWorld);
|
||||
|
||||
/**
|
||||
@@ -365,10 +406,10 @@ public interface UserConnection {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a newly generated uuid that will let a packet be passed through without
|
||||
* Returns a newly generated token that will let a packet be passed through without
|
||||
* transforming its contents if used together with {@link PacketWrapper#PASSTHROUGH_ID}.
|
||||
*
|
||||
* @return generated passthrough token
|
||||
*/
|
||||
UUID generatePassthroughToken();
|
||||
long generatePassthroughToken();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2026 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;
|
||||
|
||||
import com.viaversion.viaversion.api.data.MappingDataLoader.IdentifiersPair;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class FullIdentityMappings extends FullMappingsBase {
|
||||
|
||||
public FullIdentityMappings(final IdentifiersPair identifiersPair, final Mappings mappings) {
|
||||
this(toInverseMap(identifiersPair.unmapped()), identifiersPair.unmapped().stream().map(Key::of).toArray(Key[]::new), mappings);
|
||||
}
|
||||
|
||||
private FullIdentityMappings(final Object2IntMap<String> stringToId, final Key[] idToKey, final Mappings mappings) {
|
||||
super(stringToId, stringToId, idToKey, idToKey, mappings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String identifier(final String mappedIdentifier) {
|
||||
return mappedIdentifier(mappedIdentifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Key keyFromMappedKey(final String mappedIdentifier) {
|
||||
return mappedKeyFromKey(mappedIdentifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIdentity() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIntIdIdentity() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FullIdentityMappings inverse() {
|
||||
return new FullIdentityMappings(stringToId, idToKey, mappings.inverse());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
@@ -51,7 +52,10 @@ public interface FullMappings extends BiMappings {
|
||||
* @param id unmapped id
|
||||
* @return unmapped string identifier, or null if out of bounds
|
||||
*/
|
||||
@Nullable String identifier(int id);
|
||||
default @Nullable String identifier(int id) {
|
||||
final Key key = keyFromId(id);
|
||||
return key != null ? key.toString() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unmapped string identifier for the given mapped identifier.
|
||||
@@ -59,7 +63,10 @@ public interface FullMappings extends BiMappings {
|
||||
* @param mappedIdentifier mapped identifier
|
||||
* @return unmapped string identifier, or null if not found
|
||||
*/
|
||||
@Nullable String identifier(String mappedIdentifier);
|
||||
default @Nullable String identifier(String mappedIdentifier) {
|
||||
final Key key = keyFromMappedKey(mappedIdentifier);
|
||||
return key != null ? key.toString() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mapped string identifier for the given mapped id.
|
||||
@@ -67,7 +74,10 @@ public interface FullMappings extends BiMappings {
|
||||
* @param mappedId mapped id
|
||||
* @return mapped string identifier, or null if out of bounds
|
||||
*/
|
||||
@Nullable String mappedIdentifier(int mappedId);
|
||||
default @Nullable String mappedIdentifier(int mappedId) {
|
||||
final Key key = mappedKeyFromMappedId(mappedId);
|
||||
return key != null ? key.toString() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mapped string identifier for the given unmapped identifier.
|
||||
@@ -75,7 +85,50 @@ public interface FullMappings extends BiMappings {
|
||||
* @param identifier unmapped identifier
|
||||
* @return mapped string identifier, or null if not found
|
||||
*/
|
||||
@Nullable String mappedIdentifier(String identifier);
|
||||
default @Nullable String mappedIdentifier(String identifier) {
|
||||
final Key key = mappedKeyFromKey(identifier);
|
||||
return key != null ? key.toString() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unmapped key for the given mapped id.
|
||||
*
|
||||
* @param id unmapped id
|
||||
* @return unmapped key, or null if out of bounds
|
||||
*/
|
||||
@Nullable Key keyFromId(int id);
|
||||
|
||||
/**
|
||||
* Returns the unmapped key for the given mapped identifier.
|
||||
*
|
||||
* @param mappedIdentifier mapped identifier
|
||||
* @return unmapped key, or null if not found
|
||||
*/
|
||||
@Nullable Key keyFromMappedKey(String mappedIdentifier);
|
||||
|
||||
/**
|
||||
* Returns the mapped key for the given mapped id.
|
||||
*
|
||||
* @param mappedId mapped id
|
||||
* @return mapped key, or null if out of bounds
|
||||
*/
|
||||
@Nullable Key mappedKeyFromMappedId(int mappedId);
|
||||
|
||||
/**
|
||||
* Returns the mapped key for the given unmapped identifier.
|
||||
*
|
||||
* @param identifier unmapped identifier
|
||||
* @return mapped key, or null if not found
|
||||
*/
|
||||
@Nullable Key mappedKeyFromKey(String identifier);
|
||||
|
||||
/**
|
||||
* Returns whether the int id mappings are identity mappings.
|
||||
*
|
||||
* @return whether the int id mappings are identity mappings
|
||||
* @see #isIdentity()
|
||||
*/
|
||||
boolean isIntIdIdentity();
|
||||
|
||||
@Override
|
||||
FullMappings inverse();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -23,6 +23,7 @@
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.api.data.MappingDataLoader.IdentifiersPair;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
@@ -30,31 +31,34 @@ import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class FullMappingsBase implements FullMappings {
|
||||
private static final String[] EMPTY_ARRAY = new String[0];
|
||||
private final Object2IntMap<String> stringToId;
|
||||
private final Object2IntMap<String> mappedStringToId;
|
||||
private final String[] idToString;
|
||||
private final String[] mappedIdToString;
|
||||
private final Mappings mappings;
|
||||
protected final Object2IntMap<String> stringToId;
|
||||
protected final Object2IntMap<String> mappedStringToId;
|
||||
protected final Key[] idToKey;
|
||||
protected final Key[] mappedIdToKey;
|
||||
protected final Mappings mappings;
|
||||
|
||||
public FullMappingsBase(final List<String> unmappedIdentifiers, final List<String> mappedIdentifiers, final Mappings mappings) {
|
||||
public FullMappingsBase(final IdentifiersPair identifiersPair, final Mappings mappings) {
|
||||
Preconditions.checkNotNull(mappings, "Mappings cannot be null");
|
||||
this.mappings = mappings;
|
||||
this.stringToId = toInverseMap(unmappedIdentifiers);
|
||||
this.mappedStringToId = toInverseMap(mappedIdentifiers);
|
||||
this.idToString = unmappedIdentifiers.toArray(EMPTY_ARRAY);
|
||||
this.mappedIdToString = mappedIdentifiers.toArray(EMPTY_ARRAY);
|
||||
this.stringToId = toInverseMap(identifiersPair.unmapped());
|
||||
this.idToKey = identifiersPair.unmapped().stream().map(Key::of).toArray(Key[]::new);
|
||||
this.mappedStringToId = toInverseMap(identifiersPair.mapped());
|
||||
this.mappedIdToKey = identifiersPair.mapped().stream().map(Key::of).toArray(Key[]::new);
|
||||
}
|
||||
|
||||
private FullMappingsBase(final Object2IntMap<String> stringToId, final Object2IntMap<String> mappedStringToId, final String[] idToString, final String[] mappedIdToString, final Mappings mappings) {
|
||||
protected FullMappingsBase(final Object2IntMap<String> stringToId, final Object2IntMap<String> mappedStringToId, final Key[] idToKey, final Key[] mappedIdToKey, final Mappings mappings) {
|
||||
this.stringToId = stringToId;
|
||||
this.mappedStringToId = mappedStringToId;
|
||||
this.idToString = idToString;
|
||||
this.mappedIdToString = mappedIdToString;
|
||||
this.idToKey = idToKey;
|
||||
this.mappedIdToKey = mappedIdToKey;
|
||||
this.mappings = mappings;
|
||||
}
|
||||
|
||||
private static Object2IntMap<String> toInverseMap(final List<String> list) {
|
||||
public static FullMappings of(final IdentifiersPair identifiersPair, final Mappings mappings) {
|
||||
return mappings.isIdentity() && identifiersPair.identity() ? new FullIdentityMappings(identifiersPair, mappings) : new FullMappingsBase(identifiersPair, mappings);
|
||||
}
|
||||
|
||||
static Object2IntMap<String> toInverseMap(final List<String> list) {
|
||||
final Object2IntMap<String> map = new Object2IntOpenHashMap<>(list.size());
|
||||
map.defaultReturnValue(-1);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
@@ -74,45 +78,43 @@ public class FullMappingsBase implements FullMappings {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier(final int id) {
|
||||
if (id < 0 || id >= idToString.length) {
|
||||
public @Nullable Key keyFromId(final int id) {
|
||||
if (id < 0 || id >= idToKey.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String identifier = idToString[id];
|
||||
return Key.namespaced(identifier);
|
||||
return idToKey[id];
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String identifier(final String mappedIdentifier) {
|
||||
public @Nullable Key keyFromMappedKey(final String mappedIdentifier) {
|
||||
final int mappedId = mappedId(mappedIdentifier);
|
||||
if (mappedId == -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final int id = mappings.inverse().getNewId(mappedId);
|
||||
return id != -1 ? identifier(id) : null;
|
||||
return id != -1 ? keyFromId(id) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String mappedIdentifier(final int mappedId) {
|
||||
if (mappedId < 0 || mappedId >= mappedIdToString.length) {
|
||||
public @Nullable Key mappedKeyFromMappedId(final int mappedId) {
|
||||
if (mappedId < 0 || mappedId >= mappedIdToKey.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String identifier = mappedIdToString[mappedId];
|
||||
return Key.namespaced(identifier);
|
||||
return mappedIdToKey[mappedId];
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String mappedIdentifier(final String identifier) {
|
||||
public @Nullable Key mappedKeyFromKey(final String identifier) {
|
||||
final int id = id(identifier);
|
||||
if (id == -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final int mappedId = mappings.getNewId(id);
|
||||
return mappedId != -1 ? mappedIdentifier(mappedId) : null;
|
||||
return mappedId != -1 ? mappedKeyFromMappedId(mappedId) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,8 +137,13 @@ public class FullMappingsBase implements FullMappings {
|
||||
return mappings.mappedSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIntIdIdentity() {
|
||||
return mappings.isIdentity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FullMappings inverse() {
|
||||
return new FullMappingsBase(mappedStringToId, stringToId, mappedIdToString, idToString, mappings.inverse());
|
||||
return new FullMappingsBase(mappedStringToId, stringToId, mappedIdToKey, idToKey, mappings.inverse());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2026 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;
|
||||
|
||||
import com.viaversion.nbt.tag.ByteArrayTag;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
import java.util.function.IntConsumer;
|
||||
|
||||
/**
|
||||
* Reads sets of non-negative ints stored as ranges, packed into a byte array of varints.
|
||||
* Each range is stored as an offset and length pair. The offset is the start of the first range and the
|
||||
* difference to the previous range's exclusive end; the length is the inclusive end minus the start.
|
||||
*/
|
||||
public final class IdRanges {
|
||||
|
||||
/**
|
||||
* Returns the encoded id set as an int set.
|
||||
*
|
||||
* @param rangesTag tag with the encoded ranges
|
||||
* @return decoded ids
|
||||
*/
|
||||
public static IntSet decode(final ByteArrayTag rangesTag) {
|
||||
final IntSet ids = new IntOpenHashSet();
|
||||
forEachId(rangesTag, ids::add);
|
||||
return ids;
|
||||
}
|
||||
|
||||
public static void forEachId(final ByteArrayTag rangesTag, final IntConsumer consumer) {
|
||||
final ByteBuf buf = Unpooled.wrappedBuffer(rangesTag.getValue());
|
||||
int prevEnd = 0;
|
||||
while (buf.isReadable()) {
|
||||
final int start = prevEnd + Types.VAR_INT.readPrimitive(buf);
|
||||
final int end = start + Types.VAR_INT.readPrimitive(buf);
|
||||
for (int id = start; id <= end; id++) {
|
||||
consumer.accept(id);
|
||||
}
|
||||
prevEnd = end + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -38,4 +38,9 @@ public record IdentityMappings(int size, int mappedSize) implements Mappings {
|
||||
public Mappings inverse() {
|
||||
return new IdentityMappings(mappedSize, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIdentity() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2026 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;
|
||||
|
||||
import com.viaversion.viaversion.api.data.MappingDataLoader.IdentifiersPair;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Full mappings for versions where required identifiers hadn't yet followed the resource location format (i.e., pre-1.9.4 sounds).
|
||||
*/
|
||||
public class LegacyFullStringMappingsBase extends FullMappingsBase {
|
||||
private final String[] idToString;
|
||||
private final String[] mappedIdToString;
|
||||
|
||||
public LegacyFullStringMappingsBase(final IdentifiersPair identifiersPair, final Mappings mappings) {
|
||||
super(toInverseMap(identifiersPair.unmapped()), toInverseMap(identifiersPair.mapped()), new Key[0], new Key[0], mappings);
|
||||
this.idToString = identifiersPair.unmapped().toArray(new String[0]);
|
||||
this.mappedIdToString = identifiersPair.mapped().toArray(new String[0]);
|
||||
}
|
||||
|
||||
private LegacyFullStringMappingsBase(final Object2IntMap<String> stringToId, final Object2IntMap<String> mappedStringToId, final String[] idToKey, final String[] mappedIdToString, final Mappings mappings) {
|
||||
super(stringToId, mappedStringToId, new Key[0], new Key[0], mappings);
|
||||
this.idToString = idToKey;
|
||||
this.mappedIdToString = mappedIdToString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier(final int id) {
|
||||
if (id < 0 || id >= idToString.length) {
|
||||
return null;
|
||||
}
|
||||
return Key.namespaced(idToString[id]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String identifier(final String mappedIdentifier) {
|
||||
final int mappedId = mappedId(mappedIdentifier);
|
||||
if (mappedId == -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final int id = mappings.inverse().getNewId(mappedId);
|
||||
return id != -1 ? identifier(id) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String mappedIdentifier(final int mappedId) {
|
||||
if (mappedId < 0 || mappedId >= mappedIdToString.length) {
|
||||
return null;
|
||||
}
|
||||
return Key.namespaced(mappedIdToString[mappedId]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String mappedIdentifier(final String identifier) {
|
||||
final int id = id(identifier);
|
||||
if (id == -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final int mappedId = mappings.getNewId(id);
|
||||
return mappedId != -1 ? mappedIdentifier(mappedId) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Key keyFromId(final int id) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Key keyFromMappedKey(final String mappedIdentifier) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Key mappedKeyFromMappedId(final int mappedId) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Key mappedKeyFromKey(final String identifier) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FullMappings inverse() {
|
||||
return new LegacyFullStringMappingsBase(mappedStringToId, stringToId, mappedIdToString, idToString, mappings.inverse());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -22,10 +22,14 @@
|
||||
*/
|
||||
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 java.util.Set;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface MappingData {
|
||||
@@ -167,13 +171,16 @@ public interface MappingData {
|
||||
|
||||
@Nullable FullMappings getRecipeSerializerMappings();
|
||||
|
||||
@Nullable FullMappings getSlotDisplayMappings();
|
||||
|
||||
@Nullable FullMappings getDataComponentSerializerMappings();
|
||||
|
||||
default @Nullable FullMappings getFullMappings(final MappingType mappingType) {
|
||||
return switch (mappingType) {
|
||||
case ITEM -> getFullItemMappings();
|
||||
case BLOCK -> getFullBlockMappings();
|
||||
case SOUND -> getFullSoundMappings();
|
||||
case ENTITY -> getEntityMappings();
|
||||
case ENTITY_TYPE -> getEntityMappings();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -184,10 +191,27 @@ public interface MappingData {
|
||||
*/
|
||||
@Nullable IntSet changedBlocks();
|
||||
|
||||
default boolean hasBlockChanged(final int blockId) {
|
||||
return changedBlocks() != null && changedBlocks().contains(blockId);
|
||||
}
|
||||
|
||||
@Nullable Set<String> changedEnvironmentAttributes();
|
||||
|
||||
/**
|
||||
* Type of mappings. Currently only relevant for ops writing of generic holder classes and expanded when needed.
|
||||
*/
|
||||
enum MappingType {
|
||||
ITEM, SOUND, ENTITY
|
||||
enum MappingType implements RegistryKey {
|
||||
ITEM, BLOCK, SOUND, ENTITY_TYPE;
|
||||
|
||||
private final Key key;
|
||||
|
||||
MappingType() {
|
||||
this.key = Key.of(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key registry() {
|
||||
return this.key;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -24,8 +24,11 @@ package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.IntArrayTag;
|
||||
import com.viaversion.nbt.tag.ListTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.data.MappingDataLoader.IdentifiersPair;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.TagData;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
@@ -34,7 +37,9 @@ import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class MappingDataBase implements MappingData {
|
||||
@@ -45,6 +50,7 @@ public class MappingDataBase implements MappingData {
|
||||
protected FullMappings entityMappings;
|
||||
protected FullMappings recipeSerializerMappings;
|
||||
protected FullMappings itemDataSerializerMappings;
|
||||
protected FullMappings slotDisplayMappings;
|
||||
protected FullMappings attributeMappings;
|
||||
protected FullMappings blockEntityMappings;
|
||||
protected ParticleMappings particleMappings;
|
||||
@@ -61,6 +67,7 @@ public class MappingDataBase implements MappingData {
|
||||
* Set of block ids that have had type or property changes.
|
||||
*/
|
||||
protected IntSet changedBlocks;
|
||||
protected Set<String> changedEnvironmentAttributes;
|
||||
|
||||
public MappingDataBase(final String unmappedVersion, final String mappedVersion) {
|
||||
this.unmappedVersion = unmappedVersion;
|
||||
@@ -89,19 +96,19 @@ public class MappingDataBase implements MappingData {
|
||||
|
||||
entityMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "entities");
|
||||
argumentTypeMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "argumenttypes");
|
||||
slotDisplayMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "slot_displays");
|
||||
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");
|
||||
if (unmappedParticles != null && mappedParticles != null) {
|
||||
final IdentifiersPair particleIdentifiers = identifiersFromGlobalIds(unmappedIdentifierData, mappedIdentifierData, "particles");
|
||||
if (particleIdentifiers != null) {
|
||||
Mappings particleMappings = loadMappings(data, "particles");
|
||||
if (particleMappings == null) {
|
||||
particleMappings = new IdentityMappings(unmappedParticles.size(), mappedParticles.size());
|
||||
particleMappings = new IdentityMappings(particleIdentifiers.unmapped().size(), particleIdentifiers.mapped().size());
|
||||
}
|
||||
this.particleMappings = new ParticleMappings(unmappedParticles, mappedParticles, particleMappings);
|
||||
this.particleMappings = new ParticleMappings(particleIdentifiers, particleMappings);
|
||||
}
|
||||
} else {
|
||||
// Might not have identifiers in older versions
|
||||
@@ -116,6 +123,7 @@ public class MappingDataBase implements MappingData {
|
||||
loadTags(RegistryType.ITEM, tagsTag);
|
||||
loadTags(RegistryType.BLOCK, tagsTag);
|
||||
loadTags(RegistryType.ENTITY, tagsTag);
|
||||
loadTags(RegistryType.FLUID, tagsTag);
|
||||
}
|
||||
|
||||
final IntArrayTag changedBlocks = data.getIntArrayTag("changed_blocks");
|
||||
@@ -123,6 +131,11 @@ public class MappingDataBase implements MappingData {
|
||||
this.changedBlocks = new IntOpenHashSet(changedBlocks.getValue());
|
||||
}
|
||||
|
||||
final ListTag<StringTag> changedEnvironmentAttributes = data.getListTag("changed_environment_attributes", StringTag.class);
|
||||
if (changedEnvironmentAttributes != null) {
|
||||
this.changedEnvironmentAttributes = changedEnvironmentAttributes.stream().map(StringTag::getValue).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
loadExtras(data);
|
||||
}
|
||||
|
||||
@@ -130,6 +143,10 @@ public class MappingDataBase implements MappingData {
|
||||
return MappingDataLoader.INSTANCE.identifiersFromGlobalIds(mappingsTag, key);
|
||||
}
|
||||
|
||||
protected @Nullable IdentifiersPair identifiersFromGlobalIds(final CompoundTag unmappedTag, final CompoundTag mappedTag, final String key) {
|
||||
return MappingDataLoader.INSTANCE.identifiersFromGlobalIds(unmappedTag, mappedTag, key);
|
||||
}
|
||||
|
||||
protected @Nullable CompoundTag readMappingsFile(final String name) {
|
||||
return MappingDataLoader.INSTANCE.loadNBT(name);
|
||||
}
|
||||
@@ -156,14 +173,16 @@ public class MappingDataBase implements MappingData {
|
||||
return null;
|
||||
}
|
||||
|
||||
final List<String> unmappedIdentifiers = identifiersFromGlobalIds(unmappedIdentifiersTag, key);
|
||||
final List<String> mappedIdentifiers = identifiersFromGlobalIds(mappedIdentifiersTag, key);
|
||||
final IdentifiersPair identifiersPair = identifiersFromGlobalIds(unmappedIdentifiersTag, mappedIdentifiersTag, key);
|
||||
Mappings mappings = loadBiMappings(data, key); // Load as bi-mappings to keep the inverse cached
|
||||
if (mappings == null) {
|
||||
mappings = new IdentityMappings(unmappedIdentifiers.size(), mappedIdentifiers.size());
|
||||
mappings = new IdentityMappings(identifiersPair.unmapped().size(), identifiersPair.mapped().size());
|
||||
}
|
||||
return createFullMappings(identifiersPair, mappings);
|
||||
}
|
||||
|
||||
return new FullMappingsBase(unmappedIdentifiers, mappedIdentifiers, mappings);
|
||||
protected FullMappings createFullMappings(final IdentifiersPair identifiersPair, final Mappings mappings) {
|
||||
return FullMappingsBase.of(identifiersPair, mappings);
|
||||
}
|
||||
|
||||
protected @Nullable BiMappings loadBiMappings(final CompoundTag data, final String key) {
|
||||
@@ -172,7 +191,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;
|
||||
}
|
||||
@@ -335,11 +354,21 @@ public class MappingDataBase implements MappingData {
|
||||
return recipeSerializerMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable FullMappings getSlotDisplayMappings() {
|
||||
return slotDisplayMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable IntSet changedBlocks() {
|
||||
return changedBlocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Set<String> changedEnvironmentAttributes() {
|
||||
return changedEnvironmentAttributes;
|
||||
}
|
||||
|
||||
protected Logger getLogger() {
|
||||
return Via.getPlatform().getLogger();
|
||||
}
|
||||
@@ -354,7 +383,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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -31,13 +31,17 @@ import com.google.gson.JsonSyntaxException;
|
||||
import com.viaversion.nbt.io.NBTIO;
|
||||
import com.viaversion.nbt.io.TagReader;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.IntArrayTag;
|
||||
import com.viaversion.nbt.tag.IntTag;
|
||||
import com.viaversion.nbt.tag.ListTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.util.GsonUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import java.io.BufferedInputStream;
|
||||
@@ -51,6 +55,7 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
@@ -59,15 +64,16 @@ public class MappingDataLoader {
|
||||
public static final MappingDataLoader INSTANCE = new MappingDataLoader(MappingDataLoader.class, "assets/viaversion/data/");
|
||||
public static final TagReader<CompoundTag> MAPPINGS_READER = NBTIO.reader(CompoundTag.class).named();
|
||||
private static final Map<String, String[]> GLOBAL_IDENTIFIER_INDEXES = new HashMap<>();
|
||||
private static final int VERSION = 2;
|
||||
private static final byte DIRECT_ID = 0;
|
||||
private static final byte SHIFTS_ID = 1;
|
||||
private static final byte CHANGES_ID = 2;
|
||||
private static final byte IDENTITY_ID = 3;
|
||||
|
||||
private final Map<String, CompoundTag> mappingsCache = new HashMap<>();
|
||||
private final Map<String, CompoundTag> mappingsCache = new ConcurrentHashMap<>();
|
||||
private final Class<?> dataLoaderClass;
|
||||
private final String dataPath;
|
||||
private boolean cacheValid = true;
|
||||
private volatile boolean cacheValid = true;
|
||||
|
||||
public MappingDataLoader(final Class<?> dataLoaderClass, final String dataPath) {
|
||||
this.dataLoaderClass = dataLoaderClass;
|
||||
@@ -81,8 +87,9 @@ public class MappingDataLoader {
|
||||
for (final Map.Entry<String, Tag> entry : globalIdentifiers.entrySet()) {
|
||||
//noinspection unchecked
|
||||
final ListTag<StringTag> value = (ListTag<StringTag>) entry.getValue();
|
||||
final String[] array = new String[value.size()];
|
||||
for (int i = 0, size = value.size(); i < size; i++) {
|
||||
final int size = value.size();
|
||||
final String[] array = new String[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
array[i] = value.get(i).getValue();
|
||||
}
|
||||
GLOBAL_IDENTIFIER_INDEXES.put(entry.getKey(), array);
|
||||
@@ -103,14 +110,14 @@ public class MappingDataLoader {
|
||||
throw new IllegalArgumentException("Unknown global identifier key: " + registry);
|
||||
}
|
||||
if (globalId < 0 || globalId >= array.length) {
|
||||
throw new IllegalArgumentException("Unknown global identifier index: " + globalId);
|
||||
throw new IllegalArgumentException("Unknown global identifier index: " + registry + "/" + globalId);
|
||||
}
|
||||
return array[globalId];
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
mappingsCache.clear();
|
||||
cacheValid = false;
|
||||
mappingsCache.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,17 +166,14 @@ public class MappingDataLoader {
|
||||
return loadNBTFromFile(name);
|
||||
}
|
||||
|
||||
CompoundTag data = mappingsCache.get(name);
|
||||
if (data != null) {
|
||||
return data;
|
||||
if (cache) {
|
||||
// Also blocks concurrent loaders of the same file until the first one has finished
|
||||
return mappingsCache.computeIfAbsent(name, this::loadNBTFromFile);
|
||||
}
|
||||
|
||||
data = loadNBTFromFile(name);
|
||||
|
||||
if (cache && data != null) {
|
||||
mappingsCache.put(name, data);
|
||||
}
|
||||
return data;
|
||||
// Still do a lookup, but don't store it
|
||||
final CompoundTag data = mappingsCache.get(name);
|
||||
return data != null ? data : loadNBTFromFile(name);
|
||||
}
|
||||
|
||||
public @Nullable CompoundTag loadNBT(final String name) {
|
||||
@@ -210,15 +214,29 @@ public class MappingDataLoader {
|
||||
return null;
|
||||
}
|
||||
|
||||
final int version = mappingsTag.getInt("version", -1);
|
||||
if (version != VERSION) {
|
||||
throw new IllegalArgumentException("Invalid version: " + version);
|
||||
}
|
||||
|
||||
final int mappedSize = tag.getInt("mappedSize", -1);
|
||||
final byte strategy = tag.getByteTag("id").asByte();
|
||||
final V mappings;
|
||||
if (strategy == DIRECT_ID) {
|
||||
final IntArrayTag valuesTag = tag.getIntArrayTag("val");
|
||||
return IntArrayMappings.of(valuesTag.getValue(), mappedSize);
|
||||
// Zigzag varints of the difference to the previous mapped id
|
||||
final int size = tag.getIntTag("size").asInt();
|
||||
final ByteBuf buf = Unpooled.wrappedBuffer(tag.getByteArrayTag("val").getValue());
|
||||
final int[] values = new int[size];
|
||||
int prev = 0;
|
||||
for (int i = 0; i < size; i++) {
|
||||
prev += readZigZagVarInt(buf);
|
||||
values[i] = prev;
|
||||
}
|
||||
return IntArrayMappings.of(values, mappedSize);
|
||||
} else if (strategy == SHIFTS_ID) {
|
||||
final int[] shiftsAt = tag.getIntArrayTag("at").getValue();
|
||||
final int[] shiftsTo = tag.getIntArrayTag("to").getValue();
|
||||
final ValuePairs pairs = readAtValuePairs(tag);
|
||||
final int[] shiftsAt = pairs.first;
|
||||
final int[] shiftsTo = pairs.second;
|
||||
final int size = tag.getIntTag("size").asInt();
|
||||
mappings = holderSupplier.get(size);
|
||||
|
||||
@@ -241,8 +259,9 @@ public class MappingDataLoader {
|
||||
}
|
||||
}
|
||||
} else if (strategy == CHANGES_ID) {
|
||||
final int[] changesAt = tag.getIntArrayTag("at").getValue();
|
||||
final int[] values = tag.getIntArrayTag("val").getValue();
|
||||
final ValuePairs pairs = readAtValuePairs(tag);
|
||||
final int[] changesAt = pairs.first;
|
||||
final int[] values = pairs.second;
|
||||
final int size = tag.getIntTag("size").asInt();
|
||||
final boolean fillBetween = tag.get("nofill") == null;
|
||||
mappings = holderSupplier.get(size);
|
||||
@@ -261,6 +280,13 @@ public class MappingDataLoader {
|
||||
// Assign the changed value
|
||||
addConsumer.addTo(mappings, changedId, values[i]);
|
||||
}
|
||||
|
||||
// Fill the remainder
|
||||
if (fillBetween && nextUnhandledId != size) {
|
||||
for (int id = nextUnhandledId; id < size; id++) {
|
||||
addConsumer.addTo(mappings, id, id);
|
||||
}
|
||||
}
|
||||
} else if (strategy == IDENTITY_ID) {
|
||||
final IntTag sizeTag = tag.getIntTag("size");
|
||||
return new IdentityMappings(sizeTag.asInt(), mappedSize);
|
||||
@@ -270,15 +296,98 @@ public class MappingDataLoader {
|
||||
return mappingsSupplier.create(mappings, mappedSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads alternating id and value pairs from varints. The id as the difference to the previous id,
|
||||
* the value as the zigzag difference to the previous value.
|
||||
*
|
||||
* @param tag tag to read the packed values from
|
||||
* @return array of ids and array of values
|
||||
*/
|
||||
private static ValuePairs readAtValuePairs(final CompoundTag tag) {
|
||||
final ByteBuf buf = Unpooled.wrappedBuffer(tag.getByteArrayTag("val").getValue());
|
||||
final IntList at = new IntArrayList();
|
||||
final IntList values = new IntArrayList();
|
||||
int prevAt = -1;
|
||||
int prevValue = 0;
|
||||
while (buf.isReadable()) {
|
||||
prevAt = prevAt + 1 + Types.VAR_INT.readPrimitive(buf);
|
||||
prevValue += readZigZagVarInt(buf);
|
||||
at.add(prevAt);
|
||||
values.add(prevValue);
|
||||
}
|
||||
return new ValuePairs(at.toIntArray(), values.toIntArray());
|
||||
}
|
||||
|
||||
private static int readZigZagVarInt(final ByteBuf buf) {
|
||||
// https://lemire.me/blog/2022/11/25/making-all-your-integers-positive-with-zigzag-encoding/
|
||||
// In short, using deltas to previous ids makes the numbers small, and using zigzag encoding means they're all positive.
|
||||
// Being all positive means we can use varints to make most of the data much shorter than 8 bytes.
|
||||
// All of that combined ends up having a decent effect when compressed in the jar file as well.
|
||||
final int value = Types.VAR_INT.readPrimitive(buf);
|
||||
return (value >>> 1) ^ -(value & 1);
|
||||
}
|
||||
|
||||
public @Nullable List<String> identifiersFromGlobalIds(final CompoundTag mappingsTag, final String key) {
|
||||
final Mappings mappings = loadMappings(mappingsTag, key);
|
||||
if (mappings == null) {
|
||||
return mappings != null ? identifiers(mappings, key) : null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a pair of identifier lists, also keeping track of whether the two lists are equal.
|
||||
*
|
||||
* @param unmappedTag unmapped mappings tag
|
||||
* @param mappedTag mapped mappings tag
|
||||
* @param key mappings key
|
||||
* @return pair of identifier lists
|
||||
*/
|
||||
public @Nullable IdentifiersPair identifiersFromGlobalIds(final CompoundTag unmappedTag, final CompoundTag mappedTag, final String key) {
|
||||
final Mappings unmapped = loadMappings(unmappedTag, key);
|
||||
if (unmapped == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final List<String> identifiers = new ArrayList<>(mappings.size());
|
||||
for (int i = 0; i < mappings.size(); i++) {
|
||||
identifiers.add(identifierFromGlobalId(key, mappings.getNewId(i)));
|
||||
final Mappings mapped = loadMappings(mappedTag, key);
|
||||
if (mapped == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final int size = unmapped.size();
|
||||
if (size != mapped.size()) {
|
||||
return new IdentifiersPair(identifiers(unmapped, key), identifiers(mapped, key), false);
|
||||
}
|
||||
|
||||
// Small optimization to only load one array and reduce loading for full mappings
|
||||
final List<String> unmappedIdentifiers = new ArrayList<>(size);
|
||||
final List<String> mappedIdentifiers = new ArrayList<>(size);
|
||||
boolean identity = true;
|
||||
for (int i = 0; i < size; i++) {
|
||||
final int unmappedGlobalId = unmapped.getNewId(i);
|
||||
final int mappedGlobalId = mapped.getNewId(i);
|
||||
final String unmappedIdentifier = identifierFromGlobalId(key, unmappedGlobalId);
|
||||
if (unmappedGlobalId == mappedGlobalId) {
|
||||
unmappedIdentifiers.add(unmappedIdentifier);
|
||||
mappedIdentifiers.add(unmappedIdentifier);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mappedGlobalId == -1) {
|
||||
throw new IllegalArgumentException("Mapped global id -1 for unmapped global id: " + key + "/" + unmappedIdentifier + " (" + unmappedGlobalId + ")");
|
||||
}
|
||||
|
||||
identity = false;
|
||||
unmappedIdentifiers.add(unmappedIdentifier);
|
||||
mappedIdentifiers.add(identifierFromGlobalId(key, mappedGlobalId));
|
||||
}
|
||||
return identity ? new IdentifiersPair(unmappedIdentifiers) : new IdentifiersPair(unmappedIdentifiers, mappedIdentifiers);
|
||||
}
|
||||
|
||||
private List<String> identifiers(final Mappings mappings, final String key) {
|
||||
final int size = mappings.size();
|
||||
final List<String> identifiers = new ArrayList<>(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
final int globalId = mappings.getNewId(i);
|
||||
identifiers.add(identifierFromGlobalId(key, globalId));
|
||||
}
|
||||
return identifiers;
|
||||
}
|
||||
@@ -342,4 +451,18 @@ public class MappingDataLoader {
|
||||
|
||||
T create(V mappings, int mappedSize);
|
||||
}
|
||||
|
||||
public record IdentifiersPair(List<String> unmapped, List<String> mapped, boolean identity) {
|
||||
|
||||
public IdentifiersPair(final List<String> unmapped, final List<String> mapped) {
|
||||
this(unmapped, mapped, false);
|
||||
}
|
||||
|
||||
public IdentifiersPair(final List<String> identifiers) {
|
||||
this(identifiers, identifiers, true);
|
||||
}
|
||||
}
|
||||
|
||||
private record ValuePairs(int[] first, int[] second) {
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -22,6 +22,8 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface Mappings {
|
||||
|
||||
/**
|
||||
@@ -84,4 +86,40 @@ public interface Mappings {
|
||||
* @return mappings with keys and values swapped
|
||||
*/
|
||||
Mappings inverse();
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether the mappings are unchanged identity mappings.
|
||||
*
|
||||
* @return whether the mappings are unchanged identity mappings
|
||||
*/
|
||||
default boolean isIdentity() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the mappings null or identity mappings.
|
||||
*
|
||||
* @param mappings mappings
|
||||
* @return whether the mappings are identity mappings
|
||||
* @see #isFullIdentity(Mappings)
|
||||
*/
|
||||
static boolean isIntIdIdentity(@Nullable final Mappings mappings) {
|
||||
if (mappings == null) {
|
||||
return true;
|
||||
}
|
||||
return mappings instanceof FullMappings fullMappings ? fullMappings.isIntIdIdentity() : mappings.isIdentity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the mappings null or full identity mappings.
|
||||
* Stronger than {@link #isIntIdIdentity(Mappings)}, but equal to that if not {@link FullMappings}.
|
||||
*
|
||||
* @param mappings mappings
|
||||
* @return whether the mappings are full identity mappings
|
||||
* @see #isIntIdIdentity(Mappings)
|
||||
*/
|
||||
static boolean isFullIdentity(@Nullable final Mappings mappings) {
|
||||
return mappings == null || mappings.isIdentity();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -22,16 +22,16 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.viaversion.viaversion.api.data.MappingDataLoader.IdentifiersPair;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import java.util.List;
|
||||
|
||||
public class ParticleMappings extends FullMappingsBase {
|
||||
private final IntList itemParticleIds = new IntArrayList(4);
|
||||
private final IntList blockParticleIds = new IntArrayList(4);
|
||||
|
||||
public ParticleMappings(final List<String> unmappedIdentifiers, final List<String> mappedIdentifiers, final Mappings mappings) {
|
||||
super(unmappedIdentifiers, mappedIdentifiers, mappings);
|
||||
public ParticleMappings(final IdentifiersPair identifiersPair, final Mappings mappings) {
|
||||
super(identifiersPair, mappings);
|
||||
addBlockParticle("block");
|
||||
addBlockParticle("falling_dust");
|
||||
addBlockParticle("block_marker");
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -23,7 +23,10 @@
|
||||
package com.viaversion.viaversion.api.data.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.util.KeyMappings;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
@@ -42,8 +45,9 @@ public interface EntityTracker {
|
||||
*
|
||||
* @param id entity id
|
||||
* @param type entity type
|
||||
* @return tracked entity
|
||||
*/
|
||||
void addEntity(int id, EntityType type);
|
||||
TrackedEntity addEntity(int id, EntityType type);
|
||||
|
||||
/**
|
||||
* Returns whether the entity is currently tracked.
|
||||
@@ -74,8 +78,9 @@ public interface EntityTracker {
|
||||
* Untracks an entity.
|
||||
*
|
||||
* @param id entity id
|
||||
* @return previously tracked entity
|
||||
*/
|
||||
void removeEntity(int id);
|
||||
@Nullable TrackedEntity removeEntity(int id);
|
||||
|
||||
/**
|
||||
* Clears stored entity types and data, only leaving behind the client entity.
|
||||
@@ -87,25 +92,6 @@ public interface EntityTracker {
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param id entity id
|
||||
* @return stored entity data if an entity with the id is tracked, else null
|
||||
* @throws IllegalArgumentException if entity data storage has not been enabled via the implementation
|
||||
*/
|
||||
@Nullable StoredEntityData entityData(int id);
|
||||
|
||||
/**
|
||||
* Returns stored entity data if it has previously been initialized by {@link #entityData(int)}, else null.
|
||||
*
|
||||
* @param id entity id
|
||||
* @return stored entity data if it has previously been initialized by {@link #entityData(int)}
|
||||
* @throws IllegalArgumentException if entity data storage has not been enabled via the implementation
|
||||
*/
|
||||
@Nullable StoredEntityData entityDataIfPresent(int id);
|
||||
|
||||
/**
|
||||
* Returns whether the client entity id has been set.
|
||||
*
|
||||
@@ -203,6 +189,24 @@ public interface EntityTracker {
|
||||
|
||||
void setBiomesSent(int biomesSent);
|
||||
|
||||
/**
|
||||
* Returns the cached chunk type for the current dimension if set.
|
||||
*
|
||||
* @param mapped whether to return the mapped chunk type
|
||||
* @return cached chunk type
|
||||
*/
|
||||
@Nullable Type<Chunk> chunkType(boolean mapped);
|
||||
|
||||
/**
|
||||
* Caches the chunk type for the current dimension.
|
||||
* <p>
|
||||
* Invalidates when the world section height or the number of biomes change.
|
||||
*
|
||||
* @param mapped whether to set the mapped chunk type
|
||||
* @param chunkType chunk type
|
||||
*/
|
||||
void setChunkType(boolean mapped, @Nullable Type<Chunk> chunkType);
|
||||
|
||||
EntityType playerType();
|
||||
|
||||
@Nullable DimensionData dimensionData(String dimension);
|
||||
@@ -210,4 +214,8 @@ public interface EntityTracker {
|
||||
@Nullable DimensionData dimensionData(int dimensionId);
|
||||
|
||||
void setDimensions(Map<String, DimensionData> dimensions);
|
||||
|
||||
@Nullable KeyMappings registryKeys(String registryKey);
|
||||
|
||||
void addRegistryKeys(String registryKey, KeyMappings mappings);
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* 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.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface StoredEntityData {
|
||||
|
||||
/**
|
||||
* Returns the entity type of the stored entity.
|
||||
*
|
||||
* @return entity type
|
||||
*/
|
||||
EntityType type();
|
||||
|
||||
/**
|
||||
* Checks if the storage contains an object of the given type.
|
||||
*
|
||||
* @param objectClass object class to check
|
||||
* @return whether an object of the given type is in the storage
|
||||
*/
|
||||
boolean has(Class<?> objectClass);
|
||||
|
||||
/**
|
||||
* Returns an object from the storage if present.
|
||||
*
|
||||
* @param objectClass class of the object to get
|
||||
* @param <T> object type
|
||||
* @return object if present
|
||||
*/
|
||||
@Nullable <T> T get(Class<T> objectClass);
|
||||
|
||||
/**
|
||||
* Removes and returns an object from the storage if present.
|
||||
*
|
||||
* @param objectClass class of the object to remove
|
||||
* @param <T> object type
|
||||
* @return removed object if present
|
||||
*/
|
||||
@Nullable <T> T remove(Class<T> objectClass);
|
||||
|
||||
/**
|
||||
* Stores an object based on its class.
|
||||
*
|
||||
* @param object object to store
|
||||
*/
|
||||
void put(Object object);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -22,7 +22,9 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface TrackedEntity {
|
||||
|
||||
@@ -34,18 +36,37 @@ public interface TrackedEntity {
|
||||
EntityType entityType();
|
||||
|
||||
/**
|
||||
* Object to hold arbitrary additional data.
|
||||
* Checks if the storage contains an object of the given type.
|
||||
*
|
||||
* @return entity data
|
||||
* @param objectClass object class to check
|
||||
* @return whether an object of the given type is in the storage
|
||||
*/
|
||||
StoredEntityData data();
|
||||
boolean has(Class<? extends StorableObject> objectClass);
|
||||
|
||||
/**
|
||||
* Returns whether the stored entity currently has any additional data.
|
||||
* Returns an object from the storage if present.
|
||||
*
|
||||
* @return whether the stored entity currently has additional data
|
||||
* @param objectClass class of the object to get
|
||||
* @param <T> object type
|
||||
* @return object if present
|
||||
*/
|
||||
boolean hasData();
|
||||
@Nullable <T extends StorableObject> T get(Class<T> objectClass);
|
||||
|
||||
/**
|
||||
* Removes and returns an object from the storage if present.
|
||||
*
|
||||
* @param objectClass class of the object to remove
|
||||
* @param <T> object type
|
||||
* @return removed object if present
|
||||
*/
|
||||
@Nullable <T extends StorableObject> T remove(Class<T> objectClass);
|
||||
|
||||
/**
|
||||
* Stores an object based on its class.
|
||||
*
|
||||
* @param object object to store
|
||||
*/
|
||||
void put(StorableObject object);
|
||||
|
||||
/**
|
||||
* Returns whether entity data has already been sent at least once for this entity.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -22,8 +22,6 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Used for converting items to hashed items and caching them for later use during serverbound packets.
|
||||
* <p>
|
||||
@@ -41,11 +39,4 @@ public interface ItemHasher {
|
||||
boolean isProcessingClientboundInventoryPacket();
|
||||
|
||||
void setProcessingClientboundInventoryPacket(boolean processingClientboundInventoryPacket);
|
||||
|
||||
/**
|
||||
* Sets the enchantment registry for this connection.
|
||||
*
|
||||
* @param enchantments list of enchantment identifiers
|
||||
*/
|
||||
void setEnchantments(List<String> enchantments);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -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,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -31,8 +31,8 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
* Represents an animal variant (e.g. for cows, pigs, chickens).
|
||||
*
|
||||
* @param modelType model type id
|
||||
* @param texture texture path
|
||||
* @param biomes biomes this variant can spawn in, if limited to specific biomes
|
||||
* @param texture texture path
|
||||
* @param biomes biomes this variant can spawn in, if limited to specific biomes
|
||||
*/
|
||||
public record AnimalVariant(int modelType, String texture, @Nullable HolderSet biomes) {
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -38,7 +38,7 @@ public interface EitherHolder<T> {
|
||||
/**
|
||||
* Returns an indirect holder via the resource key.
|
||||
*
|
||||
* @param key the resource key
|
||||
* @param key the resource key
|
||||
* @param <T> the type of the value
|
||||
* @return a new holder with the given resource key
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -22,11 +22,12 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
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;
|
||||
import java.util.function.ToIntFunction;
|
||||
|
||||
/**
|
||||
* Set of ids that either holds a string tag key or an array of ids.
|
||||
@@ -40,6 +41,7 @@ public interface HolderSet {
|
||||
* @return a new holder set
|
||||
*/
|
||||
static HolderSet of(final String tagKey) {
|
||||
Preconditions.checkNotNull(tagKey);
|
||||
return new HolderSetImpl.Tag(tagKey);
|
||||
}
|
||||
|
||||
@@ -50,22 +52,23 @@ public interface HolderSet {
|
||||
* @return a new holder set
|
||||
*/
|
||||
static HolderSet of(final int[] ids) {
|
||||
Preconditions.checkNotNull(ids);
|
||||
return new HolderSetImpl.Ids(ids);
|
||||
}
|
||||
|
||||
static HolderSet fromTag(final Tag tag, final Function<String, Integer> mappingFunction) {
|
||||
static HolderSet fromTag(final Tag tag, final ToIntFunction<String> mappingFunction) {
|
||||
if (tag instanceof StringTag stringTag) {
|
||||
if (stringTag.getValue().startsWith("#")) {
|
||||
return HolderSet.of(stringTag.getValue().substring(1));
|
||||
}
|
||||
|
||||
final int id = mappingFunction.apply(stringTag.getValue());
|
||||
final int id = mappingFunction.applyAsInt(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);
|
||||
ids[i] = mappingFunction.applyAsInt(value);
|
||||
}
|
||||
return HolderSet.of(ids);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -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;
|
||||
|
||||
@@ -56,8 +58,8 @@ public record PaintingVariant(int width, int height, String assetId, @Nullable T
|
||||
final int width = Types.VAR_INT.readPrimitive(buffer);
|
||||
final int height = Types.VAR_INT.readPrimitive(buffer);
|
||||
final String assetId = Types.STRING.read(buffer);
|
||||
final Tag title = Types.OPTIONAL_TAG.read(buffer);
|
||||
final Tag author = Types.OPTIONAL_TAG.read(buffer);
|
||||
final Tag title = Types.TRUSTED_OPTIONAL_TAG.read(buffer);
|
||||
final Tag author = Types.TRUSTED_OPTIONAL_TAG.read(buffer);
|
||||
return new PaintingVariant(width, height, assetId, title, author);
|
||||
}
|
||||
|
||||
@@ -66,8 +68,24 @@ public record PaintingVariant(int width, int height, String assetId, @Nullable T
|
||||
Types.VAR_INT.writePrimitive(buffer, variant.width());
|
||||
Types.VAR_INT.writePrimitive(buffer, variant.height());
|
||||
Types.STRING.write(buffer, variant.assetId());
|
||||
Types.OPTIONAL_TAG.write(buffer, variant.title());
|
||||
Types.OPTIONAL_TAG.write(buffer, variant.author());
|
||||
Types.TRUSTED_OPTIONAL_TAG.write(buffer, variant.title());
|
||||
Types.TRUSTED_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.TRUSTED_TAG, value.title())
|
||||
.writeOptional("author", Types.TRUSTED_TAG, value.author()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Key identifier(final Ops ops, final int id) {
|
||||
return ops.context().registryAccess().registryKey("painting_variant", id);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
+15
-9
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -20,17 +20,23 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.protocol;
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.data.MappingData.MappingType;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
|
||||
/**
|
||||
* A simple protocol which does not have any packet types.
|
||||
* <p>
|
||||
* {@link AbstractProtocol} should be preferred over this class in most cases.
|
||||
* 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 abstract class AbstractSimpleProtocol extends AbstractProtocol<SimpleProtocol.DummyPacketTypes, SimpleProtocol.DummyPacketTypes,
|
||||
SimpleProtocol.DummyPacketTypes, SimpleProtocol.DummyPacketTypes> implements SimpleProtocol {
|
||||
public interface RegistryKey {
|
||||
|
||||
protected AbstractSimpleProtocol() {
|
||||
super(null, null, null, null);
|
||||
Key registry();
|
||||
|
||||
static RegistryKey of(final String key) {
|
||||
return new SimpleRegistryKey(Key.of(key));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
@@ -22,25 +22,28 @@
|
||||
*/
|
||||
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"),
|
||||
FLUID("fluid"),
|
||||
ENTITY("entity_type"),
|
||||
GAME_EVENT("game_event"),
|
||||
ENCHANTMENT("enchantment");
|
||||
ENCHANTMENT("enchantment"),
|
||||
DAMAGE_TYPE("damage_type"),
|
||||
BANNER_PATTERN("banner_pattern");
|
||||
|
||||
private static final Map<String, RegistryType> MAP = new HashMap<>();
|
||||
private static final RegistryType[] VALUES = values();
|
||||
|
||||
static {
|
||||
for (RegistryType type : getValues()) {
|
||||
MAP.put(type.resourceLocation, type);
|
||||
MAP.put(type.identifier(), type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,17 +51,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 Key key;
|
||||
|
||||
RegistryType(final String resourceLocation) {
|
||||
this.resourceLocation = resourceLocation;
|
||||
RegistryType(final String identifier) {
|
||||
this.key = Key.of(identifier);
|
||||
}
|
||||
|
||||
public String resourceLocation() {
|
||||
return resourceLocation;
|
||||
public String identifier() {
|
||||
return key.path();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key registry() {
|
||||
return this.key;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2026 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.EitherImpl;
|
||||
|
||||
public final class ResolvableFloat extends EitherImpl<Float, String> {
|
||||
|
||||
private ResolvableFloat(final Float left, final String right) {
|
||||
super(left, right);
|
||||
}
|
||||
|
||||
public static ResolvableFloat of(final String value) {
|
||||
return new ResolvableFloat(null, value);
|
||||
}
|
||||
|
||||
public static ResolvableFloat of(final Float value) {
|
||||
return new ResolvableFloat(value, null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2026 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.EitherImpl;
|
||||
|
||||
public final class ResolvableInt extends EitherImpl<Integer, String> {
|
||||
|
||||
private ResolvableInt(final Integer left, final String right) {
|
||||
super(left, right);
|
||||
}
|
||||
|
||||
public static ResolvableInt of(final String value) {
|
||||
return new ResolvableInt(null, value);
|
||||
}
|
||||
|
||||
public static ResolvableInt of(final Integer value) {
|
||||
return new ResolvableInt(value, null);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2026 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 registry) implements RegistryKey {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return registry.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 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
|
||||
|
||||
Loaded 100 of 1235 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user