mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2026-11-04 08:52:08 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
757db4f25b | ||
|
|
51f061bfc1 | ||
|
|
14b3296959 | ||
|
|
22e823e919 | ||
|
|
bd3877bb46 | ||
|
|
368881055d | ||
|
|
be0f50ad69 | ||
|
|
b63f50750d | ||
|
|
50e7c15db1 | ||
|
|
ef004cfa9c | ||
|
|
4f4fd5db8f | ||
|
|
57157fd521 | ||
|
|
db8d9ab411 | ||
|
|
f92a47df21 | ||
|
|
00a08e95ef | ||
|
|
1c652f82fc | ||
|
|
7bb2c3e188 | ||
|
|
92bbec9b73 | ||
|
|
2604f8e37f | ||
|
|
938164f22d | ||
|
|
2b6948cec3 | ||
|
|
9cfa44368a | ||
|
|
f86925d747 | ||
|
|
5a89919058 | ||
|
|
bf41b02718 | ||
|
|
593106ff79 | ||
|
|
0add20f841 | ||
|
|
dc521d9918 | ||
|
|
98c20752c3 | ||
|
|
bbd17ea7c8 | ||
|
|
b2902561bb | ||
|
|
010fc0bb13 | ||
|
|
d1a13c6f78 | ||
|
|
7be2b232d1 | ||
|
|
07baf2d068 | ||
|
|
53a45d6ab6 | ||
|
|
831da784e6 | ||
|
|
69620f894b | ||
|
|
e5be7a8260 | ||
|
|
a20f6db968 | ||
|
|
a5949b9d4b | ||
|
|
e433fb3066 | ||
|
|
f3be21ed9d | ||
|
|
2a2150beed | ||
|
|
f3af5f189c | ||
|
|
ca69def762 | ||
|
|
b268342acd | ||
|
|
bb61f4dece | ||
|
|
2360ea2c6b | ||
|
|
44819eaf03 | ||
|
|
a839cb0684 | ||
|
|
b243e5ee32 | ||
|
|
ab20f50510 | ||
|
|
1f4f45195c | ||
|
|
9e200b092b | ||
|
|
16b057ecee | ||
|
|
a1f7c804c3 | ||
|
|
af9edc87fb | ||
|
|
fea7604ab1 | ||
|
|
aeb0f4a7ee | ||
|
|
76b98eb396 | ||
|
|
b33221b95c | ||
|
|
8ce26b1353 | ||
|
|
9a79f9e217 | ||
|
|
44476f2468 | ||
|
|
54655e34e7 | ||
|
|
863258df4e | ||
|
|
8a5fce2d2e | ||
|
|
5374c3b626 | ||
|
|
96e0d85bc0 | ||
|
|
84576d1d95 | ||
|
|
c6f0717ad5 | ||
|
|
395bebac62 | ||
|
|
6d19ad3b81 | ||
|
|
38080fc5cc | ||
|
|
285dcdd81f | ||
|
|
1f5fd88fef | ||
|
|
531f7d078e | ||
|
|
2806671813 | ||
|
|
7634a7ec7a | ||
|
|
8cd5bd3368 | ||
|
|
0735e4afb5 | ||
|
|
3568eee8f2 | ||
|
|
e694b3532a | ||
|
|
2bcf79c501 | ||
|
|
7ded34c55e | ||
|
|
3bdeed8a9f | ||
|
|
30df707369 | ||
|
|
cf8058016c | ||
|
|
3468b0a785 | ||
|
|
d273b06e05 | ||
|
|
4f561ba4a7 | ||
|
|
0a5035d209 | ||
|
|
609b657c68 | ||
|
|
5885074fcd | ||
|
|
d499918e4b | ||
|
|
17d7b4873f | ||
|
|
38243bad78 | ||
|
|
50577abbb5 | ||
|
|
277de42948 | ||
|
|
4c26915fdf | ||
|
|
7c98b75543 | ||
|
|
7d39bcc365 | ||
|
|
85688beba8 | ||
|
|
fd16c4469c | ||
|
|
a37605e920 | ||
|
|
1d4e41f867 | ||
|
|
1f4acbbc60 | ||
|
|
eff547019c | ||
|
|
bbb52f575a | ||
|
|
74ad2d15fb | ||
|
|
024fe774f4 | ||
|
|
0df9c50251 | ||
|
|
e8637e5753 | ||
|
|
64b454de6f | ||
|
|
433f46e34e | ||
|
|
fbe6a67750 | ||
|
|
454e97c844 | ||
|
|
fccea9b55d | ||
|
|
917427c940 | ||
|
|
b7ddc108f5 | ||
|
|
db65302112 | ||
|
|
795b195690 | ||
|
|
b7c42f9b2e | ||
|
|
1a0c79c46a | ||
|
|
95d809f53a | ||
|
|
f8c249f2c2 | ||
|
|
fe890fa59e | ||
|
|
9806afed99 | ||
|
|
432c669daf | ||
|
|
838d83897b | ||
|
|
e10c73138d | ||
|
|
e0892faf13 | ||
|
|
c03cb66bbd | ||
|
|
ea1d86642e | ||
|
|
6c9c7288c4 | ||
|
|
8dab7f7284 | ||
|
|
f0c16003e0 | ||
|
|
4d4b18b80e | ||
|
|
99abab0d62 | ||
|
|
f7656fb45f | ||
|
|
6a440aaeda | ||
|
|
075ca7044d | ||
|
|
a8cd653a7a | ||
|
|
191dd24117 | ||
|
|
6ad05d8bc2 | ||
|
|
c5a2a6ae6e | ||
|
|
31f7f4edc1 | ||
|
|
b2a2712949 | ||
|
|
7bd6a849a3 | ||
|
|
473b4af0d0 | ||
|
|
b7c8891497 | ||
|
|
be5344b3e4 | ||
|
|
cc4ea71722 | ||
|
|
f288f2d716 | ||
|
|
61a4cead72 | ||
|
|
b9ead8109f | ||
|
|
12cde18a3d | ||
|
|
b8adbde876 | ||
|
|
6faf407cc9 | ||
|
|
f3f19dfd4e | ||
|
|
80ed7e1e75 | ||
|
|
6363cd38ab | ||
|
|
5ca359b287 | ||
|
|
c18c670bdb | ||
|
|
345406ecae | ||
|
|
4a159bf16a | ||
|
|
6a2482f42f | ||
|
|
8075d49ad2 | ||
|
|
36aecf3444 | ||
|
|
f0aa7d9dae | ||
|
|
b63e031662 | ||
|
|
8825ef0f44 | ||
|
|
eea2687e66 | ||
|
|
712f656a3a | ||
|
|
181a0cb7c1 | ||
|
|
b367037cef | ||
|
|
b90b573f1d | ||
|
|
74aeadd688 | ||
|
|
6f27988cf6 | ||
|
|
81aad86d9f | ||
|
|
1e7dbf38fd | ||
|
|
0404184e15 | ||
|
|
64a7d9f8bd | ||
|
|
924346882c | ||
|
|
1d7332101f | ||
|
|
30e63ebc3b | ||
|
|
217c9459f5 | ||
|
|
ead2c6f330 | ||
|
|
1a972da613 | ||
|
|
44dbbf37e2 | ||
|
|
def010c2bf | ||
|
|
75744d5525 | ||
|
|
7f66786b76 | ||
|
|
6993308019 | ||
|
|
a69b0b499c | ||
|
|
a48731ded2 | ||
|
|
11857f1abe | ||
|
|
fdf2d5e87b | ||
|
|
069c537dbb | ||
|
|
22e86fb127 | ||
|
|
d08da420b2 | ||
|
|
5bddf285e3 | ||
|
|
3ba77829fe | ||
|
|
3c3cd07fd7 | ||
|
|
5a2d3b6b31 | ||
|
|
0c21ddfe40 | ||
|
|
9b65b59411 | ||
|
|
d3248037d8 | ||
|
|
e0f3a98d79 | ||
|
|
39a4d4e973 | ||
|
|
8a9bf708f2 | ||
|
|
5070e51b04 | ||
|
|
12baac5cbd | ||
|
|
8669c17512 | ||
|
|
fe993fc2a7 | ||
|
|
54af45da27 | ||
|
|
175daef7da | ||
|
|
986ecaaf8d | ||
|
|
b42c19752c | ||
|
|
d98de382fc | ||
|
|
13bc18b496 | ||
|
|
4160b37f13 | ||
|
|
f9f7a24dda | ||
|
|
21fd034c02 | ||
|
|
6a59e887c8 | ||
|
|
32488cf2ff | ||
|
|
774a35db17 | ||
|
|
32f41382fa | ||
|
|
c9573a1cfd | ||
|
|
def9df84b4 | ||
|
|
fd4bc59058 | ||
|
|
aecd74425d | ||
|
|
53584b01f7 | ||
|
|
7f97ae80c3 | ||
|
|
4dd4b2f53b | ||
|
|
8a9cc8bd9b | ||
|
|
9e3861fb21 | ||
|
|
b74ac19d9d | ||
|
|
4cca914c5d | ||
|
|
fa90711056 | ||
|
|
d5d4073857 | ||
|
|
b8e0b39eeb | ||
|
|
6ec175dff2 | ||
|
|
9bd1785886 | ||
|
|
9fabc4b11e | ||
|
|
3969186439 | ||
|
|
422826a9b8 | ||
|
|
ddcaa78b61 | ||
|
|
d3c6065367 | ||
|
|
df5353be29 | ||
|
|
9e8e23d308 | ||
|
|
3693ec6021 | ||
|
|
0a5ba125f7 | ||
|
|
8f861f670c | ||
|
|
0f806f1016 | ||
|
|
fbba2dc81b | ||
|
|
61f537e9b9 | ||
|
|
ba84a588f1 | ||
|
|
4ec0969b45 | ||
|
|
19a04666e5 | ||
|
|
9a5e2f8e8c | ||
|
|
a33feff59b | ||
|
|
612a6b3696 | ||
|
|
b42e466248 | ||
|
|
e4ea6aa5e2 | ||
|
|
c40e092b48 | ||
|
|
46a33a42ec | ||
|
|
d31892513c | ||
|
|
e6af10a0b6 | ||
|
|
f6dcd149cb | ||
|
|
1fb2bd410f | ||
|
|
b1e667fadb | ||
|
|
7eb0522150 | ||
|
|
3f6c172d7b | ||
|
|
9e7fad2840 | ||
|
|
2f3c869f4d | ||
|
|
c6b287bfac | ||
|
|
0f59bf96c8 | ||
|
|
ca5028a7fa | ||
|
|
9740910d98 | ||
|
|
cb9907743d | ||
|
|
4617e6e416 | ||
|
|
de0c869dbb | ||
|
|
29ec02687c | ||
|
|
481b06cd2a | ||
|
|
624fb6acd4 |
No files matched your search
+1
-1
@@ -1,3 +1,3 @@
|
||||
github: kennytv
|
||||
patreon: kennytv
|
||||
custom: ['https://florianmichael.de/donate']
|
||||
custom: ['https://florianreuth.de/donate']
|
||||
@@ -48,21 +48,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 downward/in what version range the issue happens.**
|
||||
placeholder: |
|
||||
Example:
|
||||
1. Login with a 1.16.5 client
|
||||
2. Place a sign
|
||||
3. The sign text is displayed wrong
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Expected Behavior
|
||||
description: |
|
||||
Describe what exactly you expected to happen.
|
||||
placeholder: |
|
||||
Example: "Placed sign text should not disappear."
|
||||
3. The sign text disappears
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
cooldown:
|
||||
default-days: 7
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
interval: "monthly"
|
||||
- package-ecosystem: "gradle"
|
||||
cooldown:
|
||||
default-days: 7
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "monthly"
|
||||
@@ -1,25 +1,26 @@
|
||||
name: Java CI with Gradle
|
||||
|
||||
on: [push, pull_request]
|
||||
name: Build
|
||||
on: [pull_request, push, workflow_dispatch]
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# Only run on PRs if the source branch is on a different repo. We do not need to run everything twice.
|
||||
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
|
||||
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@v4
|
||||
uses: gradle/actions/setup-gradle@f29f5a9d7b09a7c6b29859002d29d24e1674c884 # 5.0.1
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # 5.2.0
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
check-latest: true
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
run: ./gradlew build --refresh-dependencies
|
||||
@@ -4,26 +4,38 @@ on:
|
||||
branches:
|
||||
- master
|
||||
- dev
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
if: github.repository_owner == 'ViaVersion'
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@v4
|
||||
uses: gradle/actions/setup-gradle@f29f5a9d7b09a7c6b29859002d29d24e1674c884 # 5.0.1
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # 5.2.0
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
check-latest: true
|
||||
- name: Publish
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build --refresh-dependencies
|
||||
- name: Publish to Hangar
|
||||
env:
|
||||
HANGAR_TOKEN: ${{ secrets.HANGAR_TOKEN }}
|
||||
run: ./gradlew publishAllPublicationsToHangar --stacktrace
|
||||
continue-on-error: true
|
||||
- name: Publish to Modrinth
|
||||
env:
|
||||
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
|
||||
run: ./gradlew build modrinth publishAllPublicationsToHangar --stacktrace
|
||||
run: ./gradlew modrinth --stacktrace
|
||||
continue-on-error: true
|
||||
@@ -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@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Update Gradle Wrapper
|
||||
uses: gradle-update/update-gradle-wrapper-action@v2
|
||||
+19
-95
@@ -1,112 +1,36 @@
|
||||
### Java files ###
|
||||
*.class
|
||||
# Gradle
|
||||
|
||||
# Package Files
|
||||
#*.jar
|
||||
*.war
|
||||
*.ear
|
||||
.gradle/
|
||||
build/
|
||||
out/
|
||||
classes/
|
||||
.kotlin/
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
# Eclipse
|
||||
|
||||
*.launch
|
||||
|
||||
# Idea
|
||||
|
||||
### Intellij ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
|
||||
# Ignore project files
|
||||
*.iml
|
||||
|
||||
# Ignore IDEA directory
|
||||
.idea/*
|
||||
.idea/
|
||||
!.idea/copyright/*
|
||||
!.idea/scopes/*
|
||||
|
||||
# Include the project's dictionary
|
||||
!.idea/dictionaries/
|
||||
!.idea/dictionaries/*
|
||||
|
||||
# File-based project format:
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
### Plugin-specific files: ###
|
||||
# IntelliJ
|
||||
/out/
|
||||
# VSCode
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
|
||||
|
||||
|
||||
### Eclipse ###
|
||||
*.pydevproject
|
||||
.metadata
|
||||
.gradle
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.settings/
|
||||
.loadpath
|
||||
|
||||
# Eclipse Core
|
||||
.vscode/
|
||||
bin/
|
||||
.classpath
|
||||
.project
|
||||
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
# macOS
|
||||
|
||||
# Locally stored "Eclipse launch configurations"
|
||||
*.launch
|
||||
.DS_Store
|
||||
|
||||
# CDT-specific
|
||||
.cproject
|
||||
# Misc
|
||||
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
.classpath
|
||||
|
||||
# PDT-specific
|
||||
.buildpath
|
||||
|
||||
# sbteclipse plugin
|
||||
.target
|
||||
|
||||
# TeXlipse plugin
|
||||
.texlipse
|
||||
|
||||
|
||||
|
||||
### Maven ###
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
|
||||
|
||||
|
||||
### NetBeans ###
|
||||
nbproject/private/
|
||||
build/
|
||||
nbbuild/
|
||||
dist/
|
||||
nbdist/
|
||||
nbactions.xml
|
||||
nb-configuration.xml
|
||||
.nb-gradle/
|
||||
|
||||
### Run Folder (ViaProxy) ###
|
||||
common/run/
|
||||
run/
|
||||
@@ -1,18 +1,18 @@
|
||||
# ViaBackwards
|
||||
|
||||
[](https://github.com/ViaVersion/ViaBackwards/releases)
|
||||
[](https://github.com/ViaVersion/ViaBackwards/actions)
|
||||
[](https://github.com/ViaVersion/ViaBackwards/actions)
|
||||
[](https://viaversion.com/discord)
|
||||
|
||||
**Allows the connection of older clients to newer server versions for Minecraft servers.**
|
||||
|
||||
Requires [ViaVersion](https://hangar.papermc.io/ViaVersion/ViaVersion) to be installed..
|
||||
Requires [ViaVersion](https://hangar.papermc.io/ViaVersion/ViaVersion) to be installed.
|
||||
|
||||
Supported Versions
|
||||
-
|
||||
As a plugin, ViaBackwards runs on servers on releases 1.10-latest. You can also use ViaBackwards in ViaFabric or ViaFabricPlus.
|
||||
- in **ViaFabric**, put ViaBackwards into the `mods` folder
|
||||
- in **ViaFabricPlus**, put ViaBackwards into the `ViaFabricPlus/jars` folder
|
||||
- in **ViaFabricPlus**, put ViaBackwards into the `config/viafabriclus/jars` folder
|
||||
|
||||
See [HERE](https://viaversion.com) for an overview of the different Via* projects.
|
||||
|
||||
@@ -42,7 +42,7 @@ Known issues
|
||||
1.17 will not be able to see or interact with blocks below y=0 and above y=255
|
||||
* <1.17 clients on 1.17+ servers might experience inventory desyncs on certain inventory click actions
|
||||
* Sound mappings are incomplete ([see here](https://github.com/ViaVersion/ViaBackwards/issues/326))
|
||||
* <1.19.4 clients on 1.20+ servers won't be able to use the smithing table, this can be fixed by
|
||||
* <1.19.4 clients on 1.20+ servers won't be able to use the smithing table. This can be fixed by
|
||||
installing [AxSmithing](https://github.com/ViaVersionAddons/AxSmithing)
|
||||
|
||||
Other Links
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
# Security Policy
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
If you discover a **security vulnerability**, please **do not** open a public issue. Instead, use one of the following **confidential contact methods**:
|
||||
|
||||
* **Email:** [security@viaversion.com](mailto:security@viaversion.com)
|
||||
* **Discord:** Join our [Discord server](https://discord.gg/viaversion) and visit the [#exploit-report](https://discord.com/channels/316206679014244363/1388847764137316485) channel for further instructions.
|
||||
|
||||
If your issue is **not security-related** (e.g., bug reports, feature requests, or usage questions), please use the [GitHub Issues page](https://github.com/ViaVersion/ViaBackwards/issues) or contact us via the [Discord server](https://discord.gg/viaversion).
|
||||
@@ -8,5 +8,7 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
// version must be manually kept in sync with the one in root project settings.gradle.kts
|
||||
implementation("com.gradleup.shadow", "shadow-gradle-plugin", "8.3.0")
|
||||
implementation("com.gradleup.shadow:shadow-gradle-plugin:9.4.1")
|
||||
|
||||
// A nice no-conflict comment for patching in downgrading
|
||||
}
|
||||
@@ -1,6 +1,12 @@
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.JavaPluginExtension
|
||||
import org.gradle.api.provider.ListProperty
|
||||
import org.gradle.api.provider.ValueSource
|
||||
import org.gradle.api.provider.ValueSourceParameters
|
||||
import org.gradle.jvm.toolchain.JavaLanguageVersion
|
||||
import org.gradle.process.ExecOperations
|
||||
import java.io.ByteArrayOutputStream
|
||||
import javax.inject.Inject
|
||||
|
||||
fun Project.latestCommitHash(): String {
|
||||
return runGitCommand(listOf("rev-parse", "--short", "HEAD"))
|
||||
@@ -15,11 +21,36 @@ fun Project.branchName(): String {
|
||||
}
|
||||
|
||||
fun Project.runGitCommand(args: List<String>): String {
|
||||
return providers.exec {
|
||||
commandLine = listOf("git") + args
|
||||
}.standardOutput.asBytes.get().toString(Charsets.UTF_8).trim()
|
||||
return providers.of(GitCommand::class.java) { parameters.args.set(args) }.getOrNull() ?: "unknown"
|
||||
}
|
||||
|
||||
abstract class GitCommand : ValueSource<String, GitCommand.GitCommandParameters> {
|
||||
|
||||
@get:Inject
|
||||
abstract val execOperations: ExecOperations
|
||||
|
||||
interface GitCommandParameters : ValueSourceParameters {
|
||||
val args: ListProperty<String>
|
||||
}
|
||||
|
||||
override fun obtain(): String? {
|
||||
try {
|
||||
val command = listOf("git") + parameters.args.get()
|
||||
val output = ByteArrayOutputStream()
|
||||
execOperations.exec {
|
||||
commandLine = command
|
||||
standardOutput = output
|
||||
isIgnoreExitValue = true
|
||||
}
|
||||
|
||||
return output.toString(Charsets.UTF_8).trim().takeIf { it.isNotBlank() }
|
||||
} catch (e: Exception) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun Project.parseMinecraftSnapshotVersion(version: String): String? {
|
||||
val separatorIndex = version.indexOf('-')
|
||||
val lastSeparatorIndex = version.lastIndexOf('-')
|
||||
|
||||
@@ -8,7 +8,7 @@ tasks {
|
||||
val ver = project.version.toString()
|
||||
val desc = project.description
|
||||
filesMatching(listOf("plugin.yml", "META-INF/sponge_plugins.json", "fabric.mod.json")) {
|
||||
expand("version" to ver, "description" to desc)
|
||||
expand(mapOf("version" to ver, "description" to desc))
|
||||
}
|
||||
}
|
||||
javadoc {
|
||||
@@ -18,6 +18,7 @@ tasks {
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.compilerArgs.addAll(listOf("-nowarn", "-Xlint:-unchecked", "-Xlint:-deprecation"))
|
||||
options.isFork = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ tasks {
|
||||
from(project.rootProject.file("LICENSE"))
|
||||
}
|
||||
val shadowJar = named<ShadowJar>("shadowJar") {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
archiveClassifier.set("")
|
||||
configureRelocations()
|
||||
}
|
||||
|
||||
+1
-2
@@ -13,8 +13,7 @@ val main = setOf(
|
||||
projects.viabackwards,
|
||||
projects.viabackwardsCommon,
|
||||
projects.viabackwardsBukkit,
|
||||
projects.viabackwardsVelocity,
|
||||
projects.viabackwardsFabric
|
||||
projects.viabackwardsVelocity
|
||||
).map { it.path }
|
||||
|
||||
subprojects {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -19,11 +19,12 @@
|
||||
package com.viaversion.viabackwards;
|
||||
|
||||
import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
|
||||
import com.viaversion.viabackwards.listener.BlockBreakListener;
|
||||
import com.viaversion.viabackwards.listener.FireDamageListener;
|
||||
import com.viaversion.viabackwards.listener.FireExtinguishListener;
|
||||
import com.viaversion.viabackwards.listener.LecternInteractListener;
|
||||
import com.viaversion.viabackwards.listener.PlayerItemDropListener;
|
||||
import com.viaversion.viabackwards.listener.DurabilitySync1_11;
|
||||
import com.viaversion.viabackwards.listener.PlayerHurtSound1_12;
|
||||
import com.viaversion.viabackwards.listener.FireExtinguish1_16;
|
||||
import com.viaversion.viabackwards.listener.LecternInteract1_14;
|
||||
import com.viaversion.viabackwards.listener.ItemDropSync1_17;
|
||||
import com.viaversion.viabackwards.listener.SpearAttack1_21_11;
|
||||
import com.viaversion.viabackwards.protocol.v1_20_2to1_20.provider.AdvancementCriteriaProvider;
|
||||
import com.viaversion.viabackwards.provider.BukkitAdvancementCriteriaProvider;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
@@ -53,20 +54,23 @@ public class BukkitPlugin extends JavaPlugin implements ViaBackwardsPlatform {
|
||||
ViaBackwardsPlatform.super.enable();
|
||||
|
||||
final ProtocolVersion protocolVersion = Via.getAPI().getServerVersion().highestSupportedProtocolVersion();
|
||||
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_21_11)) {
|
||||
new SpearAttack1_21_11(this).register();
|
||||
}
|
||||
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_17)) {
|
||||
new PlayerItemDropListener(this).register();
|
||||
new ItemDropSync1_17(this).register();
|
||||
}
|
||||
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_16)) {
|
||||
new FireExtinguishListener(this).register();
|
||||
new FireExtinguish1_16(this).register();
|
||||
}
|
||||
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_14)) {
|
||||
new LecternInteractListener(this).register();
|
||||
new LecternInteract1_14(this).register();
|
||||
}
|
||||
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_12)) {
|
||||
new FireDamageListener(this).register();
|
||||
new PlayerHurtSound1_12(this).register();
|
||||
}
|
||||
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_11)) {
|
||||
new BlockBreakListener(this).register();
|
||||
new DurabilitySync1_11(this).register();
|
||||
}
|
||||
|
||||
final ViaProviders providers = Via.getManager().getProviders();
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -27,9 +27,9 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class BlockBreakListener extends ViaBukkitListener {
|
||||
public class DurabilitySync1_11 extends ViaBukkitListener {
|
||||
|
||||
public BlockBreakListener(final BukkitPlugin plugin) {
|
||||
public DurabilitySync1_11(final BukkitPlugin plugin) {
|
||||
super(plugin, Protocol1_11To1_10.class);
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -28,9 +28,9 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class FireExtinguishListener extends ViaBukkitListener {
|
||||
public class FireExtinguish1_16 extends ViaBukkitListener {
|
||||
|
||||
public FireExtinguishListener(BukkitPlugin plugin) {
|
||||
public FireExtinguish1_16(BukkitPlugin plugin) {
|
||||
super(plugin, Protocol1_16To1_15_2.class);
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -27,9 +27,9 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class PlayerItemDropListener extends ViaBukkitListener {
|
||||
public class ItemDropSync1_17 extends ViaBukkitListener {
|
||||
|
||||
public PlayerItemDropListener(final BukkitPlugin plugin) {
|
||||
public ItemDropSync1_17(final BukkitPlugin plugin) {
|
||||
super(plugin, Protocol1_13_1To1_13.class); // Starts with 1.13 clients on 1.17 servers
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -30,9 +30,9 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
|
||||
public class LecternInteractListener extends ViaBukkitListener {
|
||||
public class LecternInteract1_14 extends ViaBukkitListener {
|
||||
|
||||
public LecternInteractListener(BukkitPlugin plugin) {
|
||||
public LecternInteract1_14(BukkitPlugin plugin) {
|
||||
super(plugin, Protocol1_14To1_13_2.class);
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -28,9 +28,9 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
public class FireDamageListener extends ViaBukkitListener {
|
||||
public class PlayerHurtSound1_12 extends ViaBukkitListener {
|
||||
|
||||
public FireDamageListener(BukkitPlugin plugin) {
|
||||
public PlayerHurtSound1_12(BukkitPlugin plugin) {
|
||||
super(plugin, Protocol1_12To1_11_1.class);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.listener;
|
||||
|
||||
import com.viaversion.viabackwards.BukkitPlugin;
|
||||
import com.viaversion.viabackwards.protocol.v1_21_11to1_21_9.Protocol1_21_11To1_21_9;
|
||||
import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class SpearAttack1_21_11 extends ViaBukkitListener {
|
||||
|
||||
public SpearAttack1_21_11(final BukkitPlugin plugin) {
|
||||
super(plugin, Protocol1_21_11To1_21_9.class);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onBlockBreak(final BlockBreakEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (!isOnPipe(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ItemStack item = player.getInventory().getItemInMainHand();
|
||||
if (item.getType().name().endsWith("_SPEAR")) {
|
||||
// Prevent spears from breaking blocks
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+24
-16
@@ -27,29 +27,37 @@ java {
|
||||
|
||||
// Task to quickly test/debug code changes using https://github.com/ViaVersion/ViaProxy
|
||||
// For further instructions see the ViaProxy repository README
|
||||
tasks.register<JavaExec>("runViaProxy") {
|
||||
dependsOn(tasks.shadowJar)
|
||||
val prepareViaProxyFiles by tasks.registering(Copy::class) {
|
||||
dependsOn(project.tasks.shadowJar)
|
||||
|
||||
val viaProxyConfiguration = configurations.create("viaProxy")
|
||||
viaProxyConfiguration.dependencies.add(dependencies.create(rootProject.libs.viaProxy.get().copy().setTransitive(false)))
|
||||
from(project.tasks.shadowJar.map { it.archiveFile.get().asFile })
|
||||
into(layout.projectDirectory.dir("run/jars"))
|
||||
|
||||
val projectName = project.name
|
||||
rename { "${projectName}.jar" }
|
||||
}
|
||||
|
||||
val cleanupViaProxyFiles by tasks.registering(Delete::class) {
|
||||
delete(
|
||||
layout.projectDirectory.file("run/jars/${project.name}.jar"),
|
||||
layout.projectDirectory.dir("run/logs")
|
||||
)
|
||||
}
|
||||
|
||||
val viaProxyConfiguration: Configuration by configurations.creating {
|
||||
dependencies.add(rootProject.libs.viaProxy.get().copy().setTransitive(false))
|
||||
}
|
||||
|
||||
tasks.register<JavaExec>("runViaProxy") {
|
||||
dependsOn(prepareViaProxyFiles)
|
||||
finalizedBy(cleanupViaProxyFiles)
|
||||
|
||||
mainClass.set("net.raphimc.viaproxy.ViaProxy")
|
||||
classpath = viaProxyConfiguration
|
||||
workingDir = file("run")
|
||||
workingDir = layout.projectDirectory.dir("run").asFile
|
||||
jvmArgs = listOf("-DskipUpdateCheck")
|
||||
|
||||
if (System.getProperty("viaproxy.gui.autoStart") != null) {
|
||||
jvmArgs("-Dviaproxy.gui.autoStart")
|
||||
}
|
||||
|
||||
doFirst {
|
||||
val jarsDir = file("$workingDir/jars")
|
||||
jarsDir.mkdirs()
|
||||
file("$jarsDir/${project.name}.jar").writeBytes(tasks.shadowJar.get().archiveFile.get().asFile.readBytes())
|
||||
}
|
||||
|
||||
doLast {
|
||||
file("$workingDir/jars/${project.name}.jar").delete()
|
||||
file("$workingDir/logs").deleteRecursively()
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,7 +17,10 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards;
|
||||
|
||||
import com.viaversion.viabackwards.api.DialogStyleConfig;
|
||||
import com.viaversion.viaversion.util.ChatColorUtil;
|
||||
import com.viaversion.viaversion.util.Config;
|
||||
import com.viaversion.viaversion.util.ConfigSection;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
@@ -36,9 +39,15 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback
|
||||
private boolean handlePingsAsInvAcknowledgements;
|
||||
private boolean bedrockAtY0;
|
||||
private boolean sculkShriekersToCryingObsidian;
|
||||
private boolean scaffoldingToWater;
|
||||
private boolean mapDarknessEffect;
|
||||
private boolean mapCustomModelData;
|
||||
private boolean mapDisplayEntities;
|
||||
private boolean suppressEmulationWarnings;
|
||||
private boolean dialogsViaChests;
|
||||
private DialogStyleConfig dialogStyleConfig;
|
||||
private boolean codeOfConductAsDialog;
|
||||
private boolean passOriginalItemNameToResourcePacks;
|
||||
|
||||
public ViaBackwardsConfig(File configFile, Logger logger) {
|
||||
super(configFile, logger);
|
||||
@@ -59,9 +68,37 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback
|
||||
handlePingsAsInvAcknowledgements = getBoolean("handle-pings-as-inv-acknowledgements", false);
|
||||
bedrockAtY0 = getBoolean("bedrock-at-y-0", false);
|
||||
sculkShriekersToCryingObsidian = getBoolean("sculk-shriekers-to-crying-obsidian", false);
|
||||
scaffoldingToWater = getBoolean("scaffolding-to-water", false);
|
||||
mapDarknessEffect = getBoolean("map-darkness-effect", true);
|
||||
mapCustomModelData = getBoolean("map-custom-model-data", true);
|
||||
mapDisplayEntities = getBoolean("map-display-entities", true);
|
||||
suppressEmulationWarnings = getBoolean("suppress-emulation-warnings", false);
|
||||
dialogsViaChests = getBoolean("dialogs-via-chests", true);
|
||||
dialogStyleConfig = loadDialogStyleConfig(getSection("dialog-style"));
|
||||
codeOfConductAsDialog = getBoolean("code-of-conduct-as-dialog", true);
|
||||
passOriginalItemNameToResourcePacks = getBoolean("pass-original-item-name-to-resource-packs", true);
|
||||
}
|
||||
|
||||
private DialogStyleConfig loadDialogStyleConfig(final ConfigSection section) {
|
||||
return new DialogStyleConfig(
|
||||
getString(section, "page-navigation-title", "&9&lPage navigation"),
|
||||
getString(section, "page-navigation-next", "&9Left click: &6Go to next page"),
|
||||
getString(section, "page-navigation-previous", "&9Right click: &6Go to previous page"),
|
||||
getString(section, "increase-value", "&9Left click: &6Increase value by %s"),
|
||||
getString(section, "decrease-value", "&9Right click: &6Decrease value by %s"),
|
||||
getString(section, "value-range", "&7(Value between &a%s &7and &a%s&7)"),
|
||||
getString(section, "next-option", "&9Left click: &6Go to next option"),
|
||||
getString(section, "previous-option", "&9Right click: &6Go to previous option"),
|
||||
getString(section, "current-value", "&7Current value: &a%s"),
|
||||
getString(section, "edit-value", "&9Left click: &6Edit text"),
|
||||
getString(section, "set-text", "&9Left click/close: &6Set text"),
|
||||
getString(section, "close", "&9Left click: &6Close"),
|
||||
getString(section, "toggle-value", "&9Left click: &6Toggle value")
|
||||
);
|
||||
}
|
||||
|
||||
protected String getString(final ConfigSection section, final String key, final String def) {
|
||||
return ChatColorUtil.translateAlternateColorCodes(section.getString(key, def));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,6 +141,11 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback
|
||||
return sculkShriekersToCryingObsidian;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean scaffoldingToWater() {
|
||||
return scaffoldingToWater;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mapDarknessEffect() {
|
||||
return mapDarknessEffect;
|
||||
@@ -114,11 +156,36 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback
|
||||
return mapCustomModelData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mapDisplayEntities() {
|
||||
return mapDisplayEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean suppressEmulationWarnings() {
|
||||
return suppressEmulationWarnings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dialogsViaChests() {
|
||||
return dialogsViaChests;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DialogStyleConfig dialogStyleConfig() {
|
||||
return dialogStyleConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean codeOfConductAsDialog() {
|
||||
return codeOfConductAsDialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passOriginalItemNameToResourcePacks() {
|
||||
return passOriginalItemNameToResourcePacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getDefaultConfigURL() {
|
||||
return getClass().getClassLoader().getResource("assets/viabackwards/config.yml");
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards;
|
||||
|
||||
import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ViaBackwardsPlatformImpl implements ViaBackwardsPlatform {
|
||||
|
||||
private final Logger logger;
|
||||
|
||||
public ViaBackwardsPlatformImpl() {
|
||||
logger = Via.getPlatform().createLogger("ViaBackwards");
|
||||
init(new File(getDataFolder(), "viabackwards.yml"));
|
||||
enable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDataFolder() {
|
||||
return Via.getPlatform().getDataFolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOutdated() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,17 +18,20 @@
|
||||
package com.viaversion.viabackwards.api;
|
||||
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
|
||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viabackwards.api.rewriters.BackwardsRegistryRewriter;
|
||||
import com.viaversion.viabackwards.protocol.registration.BackwardsRegistrations;
|
||||
import com.viaversion.viabackwards.utils.BackwardsProtocolLogger;
|
||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
||||
import com.viaversion.viaversion.util.ProtocolLogger;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public abstract class BackwardsProtocol<CU extends ClientboundPacketType, CM extends ClientboundPacketType, SM extends ServerboundPacketType, SU extends ServerboundPacketType>
|
||||
extends AbstractProtocol<CU, CM, SM, SU> {
|
||||
|
||||
@Deprecated
|
||||
protected BackwardsProtocol() {
|
||||
}
|
||||
|
||||
@@ -37,36 +40,29 @@ public abstract class BackwardsProtocol<CU extends ClientboundPacketType, CM ext
|
||||
super(oldClientboundPacketEnum, clientboundPacketEnum, oldServerboundPacketEnum, serverboundPacketEnum);
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for the given protocol to be loaded to then asynchronously execute the runnable for this protocol.
|
||||
*/
|
||||
protected void executeAsyncAfterLoaded(Class<? extends Protocol> protocolClass, Runnable runnable) {
|
||||
Via.getManager().getProtocolManager().addMappingLoaderFuture(getClass(), protocolClass, runnable);
|
||||
@Override
|
||||
protected void applySharedRegistrations() {
|
||||
super.applySharedRegistrations();
|
||||
BackwardsRegistrations.registrations().applyMatching(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
super.registerPackets();
|
||||
|
||||
final BackwardsMappingData mappingData = getMappingData();
|
||||
if (mappingData != null && mappingData.getViaVersionProtocolClass() != null) {
|
||||
executeAsyncAfterLoaded(mappingData.getViaVersionProtocolClass(), this::loadMappingData);
|
||||
}
|
||||
protected ProtocolLogger createLogger() {
|
||||
return new BackwardsProtocolLogger(getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMappingDataToLoad() {
|
||||
// Manually load them later, since they depend on VV's mappings
|
||||
return false;
|
||||
public @Nullable Class<? extends Protocol<?, ?, ?, ?>> dependsOn() {
|
||||
return getMappingData() != null ? getMappingData().getViaVersionProtocolClass() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BackwardsMappingData getMappingData() { // Change return type to BackwardsMappings
|
||||
public @Nullable BackwardsMappingData getMappingData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable TranslatableRewriter<CU> getComponentRewriter() {
|
||||
public @Nullable BackwardsRegistryRewriter getRegistryDataRewriter() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.api;
|
||||
|
||||
public record DialogStyleConfig(String pageNavigationTitle, String pageNavigationNext, String pageNavigationPrevious,
|
||||
String increaseValue, String decreaseValue, String valueRange, String nextOption,
|
||||
String previousOption, String currentValue, String editValue, String setText,
|
||||
String close, String toggleValue) {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -78,6 +78,13 @@ public interface ViaBackwardsConfig extends Config {
|
||||
*/
|
||||
boolean sculkShriekerToCryingObsidian();
|
||||
|
||||
/**
|
||||
* Shows scaffolding as water for 1.13.2 clients on 1.14+ servers. This fixes collision issues.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean scaffoldingToWater();
|
||||
|
||||
/**
|
||||
* Maps the darkness effect to blindness for 1.18.2 clients on 1.19+ servers.
|
||||
*
|
||||
@@ -92,10 +99,47 @@ public interface ViaBackwardsConfig extends Config {
|
||||
*/
|
||||
boolean mapCustomModelData();
|
||||
|
||||
/**
|
||||
* If enabled, 1.19.3 clients will receive display entities as armor stands with custom entity data on 1.19.4+ servers.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean mapDisplayEntities();
|
||||
|
||||
/**
|
||||
* Suppresses warnings of missing emulations for certain features that are not supported (e.g. world height in 1.17+).
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean suppressEmulationWarnings();
|
||||
|
||||
/**
|
||||
* If enabled, dialogs will be shown via chest inventories for 1.21.5 clients on 1.21.6+ servers.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean dialogsViaChests();
|
||||
|
||||
/**
|
||||
* Returns the dialog style configuration.
|
||||
*
|
||||
* @return the dialog style configuration
|
||||
*/
|
||||
DialogStyleConfig dialogStyleConfig();
|
||||
|
||||
/**
|
||||
* If true, the code of conduct will be displayed as a dialog for 1.21.7 clients on 1.21.9+ servers.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean codeOfConductAsDialog();
|
||||
|
||||
/**
|
||||
* Injects the original vanilla 1.21.4+ item name into custom_model_data strings for resource packs.
|
||||
* Disable if your server creates custom items using modern items as their base.
|
||||
* Tip: For server custom items, base them on items in the game before 1.21.4 (e.g. saddle) to ensure compatibility.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean passOriginalItemNameToResourcePacks();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,47 +20,55 @@ package com.viaversion.viabackwards.api;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.ViaBackwardsConfig;
|
||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_11to1_10.Protocol1_11To1_10;
|
||||
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.Protocol1_12To1_11_1;
|
||||
import com.viaversion.viabackwards.api.data.TranslatableMappings;
|
||||
import com.viaversion.viabackwards.protocol.registration.BackwardsRegistrations;
|
||||
import com.viaversion.viabackwards.protocol.v1_10to1_9_3.Protocol1_10To1_9_3;
|
||||
import com.viaversion.viabackwards.protocol.v1_11_1to1_11.Protocol1_11_1To1_11;
|
||||
import com.viaversion.viabackwards.protocol.v1_12_2to1_12_1.Protocol1_12_2To1_12_1;
|
||||
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import com.viaversion.viabackwards.protocol.v1_11to1_10.Protocol1_11To1_10;
|
||||
import com.viaversion.viabackwards.protocol.v1_12_1to1_12.Protocol1_12_1To1_12;
|
||||
import com.viaversion.viabackwards.protocol.v1_13_2to1_13_1.Protocol1_13_2To1_13_1;
|
||||
import com.viaversion.viabackwards.protocol.v1_14to1_13_2.Protocol1_14To1_13_2;
|
||||
import com.viaversion.viabackwards.protocol.v1_12_2to1_12_1.Protocol1_12_2To1_12_1;
|
||||
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.Protocol1_12To1_11_1;
|
||||
import com.viaversion.viabackwards.protocol.v1_13_1to1_13.Protocol1_13_1To1_13;
|
||||
import com.viaversion.viabackwards.protocol.v1_13_2to1_13_1.Protocol1_13_2To1_13_1;
|
||||
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import com.viaversion.viabackwards.protocol.v1_14_1to1_14.Protocol1_14_1To1_14;
|
||||
import com.viaversion.viabackwards.protocol.v1_14_2to1_14_1.Protocol1_14_2To1_14_1;
|
||||
import com.viaversion.viabackwards.protocol.v1_14_3to1_14_2.Protocol1_14_3To1_14_2;
|
||||
import com.viaversion.viabackwards.protocol.v1_14_4to1_14_3.Protocol1_14_4To1_14_3;
|
||||
import com.viaversion.viabackwards.protocol.v1_15to1_14_4.Protocol1_15To1_14_4;
|
||||
import com.viaversion.viabackwards.protocol.v1_14_1to1_14.Protocol1_14_1To1_14;
|
||||
import com.viaversion.viabackwards.protocol.v1_15_2to1_15_1.Protocol1_15_2To1_15_1;
|
||||
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.Protocol1_16To1_15_2;
|
||||
import com.viaversion.viabackwards.protocol.v1_14to1_13_2.Protocol1_14To1_13_2;
|
||||
import com.viaversion.viabackwards.protocol.v1_15_1to1_15.Protocol1_15_1To1_15;
|
||||
import com.viaversion.viabackwards.protocol.v1_15_2to1_15_1.Protocol1_15_2To1_15_1;
|
||||
import com.viaversion.viabackwards.protocol.v1_15to1_14_4.Protocol1_15To1_14_4;
|
||||
import com.viaversion.viabackwards.protocol.v1_16_1to1_16.Protocol1_16_1To1_16;
|
||||
import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.Protocol1_16_2To1_16_1;
|
||||
import com.viaversion.viabackwards.protocol.v1_16_3to1_16_2.Protocol1_16_3To1_16_2;
|
||||
import com.viaversion.viabackwards.protocol.v1_16_4to1_16_3.Protocol1_16_4To1_16_3;
|
||||
import com.viaversion.viabackwards.protocol.v1_17to1_16_4.Protocol1_17To1_16_4;
|
||||
import com.viaversion.viabackwards.protocol.v1_16_1to1_16.Protocol1_16_1To1_16;
|
||||
import com.viaversion.viabackwards.protocol.v1_18to1_17_1.Protocol1_18To1_17_1;
|
||||
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.Protocol1_16To1_15_2;
|
||||
import com.viaversion.viabackwards.protocol.v1_17_1to1_17.Protocol1_17_1To1_17;
|
||||
import com.viaversion.viabackwards.protocol.v1_19to1_18_2.Protocol1_19To1_18_2;
|
||||
import com.viaversion.viabackwards.protocol.v1_17to1_16_4.Protocol1_17To1_16_4;
|
||||
import com.viaversion.viabackwards.protocol.v1_18_2to1_18.Protocol1_18_2To1_18;
|
||||
import com.viaversion.viabackwards.protocol.v1_18to1_17_1.Protocol1_18To1_17_1;
|
||||
import com.viaversion.viabackwards.protocol.v1_19_1to1_19.Protocol1_19_1To1_19;
|
||||
import com.viaversion.viabackwards.protocol.v1_19_3to1_19_1.Protocol1_19_3To1_19_1;
|
||||
import com.viaversion.viabackwards.protocol.v1_19_4to1_19_3.Protocol1_19_4To1_19_3;
|
||||
import com.viaversion.viabackwards.protocol.v1_21_4to1_21_2.Protocol1_21_4To1_21_2;
|
||||
import com.viaversion.viabackwards.protocol.v1_20to1_19_4.Protocol1_20To1_19_4;
|
||||
import com.viaversion.viabackwards.protocol.v1_19_1to1_19.Protocol1_19_1To1_19;
|
||||
import com.viaversion.viabackwards.protocol.v1_19to1_18_2.Protocol1_19To1_18_2;
|
||||
import com.viaversion.viabackwards.protocol.v1_20_2to1_20.Protocol1_20_2To1_20;
|
||||
import com.viaversion.viabackwards.protocol.v1_20_3to1_20_2.Protocol1_20_3To1_20_2;
|
||||
import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.Protocol1_20_5To1_20_3;
|
||||
import com.viaversion.viabackwards.protocol.v1_20_2to1_20.Protocol1_20_2To1_20;
|
||||
import com.viaversion.viabackwards.protocol.v1_20to1_19_4.Protocol1_20To1_19_4;
|
||||
import com.viaversion.viabackwards.protocol.v1_21_11to1_21_9.Protocol1_21_11To1_21_9;
|
||||
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.Protocol1_21_2To1_21;
|
||||
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.task.PlayerPacketsTickTask;
|
||||
import com.viaversion.viabackwards.protocol.v1_21_4to1_21_2.Protocol1_21_4To1_21_2;
|
||||
import com.viaversion.viabackwards.protocol.v1_21_5to1_21_4.Protocol1_21_5To1_21_4;
|
||||
import com.viaversion.viabackwards.protocol.v1_21_6to1_21_5.Protocol1_21_6To1_21_5;
|
||||
import com.viaversion.viabackwards.protocol.v1_21_6to1_21_5.task.ChestDialogViewTask;
|
||||
import com.viaversion.viabackwards.protocol.v1_21_7to1_21_6.Protocol1_21_7To1_21_6;
|
||||
import com.viaversion.viabackwards.protocol.v1_21_9to1_21_7.Protocol1_21_9To1_21_7;
|
||||
import com.viaversion.viabackwards.protocol.v1_21to1_20_5.Protocol1_21To1_20_5;
|
||||
import com.viaversion.viabackwards.protocol.v1_9_3to1_9_1.Protocol1_9_3To1_9_1;
|
||||
import com.viaversion.viabackwards.protocol.v1_10to1_9_3.Protocol1_10To1_9_3;
|
||||
import com.viaversion.viabackwards.protocol.v1_9_1to1_9.Protocol1_9_1To1_9;
|
||||
import com.viaversion.viabackwards.protocol.v1_9_3to1_9_1.Protocol1_9_3To1_9_1;
|
||||
import com.viaversion.viabackwards.protocol.v26_1to1_21_11.Protocol26_1To1_21_11;
|
||||
import com.viaversion.viabackwards.utils.VersionInfo;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.ProtocolManager;
|
||||
@@ -72,13 +80,16 @@ import java.util.logging.Logger;
|
||||
|
||||
public interface ViaBackwardsPlatform {
|
||||
|
||||
String MINIMUM_VV_VERSION = "5.2.1";
|
||||
String MINIMUM_VV_VERSION = "5.8.1";
|
||||
|
||||
default void init(final File configFile) {
|
||||
init(new ViaBackwardsConfig(configFile, getLogger()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize ViaBackwards.
|
||||
*/
|
||||
default void init(final File configFile) {
|
||||
ViaBackwardsConfig config = new ViaBackwardsConfig(configFile, getLogger());
|
||||
default void init(final com.viaversion.viabackwards.api.ViaBackwardsConfig config) {
|
||||
config.reload();
|
||||
Via.getManager().getConfigurationProvider().register(config);
|
||||
|
||||
@@ -92,9 +103,11 @@ public interface ViaBackwardsPlatform {
|
||||
Via.getManager().getSubPlatforms().add(VersionInfo.getImplementationVersion());
|
||||
|
||||
getLogger().info("Loading translations...");
|
||||
TranslatableRewriter.loadTranslatables();
|
||||
TranslatableMappings.loadTranslatables();
|
||||
|
||||
getLogger().info("Registering protocols...");
|
||||
BackwardsRegistrations.apply();
|
||||
|
||||
final ProtocolManager protocolManager = Via.getManager().getProtocolManager();
|
||||
protocolManager.registerProtocol(new Protocol1_9_1To1_9(), ProtocolVersion.v1_9, ProtocolVersion.v1_9_1);
|
||||
protocolManager.registerProtocol(new Protocol1_9_3To1_9_1(), Arrays.asList(ProtocolVersion.v1_9_1, ProtocolVersion.v1_9_2), ProtocolVersion.v1_9_3);
|
||||
@@ -146,6 +159,14 @@ public interface ViaBackwardsPlatform {
|
||||
protocolManager.registerProtocol(new Protocol1_21To1_20_5(), ProtocolVersion.v1_20_5, ProtocolVersion.v1_21);
|
||||
protocolManager.registerProtocol(new Protocol1_21_2To1_21(), ProtocolVersion.v1_21, ProtocolVersion.v1_21_2);
|
||||
protocolManager.registerProtocol(new Protocol1_21_4To1_21_2(), ProtocolVersion.v1_21_2, ProtocolVersion.v1_21_4);
|
||||
protocolManager.registerProtocol(new Protocol1_21_5To1_21_4(), ProtocolVersion.v1_21_4, ProtocolVersion.v1_21_5);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_21_6To1_21_5(), ProtocolVersion.v1_21_5, ProtocolVersion.v1_21_6);
|
||||
protocolManager.registerProtocol(new Protocol1_21_7To1_21_6(), ProtocolVersion.v1_21_6, ProtocolVersion.v1_21_7);
|
||||
protocolManager.registerProtocol(new Protocol1_21_9To1_21_7(), ProtocolVersion.v1_21_7, ProtocolVersion.v1_21_9);
|
||||
protocolManager.registerProtocol(new Protocol1_21_11To1_21_9(), ProtocolVersion.v1_21_9, ProtocolVersion.v1_21_11);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol26_1To1_21_11(), ProtocolVersion.v1_21_11, ProtocolVersion.v26_1);
|
||||
}
|
||||
|
||||
default void enable() {
|
||||
@@ -153,6 +174,10 @@ public interface ViaBackwardsPlatform {
|
||||
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_21_2)) {
|
||||
Via.getPlatform().runRepeatingSync(new PlayerPacketsTickTask(), 1L);
|
||||
}
|
||||
|
||||
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_21_6)) {
|
||||
Via.getPlatform().runRepeatingSync(new ChestDialogViewTask(), 20L);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+6
-16
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,6 +18,10 @@
|
||||
package com.viaversion.viabackwards.api.data;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.NumberTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
@@ -30,11 +34,6 @@ import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectArrayMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.NumberTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
@@ -45,7 +44,6 @@ public class BackwardsMappingData extends MappingDataBase {
|
||||
|
||||
private final Class<? extends Protocol<?, ?, ?, ?>> vvProtocolClass;
|
||||
protected Int2ObjectMap<MappedItem> backwardsItemMappings;
|
||||
private Map<String, String> backwardsSoundMappings;
|
||||
private Map<String, String> entityNames;
|
||||
private Int2ObjectMap<String> enchantmentNames;
|
||||
|
||||
@@ -83,7 +81,6 @@ public class BackwardsMappingData extends MappingDataBase {
|
||||
|
||||
this.entityNames = loadNameByStringMappings(data, "entitynames");
|
||||
this.enchantmentNames = loadNameByIdMappings(data, "enchantmentnames");
|
||||
this.backwardsSoundMappings = loadNameByStringMappings(data, "soundnames");
|
||||
}
|
||||
|
||||
private @Nullable Map<String, String> loadNameByStringMappings(final CompoundTag data, final String key) {
|
||||
@@ -161,10 +158,7 @@ public class BackwardsMappingData extends MappingDataBase {
|
||||
}
|
||||
|
||||
public @Nullable String getMappedNamedSound(final String id) {
|
||||
if (backwardsSoundMappings == null) {
|
||||
return null;
|
||||
}
|
||||
return backwardsSoundMappings.get(Key.stripMinecraftNamespace(id));
|
||||
return getFullSoundMappings().mappedIdentifier(id);
|
||||
}
|
||||
|
||||
public @Nullable String mappedEntityName(final String entityName) {
|
||||
@@ -187,10 +181,6 @@ public class BackwardsMappingData extends MappingDataBase {
|
||||
return backwardsItemMappings;
|
||||
}
|
||||
|
||||
public @Nullable Map<String, String> getBackwardsSoundMappings() {
|
||||
return backwardsSoundMappings;
|
||||
}
|
||||
|
||||
public @Nullable Class<? extends Protocol<?, ?, ?, ?>> getViaVersionProtocolClass() {
|
||||
return vvProtocolClass;
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.api.data;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+14
-39
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -15,26 +15,19 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.api.rewriters;
|
||||
package com.viaversion.viabackwards.api.data;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class TranslatableRewriter<C extends ClientboundPacketType> extends ComponentRewriter<C> {
|
||||
public final class TranslatableMappings {
|
||||
|
||||
private static final Map<String, Map<String, String>> TRANSLATABLES = new HashMap<>();
|
||||
private final Map<String, String> translatables;
|
||||
|
||||
public static void loadTranslatables() {
|
||||
if (!TRANSLATABLES.isEmpty()) {
|
||||
@@ -53,42 +46,24 @@ public class TranslatableRewriter<C extends ClientboundPacketType> extends Compo
|
||||
}
|
||||
}
|
||||
|
||||
public TranslatableRewriter(final BackwardsProtocol<C, ?, ?, ?> protocol, final ReadType type) {
|
||||
this(protocol, type, protocol.getClass().getSimpleName().replace("Protocol", "").split("To")[0].replace("_", "."));
|
||||
public static Map<String, String> translatablesFor(final Protocol<?, ?, ?, ?> protocol) {
|
||||
final String version = protocol.getClass().getSimpleName()
|
||||
.replace("Protocol", "")
|
||||
.split("To")[0]
|
||||
.replace("_", ".");
|
||||
return translatablesFor(version);
|
||||
}
|
||||
|
||||
public TranslatableRewriter(final BackwardsProtocol<C, ?, ?, ?> protocol, final ReadType type, final String version) {
|
||||
super(protocol, type);
|
||||
public static Map<String, String> translatablesFor(final String version) {
|
||||
final Map<String, String> translatableMappings = getTranslatableMappings(version);
|
||||
if (translatableMappings == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing " + version + " translatables!");
|
||||
this.translatables = new HashMap<>();
|
||||
} else {
|
||||
this.translatables = translatableMappings;
|
||||
return new HashMap<>();
|
||||
}
|
||||
return translatableMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleTranslate(final JsonObject root, final String translate) {
|
||||
final String newTranslate = mappedTranslationKey(translate);
|
||||
if (newTranslate != null) {
|
||||
root.addProperty("translate", newTranslate);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleTranslate(final UserConnection connection, final CompoundTag parentTag, final StringTag translateTag) {
|
||||
final String newTranslate = mappedTranslationKey(translateTag.getValue());
|
||||
if (newTranslate != null) {
|
||||
parentTag.put("translate", new StringTag(newTranslate));
|
||||
}
|
||||
}
|
||||
|
||||
public @Nullable String mappedTranslationKey(final String translationKey) {
|
||||
return translatables.get(translationKey);
|
||||
}
|
||||
|
||||
public static Map<String, String> getTranslatableMappings(final String sectionIdentifier) {
|
||||
public static @Nullable Map<String, String> getTranslatableMappings(final String sectionIdentifier) {
|
||||
return TRANSLATABLES.get(sectionIdentifier);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+5
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -47,7 +47,10 @@ public class EntityPositionHandler {
|
||||
}
|
||||
|
||||
public void cacheEntityPosition(PacketWrapper wrapper, double x, double y, double z, boolean create, boolean relative) {
|
||||
int entityId = wrapper.get(Types.VAR_INT, 0);
|
||||
cacheEntityPosition(wrapper, wrapper.get(Types.VAR_INT, 0), x, y, z, create, relative);
|
||||
}
|
||||
|
||||
public void cacheEntityPosition(PacketWrapper wrapper, int entityId, double x, double y, double z, boolean create, boolean relative) {
|
||||
StoredEntityData storedEntity = entityRewriter.tracker(wrapper.user()).entityData(entityId);
|
||||
if (storedEntity == null) {
|
||||
if (Via.getManager().isDebug()) { // There is too many plugins violating this out there, and reading seems to be hard! :>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
package com.viaversion.viabackwards.api.entities.storage;
|
||||
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
import java.util.Locale;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+38
-19
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -26,11 +26,14 @@ import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.MappedItem;
|
||||
import com.viaversion.viabackwards.item.DataItemWithExtras;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class BackwardsItemRewriter<C extends ClientboundPacketType, S extends ServerboundPacketType,
|
||||
@@ -52,29 +55,45 @@ public class BackwardsItemRewriter<C extends ClientboundPacketType, S extends Se
|
||||
|
||||
CompoundTag display = item.tag() != null ? item.tag().getCompoundTag("display") : null;
|
||||
if (protocol.getComponentRewriter() != null && display != null) {
|
||||
// Handle name and lore components
|
||||
StringTag name = display.getStringTag("Name");
|
||||
if (name != null) {
|
||||
String newValue = protocol.getComponentRewriter().processText(connection, name.getValue()).toString();
|
||||
if (!newValue.equals(name.getValue())) {
|
||||
saveStringTag(display, name, "Name");
|
||||
}
|
||||
|
||||
name.setValue(newValue);
|
||||
final DataItemWithExtras fullItem;
|
||||
if (item instanceof DataItemWithExtras) {
|
||||
fullItem = (DataItemWithExtras) item;
|
||||
} else {
|
||||
item = fullItem = new DataItemWithExtras(item);
|
||||
}
|
||||
|
||||
ListTag<StringTag> lore = display.getListTag("Lore", StringTag.class);
|
||||
// Handle name and lore components
|
||||
final JsonElement name = fullItem.name();
|
||||
if (name != null) {
|
||||
final JsonElement updatedName = name.deepCopy();
|
||||
protocol.getComponentRewriter().processText(connection, updatedName);
|
||||
if (!updatedName.equals(name)) {
|
||||
final StringTag rawName = fullItem.rawName();
|
||||
saveStringTag(display, rawName, "Name");
|
||||
rawName.setValue(updatedName.toString());
|
||||
}
|
||||
}
|
||||
|
||||
final List<JsonElement> lore = fullItem.lore();
|
||||
if (lore != null) {
|
||||
boolean changed = false;
|
||||
for (StringTag loreEntry : lore) {
|
||||
String newValue = protocol.getComponentRewriter().processText(connection, loreEntry.getValue()).toString();
|
||||
if (!changed && !newValue.equals(loreEntry.getValue())) {
|
||||
// Backup original lore before doing any modifications
|
||||
changed = true;
|
||||
saveListTag(display, lore, "Lore");
|
||||
final ListTag<StringTag> rawLore = fullItem.rawLore();
|
||||
for (int i = 0; i < lore.size(); i++) {
|
||||
final JsonElement loreEntry = lore.get(i);
|
||||
final JsonElement updatedLoreEntry = loreEntry.deepCopy();
|
||||
protocol.getComponentRewriter().processText(connection, updatedLoreEntry);
|
||||
if (updatedLoreEntry.equals(loreEntry)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
loreEntry.setValue(newValue);
|
||||
if (!changed) {
|
||||
// Backup original lore before doing any modifications
|
||||
changed = true;
|
||||
saveListTag(display, rawLore, "Lore");
|
||||
}
|
||||
|
||||
final StringTag rawLoreEntry = rawLore.get(i);
|
||||
rawLoreEntry.setValue(updatedLoreEntry.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,7 +132,7 @@ public class BackwardsItemRewriter<C extends ClientboundPacketType, S extends Se
|
||||
public @Nullable Item handleItemToServer(UserConnection connection, @Nullable Item item) {
|
||||
if (item == null) return null;
|
||||
|
||||
super.handleItemToServer(connection, item);
|
||||
item = super.handleItemToServer(connection, item);
|
||||
if (item.tag() != null) {
|
||||
Tag originalId = item.tag().remove(nbtTagName("id"));
|
||||
if (originalId instanceof IntTag) {
|
||||
|
||||
+6
-8
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,19 +17,17 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.ListTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.ListTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public abstract class BackwardsItemRewriterBase<C extends ClientboundPacketType, S extends ServerboundPacketType,
|
||||
@@ -49,7 +47,7 @@ public abstract class BackwardsItemRewriterBase<C extends ClientboundPacketType,
|
||||
@Override
|
||||
public @Nullable Item handleItemToServer(UserConnection connection, @Nullable Item item) {
|
||||
if (item == null) return null;
|
||||
super.handleItemToServer(connection, item);
|
||||
item = super.handleItemToServer(connection, item);
|
||||
|
||||
restoreDisplayTag(item);
|
||||
return item;
|
||||
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryEntry;
|
||||
import com.viaversion.viaversion.rewriter.RegistryDataRewriter;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
|
||||
public class BackwardsRegistryRewriter extends RegistryDataRewriter {
|
||||
|
||||
private final BackwardsProtocol<?, ?, ?, ?> protocol;
|
||||
|
||||
public BackwardsRegistryRewriter(final BackwardsProtocol<?, ?, ?, ?> protocol) {
|
||||
super(protocol);
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegistryEntry[] handle(final UserConnection connection, final String key, final RegistryEntry[] entries) {
|
||||
if (Key.stripMinecraftNamespace(key).equals("worldgen/biome")) {
|
||||
for (final RegistryEntry entry : entries) {
|
||||
final CompoundTag biome = (CompoundTag) entry.tag();
|
||||
if (biome == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final CompoundTag effects = biome.getCompoundTag("effects");
|
||||
updateBiomeEffects(effects);
|
||||
}
|
||||
}
|
||||
return super.handle(connection, key, entries);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateJukeboxSongs(final RegistryEntry[] entries) {
|
||||
for (final RegistryEntry entry : entries) {
|
||||
if (entry.tag() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
updateSound((CompoundTag) entry.tag(), "sound_event");
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBiomeEffects(final CompoundTag effects) {
|
||||
updateSound(effects.getCompoundTag("mood_sound"), "sound");
|
||||
updateSound(effects.getCompoundTag("additions_sound"), "sound");
|
||||
updateSound(effects.getCompoundTag("music"), "sound");
|
||||
updateSound(effects, "ambient_sound");
|
||||
}
|
||||
|
||||
private void updateSound(final CompoundTag tag, final String name) {
|
||||
if (tag == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String sound = tag.getString(name);
|
||||
if (sound == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String mappedSound = protocol.getMappingData().getMappedNamedSound(sound);
|
||||
if (mappedSound == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mappedSound.isEmpty()) {
|
||||
tag.putString(name, "minecraft:intentionally_empty");
|
||||
} else {
|
||||
tag.putString(name, mappedSound);
|
||||
}
|
||||
}
|
||||
}
|
||||
+194
-69
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,17 +18,21 @@
|
||||
package com.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.FloatTag;
|
||||
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.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
|
||||
import com.viaversion.viabackwards.api.data.MappedItem;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.EitherHolder;
|
||||
import com.viaversion.viaversion.api.minecraft.Holder;
|
||||
import com.viaversion.viaversion.api.minecraft.HolderSet;
|
||||
import com.viaversion.viaversion.api.minecraft.SoundEvent;
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
@@ -36,8 +40,9 @@ import com.viaversion.viaversion.api.minecraft.item.data.CustomModelData1_21_4;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.rewriter.StructuredItemRewriter;
|
||||
import com.viaversion.viaversion.util.ArrayUtil;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
@@ -47,60 +52,35 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
public class BackwardsStructuredItemRewriter<C extends ClientboundPacketType, S extends ServerboundPacketType,
|
||||
T extends BackwardsProtocol<C, ?, ?, S>> extends StructuredItemRewriter<C, S, T> {
|
||||
|
||||
public BackwardsStructuredItemRewriter(
|
||||
T protocol,
|
||||
Type<Item> itemType, Type<Item[]> itemArrayType, Type<Item> mappedItemType, Type<Item[]> mappedItemArrayType,
|
||||
Type<Item> itemCostType, Type<Item> optionalItemCostType, Type<Item> mappedItemCostType, Type<Item> mappedOptionalItemCostType
|
||||
) {
|
||||
super(protocol, itemType, itemArrayType, mappedItemType, mappedItemArrayType, itemCostType, optionalItemCostType, mappedItemCostType, mappedOptionalItemCostType);
|
||||
}
|
||||
private static final int[] EMPTY_INT_ARRAY = new int[0];
|
||||
private static final String GLOBAL_MODEL_DATA_MARKER = "VB|injected_cmd";
|
||||
|
||||
public BackwardsStructuredItemRewriter(final T protocol, final Type<Item> itemType, final Type<Item[]> itemArrayType, final Type<Item> mappedItemType, final Type<Item[]> mappedItemArrayType) {
|
||||
super(protocol, itemType, itemArrayType, mappedItemType, mappedItemArrayType);
|
||||
}
|
||||
private final String nbtTagName;
|
||||
|
||||
public BackwardsStructuredItemRewriter(final T protocol, final Type<Item> itemType, final Type<Item[]> itemArrayType) {
|
||||
super(protocol, itemType, itemArrayType);
|
||||
public BackwardsStructuredItemRewriter(T protocol) {
|
||||
super(protocol);
|
||||
this.nbtTagName = "VB|" + protocol.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item handleItemToClient(final UserConnection connection, final Item item) {
|
||||
if (item.isEmpty()) {
|
||||
return item;
|
||||
}
|
||||
|
||||
final StructuredDataContainer dataContainer = item.dataContainer();
|
||||
updateItemDataComponentTypeIds(dataContainer, true);
|
||||
protected void backupInconvertibleData(final UserConnection connection, final Item item, final StructuredDataContainer dataContainer, final CompoundTag backupTag) {
|
||||
super.backupInconvertibleData(connection, item, dataContainer, backupTag);
|
||||
|
||||
final BackwardsMappingData mappingData = protocol.getMappingData();
|
||||
final MappedItem mappedItem = mappingData != null ? mappingData.getMappedItem(item.identifier()) : null;
|
||||
if (mappedItem == null) {
|
||||
// Just rewrite the id
|
||||
if (mappingData != null && mappingData.getItemMappings() != null) {
|
||||
item.setIdentifier(mappingData.getNewItemId(item.identifier()));
|
||||
}
|
||||
|
||||
updateItemDataComponents(connection, item, true);
|
||||
return item;
|
||||
return;
|
||||
}
|
||||
|
||||
// Save original id, set remapped id
|
||||
final CompoundTag tag = createCustomTag(item);
|
||||
tag.putInt(nbtTagName("id"), item.identifier());
|
||||
item.setIdentifier(mappedItem.id());
|
||||
final CompoundTag customTag = createCustomTag(item);
|
||||
customTag.putInt(nbtTagName("id"), item.identifier()); // Save original id
|
||||
|
||||
// Add custom model data
|
||||
if (mappedItem.customModelData() != null) {
|
||||
final boolean addOriginalIdentifier = ViaBackwards.getConfig().passOriginalItemNameToResourcePacks();
|
||||
if (mappedItem.customModelData() != null || addOriginalIdentifier) {
|
||||
if (connection.getProtocolInfo().protocolVersion().newerThanOrEqualTo(ProtocolVersion.v1_21_4)) {
|
||||
if (!dataContainer.has(StructuredDataKey.CUSTOM_MODEL_DATA1_21_4)) {
|
||||
dataContainer.set(StructuredDataKey.CUSTOM_MODEL_DATA1_21_4, new CustomModelData1_21_4(
|
||||
new float[]{mappedItem.customModelData().floatValue()},
|
||||
new boolean[0],
|
||||
new String[0],
|
||||
new int[0]
|
||||
));
|
||||
}
|
||||
} else if (!dataContainer.has(StructuredDataKey.CUSTOM_MODEL_DATA1_20_5)) {
|
||||
addCustomModelData(item, addOriginalIdentifier, mappedItem, customTag);
|
||||
} else if (mappedItem.customModelData() != null && !dataContainer.has(StructuredDataKey.CUSTOM_MODEL_DATA1_20_5)) {
|
||||
dataContainer.set(StructuredDataKey.CUSTOM_MODEL_DATA1_20_5, mappedItem.customModelData());
|
||||
}
|
||||
}
|
||||
@@ -108,38 +88,63 @@ public class BackwardsStructuredItemRewriter<C extends ClientboundPacketType, S
|
||||
// Set custom name - only done if there is no original one
|
||||
if (!dataContainer.has(StructuredDataKey.CUSTOM_NAME)) {
|
||||
dataContainer.set(StructuredDataKey.CUSTOM_NAME, mappedItem.tagName());
|
||||
tag.putBoolean(nbtTagName("added_custom_name"), true);
|
||||
customTag.putBoolean(nbtTagName("added_custom_name"), true);
|
||||
}
|
||||
}
|
||||
|
||||
updateItemDataComponents(connection, item, true);
|
||||
return item;
|
||||
private void addCustomModelData(final Item item, final boolean addOriginalIdentifier, final MappedItem mappedItem, final CompoundTag customTag) {
|
||||
final StructuredDataContainer dataContainer = item.dataContainer();
|
||||
CustomModelData1_21_4 customModelData = dataContainer.get(StructuredDataKey.CUSTOM_MODEL_DATA1_21_4);
|
||||
if (customModelData == null) {
|
||||
final String[] strings = addOriginalIdentifier
|
||||
? new String[]{protocol.getMappingData().getFullItemMappings().identifier(item.identifier())}
|
||||
: new String[0];
|
||||
customModelData = new CustomModelData1_21_4(
|
||||
mappedItem.customModelData() != null ? new float[]{mappedItem.customModelData().floatValue()} : new float[0],
|
||||
new boolean[0],
|
||||
strings,
|
||||
EMPTY_INT_ARRAY
|
||||
);
|
||||
dataContainer.set(StructuredDataKey.CUSTOM_MODEL_DATA1_21_4, customModelData);
|
||||
// Add one global marker and one for this specific version, so it is removed at the correct protocol
|
||||
customTag.putBoolean(GLOBAL_MODEL_DATA_MARKER, true);
|
||||
customTag.putBoolean(nbtTagName("added_custom_model_data"), true);
|
||||
} else if (addOriginalIdentifier && !customTag.contains(GLOBAL_MODEL_DATA_MARKER)) {
|
||||
final String identifier = protocol.getMappingData().getFullItemMappings().identifier(item.identifier());
|
||||
dataContainer.set(StructuredDataKey.CUSTOM_MODEL_DATA1_21_4, new CustomModelData1_21_4(
|
||||
customModelData.floats(), customModelData.booleans(), ArrayUtil.add(customModelData.strings(), identifier), customModelData.colors()
|
||||
));
|
||||
customTag.putBoolean(GLOBAL_MODEL_DATA_MARKER, true);
|
||||
customTag.putString(nbtTagName("injected_custom_model_data"), identifier);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item handleItemToServer(final UserConnection connection, final Item item) {
|
||||
if (item.isEmpty()) {
|
||||
return item;
|
||||
protected void restoreBackupData(final Item item, final StructuredDataContainer container, final CompoundTag customData) {
|
||||
super.restoreBackupData(item, container, customData);
|
||||
if (removeBackupTag(customData, "id") instanceof final IntTag originalTag) {
|
||||
item.setIdentifier(originalTag.asInt());
|
||||
removeCustomTag(container, customData);
|
||||
}
|
||||
|
||||
final StructuredDataContainer dataContainer = item.dataContainer();
|
||||
updateItemDataComponentTypeIds(dataContainer, false);
|
||||
|
||||
final BackwardsMappingData mappingData = protocol.getMappingData();
|
||||
if (mappingData != null && mappingData.getItemMappings() != null) {
|
||||
item.setIdentifier(mappingData.getOldItemId(item.identifier()));
|
||||
if (removeBackupTag(customData, "injected_custom_model_data") instanceof StringTag injectedCustomModelData) {
|
||||
customData.remove(GLOBAL_MODEL_DATA_MARKER);
|
||||
container.replace(StructuredDataKey.CUSTOM_MODEL_DATA1_21_4, customModelData -> {
|
||||
final String target = injectedCustomModelData.getValue();
|
||||
final String[] strings = customModelData.strings();
|
||||
for (int i = 0; i < strings.length; i++) {
|
||||
if (strings[i].equals(target)) {
|
||||
// Remove the injected string
|
||||
final String[] filteredStrings = ArrayUtil.remove(strings, i);
|
||||
return new CustomModelData1_21_4(customModelData.floats(), customModelData.booleans(), filteredStrings, customModelData.colors());
|
||||
}
|
||||
}
|
||||
return customModelData;
|
||||
});
|
||||
} else if (removeBackupTag(customData, "added_custom_model_data") != null) {
|
||||
customData.remove(GLOBAL_MODEL_DATA_MARKER);
|
||||
container.remove(StructuredDataKey.CUSTOM_MODEL_DATA1_21_4);
|
||||
}
|
||||
|
||||
final CompoundTag customData = dataContainer.get(StructuredDataKey.CUSTOM_DATA);
|
||||
if (customData != null) {
|
||||
if (customData.remove(nbtTagName("id")) instanceof final IntTag originalTag) {
|
||||
item.setIdentifier(originalTag.asInt());
|
||||
removeCustomTag(dataContainer, customData);
|
||||
}
|
||||
}
|
||||
|
||||
restoreTextComponents(item);
|
||||
updateItemDataComponents(connection, item, false);
|
||||
return item;
|
||||
}
|
||||
|
||||
protected void saveListTag(CompoundTag tag, ListTag<?> original, String name) {
|
||||
@@ -195,7 +200,7 @@ public class BackwardsStructuredItemRewriter<C extends ClientboundPacketType, S
|
||||
protected HolderSet restoreHolderSet(final CompoundTag tag, final String key) {
|
||||
final Tag savedTag = tag.get(key);
|
||||
if (savedTag == null) {
|
||||
return HolderSet.of(new int[0]);
|
||||
return HolderSet.of(EMPTY_INT_ARRAY);
|
||||
}
|
||||
|
||||
if (savedTag instanceof StringTag tagKey) {
|
||||
@@ -203,7 +208,7 @@ public class BackwardsStructuredItemRewriter<C extends ClientboundPacketType, S
|
||||
} else if (savedTag instanceof IntArrayTag idsTag) {
|
||||
return HolderSet.of(idsTag.getValue());
|
||||
} else {
|
||||
return HolderSet.of(new int[0]);
|
||||
return HolderSet.of(EMPTY_INT_ARRAY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,6 +222,28 @@ public class BackwardsStructuredItemRewriter<C extends ClientboundPacketType, S
|
||||
}
|
||||
}
|
||||
|
||||
protected <V> Tag eitherHolderToTag(final EitherHolder<V> holder, final BiConsumer<V, CompoundTag> valueSaveFunction) {
|
||||
if (holder.hasKey()) {
|
||||
return new StringTag(holder.key());
|
||||
} else {
|
||||
return holderToTag(holder.holder(), valueSaveFunction);
|
||||
}
|
||||
}
|
||||
|
||||
protected <V> void saveEitherHolderData(final StructuredDataKey<EitherHolder<V>> key, final StructuredDataContainer data, final CompoundTag backupTag, final BiConsumer<V, CompoundTag> valueSaveFunction) {
|
||||
final EitherHolder<V> holder = data.get(key);
|
||||
if (holder != null) {
|
||||
backupTag.put(key.identifier(), eitherHolderToTag(holder, valueSaveFunction));
|
||||
}
|
||||
}
|
||||
|
||||
protected <V> void saveHolderData(final StructuredDataKey<Holder<V>> key, final StructuredDataContainer data, final CompoundTag backupTag, final BiConsumer<V, CompoundTag> valueSaveFunction) {
|
||||
final Holder<V> holder = data.get(key);
|
||||
if (holder != null) {
|
||||
backupTag.put(key.identifier(), holderToTag(holder, valueSaveFunction));
|
||||
}
|
||||
}
|
||||
|
||||
protected <V> Holder<V> restoreHolder(final CompoundTag tag, final String key, final Function<CompoundTag, V> valueRestoreFunction) {
|
||||
final Tag savedTag = tag.get(key);
|
||||
if (savedTag == null) {
|
||||
@@ -232,8 +259,106 @@ public class BackwardsStructuredItemRewriter<C extends ClientboundPacketType, S
|
||||
}
|
||||
}
|
||||
|
||||
protected <V> EitherHolder<V> restoreEitherHolder(final CompoundTag tag, final String key, final Function<CompoundTag, V> valueRestoreFunction) {
|
||||
final Tag savedTag = tag.get(key);
|
||||
if (savedTag == null) {
|
||||
return EitherHolder.of(Holder.of(0));
|
||||
}
|
||||
|
||||
if (savedTag instanceof StringTag keyTag) {
|
||||
return EitherHolder.of(keyTag.getValue());
|
||||
} else {
|
||||
return EitherHolder.of(restoreHolder(tag, key, valueRestoreFunction));
|
||||
}
|
||||
}
|
||||
|
||||
protected <V> void restoreHolderData(final StructuredDataKey<Holder<V>> key, final StructuredDataContainer data, final CompoundTag backupTag, final Function<CompoundTag, V> valueRestoreFunction) {
|
||||
if (backupTag.contains(key.identifier())) {
|
||||
data.set(key, restoreHolder(backupTag, key.identifier(), valueRestoreFunction));
|
||||
}
|
||||
}
|
||||
|
||||
protected void saveStringData(final StructuredDataKey<String> key, final StructuredDataContainer data, final CompoundTag backupTag) {
|
||||
final String value = data.get(key);
|
||||
if (value != null) {
|
||||
backupTag.putString(key.identifier(), value);
|
||||
}
|
||||
}
|
||||
|
||||
protected void restoreStringData(final StructuredDataKey<String> key, final StructuredDataContainer data, final CompoundTag backupTag) {
|
||||
final String value = backupTag.getString(key.identifier());
|
||||
if (value != null) {
|
||||
data.set(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
protected void saveKeyData(final StructuredDataKey<Key> key, final StructuredDataContainer data, final CompoundTag backupTag) {
|
||||
final Key value = data.get(key);
|
||||
if (value != null) {
|
||||
backupTag.putString(key.identifier(), value.original());
|
||||
}
|
||||
}
|
||||
|
||||
protected void restoreKeyData(final StructuredDataKey<Key> key, final StructuredDataContainer data, final CompoundTag backupTag) {
|
||||
final String value = backupTag.getString(key.identifier());
|
||||
if (value != null) {
|
||||
data.set(key, Key.of(value));
|
||||
}
|
||||
}
|
||||
|
||||
protected void saveIntData(final StructuredDataKey<Integer> key, final StructuredDataContainer data, final CompoundTag backupTag) {
|
||||
final Integer variant = data.get(key);
|
||||
if (variant != null) {
|
||||
backupTag.putInt(key.identifier(), variant);
|
||||
}
|
||||
}
|
||||
|
||||
protected void restoreIntData(final StructuredDataKey<Integer> key, final StructuredDataContainer data, final CompoundTag backupTag) {
|
||||
final IntTag variant = backupTag.getIntTag(key.identifier());
|
||||
if (variant != null) {
|
||||
data.set(key, variant.asInt());
|
||||
}
|
||||
}
|
||||
|
||||
protected void saveFloatData(final StructuredDataKey<Float> key, final StructuredDataContainer data, final CompoundTag backupTag) {
|
||||
final Float variant = data.get(key);
|
||||
if (variant != null) {
|
||||
backupTag.putFloat(key.identifier(), variant);
|
||||
}
|
||||
}
|
||||
|
||||
protected void restoreFloatData(final StructuredDataKey<Float> key, final StructuredDataContainer data, final CompoundTag backupTag) {
|
||||
final FloatTag variant = backupTag.getFloatTag(key.identifier());
|
||||
if (variant != null) {
|
||||
data.set(key, variant.asFloat());
|
||||
}
|
||||
}
|
||||
|
||||
protected void saveSoundEventHolder(final CompoundTag tag, final Holder<SoundEvent> holder) {
|
||||
tag.put("sound_event", holderToTag(holder, this::saveSoundEvent));
|
||||
}
|
||||
|
||||
protected void saveSoundEvent(final SoundEvent soundEvent, final CompoundTag tag) {
|
||||
tag.putString("identifier", soundEvent.identifier());
|
||||
if (soundEvent.fixedRange() != null) {
|
||||
tag.putFloat("fixed_range", soundEvent.fixedRange());
|
||||
}
|
||||
}
|
||||
|
||||
protected Holder<SoundEvent> restoreSoundEventHolder(final CompoundTag tag) {
|
||||
return restoreSoundEventHolder(tag, "sound_event");
|
||||
}
|
||||
|
||||
protected Holder<SoundEvent> restoreSoundEventHolder(final CompoundTag tag, final String key) {
|
||||
return restoreHolder(tag, key, soundEventTag -> {
|
||||
final String identifier = soundEventTag.getString("identifier");
|
||||
final FloatTag fixedRange = soundEventTag.getFloatTag("fixed_range");
|
||||
return new SoundEvent(identifier, fixedRange != null ? fixedRange.asFloat() : null);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String nbtTagName() {
|
||||
return "VB|" + protocol.getClass().getSimpleName();
|
||||
return this.nbtTagName;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,12 +17,12 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.viabackwards.utils.ChatUtil;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.ListTag;
|
||||
import com.viaversion.nbt.tag.NumberTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.viabackwards.utils.ChatUtil;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
+32
-38
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -24,7 +24,6 @@ import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
||||
|
||||
@@ -39,56 +38,50 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTrackerWithData(C packetType, EntityType fallingBlockType) {
|
||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types.VAR_INT); // 0 - Entity id
|
||||
map(Types.UUID); // 1 - Entity UUID
|
||||
map(Types.VAR_INT); // 2 - Entity Type
|
||||
map(Types.DOUBLE); // 3 - X
|
||||
map(Types.DOUBLE); // 4 - Y
|
||||
map(Types.DOUBLE); // 5 - Z
|
||||
map(Types.BYTE); // 6 - Pitch
|
||||
map(Types.BYTE); // 7 - Yaw
|
||||
map(Types.INT); // 8 - Data
|
||||
handler(getSpawnTrackerWithDataHandler(fallingBlockType));
|
||||
}
|
||||
public void registerTrackerWithData(C packetType) {
|
||||
protocol.registerClientbound(packetType, wrapper -> {
|
||||
wrapper.passthrough(Types.VAR_INT); // Entity ID
|
||||
wrapper.passthrough(Types.UUID); // Entity UUID
|
||||
wrapper.passthrough(Types.VAR_INT); // Entity Type
|
||||
wrapper.passthrough(Types.DOUBLE); // X
|
||||
wrapper.passthrough(Types.DOUBLE); // Y
|
||||
wrapper.passthrough(Types.DOUBLE); // Z
|
||||
wrapper.passthrough(Types.BYTE); // Pitch
|
||||
wrapper.passthrough(Types.BYTE); // Yaw
|
||||
wrapper.passthrough(Types.INT); // Data
|
||||
getSpawnTrackerWithDataHandler().handle(wrapper);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTrackerWithData1_19(C packetType, EntityType fallingBlockType) {
|
||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types.VAR_INT); // Entity id
|
||||
map(Types.UUID); // Entity UUID
|
||||
map(Types.VAR_INT); // Entity type
|
||||
map(Types.DOUBLE); // X
|
||||
map(Types.DOUBLE); // Y
|
||||
map(Types.DOUBLE); // Z
|
||||
map(Types.BYTE); // Pitch
|
||||
map(Types.BYTE); // Yaw
|
||||
map(Types.BYTE); // Head yaw
|
||||
map(Types.VAR_INT); // Data
|
||||
handler(getSpawnTrackerWithDataHandler1_19(fallingBlockType));
|
||||
}
|
||||
public void registerTrackerWithData1_19(C packetType) {
|
||||
protocol.registerClientbound(packetType, wrapper -> {
|
||||
wrapper.passthrough(Types.VAR_INT); // Entity id
|
||||
wrapper.passthrough(Types.UUID); // Entity UUID
|
||||
wrapper.passthrough(Types.VAR_INT); // Entity type
|
||||
wrapper.passthrough(Types.DOUBLE); // X
|
||||
wrapper.passthrough(Types.DOUBLE); // Y
|
||||
wrapper.passthrough(Types.DOUBLE); // Z
|
||||
wrapper.passthrough(Types.BYTE); // Pitch
|
||||
wrapper.passthrough(Types.BYTE); // Yaw
|
||||
wrapper.passthrough(Types.BYTE); // Head yaw
|
||||
wrapper.passthrough(Types.VAR_INT); // Data
|
||||
getSpawnTrackerWithDataHandler1_19().handle(wrapper);
|
||||
});
|
||||
}
|
||||
|
||||
public PacketHandler getSpawnTrackerWithDataHandler(EntityType fallingBlockType) {
|
||||
public PacketHandler getSpawnTrackerWithDataHandler() {
|
||||
return wrapper -> {
|
||||
// Check against the UNMAPPED entity type
|
||||
EntityType entityType = trackAndMapEntity(wrapper);
|
||||
if (entityType == fallingBlockType) {
|
||||
if (entityType == typeFromId("falling_block")) {
|
||||
int blockState = wrapper.get(Types.INT, 0);
|
||||
wrapper.set(Types.INT, 0, protocol.getMappingData().getNewBlockStateId(blockState));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public PacketHandler getSpawnTrackerWithDataHandler1_19(EntityType fallingBlockType) {
|
||||
public PacketHandler getSpawnTrackerWithDataHandler1_19() {
|
||||
return wrapper -> {
|
||||
if (protocol.getMappingData() == null) {
|
||||
return;
|
||||
@@ -96,14 +89,15 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
||||
|
||||
// Check against the UNMAPPED entity type
|
||||
EntityType entityType = trackAndMapEntity(wrapper);
|
||||
if (entityType == fallingBlockType) {
|
||||
if (entityType == typeFromId("falling_block")) {
|
||||
int blockState = wrapper.get(Types.VAR_INT, 2);
|
||||
wrapper.set(Types.VAR_INT, 2, protocol.getMappingData().getNewBlockStateId(blockState));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void registerSpawnTracker(C packetType) {
|
||||
@Override
|
||||
public void registerTracker(C packetType) {
|
||||
protocol.registerClientbound(packetType, wrapper -> {
|
||||
wrapper.passthrough(Types.VAR_INT); // Entity ID
|
||||
wrapper.passthrough(Types.UUID); // Entity UUID
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -175,7 +175,7 @@ public abstract class EntityRewriterBase<C extends ClientboundPacketType, T exte
|
||||
filter().handler((event, data) -> {
|
||||
EntityDataType type = data.dataType();
|
||||
if (type == itemType) {
|
||||
protocol.getItemRewriter().handleItemToClient(event.user(), data.value());
|
||||
data.setValue(protocol.getItemRewriter().handleItemToClient(event.user(), data.value()));
|
||||
} else if (type == blockStateType) {
|
||||
int value = data.value();
|
||||
data.setValue(protocol.getMappingData().getNewBlockStateId(value));
|
||||
|
||||
+14
-15
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,9 +18,16 @@
|
||||
|
||||
package com.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.nbt.tag.ByteTag;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.IntTag;
|
||||
import com.viaversion.nbt.tag.NumberTag;
|
||||
import com.viaversion.nbt.tag.ShortTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.MappedLegacyBlockItem;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader;
|
||||
import com.viaversion.viabackwards.api.data.MappedLegacyBlockItem;
|
||||
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.data.BlockColors1_11_1;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||
@@ -41,17 +48,10 @@ import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.libs.gson.JsonPrimitive;
|
||||
import com.viaversion.nbt.tag.ByteTag;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.IntTag;
|
||||
import com.viaversion.nbt.tag.NumberTag;
|
||||
import com.viaversion.nbt.tag.ShortTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
import com.viaversion.viaversion.util.IdAndData;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import com.viaversion.viaversion.util.IdAndData;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S extends ServerboundPacketType,
|
||||
@@ -208,9 +208,9 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Item handleItemToServer(UserConnection connection, @Nullable final Item item) {
|
||||
public @Nullable Item handleItemToServer(UserConnection connection, @Nullable Item item) {
|
||||
if (item == null) return null;
|
||||
super.handleItemToServer(connection, item);
|
||||
item = super.handleItemToServer(connection, item);
|
||||
if (item.tag() != null) {
|
||||
Tag originalId = item.tag().remove(nbtTagName("id"));
|
||||
if (originalId instanceof IntTag) {
|
||||
@@ -226,10 +226,9 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
||||
|
||||
public PacketHandler getFallingBlockHandler() {
|
||||
return wrapper -> {
|
||||
final EntityTypes1_12.ObjectType type = EntityTypes1_12.ObjectType.findById(wrapper.get(Types.BYTE, 0));
|
||||
final int objectData = wrapper.get(Types.INT, 0);
|
||||
final EntityTypes1_12.ObjectType type = EntityTypes1_12.ObjectType.findById(wrapper.get(Types.BYTE, 0), objectData);
|
||||
if (type == EntityTypes1_12.ObjectType.FALLING_BLOCK) {
|
||||
final int objectData = wrapper.get(Types.INT, 0);
|
||||
|
||||
final IdAndData block = handleBlock(objectData & 4095, objectData >> 12 & 15);
|
||||
if (block == null) return;
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.nbt.tag.ByteTag;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.IntTag;
|
||||
@@ -25,6 +24,7 @@ import com.viaversion.nbt.tag.ListTag;
|
||||
import com.viaversion.nbt.tag.NumberTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
+22
-18
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -36,7 +36,6 @@ import com.viaversion.viaversion.api.type.Types;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public abstract class LegacyEntityRewriter<C extends ClientboundPacketType, T extends BackwardsProtocol<C, ?, ?, ?>> extends EntityRewriterBase<C, T> {
|
||||
@@ -87,7 +86,7 @@ public abstract class LegacyEntityRewriter<C extends ClientboundPacketType, T ex
|
||||
clientWorld.setEnvironment(wrapper.get(Types.INT, 1));
|
||||
|
||||
final int entityId = wrapper.get(Types.INT, 0);
|
||||
addTrackedEntity(wrapper, entityId, playerType);
|
||||
tracker(wrapper.user()).addEntity(entityId, playerType);
|
||||
tracker(wrapper.user()).setClientEntityId(entityId);
|
||||
});
|
||||
}
|
||||
@@ -125,48 +124,53 @@ public abstract class LegacyEntityRewriter<C extends ClientboundPacketType, T ex
|
||||
|
||||
protected PacketHandler getObjectTrackerHandler() {
|
||||
return wrapper -> {
|
||||
EntityType type = objectTypeFromId(wrapper.get(Types.BYTE, 0));
|
||||
int id = wrapper.get(Types.BYTE, 0);
|
||||
int data = wrapper.get(Types.INT, 0);
|
||||
EntityType type = objectTypeFromId(id, data);
|
||||
if (type == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
addTrackedEntity(wrapper, wrapper.get(Types.VAR_INT, 0), type);
|
||||
tracker(wrapper.user()).addEntity(wrapper.get(Types.VAR_INT, 0), type);
|
||||
};
|
||||
}
|
||||
|
||||
protected PacketHandler getTrackerAndDataHandler(Type<List<EntityData>> dataType, EntityType entityType) {
|
||||
return wrapper -> {
|
||||
addTrackedEntity(wrapper, wrapper.get(Types.VAR_INT, 0), entityType);
|
||||
tracker(wrapper.user()).addEntity(wrapper.get(Types.VAR_INT, 0), entityType);
|
||||
List<EntityData> entityDataList = wrapper.get(dataType, 0);
|
||||
handleEntityData(wrapper.get(Types.VAR_INT, 0), entityDataList, wrapper.user());
|
||||
};
|
||||
}
|
||||
|
||||
protected PacketHandler getObjectRewriter(Function<Byte, ObjectType> objectGetter) {
|
||||
protected PacketHandler getObjectRewriter(ObjectTypeGetter objectGetter) {
|
||||
return wrapper -> {
|
||||
ObjectType type = objectGetter.apply(wrapper.get(Types.BYTE, 0));
|
||||
int id = wrapper.get(Types.BYTE, 0);
|
||||
int data = wrapper.get(Types.INT, 0);
|
||||
ObjectType type = objectGetter.get(id, data);
|
||||
if (type == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityReplacement data = getObjectData(type);
|
||||
if (data != null) {
|
||||
wrapper.set(Types.BYTE, 0, (byte) data.replacementId());
|
||||
if (data.objectData() != -1) {
|
||||
wrapper.set(Types.INT, 0, data.objectData());
|
||||
EntityReplacement replacement = getObjectData(type);
|
||||
if (replacement != null) {
|
||||
wrapper.set(Types.BYTE, 0, (byte) replacement.replacementId());
|
||||
if (replacement.objectData() != -1) {
|
||||
wrapper.set(Types.INT, 0, replacement.objectData());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected void addTrackedEntity(PacketWrapper wrapper, int entityId, EntityType type) {
|
||||
tracker(wrapper.user()).addEntity(entityId, type);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
protected interface IdSetter {
|
||||
|
||||
void setId(PacketWrapper wrapper, int id);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
protected interface ObjectTypeGetter {
|
||||
|
||||
ObjectType get(int id, int data);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+37
-27
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,13 +17,47 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.rewriter.IdRewriteFunction;
|
||||
|
||||
public final class MapColorRewriter {
|
||||
|
||||
/**
|
||||
* Rewrite map colors using the provided id rewriter.
|
||||
*
|
||||
* @param wrapper packet wrapper
|
||||
* @param rewriter id rewriter returning mapped colors, or -1 if unmapped
|
||||
* @param iconCount number of icons to read
|
||||
*/
|
||||
public static void rewriteMapColors(PacketWrapper wrapper, IdRewriteFunction rewriter, int iconCount) {
|
||||
for (int i = 0; i < iconCount; i++) {
|
||||
wrapper.passthrough(Types.VAR_INT); // Type
|
||||
wrapper.passthrough(Types.BYTE); // X
|
||||
wrapper.passthrough(Types.BYTE); // Z
|
||||
wrapper.passthrough(Types.BYTE); // Direction
|
||||
wrapper.passthrough(Types.OPTIONAL_COMPONENT); // Display Name
|
||||
}
|
||||
|
||||
short columns = wrapper.passthrough(Types.UNSIGNED_BYTE);
|
||||
if (columns < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper.passthrough(Types.UNSIGNED_BYTE); // Rows
|
||||
wrapper.passthrough(Types.UNSIGNED_BYTE); // X
|
||||
wrapper.passthrough(Types.UNSIGNED_BYTE); // Z
|
||||
byte[] data = wrapper.passthrough(Types.BYTE_ARRAY_PRIMITIVE);
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
int color = data[i] & 0xFF;
|
||||
int mappedColor = rewriter.rewrite(color);
|
||||
if (mappedColor != -1) {
|
||||
data[i] = (byte) mappedColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a packethandler to rewrite map data color ids. Reading starts from the icon count.
|
||||
*
|
||||
@@ -31,30 +65,6 @@ public final class MapColorRewriter {
|
||||
* @return packethandler to rewrite map data color ids
|
||||
*/
|
||||
public static PacketHandler getRewriteHandler(IdRewriteFunction rewriter) {
|
||||
return wrapper -> {
|
||||
int iconCount = wrapper.passthrough(Types.VAR_INT);
|
||||
for (int i = 0; i < iconCount; i++) {
|
||||
wrapper.passthrough(Types.VAR_INT); // Type
|
||||
wrapper.passthrough(Types.BYTE); // X
|
||||
wrapper.passthrough(Types.BYTE); // Z
|
||||
wrapper.passthrough(Types.BYTE); // Direction
|
||||
wrapper.passthrough(Types.OPTIONAL_COMPONENT); // Display Name
|
||||
}
|
||||
|
||||
short columns = wrapper.passthrough(Types.UNSIGNED_BYTE);
|
||||
if (columns < 1) return;
|
||||
|
||||
wrapper.passthrough(Types.UNSIGNED_BYTE); // Rows
|
||||
wrapper.passthrough(Types.UNSIGNED_BYTE); // X
|
||||
wrapper.passthrough(Types.UNSIGNED_BYTE); // Z
|
||||
byte[] data = wrapper.passthrough(Types.BYTE_ARRAY_PRIMITIVE);
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
int color = data[i] & 0xFF;
|
||||
int mappedColor = rewriter.rewrite(color);
|
||||
if (mappedColor != -1) {
|
||||
data[i] = (byte) mappedColor;
|
||||
}
|
||||
}
|
||||
};
|
||||
return wrapper -> rewriteMapColors(wrapper, rewriter, wrapper.passthrough(Types.VAR_INT));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,24 +17,22 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.minecraft.Holder;
|
||||
import com.viaversion.viaversion.api.minecraft.SoundEvent;
|
||||
import com.viaversion.viaversion.api.data.Mappings;
|
||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
|
||||
public class SoundRewriter<C extends ClientboundPacketType> extends com.viaversion.viaversion.rewriter.SoundRewriter<C> {
|
||||
|
||||
private final BackwardsProtocol<C, ?, ?, ?> protocol;
|
||||
|
||||
public SoundRewriter(final BackwardsProtocol<C, ?, ?, ?> protocol) {
|
||||
public SoundRewriter(final AbstractProtocol<C, ?, ?, ?> protocol) {
|
||||
super(protocol);
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
public void registerNamedSound(final C packetType) {
|
||||
if (protocol.getMappingData() == null || Mappings.isFullIdentity(protocol.getMappingData().getFullSoundMappings())) {
|
||||
return;
|
||||
}
|
||||
protocol.registerClientbound(packetType, wrapper -> {
|
||||
wrapper.passthrough(Types.STRING); // Sound identifier
|
||||
getNamedSoundHandler().handle(wrapper);
|
||||
@@ -42,36 +40,18 @@ public class SoundRewriter<C extends ClientboundPacketType> extends com.viaversi
|
||||
}
|
||||
|
||||
public void registerStopSound(final C packetType) {
|
||||
protocol.registerClientbound(packetType, wrapper -> getStopSoundHandler().handle(wrapper));
|
||||
}
|
||||
|
||||
public PacketHandler getNamedSoundHandler() {
|
||||
return wrapper -> {
|
||||
final String soundId = wrapper.get(Types.STRING, 0);
|
||||
final String mappedId = protocol.getMappingData().getMappedNamedSound(soundId);
|
||||
if (mappedId == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mappedId.isEmpty()) {
|
||||
wrapper.set(Types.STRING, 0, mappedId);
|
||||
} else {
|
||||
wrapper.cancel();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public PacketHandler getStopSoundHandler() {
|
||||
return wrapper -> {
|
||||
if (protocol.getMappingData() == null || Mappings.isFullIdentity(protocol.getMappingData().getFullSoundMappings())) {
|
||||
return;
|
||||
}
|
||||
protocol.registerClientbound(packetType, wrapper -> {
|
||||
final byte flags = wrapper.passthrough(Types.BYTE);
|
||||
if ((flags & 0x02) == 0) return; // No sound specified
|
||||
|
||||
if ((flags & 0x01) != 0) {
|
||||
wrapper.passthrough(Types.VAR_INT); // Source
|
||||
}
|
||||
|
||||
if ((flags & 0x02) == 0) return; // No sound specified
|
||||
final String soundId = wrapper.read(Types.STRING);
|
||||
final String mappedId = protocol.getMappingData().getMappedNamedSound(soundId);
|
||||
final String mappedId = protocol.getMappingData().getFullSoundMappings().mappedIdentifier(soundId);
|
||||
if (mappedId == null) {
|
||||
// No mapping found
|
||||
wrapper.write(Types.STRING, soundId);
|
||||
@@ -84,45 +64,22 @@ public class SoundRewriter<C extends ClientboundPacketType> extends com.viaversi
|
||||
// Cancel if set to empty
|
||||
wrapper.cancel();
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerSound1_19_3(final C packetType) {
|
||||
protocol.registerClientbound(packetType, getSoundHandler1_19_3());
|
||||
}
|
||||
|
||||
public PacketHandler getSoundHandler1_19_3() {
|
||||
public PacketHandler getNamedSoundHandler() {
|
||||
return wrapper -> {
|
||||
Holder<SoundEvent> soundEventHolder = wrapper.read(Types.SOUND_EVENT);
|
||||
if (soundEventHolder.isDirect()) {
|
||||
wrapper.write(Types.SOUND_EVENT, rewriteSoundEvent(wrapper, soundEventHolder));
|
||||
final String soundId = wrapper.get(Types.STRING, 0);
|
||||
final String mappedId = protocol.getMappingData().getFullSoundMappings().mappedIdentifier(soundId);
|
||||
if (mappedId == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int mappedId = idRewriter.rewrite(soundEventHolder.id());
|
||||
if (mappedId == -1) {
|
||||
if (!mappedId.isEmpty()) {
|
||||
wrapper.set(Types.STRING, 0, mappedId);
|
||||
} else {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mappedId != soundEventHolder.id()) {
|
||||
soundEventHolder = Holder.of(mappedId);
|
||||
}
|
||||
|
||||
wrapper.write(Types.SOUND_EVENT, soundEventHolder);
|
||||
};
|
||||
}
|
||||
|
||||
public Holder<SoundEvent> rewriteSoundEvent(final PacketWrapper wrapper, final Holder<SoundEvent> soundEventHolder) {
|
||||
final SoundEvent soundEvent = soundEventHolder.value();
|
||||
final String mappedIdentifier = protocol.getMappingData().getMappedNamedSound(soundEvent.identifier());
|
||||
if (mappedIdentifier != null) {
|
||||
if (!mappedIdentifier.isEmpty()) {
|
||||
return Holder.of(soundEvent.withIdentifier(mappedIdentifier));
|
||||
}
|
||||
wrapper.cancel();
|
||||
}
|
||||
return soundEventHolder;
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -59,16 +59,16 @@ public class StructuredEnchantmentRewriter {
|
||||
final String remappedName = mappingData.mappedEnchantmentName(id);
|
||||
return ComponentUtil.jsonStringToTag(ChatUtil.legacyToJsonString("§7" + remappedName, ENCHANTMENT_LEVEL_TRANSLATION.formatted(level), true));
|
||||
};
|
||||
rewriteEnchantmentsToClient(data, StructuredDataKey.ENCHANTMENTS, idRewriteFunction, descriptionSupplier, false);
|
||||
rewriteEnchantmentsToClient(data, StructuredDataKey.STORED_ENCHANTMENTS, idRewriteFunction, descriptionSupplier, true);
|
||||
rewriteEnchantmentsToClient(data, StructuredDataKey.ENCHANTMENTS1_20_5, idRewriteFunction, descriptionSupplier, false);
|
||||
rewriteEnchantmentsToClient(data, StructuredDataKey.STORED_ENCHANTMENTS1_20_5, idRewriteFunction, descriptionSupplier, true);
|
||||
}
|
||||
|
||||
public void handleToServer(final Item item) {
|
||||
final StructuredDataContainer data = item.dataContainer();
|
||||
final CompoundTag customData = data.get(StructuredDataKey.CUSTOM_DATA);
|
||||
if (customData != null) {
|
||||
rewriteEnchantmentsToServer(data, customData, StructuredDataKey.ENCHANTMENTS);
|
||||
rewriteEnchantmentsToServer(data, customData, StructuredDataKey.STORED_ENCHANTMENTS);
|
||||
rewriteEnchantmentsToServer(data, customData, StructuredDataKey.ENCHANTMENTS1_20_5);
|
||||
rewriteEnchantmentsToServer(data, customData, StructuredDataKey.STORED_ENCHANTMENTS1_20_5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.api.rewriters.text;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.TranslatableMappings;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class JsonNBTComponentRewriter<C extends ClientboundPacketType> extends com.viaversion.viaversion.rewriter.text.JsonNBTComponentRewriter<C> implements TranslatableRewriter {
|
||||
|
||||
private final Map<String, String> translatables;
|
||||
|
||||
public JsonNBTComponentRewriter(final BackwardsProtocol<C, ?, ?, ?> protocol, final ReadType type) {
|
||||
super(protocol, type);
|
||||
this.translatables = TranslatableMappings.translatablesFor(protocol);
|
||||
}
|
||||
|
||||
public JsonNBTComponentRewriter(final BackwardsProtocol<C, ?, ?, ?> protocol, final ReadType type, final String version) {
|
||||
super(protocol, type);
|
||||
this.translatables = TranslatableMappings.translatablesFor(version);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleTranslate(final JsonObject root, final String translate) {
|
||||
final String newTranslate = mappedTranslationKey(translate);
|
||||
if (newTranslate != null) {
|
||||
root.addProperty("translate", newTranslate);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleTranslate(final UserConnection connection, final CompoundTag parentTag, final StringTag translateTag) {
|
||||
final String newTranslate = mappedTranslationKey(translateTag.getValue());
|
||||
if (newTranslate != null) {
|
||||
parentTag.put("translate", new StringTag(newTranslate));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String mappedTranslationKey(final String translationKey) {
|
||||
return translatables.get(translationKey);
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.api.rewriters.text;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.TranslatableMappings;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class NBTComponentRewriter<C extends ClientboundPacketType> extends com.viaversion.viaversion.rewriter.text.NBTComponentRewriter<C> implements TranslatableRewriter {
|
||||
|
||||
private final Map<String, String> translatables;
|
||||
|
||||
public NBTComponentRewriter(final BackwardsProtocol<C, ?, ?, ?> protocol) {
|
||||
super(protocol);
|
||||
this.translatables = TranslatableMappings.translatablesFor(protocol);
|
||||
}
|
||||
|
||||
public NBTComponentRewriter(final BackwardsProtocol<C, ?, ?, ?> protocol, final String version) {
|
||||
super(protocol);
|
||||
this.translatables = TranslatableMappings.translatablesFor(version);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleTranslate(final JsonObject root, final String translate) {
|
||||
final String newTranslate = mappedTranslationKey(translate);
|
||||
if (newTranslate != null) {
|
||||
root.addProperty("translate", newTranslate);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleTranslate(final UserConnection connection, final CompoundTag parentTag, final StringTag translateTag) {
|
||||
final String newTranslate = mappedTranslationKey(translateTag.getValue());
|
||||
if (newTranslate != null) {
|
||||
parentTag.put("translate", new StringTag(newTranslate));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String mappedTranslationKey(final String translationKey) {
|
||||
return translatables.get(translationKey);
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.api.rewriters.text;
|
||||
|
||||
import com.viaversion.viaversion.api.rewriter.ComponentRewriter;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface TranslatableRewriter extends ComponentRewriter {
|
||||
|
||||
@Nullable
|
||||
String mappedTranslationKey(String translationKey);
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.item;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.ListTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonParser;
|
||||
import com.viaversion.viaversion.libs.gson.JsonPrimitive;
|
||||
import com.viaversion.viaversion.libs.gson.JsonSyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Prevent expensive parsing/toString by checking against cached JsonElement instances, used from 1.14 to 1.20.5.
|
||||
* <p>
|
||||
* When using this, be careful not to break caching by modifying the display tag directly.
|
||||
*/
|
||||
public final class DataItemWithExtras extends DataItem {
|
||||
|
||||
private JsonElement name;
|
||||
private List<JsonElement> lore;
|
||||
|
||||
public DataItemWithExtras(final Item from) {
|
||||
setIdentifier(from.identifier());
|
||||
setAmount(from.amount());
|
||||
setData(from.data());
|
||||
setTag(from.tag());
|
||||
|
||||
if (tag() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final CompoundTag display = tag().getCompoundTag("display");
|
||||
if (display == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final StringTag name = display.getStringTag("Name");
|
||||
if (name != null) {
|
||||
this.name = parse(name.getValue());
|
||||
}
|
||||
|
||||
final ListTag<StringTag> lore = display.getListTag("Lore", StringTag.class);
|
||||
if (lore != null) {
|
||||
this.lore = new ArrayList<>(lore.size());
|
||||
for (int i = 0; i < lore.size(); i++) {
|
||||
this.lore.add(parse(lore.get(i).getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public @Nullable JsonElement name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public @Nullable StringTag rawName() {
|
||||
if (tag() == null) {
|
||||
return null;
|
||||
}
|
||||
final CompoundTag display = tag().getCompoundTag("display");
|
||||
return display != null ? display.getStringTag("Name") : null;
|
||||
}
|
||||
|
||||
public @Nullable List<JsonElement> lore() {
|
||||
return lore;
|
||||
}
|
||||
|
||||
public @Nullable ListTag<StringTag> rawLore() {
|
||||
if (tag() == null) {
|
||||
return null;
|
||||
}
|
||||
final CompoundTag display = tag().getCompoundTag("display");
|
||||
return display != null ? display.getListTag("Lore", StringTag.class) : null;
|
||||
}
|
||||
|
||||
private JsonElement parse(final String value) {
|
||||
try {
|
||||
return JsonParser.parseString(value);
|
||||
} catch (final JsonSyntaxException e) {
|
||||
return new JsonPrimitive(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.registration;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.protocol.shared_registration.SharedRegistrations;
|
||||
|
||||
public final class BackwardsRegistrations {
|
||||
|
||||
private static final SharedRegistrations REGISTRATIONS = SharedRegistrations.create();
|
||||
|
||||
public static void apply() {
|
||||
REGISTRATIONS.registrations()
|
||||
.range(ProtocolVersion.v1_10, ProtocolVersion.v1_19_3, RegistryRegistrations::registerNamedSound1_10)
|
||||
.since(ProtocolVersion.v1_14, RegistryRegistrations::registerStopSound1_14)
|
||||
|
||||
.register();
|
||||
}
|
||||
|
||||
public static SharedRegistrations registrations() {
|
||||
return REGISTRATIONS;
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.registration;
|
||||
|
||||
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.protocol.shared_registration.PacketBound;
|
||||
import com.viaversion.viaversion.protocol.shared_registration.RegistrationContext;
|
||||
import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ClientboundPackets1_14;
|
||||
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
|
||||
|
||||
final class RegistryRegistrations {
|
||||
|
||||
static <CU extends ClientboundPacketType> void registerNamedSound1_10(final RegistrationContext<CU, ?> ctx) {
|
||||
ctx.clientbound(ClientboundPackets1_9_3.CUSTOM_SOUND, new SoundRewriter<>(ctx.protocol())::registerNamedSound, PacketBound.REMOVED_AT_MAX);
|
||||
}
|
||||
|
||||
static <CU extends ClientboundPacketType> void registerStopSound1_14(final RegistrationContext<CU, ?> ctx) {
|
||||
ctx.clientbound(ClientboundPackets1_14.STOP_SOUND, new SoundRewriter<>(ctx.protocol())::registerStopSound);
|
||||
}
|
||||
}
|
||||
-71
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.template;
|
||||
|
||||
import com.viaversion.viabackwards.api.rewriters.BackwardsStructuredItemRewriter;
|
||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.packet.ServerboundPacket1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.packet.ServerboundPackets1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2;
|
||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPackets1_21_2;
|
||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||
import com.viaversion.viaversion.rewriter.RecipeDisplayRewriter;
|
||||
|
||||
// To replace if needed:
|
||||
// ChunkType1_20_2
|
||||
// RecipeDisplayRewriter
|
||||
// Types1_21_4
|
||||
final class BlockItemPacketRewriter1_99 extends BackwardsStructuredItemRewriter<ClientboundPacket1_21_2, ServerboundPacket1_21_4, Protocol1_98To1_99> {
|
||||
|
||||
public BlockItemPacketRewriter1_99(final Protocol1_98To1_99 protocol) {
|
||||
super(protocol, Types1_21_4.ITEM, Types1_21_4.ITEM_ARRAY);
|
||||
/*super(protocol,
|
||||
Types1_21_4.ITEM, Types1_21_4.ITEM_ARRAY, Types1_OLD.ITEM, Types1_OLD.ITEM_ARRAY,
|
||||
Types1_21_4.ITEM_COST, Types1_21_4.OPTIONAL_ITEM_COST, Types1_OLD.ITEM_COST, Types1_OLD.OPTIONAL_ITEM_COST
|
||||
);*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPackets() {
|
||||
final BlockRewriter<ClientboundPacket1_21_2> blockRewriter = BlockRewriter.for1_20_2(protocol);
|
||||
blockRewriter.registerBlockEvent(ClientboundPackets1_21_2.BLOCK_EVENT);
|
||||
blockRewriter.registerBlockUpdate(ClientboundPackets1_21_2.BLOCK_UPDATE);
|
||||
blockRewriter.registerSectionBlocksUpdate1_20(ClientboundPackets1_21_2.SECTION_BLOCKS_UPDATE);
|
||||
blockRewriter.registerLevelEvent1_21(ClientboundPackets1_21_2.LEVEL_EVENT, 2001);
|
||||
blockRewriter.registerLevelChunk1_19(ClientboundPackets1_21_2.LEVEL_CHUNK_WITH_LIGHT, ChunkType1_20_2::new);
|
||||
blockRewriter.registerBlockEntityData(ClientboundPackets1_21_2.BLOCK_ENTITY_DATA);
|
||||
|
||||
// registerOpenScreen(ClientboundPackets1_21_2.OPEN_SCREEN);
|
||||
protocol.registerClientbound(ClientboundPackets1_21_2.SET_CURSOR_ITEM, this::passthroughClientboundItem);
|
||||
registerSetPlayerInventory(ClientboundPackets1_21_2.SET_PLAYER_INVENTORY);
|
||||
registerCooldown1_21_2(ClientboundPackets1_21_2.COOLDOWN);
|
||||
registerSetContent1_21_2(ClientboundPackets1_21_2.CONTAINER_SET_CONTENT);
|
||||
registerSetSlot1_21_2(ClientboundPackets1_21_2.CONTAINER_SET_SLOT);
|
||||
registerAdvancements1_20_3(ClientboundPackets1_21_2.UPDATE_ADVANCEMENTS);
|
||||
registerSetEquipment(ClientboundPackets1_21_2.SET_EQUIPMENT);
|
||||
registerMerchantOffers1_20_5(ClientboundPackets1_21_2.MERCHANT_OFFERS);
|
||||
registerContainerClick1_21_2(ServerboundPackets1_21_4.CONTAINER_CLICK);
|
||||
registerSetCreativeModeSlot(ServerboundPackets1_21_4.SET_CREATIVE_MODE_SLOT);
|
||||
|
||||
final RecipeDisplayRewriter<ClientboundPacket1_21_2> recipeRewriter = new RecipeDisplayRewriter<>(protocol);
|
||||
recipeRewriter.registerUpdateRecipes(ClientboundPackets1_21_2.UPDATE_RECIPES);
|
||||
recipeRewriter.registerRecipeBookAdd(ClientboundPackets1_21_2.RECIPE_BOOK_ADD);
|
||||
recipeRewriter.registerPlaceGhostRecipe(ClientboundPackets1_21_2.PLACE_GHOST_RECIPE);
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.template;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.viabackwards.api.rewriters.BackwardsStructuredItemRewriter;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.protocols.v1_21_11to26_1.packet.ClientboundPacket26_1;
|
||||
import com.viaversion.viaversion.protocols.v1_21_7to1_21_9.packet.ServerboundPacket1_21_9;
|
||||
|
||||
// To replace if needed:
|
||||
// ChunkType1_21_5
|
||||
// RecipeDisplayRewriter
|
||||
final class BlockItemPacketRewriter99_1 extends BackwardsStructuredItemRewriter<ClientboundPacket26_1, ServerboundPacket1_21_9, Protocol99_1To98_1> {
|
||||
|
||||
public BlockItemPacketRewriter99_1(final Protocol99_1To98_1 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPackets() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleItemDataComponentsToClient(final UserConnection connection, final Item item, final StructuredDataContainer container) {
|
||||
super.handleItemDataComponentsToClient(connection, item, container);
|
||||
// downgradeData(item, container); // static import VV method
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleItemDataComponentsToServer(final UserConnection connection, final Item item, final StructuredDataContainer container) {
|
||||
super.handleItemDataComponentsToServer(connection, item, container);
|
||||
// upgradeData(item, container); // static import VV method
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void restoreBackupData(final Item item, final StructuredDataContainer container, final CompoundTag customData) {
|
||||
super.restoreBackupData(item, container, customData);
|
||||
// restore any data if needed here
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void backupInconvertibleData(final UserConnection connection, final Item item, final StructuredDataContainer dataContainer, final CompoundTag backupTag) {
|
||||
super.backupInconvertibleData(connection, item, dataContainer, backupTag);
|
||||
// back up any data if needed here, called before the method below
|
||||
}
|
||||
}
|
||||
+7
-13
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -19,15 +19,14 @@ package com.viaversion.viabackwards.protocol.template;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.text.NBTComponentRewriter;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2;
|
||||
import com.viaversion.viaversion.util.SerializerVersion;
|
||||
import com.viaversion.viaversion.protocols.v1_21_11to26_1.packet.ClientboundPacket26_1;
|
||||
|
||||
final class ComponentRewriter1_99 extends TranslatableRewriter<ClientboundPacket1_21_2> {
|
||||
final class ComponentRewriter99_1 extends NBTComponentRewriter<ClientboundPacket26_1> {
|
||||
|
||||
public ComponentRewriter1_99(final BackwardsProtocol<ClientboundPacket1_21_2, ?, ?, ?> protocol) {
|
||||
super(protocol, ReadType.NBT);
|
||||
public ComponentRewriter99_1(final BackwardsProtocol<ClientboundPacket26_1, ?, ?, ?> protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,11 +37,6 @@ final class ComponentRewriter1_99 extends TranslatableRewriter<ClientboundPacket
|
||||
}
|
||||
|
||||
// Remove or update data from componentsTag
|
||||
// New added data which is not handled otherwise needs to be removed to prevent errors on the client
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SerializerVersion inputSerializerVersion() {
|
||||
return SerializerVersion.V1_21_4;
|
||||
// Newly added data which is not handled otherwise needs to be removed to prevent errors on the client
|
||||
}
|
||||
}
|
||||
-111
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.template;
|
||||
|
||||
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_4;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfigurationPackets1_21;
|
||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2;
|
||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPackets1_21_2;
|
||||
import com.viaversion.viaversion.rewriter.RegistryDataRewriter;
|
||||
|
||||
// Replace if needed
|
||||
// Types1_OLD
|
||||
// Types1_21_4
|
||||
final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPacket1_21_2, Protocol1_98To1_99> {
|
||||
|
||||
public EntityPacketRewriter1_99(final Protocol1_98To1_99 protocol) {
|
||||
super(protocol, Types1_21_4.ENTITY_DATA_TYPES.optionalComponentType, Types1_21_4.ENTITY_DATA_TYPES.booleanType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPackets() {
|
||||
registerTrackerWithData1_19(ClientboundPackets1_21_2.ADD_ENTITY, EntityTypes1_21_4.FALLING_BLOCK);
|
||||
registerSetEntityData(ClientboundPackets1_21_2.SET_ENTITY_DATA, /*Types1_OLD.ENTITY_DATA_LIST, */Types1_21_4.ENTITY_DATA_LIST); // Specify old and new entity data list if changed
|
||||
registerRemoveEntities(ClientboundPackets1_21_2.REMOVE_ENTITIES);
|
||||
|
||||
final RegistryDataRewriter registryDataRewriter = new RegistryDataRewriter(protocol);
|
||||
protocol.registerClientbound(ClientboundConfigurationPackets1_21.REGISTRY_DATA, registryDataRewriter::handle);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_21_2.LOGIN, wrapper -> {
|
||||
final int entityId = wrapper.passthrough(Types.INT); // Entity id
|
||||
wrapper.passthrough(Types.BOOLEAN); // Hardcore
|
||||
wrapper.passthrough(Types.STRING_ARRAY); // World List
|
||||
wrapper.passthrough(Types.VAR_INT); // Max players
|
||||
wrapper.passthrough(Types.VAR_INT); // View distance
|
||||
wrapper.passthrough(Types.VAR_INT); // Simulation distance
|
||||
wrapper.passthrough(Types.BOOLEAN); // Reduced debug info
|
||||
wrapper.passthrough(Types.BOOLEAN); // Show death screen
|
||||
wrapper.passthrough(Types.BOOLEAN); // Limited crafting
|
||||
final int dimensionId = wrapper.passthrough(Types.VAR_INT);
|
||||
final String world = wrapper.passthrough(Types.STRING);
|
||||
trackWorldDataByKey1_20_5(wrapper.user(), dimensionId, world);
|
||||
trackPlayer(wrapper.user(), entityId);
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_21_2.RESPAWN, wrapper -> {
|
||||
final int dimensionId = wrapper.passthrough(Types.VAR_INT);
|
||||
final String world = wrapper.passthrough(Types.STRING);
|
||||
trackWorldDataByKey1_20_5(wrapper.user(), dimensionId, world); // Tracks world height and name for chunk data and entity (un)tracking
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
/*filter().handler((event, data) -> {
|
||||
int id = data.dataType().typeId();
|
||||
if (id >= ac) {
|
||||
return;
|
||||
} else if (id >= ab) {
|
||||
id--;
|
||||
}
|
||||
|
||||
data.setDataType(Types1_21_4.ENTITY_DATA_TYPES.byId(id));
|
||||
});*/
|
||||
|
||||
registerEntityDataTypeHandler1_20_3(
|
||||
Types1_21_4.ENTITY_DATA_TYPES.itemType,
|
||||
Types1_21_4.ENTITY_DATA_TYPES.blockStateType,
|
||||
Types1_21_4.ENTITY_DATA_TYPES.optionalBlockStateType,
|
||||
Types1_21_4.ENTITY_DATA_TYPES.particleType,
|
||||
Types1_21_4.ENTITY_DATA_TYPES.particlesType,
|
||||
Types1_21_4.ENTITY_DATA_TYPES.componentType,
|
||||
Types1_21_4.ENTITY_DATA_TYPES.optionalComponentType
|
||||
);
|
||||
registerBlockStateHandler(EntityTypes1_21_4.ABSTRACT_MINECART, 11);
|
||||
|
||||
// Remove entity data of new entity type
|
||||
// filter().type(EntityTypes1_21_4.SNIFFER).removeIndex(newIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMappingDataLoaded() {
|
||||
// If types changed, uncomment to map them
|
||||
// mapTypes();
|
||||
|
||||
// mapEntityTypeWithData(EntityTypes1_21_4.SNIFFER, EntityTypes1_21_4.RAVAGER).tagName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(final int type) {
|
||||
return EntityTypes1_21_4.getTypeFromId(type);
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.template;
|
||||
|
||||
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_11;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1_21_11;
|
||||
import com.viaversion.viaversion.api.type.types.version.VersionedTypes;
|
||||
import com.viaversion.viaversion.protocols.v1_21_11to26_1.packet.ClientboundPacket26_1;
|
||||
|
||||
// Replace if needed
|
||||
// VersionedTypes
|
||||
final class EntityPacketRewriter99_1 extends EntityRewriter<ClientboundPacket26_1, Protocol99_1To98_1> {
|
||||
|
||||
private static final EntityDataTypes1_21_11 MAPPED_DATA_TYPES = VersionedTypes.V1_21_11.entityDataTypes;
|
||||
|
||||
public EntityPacketRewriter99_1(final Protocol99_1To98_1 protocol) {
|
||||
super(protocol, MAPPED_DATA_TYPES.optionalComponentType, MAPPED_DATA_TYPES.booleanType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPackets() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
/*filter().handler((event, data) -> {
|
||||
int id = data.dataType().typeId();
|
||||
if (id >= ac) {
|
||||
return;
|
||||
} else if (id >= ab) {
|
||||
id--;
|
||||
}
|
||||
|
||||
data.setDataType(MAPPED_DATA_TYPES.byId(id));
|
||||
});*/
|
||||
|
||||
registerEntityDataTypeHandler1_20_3(
|
||||
MAPPED_DATA_TYPES.itemType,
|
||||
MAPPED_DATA_TYPES.blockStateType,
|
||||
MAPPED_DATA_TYPES.optionalBlockStateType,
|
||||
MAPPED_DATA_TYPES.particleType,
|
||||
MAPPED_DATA_TYPES.particlesType,
|
||||
MAPPED_DATA_TYPES.componentType,
|
||||
MAPPED_DATA_TYPES.optionalComponentType
|
||||
);
|
||||
|
||||
// Remove entity data of new entity type
|
||||
// filter().type(EntityTypes1_21_11.SNIFFER).removeIndex(newIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMappingDataLoaded() {
|
||||
super.onMappingDataLoaded();
|
||||
// mapEntityTypeWithData(EntityTypes1_21_11.SNIFFER, EntityTypes1_21_11.RAVAGER).tagName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(final int type) {
|
||||
return EntityTypes1_21_11.getTypeFromId(type);
|
||||
}
|
||||
}
|
||||
-145
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.template;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
|
||||
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_4;
|
||||
import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider;
|
||||
import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_21_4;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundConfigurationPackets1_20_5;
|
||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.Protocol1_20_5To1_21;
|
||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfigurationPackets1_21;
|
||||
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.packet.ServerboundPacket1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.packet.ServerboundPackets1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2;
|
||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPackets1_21_2;
|
||||
import com.viaversion.viaversion.rewriter.ParticleRewriter;
|
||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
|
||||
import static com.viaversion.viaversion.util.ProtocolUtil.packetTypeMap;
|
||||
|
||||
// Placeholders to replace (in the entire package):
|
||||
// Protocol1_98To1_99, EntityPacketRewriter1_99, BlockItemPacketRewriter1_99
|
||||
// Protocol1_20_5To1_21 (the ViaVersion protocol class the mappings depend on)
|
||||
// ClientboundPacket1_21_2
|
||||
// ServerboundPacket1_21_4
|
||||
// ClientboundConfigurationPackets1_21
|
||||
// ServerboundConfigurationPackets1_20_5
|
||||
// EntityTypes1_21_4 (UNMAPPED type)
|
||||
// Types1_21_4.PARTICLE
|
||||
// 1.99, 1.98
|
||||
final class Protocol1_98To1_99 extends BackwardsProtocol<ClientboundPacket1_21_2, ClientboundPacket1_21_2, ServerboundPacket1_21_4, ServerboundPacket1_21_4> {
|
||||
|
||||
// ViaBackwards uses its own mappings and also needs a translatablerewriter for translation mappings
|
||||
public static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("1.99", "1.98", Protocol1_20_5To1_21.class);
|
||||
private final EntityPacketRewriter1_99 entityRewriter = new EntityPacketRewriter1_99(this);
|
||||
private final BlockItemPacketRewriter1_99 itemRewriter = new BlockItemPacketRewriter1_99(this);
|
||||
private final ParticleRewriter<ClientboundPacket1_21_2> particleRewriter = new ParticleRewriter<>(this, Types1_21_4.PARTICLE/*, Types1_OLD.PARTICLE*/);
|
||||
private final TranslatableRewriter<ClientboundPacket1_21_2> translatableRewriter = new ComponentRewriter1_99(this);
|
||||
private final TagRewriter<ClientboundPacket1_21_2> tagRewriter = new TagRewriter<>(this);
|
||||
|
||||
public Protocol1_98To1_99() {
|
||||
super(ClientboundPacket1_21_2.class, ClientboundPacket1_21_2.class, ServerboundPacket1_21_4.class, ServerboundPacket1_21_4.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
super.registerPackets();
|
||||
|
||||
tagRewriter.registerGeneric(ClientboundPackets1_21_2.UPDATE_TAGS);
|
||||
tagRewriter.registerGeneric(ClientboundConfigurationPackets1_21.UPDATE_TAGS);
|
||||
|
||||
final SoundRewriter<ClientboundPacket1_21_2> soundRewriter = new SoundRewriter<>(this);
|
||||
soundRewriter.registerSound1_19_3(ClientboundPackets1_21_2.SOUND);
|
||||
soundRewriter.registerSound1_19_3(ClientboundPackets1_21_2.SOUND_ENTITY);
|
||||
soundRewriter.registerStopSound(ClientboundPackets1_21_2.STOP_SOUND);
|
||||
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_21_2.AWARD_STATS);
|
||||
//new AttributeRewriter<>(this).register1_21(ClientboundPackets1_21_2.UPDATE_ATTRIBUTES);
|
||||
|
||||
// Registers translatable mappings (missing a whole bunch still)
|
||||
//translatableRewriter.registerOpenScreen(ClientboundPackets1_21_2.OPEN_SCREEN); // Handled by registerOpenScreen in item rewriters
|
||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.SET_ACTION_BAR_TEXT);
|
||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.SET_TITLE_TEXT);
|
||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.SET_SUBTITLE_TEXT);
|
||||
translatableRewriter.registerBossEvent(ClientboundPackets1_21_2.BOSS_EVENT);
|
||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.DISCONNECT);
|
||||
translatableRewriter.registerTabList(ClientboundPackets1_21_2.TAB_LIST);
|
||||
translatableRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_21_2.PLAYER_COMBAT_KILL);
|
||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.SYSTEM_CHAT);
|
||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.DISGUISED_CHAT);
|
||||
translatableRewriter.registerPlayerInfoUpdate1_21_4(ClientboundPackets1_21_2.PLAYER_INFO_UPDATE);
|
||||
translatableRewriter.registerPing();
|
||||
|
||||
// If needed for any particle, item, or block changes. Extend ParticleRewriter for particle serializer changes
|
||||
particleRewriter.registerLevelParticles1_20_5(ClientboundPackets1_21_2.LEVEL_PARTICLES);
|
||||
particleRewriter.registerExplode1_21_2(ClientboundPackets1_21_2.EXPLODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(final UserConnection user) {
|
||||
addEntityTracker(user, new EntityTrackerBase(user, EntityTypes1_21_4.PLAYER));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackwardsMappingData getMappingData() {
|
||||
return MAPPINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPacketRewriter1_99 getEntityRewriter() {
|
||||
return entityRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItemPacketRewriter1_99 getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParticleRewriter<ClientboundPacket1_21_2> getParticleRewriter() {
|
||||
return particleRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableRewriter<ClientboundPacket1_21_2> getComponentRewriter() {
|
||||
return translatableRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagRewriter<ClientboundPacket1_21_2> getTagRewriter() {
|
||||
return tagRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PacketTypesProvider<ClientboundPacket1_21_2, ClientboundPacket1_21_2, ServerboundPacket1_21_4, ServerboundPacket1_21_4> createPacketTypesProvider() {
|
||||
return new SimplePacketTypesProvider<>(
|
||||
packetTypeMap(unmappedClientboundPacketType, ClientboundPackets1_21_2.class, ClientboundConfigurationPackets1_21.class),
|
||||
packetTypeMap(mappedClientboundPacketType, ClientboundPackets1_21_2.class, ClientboundConfigurationPackets1_21.class),
|
||||
packetTypeMap(mappedServerboundPacketType, ServerboundPackets1_21_4.class, ServerboundConfigurationPackets1_20_5.class),
|
||||
packetTypeMap(unmappedServerboundPacketType, ServerboundPackets1_21_4.class, ServerboundConfigurationPackets1_20_5.class)
|
||||
);
|
||||
}
|
||||
}
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.template;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
|
||||
import com.viaversion.viabackwards.api.rewriters.BackwardsRegistryRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.text.NBTComponentRewriter;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_11;
|
||||
import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider;
|
||||
import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider;
|
||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType26_1;
|
||||
import com.viaversion.viaversion.api.type.types.version.VersionedTypes;
|
||||
import com.viaversion.viaversion.api.type.types.version.VersionedTypesHolder;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.data.item.ItemHasherBase;
|
||||
import com.viaversion.viaversion.protocols.v1_21_11to26_1.Protocol1_21_11To26_1;
|
||||
import com.viaversion.viaversion.protocols.v1_21_11to26_1.packet.ClientboundPacket26_1;
|
||||
import com.viaversion.viaversion.protocols.v1_21_11to26_1.packet.ClientboundPackets26_1;
|
||||
import com.viaversion.viaversion.protocols.v1_21_4to1_21_5.rewriter.RecipeDisplayRewriter1_21_5;
|
||||
import com.viaversion.viaversion.protocols.v1_21_5to1_21_6.packet.ServerboundPackets1_21_6;
|
||||
import com.viaversion.viaversion.protocols.v1_21_7to1_21_9.packet.ClientboundConfigurationPackets1_21_9;
|
||||
import com.viaversion.viaversion.protocols.v1_21_7to1_21_9.packet.ServerboundConfigurationPackets1_21_9;
|
||||
import com.viaversion.viaversion.protocols.v1_21_7to1_21_9.packet.ServerboundPacket1_21_9;
|
||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||
import com.viaversion.viaversion.rewriter.ParticleRewriter;
|
||||
import com.viaversion.viaversion.rewriter.RecipeDisplayRewriter;
|
||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
import com.viaversion.viaversion.rewriter.block.BlockRewriter1_21_5;
|
||||
|
||||
import static com.viaversion.viaversion.util.ProtocolUtil.packetTypeMap;
|
||||
|
||||
// Placeholders to replace (in the entire package):
|
||||
// Protocol1_21_11To26_1 (the ViaVersion protocol class the mappings depend on)
|
||||
// ClientboundPacket26_1
|
||||
// ServerboundPacket1_21_9
|
||||
// ClientboundConfigurationPackets1_21
|
||||
// ServerboundConfigurationPackets1_20_5
|
||||
// EntityTypes1_21_11 (UNMAPPED type)
|
||||
// VersionedTypes.V26_1
|
||||
// 99.1, 98.1
|
||||
final class Protocol99_1To98_1 extends BackwardsProtocol<ClientboundPacket26_1, ClientboundPacket26_1, ServerboundPacket1_21_9, ServerboundPacket1_21_9> {
|
||||
|
||||
// ViaBackwards uses its own mappings and also needs a translatablerewriter for translation mappings
|
||||
public static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("99.1", "98.1", Protocol1_21_11To26_1.class); // Change the VV (!) protocol class
|
||||
private final EntityPacketRewriter99_1 entityRewriter = new EntityPacketRewriter99_1(this);
|
||||
private final BlockItemPacketRewriter99_1 itemRewriter = new BlockItemPacketRewriter99_1(this);
|
||||
private final ParticleRewriter<ClientboundPacket26_1> particleRewriter = new ParticleRewriter<>(this);
|
||||
private final NBTComponentRewriter<ClientboundPacket26_1> translatableRewriter = new ComponentRewriter99_1(this);
|
||||
private final TagRewriter<ClientboundPacket26_1> tagRewriter = new TagRewriter<>(this);
|
||||
private final BackwardsRegistryRewriter registryDataRewriter = new BackwardsRegistryRewriter(this);
|
||||
private final BlockRewriter<ClientboundPacket26_1> blockRewriter = new BlockRewriter1_21_5<>(this, ChunkType26_1::new);
|
||||
private final RecipeDisplayRewriter<ClientboundPacket26_1> recipeRewriter = new RecipeDisplayRewriter1_21_5<>(this);
|
||||
|
||||
public Protocol99_1To98_1() {
|
||||
super(ClientboundPacket26_1.class, ClientboundPacket26_1.class, ServerboundPacket1_21_9.class, ServerboundPacket1_21_9.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
super.registerPackets();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(final UserConnection connection) {
|
||||
addEntityTracker(connection, new EntityTrackerBase(connection, EntityTypes1_21_11.PLAYER));
|
||||
addItemHasher(connection, new ItemHasherBase(this, connection));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackwardsMappingData getMappingData() {
|
||||
return MAPPINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPacketRewriter99_1 getEntityRewriter() {
|
||||
return entityRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItemPacketRewriter99_1 getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRewriter<ClientboundPacket26_1> getBlockRewriter() {
|
||||
return blockRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeDisplayRewriter<ClientboundPacket26_1> getRecipeRewriter() {
|
||||
return recipeRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackwardsRegistryRewriter getRegistryDataRewriter() {
|
||||
return registryDataRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParticleRewriter<ClientboundPacket26_1> getParticleRewriter() {
|
||||
return particleRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTComponentRewriter<ClientboundPacket26_1> getComponentRewriter() {
|
||||
return translatableRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagRewriter<ClientboundPacket26_1> getTagRewriter() {
|
||||
return tagRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionedTypesHolder types() {
|
||||
return VersionedTypes.V26_1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionedTypesHolder mappedTypes() {
|
||||
return VersionedTypes.V26_1;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PacketTypesProvider<ClientboundPacket26_1, ClientboundPacket26_1, ServerboundPacket1_21_9, ServerboundPacket1_21_9> createPacketTypesProvider() {
|
||||
return new SimplePacketTypesProvider<>(
|
||||
packetTypeMap(unmappedClientboundPacketType, ClientboundPackets26_1.class, ClientboundConfigurationPackets1_21_9.class),
|
||||
packetTypeMap(mappedClientboundPacketType, ClientboundPackets26_1.class, ClientboundConfigurationPackets1_21_9.class),
|
||||
packetTypeMap(mappedServerboundPacketType, ServerboundPackets1_21_6.class, ServerboundConfigurationPackets1_21_9.class),
|
||||
packetTypeMap(unmappedServerboundPacketType, ServerboundPackets1_21_6.class, ServerboundConfigurationPackets1_21_9.class)
|
||||
);
|
||||
}
|
||||
}
|
||||
+6
-11
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,7 +21,7 @@ package com.viaversion.viabackwards.protocol.v1_10to1_9_3;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
|
||||
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_10to1_9_3.rewriter.BlockItemPacketRewriter1_10;
|
||||
import com.viaversion.viabackwards.protocol.v1_10to1_9_3.rewriter.EntityPacketRewriter1_10;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
@@ -34,7 +34,7 @@ import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase;
|
||||
|
||||
public class Protocol1_10To1_9_3 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
||||
|
||||
@@ -57,7 +57,7 @@ public class Protocol1_10To1_9_3 extends BackwardsProtocol<ClientboundPackets1_9
|
||||
itemRewriter.register();
|
||||
|
||||
SoundRewriter<ClientboundPackets1_9_3> soundRewriter = new SoundRewriter<>(this);
|
||||
registerClientbound(ClientboundPackets1_9_3.CUSTOM_SOUND, new PacketHandlers() {
|
||||
replaceClientbound(ClientboundPackets1_9_3.CUSTOM_SOUND, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types.STRING); // 0 - Sound name
|
||||
@@ -70,7 +70,7 @@ public class Protocol1_10To1_9_3 extends BackwardsProtocol<ClientboundPackets1_9
|
||||
handler(soundRewriter.getNamedSoundHandler());
|
||||
}
|
||||
});
|
||||
registerClientbound(ClientboundPackets1_9_3.SOUND, new PacketHandlers() {
|
||||
replaceClientbound(ClientboundPackets1_9_3.SOUND, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types.VAR_INT); // 0 - Sound name
|
||||
@@ -92,7 +92,7 @@ public class Protocol1_10To1_9_3 extends BackwardsProtocol<ClientboundPackets1_9
|
||||
}
|
||||
});
|
||||
|
||||
TranslatableRewriter<ClientboundPackets1_9_3> componentRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON);
|
||||
JsonNBTComponentRewriter<ClientboundPackets1_9_3> componentRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.JSON);
|
||||
componentRewriter.registerComponentPacket(ClientboundPackets1_9_3.CHAT);
|
||||
}
|
||||
|
||||
@@ -116,9 +116,4 @@ public class Protocol1_10To1_9_3 extends BackwardsProtocol<ClientboundPackets1_9
|
||||
public BlockItemPacketRewriter1_10 getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMappingDataToLoad() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+12
-10
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -29,7 +29,6 @@ import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1_9;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
||||
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
|
||||
import java.util.List;
|
||||
|
||||
@@ -80,7 +79,7 @@ public class EntityPacketRewriter1_10 extends LegacyEntityRewriter<ClientboundPa
|
||||
map(Types.SHORT); // 9 - Velocity X
|
||||
map(Types.SHORT); // 10 - Velocity Y
|
||||
map(Types.SHORT); // 11 - Velocity Z
|
||||
map(Types1_9.ENTITY_DATA_LIST); // 12 - Entity data
|
||||
map(Types.ENTITY_DATA_LIST1_9); // 12 - Entity data
|
||||
|
||||
// Track entity
|
||||
handler(getTrackerHandler(Types.UNSIGNED_BYTE, 0));
|
||||
@@ -93,7 +92,7 @@ public class EntityPacketRewriter1_10 extends LegacyEntityRewriter<ClientboundPa
|
||||
return;
|
||||
}
|
||||
|
||||
List<EntityData> entityDataList = wrapper.get(Types1_9.ENTITY_DATA_LIST, 0);
|
||||
List<EntityData> entityDataList = wrapper.get(Types.ENTITY_DATA_LIST1_9, 0);
|
||||
handleEntityData(wrapper.get(Types.VAR_INT, 0), entityDataList, wrapper.user());
|
||||
|
||||
EntityReplacement entityReplacement = entityDataForType(type);
|
||||
@@ -122,14 +121,14 @@ public class EntityPacketRewriter1_10 extends LegacyEntityRewriter<ClientboundPa
|
||||
map(Types.DOUBLE); // 4 - Z
|
||||
map(Types.BYTE); // 5 - Yaw
|
||||
map(Types.BYTE); // 6 - Pitch
|
||||
map(Types1_9.ENTITY_DATA_LIST); // 7 - Entity data list
|
||||
map(Types.ENTITY_DATA_LIST1_9); // 7 - Entity data list
|
||||
|
||||
handler(getTrackerAndDataHandler(Types1_9.ENTITY_DATA_LIST, EntityTypes1_11.EntityType.PLAYER));
|
||||
handler(getTrackerAndDataHandler(Types.ENTITY_DATA_LIST1_9, EntityTypes1_11.EntityType.PLAYER));
|
||||
}
|
||||
});
|
||||
|
||||
registerRemoveEntities(ClientboundPackets1_9_3.REMOVE_ENTITIES);
|
||||
registerSetEntityData(ClientboundPackets1_9_3.SET_ENTITY_DATA, Types1_9.ENTITY_DATA_LIST);
|
||||
registerSetEntityData(ClientboundPackets1_9_3.SET_ENTITY_DATA, Types.ENTITY_DATA_LIST1_9);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -158,17 +157,20 @@ public class EntityPacketRewriter1_10 extends LegacyEntityRewriter<ClientboundPa
|
||||
}
|
||||
});
|
||||
|
||||
// Added index from incorrect entity data hierarchy, where potions add to item entities
|
||||
filter().type(EntityTypes1_10.EntityType.POTION).addIndex(6);
|
||||
|
||||
// Handle the missing NoGravity tag for every entity data
|
||||
filter().removeIndex(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return EntityTypes1_10.getTypeFromId(typeId, false);
|
||||
return EntityTypes1_10.EntityType.findById(typeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType objectTypeFromId(int typeId) {
|
||||
return EntityTypes1_10.getTypeFromId(typeId, true);
|
||||
public EntityType objectTypeFromId(int typeId, int data) {
|
||||
return EntityTypes1_10.ObjectType.getEntityType(typeId, data);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+9
-10
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -24,7 +24,6 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
||||
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
|
||||
|
||||
public class EntityPacketRewriter1_11_1 extends LegacyEntityRewriter<ClientboundPackets1_9_3, Protocol1_11_1To1_11> {
|
||||
@@ -72,13 +71,13 @@ public class EntityPacketRewriter1_11_1 extends LegacyEntityRewriter<Clientbound
|
||||
map(Types.SHORT); // 9 - Velocity X
|
||||
map(Types.SHORT); // 10 - Velocity Y
|
||||
map(Types.SHORT); // 11 - Velocity Z
|
||||
map(Types1_9.ENTITY_DATA_LIST); // 12 - Entity data
|
||||
map(Types.ENTITY_DATA_LIST1_9); // 12 - Entity data
|
||||
|
||||
// Track entity
|
||||
handler(getTrackerHandler());
|
||||
|
||||
// Rewrite entity type / data
|
||||
handler(getMobSpawnRewriter1_11(Types1_9.ENTITY_DATA_LIST));
|
||||
handler(getMobSpawnRewriter1_11(Types.ENTITY_DATA_LIST1_9));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -96,14 +95,14 @@ public class EntityPacketRewriter1_11_1 extends LegacyEntityRewriter<Clientbound
|
||||
map(Types.DOUBLE); // 4 - Z
|
||||
map(Types.BYTE); // 5 - Yaw
|
||||
map(Types.BYTE); // 6 - Pitch
|
||||
map(Types1_9.ENTITY_DATA_LIST); // 7 - Entity data list
|
||||
map(Types.ENTITY_DATA_LIST1_9); // 7 - Entity data list
|
||||
|
||||
handler(getTrackerAndDataHandler(Types1_9.ENTITY_DATA_LIST, EntityTypes1_11.EntityType.PLAYER));
|
||||
handler(getTrackerAndDataHandler(Types.ENTITY_DATA_LIST1_9, EntityTypes1_11.EntityType.PLAYER));
|
||||
}
|
||||
});
|
||||
|
||||
registerRemoveEntities(ClientboundPackets1_9_3.REMOVE_ENTITIES);
|
||||
registerSetEntityData(ClientboundPackets1_9_3.SET_ENTITY_DATA, Types1_9.ENTITY_DATA_LIST);
|
||||
registerSetEntityData(ClientboundPackets1_9_3.SET_ENTITY_DATA, Types.ENTITY_DATA_LIST1_9);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,11 +116,11 @@ public class EntityPacketRewriter1_11_1 extends LegacyEntityRewriter<Clientbound
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return EntityTypes1_11.getTypeFromId(typeId, false);
|
||||
return EntityTypes1_11.EntityType.findById(typeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType objectTypeFromId(int typeId) {
|
||||
return EntityTypes1_11.getTypeFromId(typeId, true);
|
||||
public EntityType objectTypeFromId(int typeId, int data) {
|
||||
return EntityTypes1_11.ObjectType.getEntityType(typeId, data);
|
||||
}
|
||||
}
|
||||
+2
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -23,8 +23,6 @@ import com.viaversion.viabackwards.api.rewriters.LegacyEnchantmentRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_11_1to1_11.Protocol1_11_1To1_11;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3;
|
||||
@@ -73,7 +71,7 @@ public class ItemPacketRewriter1_11_1 extends LegacyBlockItemRewriter<Clientboun
|
||||
@Override
|
||||
public Item handleItemToServer(UserConnection connection, Item item) {
|
||||
if (item == null) return null;
|
||||
super.handleItemToServer(connection, item);
|
||||
item = super.handleItemToServer(connection, item);
|
||||
|
||||
enchantmentRewriter.handleToServer(item);
|
||||
return item;
|
||||
|
||||
+7
-17
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,8 +20,7 @@ package com.viaversion.viabackwards.protocol.v1_11to1_10;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
|
||||
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_11to1_10.rewriter.BlockItemPacketRewriter1_11;
|
||||
import com.viaversion.viabackwards.protocol.v1_11to1_10.rewriter.EntityPacketRewriter1_11;
|
||||
import com.viaversion.viabackwards.protocol.v1_11to1_10.rewriter.PlayerPacketRewriter1_11;
|
||||
@@ -30,17 +29,16 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ClientboundPackets1_12;
|
||||
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase;
|
||||
|
||||
public class Protocol1_11To1_10 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
||||
|
||||
public static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("1.11", "1.10");
|
||||
private final EntityPacketRewriter1_11 entityRewriter = new EntityPacketRewriter1_11(this);
|
||||
private final BlockItemPacketRewriter1_11 itemRewriter = new BlockItemPacketRewriter1_11(this);
|
||||
private TranslatableRewriter<ClientboundPackets1_9_3> componentRewriter;
|
||||
private JsonNBTComponentRewriter<ClientboundPackets1_9_3> componentRewriter;
|
||||
|
||||
public Protocol1_11To1_10() {
|
||||
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
|
||||
@@ -52,11 +50,7 @@ public class Protocol1_11To1_10 extends BackwardsProtocol<ClientboundPackets1_9_
|
||||
itemRewriter.register();
|
||||
PlayerPacketRewriter1_11.register(this);
|
||||
|
||||
SoundRewriter<ClientboundPackets1_9_3> soundRewriter = new SoundRewriter<>(this);
|
||||
soundRewriter.registerNamedSound(ClientboundPackets1_9_3.CUSTOM_SOUND);
|
||||
soundRewriter.registerSound(ClientboundPackets1_9_3.SOUND);
|
||||
|
||||
componentRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON);
|
||||
componentRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.JSON);
|
||||
componentRewriter.registerComponentPacket(ClientboundPackets1_9_3.CHAT);
|
||||
}
|
||||
|
||||
@@ -85,12 +79,8 @@ public class Protocol1_11To1_10 extends BackwardsProtocol<ClientboundPackets1_9_
|
||||
return itemRewriter;
|
||||
}
|
||||
|
||||
public TranslatableRewriter<ClientboundPackets1_9_3> getComponentRewriter() {
|
||||
@Override
|
||||
public JsonNBTComponentRewriter<ClientboundPackets1_9_3> getComponentRewriter() {
|
||||
return componentRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMappingDataToLoad() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
package com.viaversion.viabackwards.protocol.v1_11to1_10.rewriter;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.viabackwards.api.data.MappedLegacyBlockItem;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyBlockItemRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyEnchantmentRewriter;
|
||||
@@ -35,8 +37,6 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.viaversion.protocols.v1_10to1_11.data.EntityMappings1_11;
|
||||
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3;
|
||||
@@ -60,7 +60,7 @@ public class BlockItemPacketRewriter1_11 extends LegacyBlockItemRewriter<Clientb
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.CONTAINER_SET_SLOT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Types.BYTE); // 0 - Window ID
|
||||
map(Types.SHORT); // 1 - Slot ID
|
||||
map(Types.ITEM1_8); // 2 - Slot Value
|
||||
|
||||
@@ -118,7 +118,7 @@ public class BlockItemPacketRewriter1_11 extends LegacyBlockItemRewriter<Clientb
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.CONTAINER_CLICK, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Types.BYTE); // 0 - Window ID
|
||||
map(Types.SHORT); // 1 - Slot
|
||||
map(Types.BYTE); // 2 - Button
|
||||
map(Types.SHORT); // 3 - Action number
|
||||
@@ -280,7 +280,7 @@ public class BlockItemPacketRewriter1_11 extends LegacyBlockItemRewriter<Clientb
|
||||
@Override
|
||||
public Item handleItemToServer(UserConnection connection, Item item) {
|
||||
if (item == null) return null;
|
||||
super.handleItemToServer(connection, item);
|
||||
item = super.handleItemToServer(connection, item);
|
||||
|
||||
CompoundTag tag = item.tag();
|
||||
if (tag == null) return item;
|
||||
|
||||
+11
-12
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -30,7 +30,6 @@ import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1_9;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
||||
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
|
||||
import java.util.List;
|
||||
|
||||
@@ -104,17 +103,17 @@ public class EntityPacketRewriter1_11 extends LegacyEntityRewriter<ClientboundPa
|
||||
map(Types.SHORT); // 9 - Velocity X
|
||||
map(Types.SHORT); // 10 - Velocity Y
|
||||
map(Types.SHORT); // 11 - Velocity Z
|
||||
map(Types1_9.ENTITY_DATA_LIST); // 12 - Entity data
|
||||
map(Types.ENTITY_DATA_LIST1_9); // 12 - Entity data
|
||||
|
||||
// Track entity
|
||||
handler(getTrackerHandler(Types.UNSIGNED_BYTE, 0));
|
||||
|
||||
// Rewrite entity type / data
|
||||
handler(getMobSpawnRewriter(Types1_9.ENTITY_DATA_LIST));
|
||||
handler(getMobSpawnRewriter(Types.ENTITY_DATA_LIST1_9));
|
||||
|
||||
// Sub 1.11 clients will error if the list is empty
|
||||
handler(wrapper -> {
|
||||
List<EntityData> entityDataList = wrapper.get(Types1_9.ENTITY_DATA_LIST, 0);
|
||||
List<EntityData> entityDataList = wrapper.get(Types.ENTITY_DATA_LIST1_9, 0);
|
||||
if (entityDataList.isEmpty()) {
|
||||
entityDataList.add(new EntityData(0, EntityDataTypes1_9.BYTE, (byte) 0));
|
||||
}
|
||||
@@ -136,12 +135,12 @@ public class EntityPacketRewriter1_11 extends LegacyEntityRewriter<ClientboundPa
|
||||
map(Types.DOUBLE); // 4 - Z
|
||||
map(Types.BYTE); // 5 - Yaw
|
||||
map(Types.BYTE); // 6 - Pitch
|
||||
map(Types1_9.ENTITY_DATA_LIST); // 7 - Entity data list
|
||||
map(Types.ENTITY_DATA_LIST1_9); // 7 - Entity data list
|
||||
|
||||
handler(getTrackerAndDataHandler(Types1_9.ENTITY_DATA_LIST, EntityTypes1_11.EntityType.PLAYER));
|
||||
handler(getTrackerAndDataHandler(Types.ENTITY_DATA_LIST1_9, EntityTypes1_11.EntityType.PLAYER));
|
||||
handler(wrapper -> {
|
||||
// Sub 1.11 clients will cry if the list is empty
|
||||
List<EntityData> entityDataList = wrapper.get(Types1_9.ENTITY_DATA_LIST, 0);
|
||||
List<EntityData> entityDataList = wrapper.get(Types.ENTITY_DATA_LIST1_9, 0);
|
||||
if (entityDataList.isEmpty()) {
|
||||
entityDataList.add(new EntityData(0, EntityDataTypes1_9.BYTE, (byte) 0));
|
||||
}
|
||||
@@ -150,7 +149,7 @@ public class EntityPacketRewriter1_11 extends LegacyEntityRewriter<ClientboundPa
|
||||
});
|
||||
|
||||
registerRemoveEntities(ClientboundPackets1_9_3.REMOVE_ENTITIES);
|
||||
registerSetEntityData(ClientboundPackets1_9_3.SET_ENTITY_DATA, Types1_9.ENTITY_DATA_LIST);
|
||||
registerSetEntityData(ClientboundPackets1_9_3.SET_ENTITY_DATA, Types.ENTITY_DATA_LIST1_9);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.ENTITY_EVENT, new PacketHandlers() {
|
||||
@Override
|
||||
@@ -364,11 +363,11 @@ public class EntityPacketRewriter1_11 extends LegacyEntityRewriter<ClientboundPa
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return EntityTypes1_11.getTypeFromId(typeId, false);
|
||||
return EntityTypes1_11.EntityType.findById(typeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType objectTypeFromId(int typeId) {
|
||||
return EntityTypes1_11.getTypeFromId(typeId, true);
|
||||
public EntityType objectTypeFromId(int typeId, int data) {
|
||||
return EntityTypes1_11.ObjectType.getEntityType(typeId, data);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+5
-9
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,11 +20,11 @@ package com.viaversion.viabackwards.protocol.v1_12to1_11_1;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
|
||||
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.storage.ShoulderTracker;
|
||||
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter.BlockItemPacketRewriter1_12;
|
||||
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter.ComponentRewriter1_12;
|
||||
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter.EntityPacketRewriter1_12;
|
||||
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter.SoundPacketRewriter1_12;
|
||||
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.storage.ShoulderTracker;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_12;
|
||||
@@ -50,8 +50,8 @@ public class Protocol1_12To1_11_1 extends BackwardsProtocol<ClientboundPackets1_
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
itemRewriter.register();
|
||||
entityRewriter.register();
|
||||
super.registerPackets();
|
||||
|
||||
componentRewriter.registerComponentPacket(ClientboundPackets1_12.CHAT);
|
||||
new SoundPacketRewriter1_12(this).register();
|
||||
|
||||
@@ -92,12 +92,8 @@ public class Protocol1_12To1_11_1 extends BackwardsProtocol<ClientboundPackets1_
|
||||
return itemRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComponentRewriter1_12 getComponentRewriter() {
|
||||
return componentRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMappingDataToLoad() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,7 +18,11 @@
|
||||
|
||||
package com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.IntArrayTag;
|
||||
import com.viaversion.nbt.tag.LongArrayTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyBlockItemRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.Protocol1_12To1_11_1;
|
||||
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.data.MapColorMappings1_11_1;
|
||||
@@ -30,18 +34,14 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.IntArrayTag;
|
||||
import com.viaversion.nbt.tag.LongArrayTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ClientboundPackets1_12;
|
||||
import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ServerboundPackets1_12;
|
||||
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import com.viaversion.viaversion.util.SerializerVersion;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class BlockItemPacketRewriter1_12 extends LegacyBlockItemRewriter<ClientboundPackets1_12, ServerboundPackets1_9_3, Protocol1_12To1_11_1> {
|
||||
@@ -95,7 +95,7 @@ public class BlockItemPacketRewriter1_12 extends LegacyBlockItemRewriter<Clientb
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.CONTAINER_CLICK, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Types.BYTE); // 0 - Window ID
|
||||
map(Types.SHORT); // 1 - Slot
|
||||
map(Types.BYTE); // 2 - Button
|
||||
map(Types.SHORT); // 3 - Action number
|
||||
@@ -112,9 +112,9 @@ public class BlockItemPacketRewriter1_12 extends LegacyBlockItemRewriter<Clientb
|
||||
|
||||
// Apologize (may happen in some cases, maybe if inventory is full?)
|
||||
PacketWrapper confirm = wrapper.create(ServerboundPackets1_12.CONTAINER_ACK);
|
||||
confirm.write(Types.UNSIGNED_BYTE, wrapper.get(Types.UNSIGNED_BYTE, 0));
|
||||
confirm.write(Types.BYTE, wrapper.get(Types.BYTE, 0));
|
||||
confirm.write(Types.SHORT, wrapper.get(Types.SHORT, 1));
|
||||
confirm.write(Types.BOOLEAN, false); // Success - not used
|
||||
confirm.write(Types.BOOLEAN, true); // Success - not used
|
||||
|
||||
wrapper.sendToServer(Protocol1_12To1_11_1.class);
|
||||
wrapper.cancel();
|
||||
@@ -238,7 +238,7 @@ public class BlockItemPacketRewriter1_12 extends LegacyBlockItemRewriter<Clientb
|
||||
@Override
|
||||
public @Nullable Item handleItemToServer(UserConnection connection, Item item) {
|
||||
if (item == null) return null;
|
||||
super.handleItemToServer(connection, item);
|
||||
item = super.handleItemToServer(connection, item);
|
||||
|
||||
if (item.tag() != null) {
|
||||
if (item.tag().remove("Via|LongArrayTags") instanceof CompoundTag tag) {
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,18 +18,18 @@
|
||||
|
||||
package com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter;
|
||||
|
||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.Protocol1_12To1_11_1;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ClientboundPackets1_12;
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase;
|
||||
|
||||
public class ComponentRewriter1_12 extends TranslatableRewriter<ClientboundPackets1_12> {
|
||||
public class ComponentRewriter1_12 extends JsonNBTComponentRewriter<ClientboundPackets1_12> {
|
||||
|
||||
public ComponentRewriter1_12(Protocol1_12To1_11_1 protocol) {
|
||||
super(protocol, ComponentRewriter.ReadType.JSON);
|
||||
super(protocol, ComponentRewriterBase.ReadType.JSON);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+10
-12
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.Protocol1_12To1_11_1;
|
||||
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.storage.ParrotStorage;
|
||||
@@ -30,12 +31,9 @@ import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_12;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ClientboundPackets1_12;
|
||||
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
|
||||
public class EntityPacketRewriter1_12 extends LegacyEntityRewriter<ClientboundPackets1_12, Protocol1_12To1_11_1> {
|
||||
|
||||
@@ -84,13 +82,13 @@ public class EntityPacketRewriter1_12 extends LegacyEntityRewriter<ClientboundPa
|
||||
map(Types.SHORT); // 9 - Velocity X
|
||||
map(Types.SHORT); // 10 - Velocity Y
|
||||
map(Types.SHORT); // 11 - Velocity Z
|
||||
map(Types1_12.ENTITY_DATA_LIST, Types1_9.ENTITY_DATA_LIST); // 12 - Entity data
|
||||
map(Types.ENTITY_DATA_LIST1_12, Types.ENTITY_DATA_LIST1_9); // 12 - Entity data
|
||||
|
||||
// Track entity
|
||||
handler(getTrackerHandler());
|
||||
|
||||
// Rewrite entity type / data
|
||||
handler(getMobSpawnRewriter1_11(Types1_9.ENTITY_DATA_LIST));
|
||||
handler(getMobSpawnRewriter1_11(Types.ENTITY_DATA_LIST1_9));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -106,9 +104,9 @@ public class EntityPacketRewriter1_12 extends LegacyEntityRewriter<ClientboundPa
|
||||
map(Types.DOUBLE); // 4 - Z
|
||||
map(Types.BYTE); // 5 - Yaw
|
||||
map(Types.BYTE); // 6 - Pitch
|
||||
map(Types1_12.ENTITY_DATA_LIST, Types1_9.ENTITY_DATA_LIST); // 7 - Entity data list
|
||||
map(Types.ENTITY_DATA_LIST1_12, Types.ENTITY_DATA_LIST1_9); // 7 - Entity data list
|
||||
|
||||
handler(getTrackerAndDataHandler(Types1_9.ENTITY_DATA_LIST, EntityTypes1_12.EntityType.PLAYER));
|
||||
handler(getTrackerAndDataHandler(Types.ENTITY_DATA_LIST1_9, EntityTypes1_12.EntityType.PLAYER));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -142,7 +140,7 @@ public class EntityPacketRewriter1_12 extends LegacyEntityRewriter<ClientboundPa
|
||||
|
||||
registerRespawn(ClientboundPackets1_12.RESPAWN);
|
||||
registerRemoveEntities(ClientboundPackets1_12.REMOVE_ENTITIES);
|
||||
registerSetEntityData(ClientboundPackets1_12.SET_ENTITY_DATA, Types1_12.ENTITY_DATA_LIST, Types1_9.ENTITY_DATA_LIST);
|
||||
registerSetEntityData(ClientboundPackets1_12.SET_ENTITY_DATA, Types.ENTITY_DATA_LIST1_12, Types.ENTITY_DATA_LIST1_9);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.UPDATE_ATTRIBUTES, new PacketHandlers() {
|
||||
@Override
|
||||
@@ -285,11 +283,11 @@ public class EntityPacketRewriter1_12 extends LegacyEntityRewriter<ClientboundPa
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return EntityTypes1_12.getTypeFromId(typeId, false);
|
||||
return EntityTypes1_12.EntityType.findById(typeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType objectTypeFromId(int typeId) {
|
||||
return EntityTypes1_12.getTypeFromId(typeId, true);
|
||||
public EntityType objectTypeFromId(int typeId, int data) {
|
||||
return EntityTypes1_12.ObjectType.getEntityType(typeId, data);
|
||||
}
|
||||
}
|
||||
+2
-16
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,7 +21,6 @@ package com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacySoundRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.Protocol1_12To1_11_1;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ClientboundPackets1_12;
|
||||
|
||||
@@ -33,20 +32,7 @@ public class SoundPacketRewriter1_12 extends LegacySoundRewriter<Protocol1_12To1
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.CUSTOM_SOUND, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types.STRING); // 0 - Sound name
|
||||
map(Types.VAR_INT); // 1 - Sound Category
|
||||
map(Types.INT); // 2 - x
|
||||
map(Types.INT); // 3 - y
|
||||
map(Types.INT); // 4 - z
|
||||
map(Types.FLOAT); // 5 - Volume
|
||||
map(Types.FLOAT); // 6 - Pitch
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.SOUND, new PacketHandlers() {
|
||||
protocol.replaceClientbound(ClientboundPackets1_12.SOUND, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types.VAR_INT); // 0 - Sound name
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+16
-58
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,7 +20,7 @@ package com.viaversion.viabackwards.protocol.v1_13_1to1_13;
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
|
||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_13_1to1_13.rewriter.CommandRewriter1_13_1;
|
||||
import com.viaversion.viabackwards.protocol.v1_13_1to1_13.rewriter.EntityPacketRewriter1_13_1;
|
||||
import com.viaversion.viabackwards.protocol.v1_13_1to1_13.rewriter.ItemPacketRewriter1_13_1;
|
||||
@@ -40,10 +40,9 @@ import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.v1_13to1_13_1.Protocol1_13To1_13_1;
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
import com.viaversion.viaversion.rewriter.ParticleRewriter;
|
||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
|
||||
public class Protocol1_13_1To1_13 extends BackwardsProtocol<ClientboundPackets1_13, ClientboundPackets1_13, ServerboundPackets1_13, ServerboundPackets1_13> {
|
||||
@@ -52,7 +51,7 @@ public class Protocol1_13_1To1_13 extends BackwardsProtocol<ClientboundPackets1_
|
||||
private final EntityPacketRewriter1_13_1 entityRewriter = new EntityPacketRewriter1_13_1(this);
|
||||
private final ItemPacketRewriter1_13_1 itemRewriter = new ItemPacketRewriter1_13_1(this);
|
||||
private final ParticleRewriter<ClientboundPackets1_13> particleRewriter = new ParticleRewriter<>(this);
|
||||
private final TranslatableRewriter<ClientboundPackets1_13> translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON);
|
||||
private final JsonNBTComponentRewriter<ClientboundPackets1_13> translatableRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.JSON);
|
||||
private final TagRewriter<ClientboundPackets1_13> tagRewriter = new TagRewriter<>(this);
|
||||
|
||||
public Protocol1_13_1To1_13() {
|
||||
@@ -65,17 +64,8 @@ public class Protocol1_13_1To1_13 extends BackwardsProtocol<ClientboundPackets1_
|
||||
|
||||
WorldPacketRewriter1_13_1.register(this);
|
||||
|
||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_13.CHAT);
|
||||
translatableRewriter.registerPlayerCombat(ClientboundPackets1_13.PLAYER_COMBAT);
|
||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_13.DISCONNECT);
|
||||
translatableRewriter.registerTabList(ClientboundPackets1_13.TAB_LIST);
|
||||
translatableRewriter.registerTitle(ClientboundPackets1_13.SET_TITLES);
|
||||
translatableRewriter.registerPing();
|
||||
|
||||
new CommandRewriter1_13_1(this).registerDeclareCommands(ClientboundPackets1_13.COMMANDS);
|
||||
|
||||
particleRewriter.registerLevelParticles1_13(ClientboundPackets1_13.LEVEL_PARTICLES, Types.FLOAT);
|
||||
|
||||
registerServerbound(ServerboundPackets1_13.COMMAND_SUGGESTION, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
@@ -90,16 +80,11 @@ public class Protocol1_13_1To1_13 extends BackwardsProtocol<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
registerServerbound(ServerboundPackets1_13.EDIT_BOOK, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types.ITEM1_13);
|
||||
map(Types.BOOLEAN);
|
||||
handler(wrapper -> {
|
||||
itemRewriter.handleItemToServer(wrapper.user(), wrapper.get(Types.ITEM1_13, 0));
|
||||
wrapper.write(Types.VAR_INT, 0);
|
||||
});
|
||||
}
|
||||
registerServerbound(ServerboundPackets1_13.EDIT_BOOK, wrapper -> {
|
||||
final Item item = itemRewriter.handleItemToServer(wrapper.user(), wrapper.read(Types.ITEM1_13));
|
||||
wrapper.write(Types.ITEM1_13, item);
|
||||
wrapper.passthrough(Types.BOOLEAN);
|
||||
wrapper.write(Types.VAR_INT, 0);
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_13.OPEN_SCREEN, new PacketHandlers() {
|
||||
@@ -147,7 +132,7 @@ public class Protocol1_13_1To1_13 extends BackwardsProtocol<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_13.BOSS_EVENT, new PacketHandlers() {
|
||||
replaceClientbound(ClientboundPackets1_13.BOSS_EVENT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types.UUID);
|
||||
@@ -169,39 +154,7 @@ public class Protocol1_13_1To1_13 extends BackwardsProtocol<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_13.UPDATE_ADVANCEMENTS, wrapper -> {
|
||||
wrapper.passthrough(Types.BOOLEAN); // Reset/clear
|
||||
int size = wrapper.passthrough(Types.VAR_INT); // Mapping size
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.passthrough(Types.STRING); // Identifier
|
||||
wrapper.passthrough(Types.OPTIONAL_STRING); // Parent
|
||||
|
||||
// Display data
|
||||
if (wrapper.passthrough(Types.BOOLEAN)) {
|
||||
wrapper.passthrough(Types.COMPONENT); // Title
|
||||
wrapper.passthrough(Types.COMPONENT); // Description
|
||||
Item icon = wrapper.passthrough(Types.ITEM1_13);
|
||||
itemRewriter.handleItemToClient(wrapper.user(), icon);
|
||||
wrapper.passthrough(Types.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Types.INT); // Flags
|
||||
if ((flags & 1) != 0)
|
||||
wrapper.passthrough(Types.STRING); // Background texture
|
||||
wrapper.passthrough(Types.FLOAT); // X
|
||||
wrapper.passthrough(Types.FLOAT); // Y
|
||||
}
|
||||
|
||||
wrapper.passthrough(Types.STRING_ARRAY); // Criteria
|
||||
|
||||
int arrayLength = wrapper.passthrough(Types.VAR_INT);
|
||||
for (int array = 0; array < arrayLength; array++) {
|
||||
wrapper.passthrough(Types.STRING_ARRAY); // String array
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
tagRewriter.register(ClientboundPackets1_13.UPDATE_TAGS, RegistryType.ITEM);
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_13.AWARD_STATS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -230,7 +183,12 @@ public class Protocol1_13_1To1_13 extends BackwardsProtocol<ClientboundPackets1_
|
||||
return particleRewriter;
|
||||
}
|
||||
|
||||
public TranslatableRewriter<ClientboundPackets1_13> translatableRewriter() {
|
||||
@Override
|
||||
public JsonNBTComponentRewriter<ClientboundPackets1_13> getComponentRewriter() {
|
||||
return translatableRewriter;
|
||||
}
|
||||
|
||||
public JsonNBTComponentRewriter<ClientboundPackets1_13> translatableRewriter() {
|
||||
return translatableRewriter;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+7
-8
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -55,14 +55,14 @@ public class EntityPacketRewriter1_13_1 extends LegacyEntityRewriter<Clientbound
|
||||
handler(wrapper -> {
|
||||
int entityId = wrapper.get(Types.VAR_INT, 0);
|
||||
byte type = wrapper.get(Types.BYTE, 0);
|
||||
EntityTypes1_13.EntityType entType = EntityTypes1_13.getTypeFromId(type, true);
|
||||
int data = wrapper.get(Types.INT, 0);
|
||||
EntityTypes1_13.EntityType entType = EntityTypes1_13.ObjectType.getEntityType(type, data);
|
||||
if (entType == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Rewrite falling block
|
||||
if (entType.is(EntityTypes1_13.EntityType.FALLING_BLOCK)) {
|
||||
int data = wrapper.get(Types.INT, 0);
|
||||
wrapper.set(Types.INT, 0, protocol.getMappingData().getNewBlockStateId(data));
|
||||
}
|
||||
|
||||
@@ -122,7 +122,6 @@ public class EntityPacketRewriter1_13_1 extends LegacyEntityRewriter<Clientbound
|
||||
registerTracker(ClientboundPackets1_13.ADD_PAINTING, EntityTypes1_13.EntityType.PAINTING);
|
||||
registerJoinGame(ClientboundPackets1_13.LOGIN, EntityTypes1_13.EntityType.PLAYER);
|
||||
registerRespawn(ClientboundPackets1_13.RESPAWN);
|
||||
registerRemoveEntities(ClientboundPackets1_13.REMOVE_ENTITIES);
|
||||
registerSetEntityData(ClientboundPackets1_13.SET_ENTITY_DATA, Types1_13.ENTITY_DATA_LIST);
|
||||
}
|
||||
|
||||
@@ -131,7 +130,7 @@ public class EntityPacketRewriter1_13_1 extends LegacyEntityRewriter<Clientbound
|
||||
// Rewrite items & blocks
|
||||
filter().handler((event, data) -> {
|
||||
if (data.dataType() == Types1_13.ENTITY_DATA_TYPES.itemType) {
|
||||
protocol.getItemRewriter().handleItemToClient(event.user(), (Item) data.getValue());
|
||||
data.setValue(protocol.getItemRewriter().handleItemToClient(event.user(), (Item) data.getValue()));
|
||||
} else if (data.dataType() == Types1_13.ENTITY_DATA_TYPES.optionalBlockStateType) {
|
||||
// Convert to new block id
|
||||
int value = (int) data.getValue();
|
||||
@@ -159,11 +158,11 @@ public class EntityPacketRewriter1_13_1 extends LegacyEntityRewriter<Clientbound
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return EntityTypes1_13.getTypeFromId(typeId, false);
|
||||
return EntityTypes1_13.EntityType.findById(typeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType objectTypeFromId(int typeId) {
|
||||
return EntityTypes1_13.getTypeFromId(typeId, true);
|
||||
public EntityType objectTypeFromId(int typeId, int data) {
|
||||
return EntityTypes1_13.ObjectType.getEntityType(typeId, data);
|
||||
}
|
||||
}
|
||||
+4
-19
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2025 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,7 +18,6 @@
|
||||
package com.viaversion.viabackwards.protocol.v1_13_1to1_13.rewriter;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.v1_13_1to1_13.Protocol1_13_1To1_13;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPackets1_13;
|
||||
@@ -32,10 +31,6 @@ public class ItemPacketRewriter1_13_1 extends ItemRewriter<ClientboundPackets1_1
|
||||
|
||||
@Override
|
||||
public void registerPackets() {
|
||||
registerCooldown(ClientboundPackets1_13.COOLDOWN);
|
||||
registerSetContent(ClientboundPackets1_13.CONTAINER_SET_CONTENT);
|
||||
registerSetSlot(ClientboundPackets1_13.CONTAINER_SET_SLOT);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.CUSTOM_PAYLOAD, wrapper -> {
|
||||
String channel = wrapper.passthrough(Types.STRING);
|
||||
if (channel.equals("minecraft:trader_list")) {
|
||||
@@ -43,18 +38,12 @@ public class ItemPacketRewriter1_13_1 extends ItemRewriter<ClientboundPackets1_1
|
||||
|
||||
int size = wrapper.passthrough(Types.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
//Input Item
|
||||
Item input = wrapper.passthrough(Types.ITEM1_13);
|
||||
handleItemToClient(wrapper.user(), input);
|
||||
//Output Item
|
||||
Item output = wrapper.passthrough(Types.ITEM1_13);
|
||||
handleItemToClient(wrapper.user(), output);
|
||||
passthroughClientboundItem(wrapper); // Input
|
||||
passthroughClientboundItem(wrapper); // Output
|
||||
|
||||
boolean secondItem = wrapper.passthrough(Types.BOOLEAN); //Has second item
|
||||
if (secondItem) {
|
||||
//Second Item
|
||||
Item second = wrapper.passthrough(Types.ITEM1_13);
|
||||
handleItemToClient(wrapper.user(), second);
|
||||
passthroughClientboundItem(wrapper); // Second item
|
||||
}
|
||||
|
||||
wrapper.passthrough(Types.BOOLEAN); //Trade disabled
|
||||
@@ -63,9 +52,5 @@ public class ItemPacketRewriter1_13_1 extends ItemRewriter<ClientboundPackets1_1
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
registerSetEquippedItem(ClientboundPackets1_13.SET_EQUIPPED_ITEM);
|
||||
registerContainerClick(ServerboundPackets1_13.CONTAINER_CLICK);
|
||||
registerSetCreativeModeSlot(ServerboundPackets1_13.SET_CREATIVE_MODE_SLOT);
|
||||
}
|
||||
}
|
||||
Loaded 100 of 366 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user